X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=otk%2Fwidget.cc;h=fa729a6fe9fc81da6f6cebfccef79f15c5ba9695;hb=861c829ee14fb28a1ccf03f92982ca046ae51278;hp=9ae25cfc4c2c2b31087697c440939111faf040a7;hpb=77342413efd183bd1c0681a57b68acc836022923;p=chaz%2Fopenbox diff --git a/otk/widget.cc b/otk/widget.cc index 9ae25cfc..fa729a6f 100644 --- a/otk/widget.cc +++ b/otk/widget.cc @@ -1,3 +1,9 @@ +// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- + +#ifdef HAVE_CONFIG_H +# include "../config.h" +#endif // HAVE_CONFIG_H + #include "widget.hh" #include "display.hh" #include "assassin.hh" @@ -18,32 +24,16 @@ OtkWidget::OtkWidget(OtkWidget *parent, Direction direction) _grabbed_keyboard(false), _stretchable_vert(false), _stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0), _screen(parent->getScreen()), _fixed_width(false), _fixed_height(false), - _event_dispatcher(parent->getEventDispatcher()) + _event_dispatcher(parent->getEventDispatcher()), _application(0) { + assert(parent); parent->addChild(this); create(); _event_dispatcher->registerHandler(_window, this); } -OtkWidget::OtkWidget(OtkApplication *app, Direction direction, - Cursor cursor, int bevel_width) - : OtkEventHandler(), - _dirty(false), - _parent(0), _style(app->getStyle()), _direction(direction), _cursor(cursor), - _bevel_width(bevel_width), _ignore_config(0), _visible(false), - _focused(false), _grabbed_mouse(false), _grabbed_keyboard(false), - _stretchable_vert(false), _stretchable_horz(false), _texture(0), - _bg_pixmap(0), _bg_pixel(0), _screen(app->getStyle()->getScreen()), - _fixed_width(false), _fixed_height(false), - _event_dispatcher(app) -{ - assert(app); - create(); - _event_dispatcher->registerHandler(_window, this); -} - -OtkWidget::OtkWidget(Style *style, Direction direction, - Cursor cursor, int bevel_width) +OtkWidget::OtkWidget(OtkEventDispatcher *event_dispatcher, Style *style, + Direction direction, Cursor cursor, int bevel_width) : OtkEventHandler(), _dirty(false), _parent(0), _style(style), _direction(direction), _cursor(cursor), @@ -51,10 +41,13 @@ OtkWidget::OtkWidget(Style *style, Direction direction, _focused(false), _grabbed_mouse(false), _grabbed_keyboard(false), _stretchable_vert(false), _stretchable_horz(false), _texture(0), _bg_pixmap(0), _bg_pixel(0), _screen(style->getScreen()), - _fixed_width(false), _fixed_height(false) + _fixed_width(false), _fixed_height(false), + _event_dispatcher(event_dispatcher), _application(0) { + assert(event_dispatcher); assert(style); create(); + _event_dispatcher->registerHandler(_window, this); } OtkWidget::~OtkWidget() @@ -154,7 +147,7 @@ void OtkWidget::setGeometry(int x, int y, int width, int height) _ignore_config++; } -void OtkWidget::show(void) +void OtkWidget::show(bool recursive) { if (_visible) return; @@ -163,23 +156,27 @@ void OtkWidget::show(void) if (_dirty) update(); - OtkWidgetList::iterator it = _children.begin(), end = _children.end(); - for (; it != end; ++it) - (*it)->show(); + if (recursive) { + OtkWidgetList::iterator it = _children.begin(), end = _children.end(); + for (; it != end; ++it) + (*it)->show(); + } XMapWindow(otk::OBDisplay::display, _window); _visible = true; } -void OtkWidget::hide(void) +void OtkWidget::hide(bool recursive) { if (! _visible) return; - OtkWidgetList::iterator it = _children.begin(), end = _children.end(); - for (; it != end; ++it) - (*it)->hide(); - + if (recursive) { + OtkWidgetList::iterator it = _children.begin(), end = _children.end(); + for (; it != end; ++it) + (*it)->hide(); + } + XUnmapWindow(otk::OBDisplay::display, _window); _visible = false; } @@ -234,6 +231,8 @@ void OtkWidget::ungrabKeyboard(void) void OtkWidget::render(void) { + if (!_texture) return; + _bg_pixmap = _texture->render(_rect.width(), _rect.height(), _bg_pixmap); if (_bg_pixmap) @@ -372,6 +371,7 @@ void OtkWidget::adjustVert(void) void OtkWidget::update(void) { if (_dirty) { + if (! _unmanaged) adjust(); render(); XClearWindow(OBDisplay::display, _window); @@ -426,15 +426,14 @@ void OtkWidget::setEventDispatcher(OtkEventDispatcher *disp) _event_dispatcher->registerHandler(_window, this); } -int OtkWidget::exposeHandler(const XExposeEvent &e) +void OtkWidget::exposeHandler(const XExposeEvent &e) { OtkEventHandler::exposeHandler(e); _dirty = true; update(); - return true; } -int OtkWidget::configureHandler(const XConfigureEvent &e) +void OtkWidget::configureHandler(const XConfigureEvent &e) { OtkEventHandler::configureHandler(e); if (_ignore_config) { @@ -446,8 +445,6 @@ int OtkWidget::configureHandler(const XConfigureEvent &e) } update(); } - - return true; } }