fix compiling with the new strut (new namespace)
and fix general errors that broke compiling. make xeventhandler find the OBClient for most events..
This commit is contained in:
parent
d3b7c84d4c
commit
d363f720a6
8 changed files with 115 additions and 77 deletions
|
@ -14,6 +14,8 @@ extern "C" {
|
||||||
|
|
||||||
#include "otk/timer.hh"
|
#include "otk/timer.hh"
|
||||||
#include "otk/property.hh"
|
#include "otk/property.hh"
|
||||||
|
#include "otk/rect.hh"
|
||||||
|
#include "otk/strut.hh"
|
||||||
#include "blackbox.hh"
|
#include "blackbox.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
|
@ -148,7 +150,7 @@ private:
|
||||||
std::string title, icon_title;
|
std::string title, icon_title;
|
||||||
|
|
||||||
otk::Rect rect;
|
otk::Rect rect;
|
||||||
Strut strut;
|
otk::Strut strut;
|
||||||
|
|
||||||
int old_bw; // client's borderwidth
|
int old_bw; // client's borderwidth
|
||||||
|
|
||||||
|
@ -219,7 +221,7 @@ private:
|
||||||
otk::Rect changing;
|
otk::Rect changing;
|
||||||
|
|
||||||
otk::Rect rect; // frame geometry
|
otk::Rect rect; // frame geometry
|
||||||
Strut margin; // margins between the frame and client
|
otk::Strut margin; // margins between the frame and client
|
||||||
|
|
||||||
int grab_x, grab_y; // where was the window when it was grabbed?
|
int grab_x, grab_y; // where was the window when it was grabbed?
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,9 @@ extern "C" {
|
||||||
|
|
||||||
namespace ob {
|
namespace ob {
|
||||||
|
|
||||||
OBClient::OBClient(BScreen *screen, Window window)
|
OBClient::OBClient(Window window)
|
||||||
: _screen(screen), _window(window)
|
: _window(window)
|
||||||
{
|
{
|
||||||
assert(_screen);
|
|
||||||
assert(window);
|
assert(window);
|
||||||
|
|
||||||
// initialize vars to false/invalid values
|
// initialize vars to false/invalid values
|
||||||
|
|
|
@ -13,8 +13,6 @@ extern "C" {
|
||||||
|
|
||||||
namespace ob {
|
namespace ob {
|
||||||
|
|
||||||
class BScreen;
|
|
||||||
|
|
||||||
class OBClient {
|
class OBClient {
|
||||||
public:
|
public:
|
||||||
enum Max { Max_None,
|
enum Max { Max_None,
|
||||||
|
@ -64,7 +62,6 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BScreen *_screen;
|
|
||||||
Window _window;
|
Window _window;
|
||||||
|
|
||||||
//! The id of the group the window belongs to
|
//! The id of the group the window belongs to
|
||||||
|
@ -143,7 +140,7 @@ private:
|
||||||
void updateClass();
|
void updateClass();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OBClient(BScreen *screen, Window window);
|
OBClient(Window window);
|
||||||
virtual ~OBClient();
|
virtual ~OBClient();
|
||||||
|
|
||||||
inline Window window() const { return _window; }
|
inline Window window() const { return _window; }
|
||||||
|
|
|
@ -210,5 +210,22 @@ void Openbox::eventLoop()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Openbox::addClient(Window window, OBClient *client)
|
||||||
|
{
|
||||||
|
_clients[window] = client;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Openbox::removeClient(Window window)
|
||||||
|
{
|
||||||
|
_clients[window] = (OBClient *) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
OBClient *Openbox::findClient(Window window)
|
||||||
|
{
|
||||||
|
return _clients[window];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,13 @@ extern "C" {
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include "otk/screeninfo.hh"
|
#include "otk/screeninfo.hh"
|
||||||
#include "otk/timerqueuemanager.hh"
|
#include "otk/timerqueuemanager.hh"
|
||||||
#include "otk/property.hh"
|
#include "otk/property.hh"
|
||||||
#include "xeventhandler.hh"
|
#include "xeventhandler.hh"
|
||||||
|
#include "client.hh"
|
||||||
|
|
||||||
namespace ob {
|
namespace ob {
|
||||||
|
|
||||||
|
@ -46,6 +48,9 @@ public:
|
||||||
State_Normal, //!< The window manager is running in its normal state
|
State_Normal, //!< The window manager is running in its normal state
|
||||||
State_Exiting //!< The window manager is exiting (being destroyed)
|
State_Exiting //!< The window manager is exiting (being destroyed)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! A map for looking up a specific client class from the window id
|
||||||
|
typedef std::map<Window, OBClient *> ClientMap;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// stuff that can be passed on the command line
|
// stuff that can be passed on the command line
|
||||||
|
@ -64,6 +69,9 @@ private:
|
||||||
//! The value of argv[0], i.e. how this application was executed
|
//! The value of argv[0], i.e. how this application was executed
|
||||||
char *_argv0;
|
char *_argv0;
|
||||||
|
|
||||||
|
//! A list of all managed clients
|
||||||
|
ClientMap _clients;
|
||||||
|
|
||||||
//! Manages all timers for the application
|
//! Manages all timers for the application
|
||||||
/*!
|
/*!
|
||||||
Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
|
Use of the otk::OBTimerQueueManager::fire funtion in this object ensures
|
||||||
|
@ -128,6 +136,15 @@ public:
|
||||||
*/
|
*/
|
||||||
void eventLoop();
|
void eventLoop();
|
||||||
|
|
||||||
|
//! Adds an OBClient to the client list for lookups
|
||||||
|
void addClient(Window window, OBClient *client);
|
||||||
|
|
||||||
|
//! Removes an OBClient from the client list for lookups
|
||||||
|
void removeClient(Window window);
|
||||||
|
|
||||||
|
//! Finds an OBClient based on its window id
|
||||||
|
OBClient *findClient(Window window);
|
||||||
|
|
||||||
//! Requests that the window manager exit
|
//! Requests that the window manager exit
|
||||||
/*!
|
/*!
|
||||||
Causes the Openbox::eventLoop function to stop looping, so that the window
|
Causes the Openbox::eventLoop function to stop looping, so that the window
|
||||||
|
|
|
@ -113,7 +113,8 @@ BScreen::BScreen(Blackbox *bb, unsigned int scrn) : ScreenInfo(scrn) {
|
||||||
|
|
||||||
// xatom->setSupported(this); // set-up netwm support
|
// xatom->setSupported(this); // set-up netwm support
|
||||||
#ifdef HAVE_GETPID
|
#ifdef HAVE_GETPID
|
||||||
xatom->setValue(getRootWindow(), otk::OBProperty::blackbox_pid, otk::OBProperty::cardinal,
|
xatom->setValue(getRootWindow(), otk::OBProperty::blackbox_pid,
|
||||||
|
otk::OBProperty::Atom_Cardinal,
|
||||||
(unsigned long) getpid());
|
(unsigned long) getpid());
|
||||||
#endif // HAVE_GETPID
|
#endif // HAVE_GETPID
|
||||||
unsigned long geometry[] = { getWidth(),
|
unsigned long geometry[] = { getWidth(),
|
||||||
|
@ -1519,12 +1520,12 @@ void BScreen::hideGeometry(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BScreen::addStrut(Strut *strut) {
|
void BScreen::addStrut(otk::Strut *strut) {
|
||||||
strutList.push_back(strut);
|
strutList.push_back(strut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BScreen::removeStrut(Strut *strut) {
|
void BScreen::removeStrut(otk::Strut *strut) {
|
||||||
strutList.remove(strut);
|
strutList.remove(strut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1569,7 +1570,7 @@ void BScreen::updateAvailableArea(void) {
|
||||||
StrutList::const_iterator it = strutList.begin(), end = strutList.end();
|
StrutList::const_iterator it = strutList.begin(), end = strutList.end();
|
||||||
|
|
||||||
for(; it != end; ++it) {
|
for(; it != end; ++it) {
|
||||||
Strut *strut = *it;
|
otk::Strut *strut = *it;
|
||||||
if (strut->left > current_left)
|
if (strut->left > current_left)
|
||||||
current_left = strut->left;
|
current_left = strut->left;
|
||||||
if (strut->top > current_top)
|
if (strut->top > current_top)
|
||||||
|
|
|
@ -24,6 +24,7 @@ extern "C" {
|
||||||
#include "otk/font.hh"
|
#include "otk/font.hh"
|
||||||
#include "otk/texture.hh"
|
#include "otk/texture.hh"
|
||||||
#include "otk/image.hh"
|
#include "otk/image.hh"
|
||||||
|
#include "otk/strut.hh"
|
||||||
#include "otk/property.hh"
|
#include "otk/property.hh"
|
||||||
#include "timer.hh"
|
#include "timer.hh"
|
||||||
#include "workspace.hh"
|
#include "workspace.hh"
|
||||||
|
@ -31,8 +32,6 @@ extern "C" {
|
||||||
|
|
||||||
namespace ob {
|
namespace ob {
|
||||||
|
|
||||||
struct Strut;
|
|
||||||
|
|
||||||
enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify };
|
enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify };
|
||||||
|
|
||||||
struct PixmapMask {
|
struct PixmapMask {
|
||||||
|
@ -83,7 +82,7 @@ private:
|
||||||
RectList xineramaUsableArea;
|
RectList xineramaUsableArea;
|
||||||
#endif // XINERAMA
|
#endif // XINERAMA
|
||||||
|
|
||||||
typedef std::list<Strut*> StrutList;
|
typedef std::list<otk::Strut*> StrutList;
|
||||||
StrutList strutList;
|
StrutList strutList;
|
||||||
typedef std::vector<Workspace*> WorkspaceList;
|
typedef std::vector<Workspace*> WorkspaceList;
|
||||||
WorkspaceList workspacesList;
|
WorkspaceList workspacesList;
|
||||||
|
@ -270,8 +269,8 @@ public:
|
||||||
const RectList& allAvailableAreas(void) const;
|
const RectList& allAvailableAreas(void) const;
|
||||||
#endif // XINERAMA
|
#endif // XINERAMA
|
||||||
void updateAvailableArea(void);
|
void updateAvailableArea(void);
|
||||||
void addStrut(Strut *strut);
|
void addStrut(otk::Strut *strut);
|
||||||
void removeStrut(Strut *strut);
|
void removeStrut(otk::Strut *strut);
|
||||||
|
|
||||||
unsigned int addWorkspace(void);
|
unsigned int addWorkspace(void);
|
||||||
unsigned int removeLastWorkspace(void);
|
unsigned int removeLastWorkspace(void);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
// -*- mode: C++; indent-tabs-mode: nil; -*-
|
||||||
|
|
||||||
#include "xeventhandler.hh"
|
#include "xeventhandler.hh"
|
||||||
|
#include "client.hh"
|
||||||
|
#include "openbox.hh"
|
||||||
#include "otk/display.hh"
|
#include "otk/display.hh"
|
||||||
#include "otk/rect.hh"
|
#include "otk/rect.hh"
|
||||||
|
|
||||||
|
@ -45,6 +47,10 @@ void OBXEventHandler::motion(const XMotionEvent &e)
|
||||||
void OBXEventHandler::enterNotify(const XCrossingEvent &e)
|
void OBXEventHandler::enterNotify(const XCrossingEvent &e)
|
||||||
{
|
{
|
||||||
_lasttime = e.time;
|
_lasttime = e.time;
|
||||||
|
|
||||||
|
OBClient *client = Openbox::instance->findClient(e.window);
|
||||||
|
if (!client) return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
BScreen *screen = (BScreen *) 0;
|
BScreen *screen = (BScreen *) 0;
|
||||||
BlackboxWindow *win = (BlackboxWindow *) 0;
|
BlackboxWindow *win = (BlackboxWindow *) 0;
|
||||||
|
@ -65,6 +71,10 @@ void OBXEventHandler::enterNotify(const XCrossingEvent &e)
|
||||||
void OBXEventHandler::leaveNotify(const XCrossingEvent &e)
|
void OBXEventHandler::leaveNotify(const XCrossingEvent &e)
|
||||||
{
|
{
|
||||||
_lasttime = e.time;
|
_lasttime = e.time;
|
||||||
|
|
||||||
|
OBClient *client = Openbox::instance->findClient(e.window);
|
||||||
|
if (!client) return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
BlackboxWindow *win = (BlackboxWindow *) 0;
|
BlackboxWindow *win = (BlackboxWindow *) 0;
|
||||||
|
|
||||||
|
@ -76,7 +86,9 @@ void OBXEventHandler::leaveNotify(const XCrossingEvent &e)
|
||||||
|
|
||||||
void OBXEventHandler::configureRequest(const XConfigureRequestEvent &e)
|
void OBXEventHandler::configureRequest(const XConfigureRequestEvent &e)
|
||||||
{
|
{
|
||||||
(void)e;
|
OBClient *client = Openbox::instance->findClient(e.window);
|
||||||
|
if (!client) return;
|
||||||
|
|
||||||
/* BlackboxWindow *win = (BlackboxWindow *) 0;
|
/* BlackboxWindow *win = (BlackboxWindow *) 0;
|
||||||
|
|
||||||
if ((win = searchWindow(e->xconfigurerequest.window))) {
|
if ((win = searchWindow(e->xconfigurerequest.window))) {
|
||||||
|
@ -106,6 +118,16 @@ void OBXEventHandler::mapRequest(const XMapRequestEvent &e)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("MapRequest for 0x%lx\n", e.window);
|
printf("MapRequest for 0x%lx\n", e.window);
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
|
OBClient *client = Openbox::instance->findClient(e.window);
|
||||||
|
|
||||||
|
if (client) {
|
||||||
|
// XXX: uniconify and/or unshade the window
|
||||||
|
} else {
|
||||||
|
// XXX: manage the window, i.e. grab events n shit
|
||||||
|
Openbox::instance->addClient(e.window, new OBClient(e.window));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
BlackboxWindow *win = searchWindow(e->xmaprequest.window);
|
BlackboxWindow *win = searchWindow(e->xmaprequest.window);
|
||||||
|
|
||||||
|
@ -160,48 +182,37 @@ void OBXEventHandler::mapRequest(const XMapRequestEvent &e)
|
||||||
|
|
||||||
void OBXEventHandler::unmapNotify(const XUnmapEvent &e)
|
void OBXEventHandler::unmapNotify(const XUnmapEvent &e)
|
||||||
{
|
{
|
||||||
(void)e;
|
OBClient *client = Openbox::instance->findClient(e.window);
|
||||||
/*
|
if (!client) return;
|
||||||
BlackboxWindow *win = (BlackboxWindow *) 0;
|
|
||||||
BScreen *screen = (BScreen *) 0;
|
// XXX: unmanage the window, i.e. ungrab events n reparent n shit
|
||||||
|
Openbox::instance->removeClient(e.window);
|
||||||
if ((win = searchWindow(e->xunmap.window))) {
|
|
||||||
win->unmapNotifyEvent(&e->xunmap);
|
|
||||||
} else if ((screen = searchSystrayWindow(e->xunmap.window))) {
|
|
||||||
screen->removeSystrayWindow(e->xunmap.window);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OBXEventHandler::destroyNotify(const XDestroyWindowEvent &e)
|
void OBXEventHandler::destroyNotify(const XDestroyWindowEvent &e)
|
||||||
{
|
{
|
||||||
(void)e;
|
// XXX: window group leaders can come through here too!
|
||||||
/*
|
|
||||||
BlackboxWindow *win = (BlackboxWindow *) 0;
|
OBClient *client = Openbox::instance->findClient(e.window);
|
||||||
BScreen *screen = (BScreen *) 0;
|
if (!client) return;
|
||||||
BWindowGroup *group = (BWindowGroup *) 0;
|
|
||||||
|
// XXX: unmanage the window, i.e. ungrab events n reparent n shit
|
||||||
if ((win = searchWindow(e->xdestroywindow.window))) {
|
Openbox::instance->removeClient(e.window);
|
||||||
win->destroyNotifyEvent(&e->xdestroywindow);
|
|
||||||
} else if ((group = searchGroup(e->xdestroywindow.window))) {
|
|
||||||
delete group;
|
|
||||||
} else if ((screen = searchSystrayWindow(e->xunmap.window))) {
|
|
||||||
screen->removeSystrayWindow(e->xunmap.window);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OBXEventHandler::reparentNotify(const XReparentEvent &e)
|
void OBXEventHandler::reparentNotify(const XReparentEvent &e)
|
||||||
{
|
{
|
||||||
(void)e;
|
|
||||||
/*
|
/*
|
||||||
this event is quite rare and is usually handled in unmapNotify
|
this event is quite rare and is usually handled in unmapNotify
|
||||||
however, if the window is unmapped when the reparent event occurs
|
however, if the window is unmapped when the reparent event occurs
|
||||||
the window manager never sees it because an unmap event is not sent
|
the window manager never sees it because an unmap event is not sent
|
||||||
to an already unmapped window.
|
to an already unmapped window.
|
||||||
*/
|
*/
|
||||||
|
OBClient *client = Openbox::instance->findClient(e.window);
|
||||||
|
if (!client) return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
BlackboxWindow *win = searchWindow(e->xreparent.window);
|
BlackboxWindow *win = searchWindow(e->xreparent.window);
|
||||||
if (win)
|
if (win)
|
||||||
|
@ -213,45 +224,40 @@ void OBXEventHandler::reparentNotify(const XReparentEvent &e)
|
||||||
void OBXEventHandler::propertyNotify(const XPropertyEvent &e)
|
void OBXEventHandler::propertyNotify(const XPropertyEvent &e)
|
||||||
{
|
{
|
||||||
_lasttime = e.time;
|
_lasttime = e.time;
|
||||||
/*
|
|
||||||
BlackboxWindow *win = (BlackboxWindow *) 0;
|
|
||||||
BScreen *screen = (BScreen *) 0;
|
|
||||||
|
|
||||||
if ((win = searchWindow(e->xproperty.window)))
|
OBClient *client = Openbox::instance->findClient(e.window);
|
||||||
win->propertyNotifyEvent(&e->xproperty);
|
if (!client) return;
|
||||||
else if ((screen = searchScreen(e->xproperty.window)))
|
|
||||||
screen->propertyNotifyEvent(&e->xproperty);
|
client->update(e);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OBXEventHandler::expose(const XExposeEvent &first)
|
void OBXEventHandler::expose(const XExposeEvent &first)
|
||||||
{
|
{
|
||||||
// compress expose events
|
OBClient *client = Openbox::instance->findClient(first.window);
|
||||||
XEvent e; e.xexpose = first;
|
if (!client) return;
|
||||||
unsigned int i = 0;
|
|
||||||
otk::Rect area(e.xexpose.x, e.xexpose.y, e.xexpose.width,
|
|
||||||
e.xexpose.height);
|
|
||||||
while (XCheckTypedWindowEvent(otk::OBDisplay::display,
|
|
||||||
e.xexpose.window, Expose, &e)) {
|
|
||||||
i++;
|
|
||||||
// merge expose area
|
|
||||||
area |= otk::Rect(e.xexpose.x, e.xexpose.y, e.xexpose.width,
|
|
||||||
e.xexpose.height);
|
|
||||||
}
|
|
||||||
if ( i > 0 ) {
|
|
||||||
// use the merged area
|
|
||||||
e.xexpose.x = area.x();
|
|
||||||
e.xexpose.y = area.y();
|
|
||||||
e.xexpose.width = area.width();
|
|
||||||
e.xexpose.height = area.height();
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
BlackboxWindow *win = (BlackboxWindow *) 0;
|
|
||||||
|
|
||||||
if ((win = searchWindow(e->xexpose.window)))
|
// compress expose events
|
||||||
win->exposeEvent(&e->xexpose);
|
XEvent e; e.xexpose = first;
|
||||||
*/
|
unsigned int i = 0;
|
||||||
|
otk::Rect area(e.xexpose.x, e.xexpose.y, e.xexpose.width,
|
||||||
|
e.xexpose.height);
|
||||||
|
while (XCheckTypedWindowEvent(otk::OBDisplay::display,
|
||||||
|
e.xexpose.window, Expose, &e)) {
|
||||||
|
i++;
|
||||||
|
// merge expose area
|
||||||
|
area |= otk::Rect(e.xexpose.x, e.xexpose.y, e.xexpose.width,
|
||||||
|
e.xexpose.height);
|
||||||
|
}
|
||||||
|
if ( i > 0 ) {
|
||||||
|
// use the merged area
|
||||||
|
e.xexpose.x = area.x();
|
||||||
|
e.xexpose.y = area.y();
|
||||||
|
e.xexpose.width = area.width();
|
||||||
|
e.xexpose.height = area.height();
|
||||||
|
}
|
||||||
|
|
||||||
|
// XXX: make the decorations redraw!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue