]> Dogcows Code - chaz/openbox/commitdiff
add an OtkAppWidget which are "root windows", i.e. the managed child of root, to...
authorDana Jansens <danakj@orodu.net>
Sat, 16 Nov 2002 14:30:18 +0000 (14:30 +0000)
committerDana Jansens <danakj@orodu.net>
Sat, 16 Nov 2002 14:30:18 +0000 (14:30 +0000)
Exit when all the "root windows" are hidden.
Support the WM_DELETE protocol to hide a "root window".

14 files changed:
otk/Makefile.am
otk/application.cc
otk/application.hh
otk/appwidget.cc [new file with mode: 0644]
otk/appwidget.hh [new file with mode: 0644]
otk/button.cc
otk/button.hh
otk/eventhandler.cc
otk/eventhandler.hh
otk/focuswidget.cc
otk/focuswidget.hh
otk/otk_test.cc
otk/widget.cc
otk/widget.hh

index b35b7d9a00483fc930b0552e4a56a6f8908b7423..3f32a45e2386650860821e138d074ecf3310138c 100644 (file)
@@ -9,7 +9,7 @@ libotk_a_SOURCES= color.cc display.cc font.cc gccache.cc image.cc \
                   texture.cc timer.cc timerqueuemanager.cc style.cc \
                   configuration.cc util.cc widget.cc focuswidget.cc \
                   button.cc eventhandler.cc eventdispatcher.cc \
-                  label.cc focuslabel.cc application.cc
+                  label.cc focuslabel.cc application.cc appwidget.cc
 
 MAINTAINERCLEANFILES= Makefile.in
 
@@ -20,26 +20,51 @@ otk_test: libotk.a otk_test.cc
        $(CXX) $(CPPFLAGS) -DHAVE_CONFIG_H -I. -I. -I.. -I../src $(XFT_CFLAGS) -Wall -W -pedantic -DNDEBUG -g -O2 -o otk_test otk_test.cc $(XFT_LIBS) ./libotk.a 
 
 # local dependencies
-button.o: button.cc button.hh focuswidget.hh widget.hh rect.hh \
- point.hh texture.hh color.hh util.hh style.hh font.hh image.hh \
- screeninfo.hh timer.hh configuration.hh
+application.o: application.cc application.hh eventdispatcher.hh \
+ eventhandler.hh display.hh configuration.hh timerqueuemanager.hh \
+ timerqueue.hh timer.hh image.hh color.hh screeninfo.hh rect.hh \
+ point.hh style.hh font.hh texture.hh util.hh widget.hh
+appwidget.o: appwidget.cc appwidget.hh widget.hh rect.hh point.hh \
+ texture.hh color.hh util.hh style.hh font.hh image.hh screeninfo.hh \
+ timer.hh configuration.hh eventdispatcher.hh eventhandler.hh \
+ application.hh display.hh timerqueuemanager.hh timerqueue.hh
+button.o: button.cc button.hh focuslabel.hh focuswidget.hh widget.hh \
+ rect.hh point.hh texture.hh color.hh util.hh style.hh font.hh \
+ image.hh screeninfo.hh timer.hh configuration.hh eventdispatcher.hh \
+ eventhandler.hh application.hh display.hh timerqueuemanager.hh \
+ timerqueue.hh
 color.o: color.cc color.hh display.hh screeninfo.hh rect.hh point.hh
 configuration.o: configuration.cc configuration.hh util.hh
+eventdispatcher.o: eventdispatcher.cc eventdispatcher.hh \
+ eventhandler.hh display.hh
+eventhandler.o: eventhandler.cc eventhandler.hh
+focuslabel.o: focuslabel.cc focuslabel.hh focuswidget.hh widget.hh \
+ rect.hh point.hh texture.hh color.hh util.hh style.hh font.hh \
+ image.hh screeninfo.hh timer.hh configuration.hh eventdispatcher.hh \
+ eventhandler.hh application.hh display.hh timerqueuemanager.hh \
+ timerqueue.hh
 focuswidget.o: focuswidget.cc focuswidget.hh widget.hh rect.hh \
  point.hh texture.hh color.hh util.hh style.hh font.hh image.hh \
- screeninfo.hh timer.hh configuration.hh
-font.o: font.cc font.hh util.hh display.hh display.hh color.hh \
- screeninfo.hh rect.hh point.hh
+ screeninfo.hh timer.hh configuration.hh eventdispatcher.hh \
+ eventhandler.hh application.hh display.hh timerqueuemanager.hh \
+ timerqueue.hh
+font.o: font.cc font.hh util.hh display.hh color.hh screeninfo.hh \
+ rect.hh point.hh
 gccache.o: gccache.cc gccache.hh display.hh color.hh assassin.hh \
  screeninfo.hh rect.hh point.hh
 image.o: image.cc display.hh gccache.hh color.hh image.hh \
  screeninfo.hh rect.hh point.hh timer.hh texture.hh util.hh
 imagecontrol.o: imagecontrol.cc display.hh color.hh image.hh \
  screeninfo.hh rect.hh point.hh timer.hh texture.hh util.hh
-otk_test.o: otk_test.cc focuswidget.hh widget.hh rect.hh point.hh \
- texture.hh color.hh util.hh style.hh font.hh image.hh screeninfo.hh \
- timer.hh configuration.hh button.hh display.hh timerqueuemanager.hh \
- timerqueue.hh
+label.o: label.cc label.hh widget.hh rect.hh point.hh texture.hh \
+ color.hh util.hh style.hh font.hh image.hh screeninfo.hh timer.hh \
+ configuration.hh eventdispatcher.hh eventhandler.hh application.hh \
+ display.hh timerqueuemanager.hh timerqueue.hh
+otk_test.o: otk_test.cc application.hh eventdispatcher.hh \
+ eventhandler.hh display.hh configuration.hh timerqueuemanager.hh \
+ timerqueue.hh timer.hh image.hh color.hh screeninfo.hh rect.hh \
+ point.hh style.hh font.hh texture.hh util.hh focuswidget.hh widget.hh \
+ appwidget.hh button.hh focuslabel.hh
 property.o: property.cc property.hh screeninfo.hh rect.hh point.hh \
  display.hh
 rect.o: rect.cc rect.hh point.hh
@@ -56,7 +81,5 @@ timerqueuemanager.o: timerqueuemanager.cc timerqueuemanager.hh \
 util.o: util.cc util.hh
 widget.o: widget.cc widget.hh rect.hh point.hh texture.hh color.hh \
  util.hh style.hh font.hh image.hh screeninfo.hh timer.hh \
- configuration.hh display.hh assassin.hh
-eventhandler.o: eventhandler.cc eventhandler.hh
-eventdispatcher.o: eventdispatcher.cc eventdispatcher.hh
-application.o: application.cc application.hh
+ configuration.hh eventdispatcher.hh eventhandler.hh application.hh \
+ display.hh timerqueuemanager.hh timerqueue.hh assassin.hh
index 2530fdd112c20cee6494f7280f76f4caa8b8157d..886b0033d6db3b3c8c21a26bff83ae3cd96c70d8 100644 (file)
@@ -3,8 +3,6 @@
 #include "widget.hh"
 
 extern "C" {
-#include <X11/Xlib.h>
-  
 #ifdef HAVE_STDLIB_H
 # include <stdlib.h>
 #endif
@@ -15,13 +13,16 @@ extern "C" {
 namespace otk {
 
 OtkApplication::OtkApplication(int argc, char **argv)
-  : OtkEventDispatcher(), _main_widget(0), _dockable(false)
+  : OtkEventDispatcher(),
+    _dockable(false),
+    _appwidget_count(0)
 {
   argc = argc;
   argv = argv;
 
   OBDisplay::initialize(0);
-  const ScreenInfo *s_info = OBDisplay::screenInfo(DefaultScreen(OBDisplay::display));
+  const ScreenInfo *s_info =
+    OBDisplay::screenInfo(DefaultScreen(OBDisplay::display));
 
   _timer_manager = new OBTimerQueueManager();
   _img_ctrl = new BImageControl(_timer_manager, s_info, True, 4, 5, 200);
@@ -55,36 +56,17 @@ void OtkApplication::loadStyle(void)
 
 void OtkApplication::exec(void)
 {
-  if (!_main_widget) {
-    std::cerr << "ERROR: No main widget set. You must create a main " <<
-      "OtkWidget for the OtkApplication before calling " <<
+  if (_appwidget_count <= 0) {
+    std::cerr << "ERROR: No main widgets exist. You must create and show() " <<
+      "an OtkAppWidget for the OtkApplication before calling " <<
       "OtkApplication::exec().\n";
     ::exit(1);
   }
-  while (1) {
+
+  while (_appwidget_count > 0) {
     dispatchEvents();
     _timer_manager->fire(); // fire pending events
   }
 }
 
-bool OtkApplication::setMainWidget(const OtkWidget *main_widget)
-{
-  // ignore it if it has already been set
-  if (_main_widget) {
-    std::cerr << "WARNING: More than one main OtkWidget being created for " <<
-      "the OtkApplication!\n";
-    return false;
-  }
-
-  _main_widget = main_widget;
-
-  // set WM Protocols on the window
-  Atom protocols[2];
-  protocols[0] = XInternAtom(OBDisplay::display, "WM_PROTOCOLS", false);
-  protocols[1] = XInternAtom(OBDisplay::display, "WM_DELETE_WINDOW", false);
-  XSetWMProtocols(OBDisplay::display, _main_widget->getWindow(), protocols, 2);
-
-  return true;
-}
-
 }
index d6f1ed8dac7f24fff6084291c49a65d180fa529d..7696e73d3860cd5ef23327faf23600b1eb1dea77 100644 (file)
@@ -10,7 +10,7 @@
 
 namespace otk {
 
-class OtkWidget;
+class OtkAppWidget;
 
 class OtkApplication : public OtkEventDispatcher {
 
@@ -28,20 +28,18 @@ public:
   inline Style *getStyle(void) const { return _style; }
   // more accessors
 
-protected:
-  bool setMainWidget(const OtkWidget *main_widget);
-
 private:
   void loadStyle(void);
 
-  const OtkWidget *_main_widget;
   OBTimerQueueManager *_timer_manager;
   BImageControl *_img_ctrl;
   Configuration *_style_conf;
   Style *_style;
   bool _dockable;
 
-  friend class OtkWidget; // for access to setMainWidget
+  int _appwidget_count;
+
+  friend class OtkAppWidget;
 };
 
 }
diff --git a/otk/appwidget.cc b/otk/appwidget.cc
new file mode 100644 (file)
index 0000000..f406c65
--- /dev/null
@@ -0,0 +1,53 @@
+#include "appwidget.hh"
+#include "application.hh"
+
+extern "C" {
+#include <X11/Xlib.h>
+}
+
+namespace otk {
+
+OtkAppWidget::OtkAppWidget(OtkApplication *app, Direction direction,
+                           Cursor cursor, int bevel_width)
+  : OtkWidget(app, app->getStyle(), direction, cursor, bevel_width),
+    _application(app)
+{
+  assert(app);
+
+  _wm_protocols = XInternAtom(OBDisplay::display, "WM_PROTOCOLS", false);
+  _wm_delete = XInternAtom(OBDisplay::display, "WM_DELETE_WINDOW", false);
+
+  // set WM Protocols on the window
+  Atom protocols[2];
+  protocols[0] = _wm_protocols;
+  protocols[1] = _wm_delete;
+  XSetWMProtocols(OBDisplay::display, getWindow(), protocols, 2);
+}
+
+OtkAppWidget::~OtkAppWidget()
+{
+}
+
+void OtkAppWidget::show(void)
+{
+  OtkWidget::show();
+
+  _application->_appwidget_count++;
+}
+
+void OtkAppWidget::hide(void)
+{
+  OtkWidget::hide();
+
+  _application->_appwidget_count--;
+}
+
+void OtkAppWidget::clientMessageHandler(const XClientMessageEvent &e)
+{
+  OtkEventHandler::clientMessageHandler(e);
+  if (e.message_type == _wm_protocols &&
+      static_cast<Atom>(e.data.l[0]) == _wm_delete)
+    hide();
+}
+
+}
diff --git a/otk/appwidget.hh b/otk/appwidget.hh
new file mode 100644 (file)
index 0000000..d33f2ca
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef __appwidget_hh
+#define __appwidget_hh
+
+#include "widget.hh"
+
+namespace otk {
+
+class OtkApplication;
+
+class OtkAppWidget : public OtkWidget {
+
+public:
+  OtkAppWidget(OtkApplication *app, Direction direction = Horizontal,
+               Cursor cursor = 0, int bevel_width = 1);
+  virtual ~OtkAppWidget();
+
+  virtual void show(void);
+  virtual void hide(void);
+
+  virtual void clientMessageHandler(const XClientMessageEvent &e);
+  
+private:
+
+  OtkApplication *_application;
+  Atom _wm_protocols;
+  Atom _wm_delete;
+};
+
+}
+
+#endif // __appwidget_hh
index f080c7699d24d5de5a90f0d113a72cc84de5b85e..1b2ef7cec45efee10b191d5353a1f6da47ac45dc 100644 (file)
@@ -51,18 +51,18 @@ void OtkButton::setUnfocusTexture(BTexture *texture)
   _unpr_unfocus_tx = texture;
 }
 
-int OtkButton::buttonPressHandler(const XButtonEvent &e)
+void OtkButton::buttonPressHandler(const XButtonEvent &e)
 {
   press(e.button);
   update();
-  return OtkFocusWidget::buttonPressHandler(e);
+  OtkFocusWidget::buttonPressHandler(e);
 }
 
-int OtkButton::buttonReleaseHandler(const XButtonEvent &e)
+void OtkButton::buttonReleaseHandler(const XButtonEvent &e)
 {
   release(e.button);
   update();
-  return OtkFocusWidget::buttonReleaseHandler(e);
+  OtkFocusWidget::buttonReleaseHandler(e);
 }
 
 }
index c5b9d963e86b42acc7a2b6c94e990770cead9409..a5f9369001d9f24e635059952a41fa57d6a8e5a4 100644 (file)
@@ -29,8 +29,8 @@ public:
   void press(unsigned int mouse_button);
   void release(unsigned int mouse_button);
 
-  int buttonPressHandler(const XButtonEvent &e);
-  int buttonReleaseHandler(const XButtonEvent &e);
+  void buttonPressHandler(const XButtonEvent &e);
+  void buttonReleaseHandler(const XButtonEvent &e);
 
 private:
 
index cab95e17ce8db25daa865e4d58b4898ac672c310..9d37bcff25204e2d911f2788307f4120017f1366 100644 (file)
@@ -13,7 +13,7 @@ OtkEventHandler::~OtkEventHandler()
 }
 
 
-int OtkEventHandler::handle(const XEvent &e)
+void OtkEventHandler::handle(const XEvent &e)
 {
   switch(e.type){
   case KeyPress:
@@ -79,7 +79,6 @@ int OtkEventHandler::handle(const XEvent &e)
   case SelectionRequest:
     return selectionRequestHandler(e.xselectionrequest);
   };
-  return 0;
 }
 
 }
index ea273ef4375e8f5cbc41fafc7bd4c0767a8edeb1..05dfac3bc95c92b68176aa0eb8f4c2f56ff230ce 100644 (file)
@@ -10,104 +10,103 @@ namespace otk {
 class OtkEventHandler{
 public:
   //! Dispatches events to one of the other handlers based on their type.
-  virtual int handle(const XEvent &e);
+  virtual void handle(const XEvent &e);
 
   //! Called whenever any key is pressed.
-  virtual int keyPressHandler(const XKeyEvent &) {return 1;}
+  virtual void keyPressHandler(const XKeyEvent &) {}
 
   //! Called whenever any key is released.
-  virtual int keyReleaseHandler(const XKeyEvent &) {return 1;}
+  virtual void keyReleaseHandler(const XKeyEvent &) {}
 
   //! Called whenever a button of the pointer is pressed.
-  virtual int buttonPressHandler(const XButtonEvent &) {return 1;}
+  virtual void buttonPressHandler(const XButtonEvent &) {}
 
   //! Called whenever a button of the pointer is released.
-  virtual int buttonReleaseHandler(const XButtonEvent &) {return 1;}
+  virtual void buttonReleaseHandler(const XButtonEvent &) {}
 
   //! Called whenever the pointer enters a window.
-  virtual int enterHandler(const XCrossingEvent &) {return 1;}
+  virtual void enterHandler(const XCrossingEvent &) {}
 
   //! Called whenever the pointer leaves a window.
-  virtual int leaveHandler(const XCrossingEvent &) {return 1;}
+  virtual void leaveHandler(const XCrossingEvent &) {}
 
   //! Called when a window gains focus.
-  virtual int focusHandler(const XFocusChangeEvent &) {return 1;}
+  virtual void focusHandler(const XFocusChangeEvent &) {}
 
   //! Called when a window looses focus.
-  virtual int unfocusHandler(const XFocusChangeEvent &) {return 1;}
+  virtual void unfocusHandler(const XFocusChangeEvent &) {}
 
   //! Called when a window becomes visible to the user.
-  virtual int exposeHandler(const XExposeEvent &) {return 1;}
+  virtual void exposeHandler(const XExposeEvent &) {}
 
   //! Called to handle GraphicsExpose events.
-  virtual int graphicsExposeHandler(const XGraphicsExposeEvent &) {return 1;}
+  virtual void graphicsExposeHandler(const XGraphicsExposeEvent &) {}
 
   //! Called to handle NoExpose events.
-  virtual int noExposeEventHandler(const XNoExposeEvent &) {return 1;}
+  virtual void noExposeEventHandler(const XNoExposeEvent &) {}
 
   //! Called when the window requests a change in its z-order.
-  virtual int circulateRequestHandler(const XCirculateRequestEvent &)
-  {return 1;}
+  virtual void circulateRequestHandler(const XCirculateRequestEvent &)
+  {}
 
   //! Called when a different client initiates a configure window request.
-  virtual int configureRequestHandler(const XConfigureRequestEvent &)
-  {return 1;}
+  virtual void configureRequestHandler(const XConfigureRequestEvent &)
+  {}
 
   //! Called when a different client tries to map a window.
-  virtual int mapRequestHandler(const XMapRequestEvent &) {return 1;}
+  virtual void mapRequestHandler(const XMapRequestEvent &) {}
 
   //! Called when another client attemps to change the size of a window.
-  virtual int resizeRequestHandler(const XResizeRequestEvent &) {return 1;}
+  virtual void resizeRequestHandler(const XResizeRequestEvent &) {}
 
   //! Called when the z-order of the window has changed.
-  virtual int circulateHandler(const XCirculateEvent &) {return 1;}
+  virtual void circulateHandler(const XCirculateEvent &) {}
 
   //! Called when the window as been reconfigured.
-  virtual int configureHandler(const XConfigureEvent &) {return 1;}
+  virtual void configureHandler(const XConfigureEvent &) {}
 
   //! Called when a window is created.
-  virtual int createHandler(const XCreateWindowEvent &) {return 1;}
+  virtual void createHandler(const XCreateWindowEvent &) {}
 
   //! Called when a window is destroyed.
-  virtual int destroyHandler(const XDestroyWindowEvent &) {return 1;}
+  virtual void destroyHandler(const XDestroyWindowEvent &) {}
 
   //! Called when a window is moved because of a change in the size of its 
   //! parent.
-  virtual int gravityHandler(const XGravityEvent &) {return 1;}
+  virtual void gravityHandler(const XGravityEvent &) {}
 
   //! Called when a window is mapped.
-  virtual int mapHandler(const XMapEvent &) {return 1;}
+  virtual void mapHandler(const XMapEvent &) {}
 
   //! Called when the server generats a MappingNotify event
-  virtual int mappingHandler(const XMappingEvent &) {return 1;}
+  virtual void mappingHandler(const XMappingEvent &) {}
 
   //! Called when a window is reparented
-  virtual int reparentHandler(const XReparentEvent &) {return 1;}
+  virtual void reparentHandler(const XReparentEvent &) {}
 
   //! Called when a window is unmapped
-  virtual int unmapHandler(const XUnmapEvent &) {return 1;}
+  virtual void unmapHandler(const XUnmapEvent &) {}
 
   //! Called when a the visibilty of a window changes
-  virtual int visibilityHandler(const XVisibilityEvent &) {return 1;}
+  virtual void visibilityHandler(const XVisibilityEvent &) {}
 
   //! Called when the colormap changes, or is installed or unistalled
-  virtual int colorMapHandler(const XColormapEvent &) {return 1;}
+  virtual void colorMapHandler(const XColormapEvent &) {}
 
   //! Called when a client calls XSendEvent
-  virtual int clientMessageHandler(const XClientMessageEvent &) {return 1;}
+  virtual void clientMessageHandler(const XClientMessageEvent &) {}
 
   //! Called when a property of a window changes
-  virtual int propertyHandler(const XPropertyEvent &) {return 1;}
+  virtual void propertyHandler(const XPropertyEvent &) {}
 
   //! Called when the client loses ownership of a selection
-  virtual int selectionClearHandler(const XSelectionClearEvent &) {return 1;}
+  virtual void selectionClearHandler(const XSelectionClearEvent &) {}
 
   //! Called when a ConvertSelection protocol request is sent
-  virtual int selectionHandler(const XSelectionEvent &) {return 1;}
+  virtual void selectionHandler(const XSelectionEvent &) {}
 
   //! Called when a SelectionEvent occurs
-  virtual int selectionRequestHandler(const XSelectionRequestEvent &)
-  {return 1;}
+  virtual void selectionRequestHandler(const XSelectionRequestEvent &) {}
 
   virtual ~OtkEventHandler();
 
index ffbaeb7e09bd995b4596eec63b99500bd06f18e4..c21697ce3956a138ce65f542cad5776f171ef979 100644 (file)
@@ -8,20 +8,6 @@ OtkFocusWidget::OtkFocusWidget(OtkWidget *parent, Direction direction)
   _focus_texture = parent->getTexture();
 }
 
-OtkFocusWidget::OtkFocusWidget(OtkApplication *app, Direction direction,
-                               Cursor cursor, int bevel_width)
-  : OtkWidget(app, direction, cursor, bevel_width),
-    _unfocus_texture(0), _focused(true)
-{
-}
-
-OtkFocusWidget::OtkFocusWidget(Style *style, Direction direction,
-                               Cursor cursor, int bevel_width)
-  : OtkWidget(style, direction, cursor, bevel_width),
-    _unfocus_texture(0), _focused(true)
-{
-}
-
 OtkFocusWidget::~OtkFocusWidget()
 {
 }
index e6bcb8762ae0b9dd1e49afe9aee97c44d0001bf3..d33d2abfd1624a98bfc6232dcf401188b1c39c14 100644 (file)
@@ -11,10 +11,6 @@ class OtkFocusWidget : public OtkWidget {
 public:
 
   OtkFocusWidget(OtkWidget *parent, Direction = Horizontal);
-  OtkFocusWidget(OtkApplication *app, Direction direction = Horizontal,
-                 Cursor cursor = 0, int bevel_width = 1);
-  OtkFocusWidget(Style *style, Direction direction = Horizontal,
-                 Cursor cursor = 0, int bevel_width = 1);
   virtual ~OtkFocusWidget();
 
   virtual void focus(void);
index 987563ad812d58ac048c2ca709271af5f2270f6b..39baa7f6e45a6db6d2e43bde6f61f3d975545db9 100644 (file)
@@ -1,15 +1,16 @@
 #include "application.hh"
 #include "focuswidget.hh"
+#include "appwidget.hh"
 #include "button.hh"
 
 int main(int argc, char **argv) {
   otk::OtkApplication app(argc, argv);
 
-  otk::OtkFocusWidget foo(&app);
+  otk::OtkAppWidget foo(&app);
 
   foo.resize(600, 500);
   foo.setTexture(app.getStyle()->getTitleFocus());
-  foo.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
+//  foo.setUnfocusTexture(app.getStyle()->getTitleUnfocus());
 
   foo.setBevelWidth(2);
   foo.setDirection(otk::OtkWidget::Horizontal);
index 130bafeaf54189f69e039170a2c325a7094d2b8c..0e5eaf15748c5c2a6b43c9538ff2477ded81be53 100644 (file)
@@ -18,33 +18,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);
-  app->setMainWidget(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),
@@ -52,10 +35,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()
@@ -427,15 +413,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) {
@@ -447,8 +432,6 @@ int OtkWidget::configureHandler(const XConfigureEvent &e)
     }
     update();
   }
-
-  return true;
 }
 
 }
index fb3b1e37e5d9404e707e8447d9e242a48ea6bee3..cbf2f9c55922c66dc54f96bea16abe747cca159f 100644 (file)
@@ -8,7 +8,7 @@
 #include "point.hh"
 #include "texture.hh"
 #include "style.hh"
-#include "eventhandler.hh"
+#include "eventdispatcher.hh"
 #include "application.hh"
 
 namespace otk {
@@ -22,17 +22,16 @@ public:
   typedef std::list<OtkWidget *> OtkWidgetList;
 
   OtkWidget(OtkWidget *parent, Direction = Horizontal);
-  OtkWidget(OtkApplication *app, Direction direction = Horizontal,
-            Cursor cursor = 0, int bevel_width = 1);
-  OtkWidget(Style *style, Direction direction = Horizontal,
-            Cursor cursor = 0, int bevel_width = 1);
+  OtkWidget(OtkEventDispatcher *event_dispatcher, Style *style,
+            Direction direction = Horizontal, Cursor cursor = 0,
+            int bevel_width = 1);
 
   virtual ~OtkWidget();
 
   virtual void update(void);
 
-  int exposeHandler(const XExposeEvent &e);
-  int configureHandler(const XConfigureEvent &e);
+  void exposeHandler(const XExposeEvent &e);
+  void configureHandler(const XConfigureEvent &e);
 
   inline Window getWindow(void) const { return _window; }
   inline const OtkWidget *getParent(void) const { return _parent; }
@@ -144,6 +143,7 @@ private:
   bool _fixed_height;
 
   OtkEventDispatcher *_event_dispatcher;
+  OtkApplication *_application;
 };
 
 }
This page took 0.044158 seconds and 4 git commands to generate.