all repos — openbox @ 74cb09bb2cc4832463a57743b1495eef24237d2a

openbox fork - make it a bit more like ryudo

handle map events with the Openbox class
Dana Jansens danakj@orodu.net
commit

74cb09bb2cc4832463a57743b1495eef24237d2a

parent

1eb79b9a0d75f057a85d1a5d91658a3f96ae8152

6 files changed, 82 insertions(+), 16 deletions(-)

jump to
M otk/eventhandler.hhotk/eventhandler.hh

@@ -118,7 +118,7 @@ virtual void clientMessageHandler(const XClientMessageEvent &);

#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();
M src/Makefile.amsrc/Makefile.am

@@ -16,7 +16,7 @@

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
M src/client.ccsrc/client.cc

@@ -23,9 +23,13 @@

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;

@@ -494,8 +498,10 @@ if (num > 1) _app_class = v[1];

} -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::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 @@ }

#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
M src/client.hhsrc/client.hh

@@ -19,6 +19,7 @@ #include <string>

#include "otk/strut.hh" #include "otk/rect.hh" +#include "otk/eventhandler.hh" namespace ob {

@@ -36,7 +37,7 @@ client, it will call the ActionHandler (for client messages) or update the

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 @@

//! 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
M src/openbox.ccsrc/openbox.cc

@@ -121,6 +121,9 @@ sigaction(SIGHUP, &action, (struct sigaction *) 0);

_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);

@@ -278,6 +281,60 @@ if (it != _clients.end())

return it->second; else 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); + } } }
M src/openbox.hhsrc/openbox.hh

@@ -188,6 +188,8 @@ Causes the Openbox::eventLoop function to stop looping, so that the window

manager can be destroyed. */ inline void shutdown() { _doshutdown = true; } + + virtual void mapRequestHandler(const XMapRequestEvent &); }; }