extern void dumpRegion(const gRegion ®ion);
-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. */
widget->m_visible_region = widget->m_clip_region;
widget->m_visible_region.moveBy(widget->position());
widget->m_visible_region &= parent_visible; // in parent space!
- /* TODO: check transparency here! */
- /* remove everything this widget will contain from parent's visible list */
- parent_visible -= widget->m_visible_region; // will remove child regions too!
+ if (!widget->isTransparent())
+ /* remove everything this widget will contain from parent's visible list, unless widget is transparent. */
+ parent_visible -= widget->m_visible_region; // will remove child regions too!
/* now prepare for recursing to childs */
widget->m_visible_region.moveBy(-widget->position()); // now in local space
widget->m_visible_with_childs = widget->m_visible_region;
- for (ePtrList<eWidget>::iterator i(widget->m_childs.begin()); i != widget->m_childs.end(); ++i)
- if (i->m_vis & eWidget::wVisShow)
- calcWidgetClipRegion(*i, widget->m_visible_region);
- else
- clearVisibility(*i);
+ /* add childs in reverse (Z) order - we're going from front-to-bottom here. */
+ ePtrList<eWidget>::iterator i(widget->m_childs.end());
+
+ for (;;)
+ {
+ if (i != widget->m_childs.end())
+ {
+ if (i->m_vis & eWidget::wVisShow)
+ calcWidgetClipRegion(*i, widget->m_visible_region);
+ else
+ clearVisibility(*i);
+ }
+ if (i == widget->m_childs.begin())
+ break;
+ --i;
+ }
}
void eWidgetDesktop::recalcClipRegions(eWidget *root)
m_timer->start(0, 1);
}
+void eWidgetDesktop::makeCompatiblePixmap(ePtr<gPixmap> &pm)
+{
+ makeCompatiblePixmap(*(pm.operator->()));
+}
+
void eWidgetDesktop::makeCompatiblePixmap(gPixmap &pm)
{
if (m_comp_mode != cmImmediate)
return;
- eDebug("widgetDesktop: make compatible pixmap of %p\n", &pm);
+// eDebug("widgetDesktop: make compatible pixmap of %p", &pm);
if (!m_screen.m_dc)
{
eWarning("eWidgetDesktop: no DC to make pixmap compatible with!");
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);
}
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);
eWidgetDesktop::~eWidgetDesktop()
{
+ /* tell registered root windows that they no longer have a desktop. */
+ for (ePtrList<eWidget>::iterator i(m_root.begin()); i != m_root.end(); )
+ {
+ i->m_desktop = 0;
+ i = m_root.erase(i);
+ }
/* destroy all buffers */
setCompositionMode(-1);
}