]> Dogcows Code - chaz/openbox/blobdiff - otk/widget.cc
show recursive.. recursively
[chaz/openbox] / otk / widget.cc
index 9f574ee930ba022a57ea333b3bdce1beb9ff58f2..154fc92cd6faa698a1fcbde220634873a4981581 100644 (file)
@@ -8,7 +8,7 @@
 #include "display.hh"
 #include "assassin.hh"
 #include "screeninfo.hh"
-
+#include "focuslabel.hh"
 #include <algorithm>
 #include <iostream>
 
@@ -25,7 +25,7 @@ Widget::Widget(Widget *parent, Direction direction)
     _stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0),
     _bcolor(0), _bwidth(0), _rect(0, 0, 1, 1), _screen(parent->screen()),
     _fixed_width(false), _fixed_height(false),
-    _surface(parent->screen(), _rect.size()),
+    _surface(0),
     _event_dispatcher(parent->eventDispatcher())
 {
   assert(parent);
@@ -35,9 +35,9 @@ Widget::Widget(Widget *parent, Direction direction)
   setStyle(_style); // let the widget initialize stuff
 }
 
-Widget::Widget(EventDispatcher *event_dispatcher, Style *style,
-                     Direction direction, Cursor cursor, int bevel_width,
-                     bool override_redirect)
+Widget::Widget(EventDispatcher *event_dispatcher, RenderStyle *style,
+               Direction direction, Cursor cursor, int bevel_width,
+               bool override_redirect)
   : EventHandler(),
     _dirty(false),_focused(false),
     _parent(0), _style(style), _direction(direction), _cursor(cursor),
@@ -45,8 +45,8 @@ Widget::Widget(EventDispatcher *event_dispatcher, Style *style,
     _grabbed_mouse(false), _grabbed_keyboard(false),
     _stretchable_vert(false), _stretchable_horz(false), _texture(0),
     _bg_pixmap(0), _bg_pixel(0), _bcolor(0), _bwidth(0), _rect(0, 0, 1, 1),
-    _screen(style->getScreen()), _fixed_width(false), _fixed_height(false),
-    _surface(style->getScreen(), _rect.size()),
+    _screen(style->screen()), _fixed_width(false), _fixed_height(false),
+    _surface(0),
     _event_dispatcher(event_dispatcher)
 {
   assert(event_dispatcher);
@@ -175,7 +175,7 @@ void Widget::show(bool recursive)
   if (recursive) {
     WidgetList::iterator it = _children.begin(), end = _children.end();
     for (; it != end; ++it)
-      (*it)->show();
+      (*it)->show(recursive);
   }
 
   XMapWindow(**display, _window);
@@ -261,12 +261,18 @@ void Widget::render(void)
   if (!_texture) return;
   printf("RENDER\n");
 
-  _surface = Surface(_screen, _rect.size());
-  display->renderControl(_screen)->drawBackground(_surface, *_texture);
+  Surface *s = _surface; // save the current surface
+  
+  _surface = new Surface(_screen, _rect.size());
+  display->renderControl(_screen)->drawBackground(*_surface, *_texture);
+
+  if (dynamic_cast<FocusLabel*>(this))
+    printf("IM A FOCUSLABEL RENDERING\n");
+  renderForeground(); // for inherited types to render onto the _surface
 
-  renderForeground();
+  XSetWindowBackgroundPixmap(**display, _window, _surface->pixmap());
 
-  XSetWindowBackgroundPixmap(**display, _window, _surface.pixmap());
+  delete s; // delete the old surface *after* its pixmap isn't in use anymore
 }
 
 void Widget::adjust(void)
@@ -440,7 +446,7 @@ void Widget::removeChild(Widget *child)
     _children.erase(it);
 }
 
-void Widget::setStyle(Style *style)
+void Widget::setStyle(RenderStyle *style)
 {
   assert(style);
   _style = style;
@@ -463,18 +469,28 @@ void Widget::setEventDispatcher(EventDispatcher *disp)
 void Widget::exposeHandler(const XExposeEvent &e)
 {
   EventHandler::exposeHandler(e);
-  XClearArea(**display, _window, e.x, e.y, e.width, e.height, false);
+//  XClearArea(**display, _window, e.x, e.y, e.width, e.height, false);
 }
 
 void Widget::configureHandler(const XConfigureEvent &e)
 {
   EventHandler::configureHandler(e);
+
   if (_ignore_config) {
     _ignore_config--;
   } else {
-    if (!(e.width == _rect.width() && e.height == _rect.height())) {
+    int width = e.width;
+    int height = e.height;
+
+    XEvent ev;
+    while (XCheckTypedWindowEvent(**display, _window, ConfigureNotify, &ev)) {
+      width = ev.xconfigure.width;
+      height = ev.xconfigure.height;
+    }
+
+    if (!(width == _rect.width() && height == _rect.height())) {
       _dirty = true;
-      _rect.setSize(e.width, e.height);
+      _rect.setSize(width, height);
     }
     update();
   }
This page took 0.025327 seconds and 4 git commands to generate.