some work on the positioner setup plugin
[enigma2.git] / lib / gui / ewidgetdesktop.cpp
index 04bc85d9059b7b7edb9d57bf9ec764f8f95e1e7f..9e09220319d068b3a709ba46f5df24d729e4e84c 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. */