(ralfk) media player actions
[enigma2.git] / lib / gui / ewidgetdesktop.cpp
index 04bc85d9059b7b7edb9d57bf9ec764f8f95e1e7f..9e4830830e3266cc2624c73de058dfc34351a253 100644 (file)
@@ -5,18 +5,27 @@
 
 extern void dumpRegion(const gRegion &region);
 
-void eWidgetDesktop::addRootWidget(eWidget *root, int top)
+void eWidgetDesktop::addRootWidget(eWidget *root)
 {
        assert(!root->m_desktop);
        
+       int invert_sense = 0;
                /* buffered mode paints back-to-front, while immediate mode is front-to-back. */
        if (m_comp_mode == cmBuffered)
-               top = !top;
+               invert_sense = 1;
+       
+       ePtrList<eWidget>::iterator insert_position = m_root.begin();
+       
+       for (;;)
+       {
+               if ((insert_position == m_root.end()) || (invert_sense ^ (insert_position->m_z_position < root->m_z_position)))
+               {
+                       m_root.insert(insert_position, root);
+                       break;
+               }
+               ++insert_position;
+       }
        
-       if (top)
-               m_root.push_back(root);
-       else
-               m_root.push_front(root);
        root->m_desktop = this;
 
                /* the creation will be postponed. */
@@ -278,6 +287,11 @@ void eWidgetDesktop::setRedrawTask(eMainloop &ml)
                m_timer->start(0, 1);
 }
 
+void eWidgetDesktop::makeCompatiblePixmap(ePtr<gPixmap> &pm)
+{
+       makeCompatiblePixmap(*(pm.operator->()));
+}
+
 void eWidgetDesktop::makeCompatiblePixmap(gPixmap &pm)
 {
        if (m_comp_mode != cmImmediate)
@@ -290,14 +304,17 @@ void eWidgetDesktop::makeCompatiblePixmap(gPixmap &pm)
                return;
        }
 
-       ePtr<gDC> pixmap_dc = new gDC(&pm);
-       gPainter pixmap_painter(pixmap_dc);
-       
        ePtr<gPixmap> target_pixmap;
        m_screen.m_dc->getPixmap(target_pixmap);
        
        assert(target_pixmap);
        
+       if (target_pixmap->surface && target_pixmap->surface->bpp > 8)
+               return;
+
+       ePtr<gDC> pixmap_dc = new gDC(&pm);
+       gPainter pixmap_painter(pixmap_dc);
+       
        pixmap_painter.mergePalette(target_pixmap);
 }
 
@@ -318,6 +335,7 @@ eWidgetDesktop::eWidgetDesktop(eSize size): m_mainloop(0), m_timer(0)
        m_screen.m_dirty_region = gRegion(eRect(ePoint(0, 0), size));
        m_screen.m_screen_size = size;
        m_require_redraw = 0;
+       m_style_id = 0;
 
        CONNECT(gRC::getInstance()->notify, eWidgetDesktop::notify);
        setCompositionMode(cmImmediate);