]> Dogcows Code - chaz/openbox/commitdiff
handle map events with the Openbox class
authorDana Jansens <danakj@orodu.net>
Mon, 2 Dec 2002 21:06:16 +0000 (21:06 +0000)
committerDana Jansens <danakj@orodu.net>
Mon, 2 Dec 2002 21:06:16 +0000 (21:06 +0000)
otk/eventhandler.hh
src/Makefile.am
src/client.cc
src/client.hh
src/openbox.cc
src/openbox.hh

index 8e39a8dc0db420b52f27c11fdfd7192b70680467..a70343edac8e3567bc989a83b9e4f5957f352514 100644 (file)
@@ -118,7 +118,7 @@ public:
 
 #if defined(SHAPE) || defined(DOXYGEN_IGNORE)
   //! Called when a shape extention event fires
-  virtual void shapeHandler(const XShapeEvent &) {};
+  virtual void shapeHandler(const XShapeEvent &) {}
 #endif // SHAPE 
 
   virtual ~OtkEventHandler();
index 8034df0e773f5245d12e786e42f21a4b0876d976..456c667d6f4a0c9f385d72d14ac4f07688ddf75f 100644 (file)
@@ -16,7 +16,7 @@ bin_PROGRAMS= openbox3
 openbox3_LDADD=../otk/libotk.a @LIBINTL@
 
 openbox3_SOURCES= client.cc frame.cc openbox.cc screen.cc \
-                 main.cc xeventhandler.cc
+                  main.cc
 
 MAINTAINERCLEANFILES= Makefile.in
 
index 57bf5161cf75614765292d8400f17e7d18ef5eae..34fcf6fa24d929ee3eb0922da6044c8b2811b9c7 100644 (file)
@@ -23,10 +23,14 @@ extern "C" {
 namespace ob {
 
 OBClient::OBClient(int screen, Window window)
-  : _screen(screen), _window(window)
+  : otk::OtkEventHandler(),
+    _screen(screen), _window(window)
 {
+  assert(screen >= 0);
   assert(window);
 
+  Openbox::instance->registerHandler(_window, this);
+
   ignore_unmaps = 0;
   
   // update EVERYTHING the first time!!
@@ -494,8 +498,10 @@ void OBClient::updateClass()
 }
 
 
-void OBClient::update(const XPropertyEvent &e)
+void OBClient::propertyHandler(const XPropertyEvent &e)
 {
+  otk::OtkEventHandler::propertyHandler(e);
+  
   const otk::OBProperty *property = Openbox::instance->property();
 
   if (e.atom == XA_WM_NORMAL_HINTS)
@@ -642,8 +648,10 @@ void OBClient::setState(StateAction action, long data1, long data2)
 }
 
 
-void OBClient::update(const XClientMessageEvent &e)
+void OBClient::clientMessageHandler(const XClientMessageEvent &e)
 {
+  otk::OtkEventHandler::clientMessageHandler(e);
+  
   if (e.format != 32) return;
 
   const otk::OBProperty *property = Openbox::instance->property();
@@ -659,8 +667,10 @@ void OBClient::update(const XClientMessageEvent &e)
 
 
 #if defined(SHAPE) || defined(DOXYGEN_IGNORE)
-void OBClient::update(const XShapeEvent &e)
+void OBClient::shapeHandler(const XShapeEvent &e)
 {
+  otk::OtkEventHandler::shapeHandler(e);
+  
   _shaped = e.shaped;
 }
 #endif
index 5ccf5fd51efd8c518bdd517bc3a5ef2859c13983..b7f8861c2c0a3141fb1a0e36cf324437e06c3cd5 100644 (file)
@@ -19,6 +19,7 @@ extern "C" {
 
 #include "otk/strut.hh"
 #include "otk/rect.hh"
+#include "otk/eventhandler.hh"
 
 namespace ob {
 
@@ -36,7 +37,7 @@ class OBFrame;
   class' member variables and call whatever is nessary to complete the
   change (such as causing a redraw of the titlebar after the title is changed).
 */
-class OBClient {
+class OBClient : public otk::OtkEventHandler {
 public:
 
   //! The frame window which decorates around the client window
@@ -433,16 +434,12 @@ public:
   //! Returns the position and size of the client relative to the root window
   inline const otk::Rect &area() const { return _area; }
 
-  //! Updates the OBClient class from a property change XEvent
-  void update(const XPropertyEvent &e);
-  //! Processes a client message XEvent for the window and causes an action
-  //! or whatever was specified to occur
-  void update(const XClientMessageEvent &e);
-#if defined(SHAPE) || defined(DOXYGEN_IGNORE)
-  //! Updates the client's shape status
-  void update(const XShapeEvent &e);
-#endif
+  virtual void propertyHandler(const XPropertyEvent &);
 
+  virtual void clientMessageHandler(const XClientMessageEvent &);
+
+  virtual void shapeHandler(const XShapeEvent &);
+  
   //! Changes the stored positions and size of the OBClient window
   /*!
     This does not actually change the physical geometry, that needs to be done
index 0c534a0f18df6f92018ecbca527bd46040a86a90..d2213ec40b016a5daa6152059a1436c2cdb52e4d 100644 (file)
@@ -121,6 +121,9 @@ Openbox::Openbox(int argc, char **argv)
 
   _property = new otk::OBProperty();
 
+  // set this class as the fallback event handler (for map events)
+  setFallbackHandler(this);
+
   // create the mouse cursors we'll use
   _cursors.session = XCreateFontCursor(otk::OBDisplay::display, XC_left_ptr);
   _cursors.move = XCreateFontCursor(otk::OBDisplay::display, XC_fleur);
@@ -280,5 +283,59 @@ OBClient *Openbox::findClient(Window window)
     return (OBClient*) 0;
 }
 
+
+void Openbox::mapRequestHandler(const XMapRequestEvent &e)
+{
+#ifdef    DEBUG
+  printf("MapRequest for 0x%lx\n", e.window);
+#endif // DEBUG
+
+  otk::OtkEventHandler::mapRequestHandler(e);
+
+  OBClient *client = findClient(e.window);
+
+  if (client) {
+    // XXX: uniconify and/or unshade the window
+  } else {
+    int screen = INT_MAX;
+
+    for (int i = 0; i < ScreenCount(otk::OBDisplay::display); ++i)
+      if (otk::OBDisplay::screenInfo(i)->getRootWindow() == e.parent) {
+        screen = i;
+        break;
+      }
+
+    if (screen >= ScreenCount(otk::OBDisplay::display)) {
+      /*
+        we got a map request for a window who's parent isn't root. this
+        can happen in only one circumstance:
+
+        a client window unmapped a managed window, and then remapped it
+        somewhere between unmapping the client window and reparenting it
+        to root.
+
+        regardless of how it happens, we need to find the screen that
+        the window is on
+      */
+      XWindowAttributes wattrib;
+      if (! XGetWindowAttributes(otk::OBDisplay::display, e.window,
+                                 &wattrib)) {
+        // failed to get the window attributes, perhaps the window has
+        // now been destroyed?
+        return;
+      }
+
+      for (int i = 0; i < ScreenCount(otk::OBDisplay::display); ++i)
+        if (otk::OBDisplay::screenInfo(i)->getRootWindow() == wattrib.root) {
+          screen = i;
+          break;
+        }
+    }
+
+    assert(screen < static_cast<int>(_screens.size()));
+    _screens[screen]->manageWindow(e.window);
+  }
+}
+
 }
 
index c810057f83fe9b097bde749742efa11533782fd8..8c2015f95870af95005b39bc65525f048762b1e4 100644 (file)
@@ -188,6 +188,8 @@ public:
     manager can be destroyed.
   */
   inline void shutdown() { _doshutdown = true; }
+
+  virtual void mapRequestHandler(const XMapRequestEvent &);
 };
 
 }
This page took 0.031732 seconds and 4 git commands to generate.