X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Fwidget.cc;h=c09ac4862566e8c8f93d0f4634ff6e7e33a15065;hb=6e2f3f9f8a2b4b83648c9c8b9993d321b3f60a79;hp=ca8c527aaa3a8abfe7dc91fcef98252c1a2fa1e6;hpb=1eb12ca4ad83229b0c65819a4562bb489ab74163;p=chaz%2Fopenbox diff --git a/otk/widget.cc b/otk/widget.cc index ca8c527a..c09ac486 100644 --- a/otk/widget.cc +++ b/otk/widget.cc @@ -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) @@ -331,7 +342,6 @@ void Widget::adjustHorz(void) prev_widget = tmp; } - internalResize(width, tallest + _bevel_width * 2); } @@ -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)