handle map events with the Openbox class
This commit is contained in:
parent
1eb79b9a0d
commit
74cb09bb2c
6 changed files with 82 additions and 16 deletions
|
@ -118,7 +118,7 @@ public:
|
||||||
|
|
||||||
#if defined(SHAPE) || defined(DOXYGEN_IGNORE)
|
#if defined(SHAPE) || defined(DOXYGEN_IGNORE)
|
||||||
//! Called when a shape extention event fires
|
//! Called when a shape extention event fires
|
||||||
virtual void shapeHandler(const XShapeEvent &) {};
|
virtual void shapeHandler(const XShapeEvent &) {}
|
||||||
#endif // SHAPE
|
#endif // SHAPE
|
||||||
|
|
||||||
virtual ~OtkEventHandler();
|
virtual ~OtkEventHandler();
|
||||||
|
|
|
@ -16,7 +16,7 @@ bin_PROGRAMS= openbox3
|
||||||
openbox3_LDADD=../otk/libotk.a @LIBINTL@
|
openbox3_LDADD=../otk/libotk.a @LIBINTL@
|
||||||
|
|
||||||
openbox3_SOURCES= client.cc frame.cc openbox.cc screen.cc \
|
openbox3_SOURCES= client.cc frame.cc openbox.cc screen.cc \
|
||||||
main.cc xeventhandler.cc
|
main.cc
|
||||||
|
|
||||||
MAINTAINERCLEANFILES= Makefile.in
|
MAINTAINERCLEANFILES= Makefile.in
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,14 @@ extern "C" {
|
||||||
namespace ob {
|
namespace ob {
|
||||||
|
|
||||||
OBClient::OBClient(int screen, Window window)
|
OBClient::OBClient(int screen, Window window)
|
||||||
: _screen(screen), _window(window)
|
: otk::OtkEventHandler(),
|
||||||
|
_screen(screen), _window(window)
|
||||||
{
|
{
|
||||||
|
assert(screen >= 0);
|
||||||
assert(window);
|
assert(window);
|
||||||
|
|
||||||
|
Openbox::instance->registerHandler(_window, this);
|
||||||
|
|
||||||
ignore_unmaps = 0;
|
ignore_unmaps = 0;
|
||||||
|
|
||||||
// update EVERYTHING the first time!!
|
// 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();
|
const otk::OBProperty *property = Openbox::instance->property();
|
||||||
|
|
||||||
if (e.atom == XA_WM_NORMAL_HINTS)
|
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;
|
if (e.format != 32) return;
|
||||||
|
|
||||||
const otk::OBProperty *property = Openbox::instance->property();
|
const otk::OBProperty *property = Openbox::instance->property();
|
||||||
|
@ -659,8 +667,10 @@ void OBClient::update(const XClientMessageEvent &e)
|
||||||
|
|
||||||
|
|
||||||
#if defined(SHAPE) || defined(DOXYGEN_IGNORE)
|
#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;
|
_shaped = e.shaped;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,6 +19,7 @@ extern "C" {
|
||||||
|
|
||||||
#include "otk/strut.hh"
|
#include "otk/strut.hh"
|
||||||
#include "otk/rect.hh"
|
#include "otk/rect.hh"
|
||||||
|
#include "otk/eventhandler.hh"
|
||||||
|
|
||||||
namespace ob {
|
namespace ob {
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ class OBFrame;
|
||||||
class' member variables and call whatever is nessary to complete 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).
|
change (such as causing a redraw of the titlebar after the title is changed).
|
||||||
*/
|
*/
|
||||||
class OBClient {
|
class OBClient : public otk::OtkEventHandler {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! The frame window which decorates around the client window
|
//! 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
|
//! Returns the position and size of the client relative to the root window
|
||||||
inline const otk::Rect &area() const { return _area; }
|
inline const otk::Rect &area() const { return _area; }
|
||||||
|
|
||||||
//! Updates the OBClient class from a property change XEvent
|
virtual void propertyHandler(const XPropertyEvent &);
|
||||||
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 clientMessageHandler(const XClientMessageEvent &);
|
||||||
|
|
||||||
|
virtual void shapeHandler(const XShapeEvent &);
|
||||||
|
|
||||||
//! Changes the stored positions and size of the OBClient window
|
//! Changes the stored positions and size of the OBClient window
|
||||||
/*!
|
/*!
|
||||||
This does not actually change the physical geometry, that needs to be done
|
This does not actually change the physical geometry, that needs to be done
|
||||||
|
|
|
@ -121,6 +121,9 @@ Openbox::Openbox(int argc, char **argv)
|
||||||
|
|
||||||
_property = new otk::OBProperty();
|
_property = new otk::OBProperty();
|
||||||
|
|
||||||
|
// set this class as the fallback event handler (for map events)
|
||||||
|
setFallbackHandler(this);
|
||||||
|
|
||||||
// create the mouse cursors we'll use
|
// create the mouse cursors we'll use
|
||||||
_cursors.session = XCreateFontCursor(otk::OBDisplay::display, XC_left_ptr);
|
_cursors.session = XCreateFontCursor(otk::OBDisplay::display, XC_left_ptr);
|
||||||
_cursors.move = XCreateFontCursor(otk::OBDisplay::display, XC_fleur);
|
_cursors.move = XCreateFontCursor(otk::OBDisplay::display, XC_fleur);
|
||||||
|
@ -280,5 +283,59 @@ OBClient *Openbox::findClient(Window window)
|
||||||
return (OBClient*) 0;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,6 +188,8 @@ public:
|
||||||
manager can be destroyed.
|
manager can be destroyed.
|
||||||
*/
|
*/
|
||||||
inline void shutdown() { _doshutdown = true; }
|
inline void shutdown() { _doshutdown = true; }
|
||||||
|
|
||||||
|
virtual void mapRequestHandler(const XMapRequestEvent &);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue