]> Dogcows Code - chaz/openbox/blobdiff - otk/widget.cc
not needed, the .in is commited
[chaz/openbox] / otk / widget.cc
index b0fe7ec8a65c6f9b127a8d6175b4f1728d6997c0..c09ac4862566e8c8f93d0f4634ff6e7e33a15065 100644 (file)
@@ -59,6 +59,9 @@ Widget::~Widget()
   if (_visible)
     hide();
 
+  if (_surface)
+    delete _surface;
+  
   _event_dispatcher->clearHandler(_window);
 
   std::for_each(_children.begin(), _children.end(), PointerAssassin());
@@ -154,6 +157,13 @@ void Widget::setGeometry(int x, int y, int width, int height)
   _rect = Rect(x, y, width, height);
   _dirty = true;
 
+  // make all parents dirty too
+  Widget *p = _parent;
+  while (p) {
+    p->_dirty = true;
+    p = p->_parent;
+  }
+
   // don't use an XMoveResizeWindow here, because it doesn't seem to move
   // windows with StaticGravity? This works, that didn't.
   XResizeWindow(**display, _window, width, height);
@@ -267,7 +277,8 @@ void Widget::render(void)
 
   XSetWindowBackgroundPixmap(**display, _window, _surface->pixmap());
 
-  delete s; // delete the old surface *after* its pixmap isn't in use anymore
+  if (s)
+    delete s; // delete the old surface *after* its pixmap isn't in use anymore
 }
 
 void Widget::adjust(void)
@@ -324,14 +335,13 @@ void Widget::adjustHorz(void)
     if (prev_widget)
       x = prev_widget->_rect.x() + prev_widget->_rect.width() + _bevel_width;
     else
-      x = _rect.x() + _bevel_width;
+      x = _bevel_width;
     y = (tallest - tmp->_rect.height()) / 2 + _bevel_width;
 
     tmp->move(x, y);
 
     prev_widget = tmp;
   }
-
   internalResize(width, tallest + _bevel_width * 2);
 }
 
@@ -381,7 +391,7 @@ void Widget::adjustVert(void)
     if (prev_widget)
       y = prev_widget->_rect.y() + prev_widget->_rect.height() + _bevel_width;
     else
-      y = _rect.y() + _bevel_width;
+      y = _bevel_width;
     x = (widest - tmp->_rect.width()) / 2 + _bevel_width;
 
     tmp->move(x, y);
@@ -392,18 +402,18 @@ void Widget::adjustVert(void)
   internalResize(widest + _bevel_width * 2, height);
 }
 
-void Widget::update(void)
+void Widget::update()
 {
+  WidgetList::iterator it = _children.begin(), end = _children.end();
+  for (; it != end; ++it)
+    (*it)->update();
+
   if (_dirty) {
     adjust();
     render();
     XClearWindow(**display, _window);
   }
 
-  WidgetList::iterator it = _children.begin(), end = _children.end();
-  for (; it != end; ++it)
-    (*it)->update();
-
   _dirty = false;
 }
 
@@ -411,12 +421,17 @@ void Widget::internalResize(int w, int h)
 {
   assert(w > 0 && h > 0);
 
-  if (! _fixed_width && ! _fixed_height)
+  bool fw = _fixed_width, fh = _fixed_height;
+  
+  if (! fw && ! fh)
     resize(w, h);
-  else if (! _fixed_width)
+  else if (! fw)
     resize(w, _rect.height());
-  else if (! _fixed_height)
+  else if (! fh)
     resize(_rect.width(), h);
+
+  _fixed_width = fw;
+  _fixed_height = fh;
 }
 
 void Widget::addChild(Widget *child, bool front)
This page took 0.024136 seconds and 4 git commands to generate.