From: Dana Jansens Date: Fri, 15 Nov 2002 02:30:14 +0000 (+0000) Subject: make stuff draw on expose events X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=b3822fcfb19bfdcf775fbc6ff2f89a817d16cb4c;p=chaz%2Fopenbox make stuff draw on expose events --- diff --git a/otk/button.cc b/otk/button.cc index 98d57805..18838e87 100644 --- a/otk/button.cc +++ b/otk/button.cc @@ -57,12 +57,12 @@ void OtkButton::update(void) OtkFocusWidget::resize(ft.measureString(_text) + bevel * 2, ft.height() + bevel * 2); - ft.drawString(getWindow(), bevel, bevel, *text_color, _text); OtkFocusWidget::update(); - } - _dirty = false; + ft.drawString(getWindow(), bevel, bevel, *text_color, _text); + } else + OtkFocusWidget::update(); } } diff --git a/otk/button.hh b/otk/button.hh index 55a2389c..6908322e 100644 --- a/otk/button.hh +++ b/otk/button.hh @@ -40,7 +40,7 @@ private: std::string _text; //OtkPixmap _pixmap; bool _pressed; - bool _dirty; +// bool _dirty; BTexture *_pressed_focus_tx; BTexture *_pressed_unfocus_tx; diff --git a/otk/otk_test.cc b/otk/otk_test.cc index 3c182b04..f36fcf99 100644 --- a/otk/otk_test.cc +++ b/otk/otk_test.cc @@ -59,6 +59,8 @@ int main(void) { if (XPending(otk::OBDisplay::display)) { XEvent e; XNextEvent(otk::OBDisplay::display, &e); + if (e.type == Expose) + foo.expose(e.xexpose); } } diff --git a/otk/widget.cc b/otk/widget.cc index ea90a32f..aaec59b6 100644 --- a/otk/widget.cc +++ b/otk/widget.cc @@ -390,4 +390,16 @@ void OtkWidget::removeChild(OtkWidget *child) _children.erase(it); } +void OtkWidget::expose(const XExposeEvent &e) +{ + if (e.window == _window) { + _dirty = true; + update(); + } else { + OtkWidgetList::iterator it = _children.begin(), end = _children.end(); + for (; it != end; ++it) + (*it)->expose(e); + } +} + } diff --git a/otk/widget.hh b/otk/widget.hh index 85eefe79..1651a507 100644 --- a/otk/widget.hh +++ b/otk/widget.hh @@ -27,6 +27,8 @@ public: virtual void update(void); + void expose(const XExposeEvent &e); + inline Window getWindow(void) const { return _window; } inline const OtkWidget *getParent(void) const { return _parent; } inline const OtkWidgetList &getChildren(void) const { return _children; } @@ -124,6 +126,7 @@ private: bool _fixed_width; bool _fixed_height; +protected: bool _dirty; };