summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2006-10-03 09:37:37 +0000
committerPeter Hutterer <peter@cs.unisa.edu.au>2006-10-03 09:37:37 +0000
commit7a83509c721e8e2c151af972c78eaf544256629f (patch)
tree5992c69f88a3e6cf5ef61cdd8fa4f7e843232de5
parent0393e95e81f8d0aa7390b44969ca14c255b27c9c (diff)
o x error handler is installed now, should stop MPWM from exiting when unmap
fails. + added XConn class, changed code to use XConn rather than passing dpy/screen/etc around. - cursor rendering code TAG: MPGWMPP_0_9
-rw-r--r--Changelog9
-rw-r--r--createpackage.sh4
-rw-r--r--src/Config.cpp31
-rw-r--r--src/Config.h11
-rw-r--r--src/FloorControl.cpp36
-rw-r--r--src/FloorControl.h7
-rw-r--r--src/Makefile5
-rw-r--r--src/Manager.cpp158
-rw-r--r--src/Manager.h10
-rw-r--r--src/Overlay.cpp66
-rw-r--r--src/Overlay.h7
-rw-r--r--src/PointerDevice.cpp79
-rw-r--r--src/PointerDevice.h11
-rw-r--r--src/WMWindow.cpp239
-rw-r--r--src/WMWindow.h8
-rw-r--r--src/XConn.cpp38
-rw-r--r--src/XConn.h29
-rw-r--r--src/cursor.h22
18 files changed, 360 insertions, 410 deletions
diff --git a/Changelog b/Changelog
index 0bcb04b..7d8ac38 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,12 @@
+03.10.2006
+o x error handler is installed now, should stop MPWM from exiting when unmap
+fails.
++ added XConn class, changed code to use XConn rather than passing
+dpy/screen/etc around.
+- cursor rendering code
+
+TAG: MPGWMPP_0_9
+
11.08.2006
+ added Manager::isWMDecoration()
o fixed a bug with unmap notifies, sometimes new windows didn't get closed.
diff --git a/createpackage.sh b/createpackage.sh
index c3ef252..f9cfadf 100644
--- a/createpackage.sh
+++ b/createpackage.sh
@@ -1,10 +1,10 @@
-# $Id: createpackage.sh,v 1.3 2006/07/05 06:32:39 whot Exp $
+# $Id: createpackage.sh,v 1.4 2006/10/03 09:37:37 whot Exp $
#
# This script creates a debian package for the MPWM.
#
#
-VERSION=0.8.3
+VERSION=0.8.4
if [ "$1" != "--skip-deb" ]
then
rm -rf Debian
diff --git a/src/Config.cpp b/src/Config.cpp
index 18e4e37..aae467c 100644
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -1,4 +1,4 @@
-/* $Id: Config.cpp,v 1.8 2006/06/16 07:36:54 whot Exp $ */
+/* $Id: Config.cpp,v 1.9 2006/10/03 09:37:37 whot Exp $ */
/*--
--*/
@@ -28,9 +28,9 @@ Config* Config::getInstance()
* @param root X11 root window.
* @param screen The used screen.
*/
-void Config::init(Display* dpy, Window root, int screen)
+void Config::init(XConn* x11)
{
- Config::instance = new Config(dpy, root, screen);
+ Config::instance = new Config(x11);
}
@@ -42,19 +42,18 @@ void Config::init(Display* dpy, Window root, int screen)
* @param root X11 root window.
* @param screen The used screen.
*/
-Config::Config(Display* dpy, Window root, int screen)
+Config::Config(XConn* x11)
{
- this->dpy = dpy;
- this->screen = screen;
+ this->x11 = x11;
windowBarHeight = 30;
- windowBarBG = BlackPixel(dpy, screen);
+ windowBarBG = x11->black;
resizeBarHeight = 20;
- resizeBarBG = WhitePixel(dpy, screen);
+ resizeBarBG = x11->white;
XColor color, exact_color;
- XAllocNamedColor(dpy, DefaultColormap(dpy, screen), "green", &color, &exact_color);
+ XAllocNamedColor(x11->dpy, x11->cmap, "green", &color, &exact_color);
resizeButtonHeight = resizeBarHeight;
resizeButtonWidth = 20;
resizeButtonBG = color.pixel;
@@ -69,7 +68,7 @@ Config::Config(Display* dpy, Window root, int screen)
buttonFloorWidth = 20;
buttonFloorHeight = 10;
- XAllocNamedColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), "orange",
+ XAllocNamedColor(x11->dpy, x11->cmap, "orange",
&color, &exact_color);
buttonOverlayX = buttonFloorX + 30;
buttonOverlayY = buttonFloorY;
@@ -82,12 +81,12 @@ Config::Config(Display* dpy, Window root, int screen)
buttonOwnerWidth = 20;
buttonOwnerHeight = 10;
- containerBG = WhitePixel(dpy, screen);
+ containerBG = x11->white;
- XAllocNamedColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), "blue", &color, &exact_color);
- buttonFloorPixel = WhitePixel(dpy, screen);
+ XAllocNamedColor(x11->dpy, x11->cmap, "blue", &color, &exact_color);
+ buttonFloorPixel = x11->white;
buttonClosePixel = color.pixel;
- buttonOwnerPixel = BlackPixel(dpy, screen);
+ buttonOwnerPixel = x11->black;
imgBackground = "../images/background.jpg";
@@ -121,14 +120,14 @@ long Config::cursorColor(int id)
TRACE("allocating %d/%d/%d for pointer %d\n", color.red, color.green, color.blue, id);
- long pixel = XAllocColor(dpy, DefaultColormap(dpy, screen), &color);
+ long pixel = XAllocColor(x11->dpy, x11->cmap, &color);
TRACE(" - result %d/%d/%d (pixel %ld)\n", color.red, color.green, color.blue, color.pixel);
if (!pixel)
{
ERR(" -cannot allocate color\n");
- pixel = WhitePixel(dpy, screen);
+ pixel = x11->white;
}
return color.pixel;
diff --git a/src/Config.h b/src/Config.h
index 0322e82..376686f 100644
--- a/src/Config.h
+++ b/src/Config.h
@@ -1,4 +1,4 @@
-/* $Id: Config.h,v 1.7 2006/06/16 07:36:54 whot Exp $ */
+/* $Id: Config.h,v 1.8 2006/10/03 09:37:37 whot Exp $ */
/*--
--*/
@@ -8,13 +8,12 @@
#include <X11/Xlib.h>
#include "ConfigurationError.h"
#include "logger.h"
+#include "XConn.h"
class Config
{
private:
- Display* dpy;
- Window root;
- int screen;
+ XConn* x11;
public:
int windowBarHeight;
@@ -70,12 +69,12 @@ class Config
public:
static Config* Config::getInstance();
- static void Config::init(Display* dpy, Window root, int screen);
+ static void Config::init(XConn* x11);
long cursorColor(int cursor);
protected:
- Config(Display* dpy, Window root, int screen);
+ Config(XConn* x11);
};
diff --git a/src/FloorControl.cpp b/src/FloorControl.cpp
index 50e5b6e..b82ebba 100644
--- a/src/FloorControl.cpp
+++ b/src/FloorControl.cpp
@@ -1,20 +1,20 @@
-/* $Id: FloorControl.cpp,v 1.5 2006/07/05 02:14:36 whot Exp $ */
+/* $Id: FloorControl.cpp,v 1.6 2006/10/03 09:37:37 whot Exp $ */
/*--
--*/
#include "FloorControl.h"
-FloorControl::FloorControl(Manager* manager, WMWindow* client, Display* dpy)
+FloorControl::FloorControl(Manager* manager, WMWindow* client, XConn* x11)
{
this->manager = manager;
this->client = client;
- this->dpy = dpy;
+ this->x11 = x11;
}
FloorControl::~FloorControl()
{
- XDestroyWindow(dpy, root->fcwin);
+ XDestroyWindow(x11->dpy, root->fcwin);
freeSubNodes(root);
delete root;
}
@@ -45,7 +45,7 @@ bool FloorControl::getChildren(WinTreeNodePtr node)
unsigned int no_children;
unsigned int i;
- XQueryTree(dpy, node->win, &root_return, &parent_return, &children, &no_children);
+ XQueryTree(x11->dpy, node->win, &root_return, &parent_return, &children, &no_children);
if (!no_children)
{
@@ -62,7 +62,7 @@ bool FloorControl::getChildren(WinTreeNodePtr node)
kidnode->win = children[i];
kidnode->parent = node;
- XGetWindowAttributes(dpy, kidnode->win, &kidnode->attr);
+ XGetWindowAttributes(x11->dpy, kidnode->win, &kidnode->attr);
node->children.push_back(kidnode);
i++;
@@ -87,7 +87,7 @@ void FloorControl::init()
root->win = client->getClientWindow();
root->parent = NULL;
- XGetWindowAttributes(dpy, root->win, &root->attr);
+ XGetWindowAttributes(x11->dpy, root->win, &root->attr);
unqueried.push_back(root);
@@ -123,16 +123,16 @@ void FloorControl::buildNodeGUI(WinTreePtr node, Window parent)
if (node->attr.map_state != IsViewable)
return;
- node->fcwin = XCreateSimpleWindow(dpy, parent, node->attr.x, node->attr.y,
+ node->fcwin = XCreateSimpleWindow(x11->dpy, parent, node->attr.x, node->attr.y,
node->attr.width - 2, node->attr.height - 2, 1,
- BlackPixel(dpy, 0), WhitePixel(dpy, 0));
+ BlackPixel(x11->dpy, 0), WhitePixel(x11->dpy, 0));
TRACE("Floor control creating window %x\n", node->fcwin);
- XSelectInput(dpy, node->fcwin, EnterWindowMask | LeaveWindowMask);
+ XSelectInput(x11->dpy, node->fcwin, EnterWindowMask | LeaveWindowMask);
manager->setButtonPressMask(node->fcwin);
- XMapWindow(dpy, node->fcwin);
- XFlush(dpy);
+ XMapWindow(x11->dpy, node->fcwin);
+ XFlush(x11->dpy);
vector<WinTreePtr>::iterator it = node->children.begin();
@@ -151,7 +151,7 @@ void FloorControl::buildNodeGUI(WinTreePtr node, Window parent)
void FloorControl::display()
{
buildNodeGUI(root, client->getContainer());
- XFlush(dpy);
+ XFlush(x11->dpy);
}
@@ -195,14 +195,14 @@ void FloorControl::handleEnterLeave(XCrossingEvent* ev)
XSetWindowAttributes attr;
if (ev->type == EnterNotify)
- attr.background_pixel = BlackPixel(dpy, 0);
+ attr.background_pixel = BlackPixel(x11->dpy, 0);
else
- attr.background_pixel = WhitePixel(dpy, 0);
+ attr.background_pixel = WhitePixel(x11->dpy, 0);
- XChangeWindowAttributes(dpy, node->fcwin, CWBackPixel, &attr);
- XClearWindow(dpy, node->fcwin);
- XFlush(dpy);
+ XChangeWindowAttributes(x11->dpy, node->fcwin, CWBackPixel, &attr);
+ XClearWindow(x11->dpy, node->fcwin);
+ XFlush(x11->dpy);
}
diff --git a/src/FloorControl.h b/src/FloorControl.h
index 6f1b3f5..0bd6168 100644
--- a/src/FloorControl.h
+++ b/src/FloorControl.h
@@ -1,4 +1,4 @@
-/* $Id: FloorControl.h,v 1.1 2006/06/21 08:13:15 whot Exp $ */
+/* $Id: FloorControl.h,v 1.2 2006/10/03 09:37:37 whot Exp $ */
/*--
--*/
@@ -11,6 +11,7 @@
#include "WMWindow.h"
#include "Manager.h"
#include "PointerDevice.h"
+#include "XConn.h"
using namespace std;
@@ -36,13 +37,13 @@ class PointerDevice;
class FloorControl
{
private:
- Display* dpy;
+ XConn* x11;
WinTreePtr root;
Manager* manager;
WMWindow* client;
public:
- FloorControl(Manager* manager, WMWindow* wmwindow, Display* dpy);
+ FloorControl(Manager* manager, WMWindow* wmwindow, XConn* x11);
~FloorControl();
void init();
void display();
diff --git a/src/Makefile b/src/Makefile
index 6689f1c..f0c7365 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.10 2006/06/23 07:19:27 whot Exp $
+# $Id: Makefile,v 1.11 2006/10/03 09:37:37 whot Exp $
APPNAME=mpwm
MPGXLIB=../../MPGXlib/src
@@ -6,7 +6,8 @@ CC=g++
LIBDIR=-L/usr/X11R6/lib -L$(MPGXLIB)
LIBS=-lmpx -lX11 -lXi -lXext -lMagick++
INCLUDES=-I/usr/X11R6/include/ -I$(MPGXLIB)
-OBJ= Config.o \
+OBJ= XConn.o\
+ Config.o \
DeviceError.o \
Util.o \
Manager.o \
diff --git a/src/Manager.cpp b/src/Manager.cpp
index 61573f4..4b776ed 100644
--- a/src/Manager.cpp
+++ b/src/Manager.cpp
@@ -1,16 +1,27 @@
-/* $Id: Manager.cpp,v 1.17 2006/08/11 07:17:11 whot Exp $ */
+/* $Id: Manager.cpp,v 1.18 2006/10/03 09:37:37 whot Exp $ */
/*--
--*/
#include "Manager.h"
+int MPWM_ErrorHandler(Display* dpy, XErrorEvent* ev)
+{
+ char *buffer = new char[1024];
+
+ XGetErrorText(dpy, ev->error_code, buffer, 1024);
+ DBG("%s\n", buffer);
+ delete buffer;
+
+ return 0;
+}
+
/**
* Start up and initialize internal variables.
*/
Manager::Manager()
{
- dpy = NULL;
+ x11 = NULL;
stop = false;
background = NULL;
}
@@ -32,7 +43,6 @@ void Manager::init(char* display)
initXi();
initMPGXlib();
queryInitial();
- raiseCursors();
}
/**
@@ -41,25 +51,16 @@ void Manager::init(char* display)
*/
void Manager::initX11(char* display)
{
- dpy = XOpenDisplay(display);
+ x11 = new XConn(display);
- if (!dpy)
- {
- ERR("Could not open display %s\n", display);
- throw new XError(XError::NO_DISPLAY);
- }
-
- root = DefaultRootWindow(dpy);
- screen = DefaultScreen(dpy);
-
- Config::init(dpy, root, screen);
+ Config::init(x11);
XSetWindowAttributes attr;
attr.event_mask = SubstructureRedirectMask | SubstructureNotifyMask |
ColormapChangeMask | PropertyChangeMask | ExposureMask;
- XChangeWindowAttributes(dpy, root, CWEventMask, &attr);
+ XChangeWindowAttributes(x11->dpy, x11->root, CWEventMask, &attr);
- XSync(dpy, False);
+ XSync(x11->dpy, False);
/* color background */
long mask;
@@ -68,23 +69,23 @@ void Manager::initX11(char* display)
color.red = color.blue = color.green = 26383;
- XAllocColor(dpy, DefaultColormap(dpy, screen), &color);
+ XAllocColor(x11->dpy, x11->cmap, &color);
TRACE("Background color is %d/%d/%d, %ld\n", color.red, color.blue, color.green, color.pixel);
mask = GCBackground | GCForeground;
vals.background = vals.foreground = color.pixel;
- root_gc = XCreateGC(dpy, root, mask, &vals);
+ root_gc = XCreateGC(x11->dpy, x11->root, mask, &vals);
if (!root_gc)
ERR("Could not create canvas on root window\n");
else
- XFillRectangle(dpy, root, root_gc, 0, 0, DisplayWidth(dpy, screen),
- DisplayHeight(dpy, screen));
+ XFillRectangle(x11->dpy, x11->root, root_gc, 0, 0, x11->width,
+ x11->height);
#if 1
Magick::Image* img = Util::ImageFromFile(Config::getInstance()->imgBackground);
- XImage* ximage = Util::ImageToXImage(dpy, DefaultScreen(dpy), img);
+ XImage* ximage = Util::ImageToXImage(x11->dpy, x11->screen, img);
if (!ximage)
{
@@ -92,11 +93,13 @@ void Manager::initX11(char* display)
} else
{
background = ximage;
- XPutImage(dpy, root, root_gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height);
+ XPutImage(x11->dpy, x11->root, root_gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height);
}
#endif
+ XSetErrorHandler(MPWM_ErrorHandler);
+
}
/**
@@ -107,7 +110,7 @@ void Manager::initXi()
XDeviceInfo* devices;
int devicecount;
- devices = XListInputDevices(dpy, &devicecount);
+ devices = XListInputDevices(x11->dpy, &devicecount);
if (devicecount <= 0)
throw new DeviceError(DeviceError::NO_DEVICES);
@@ -124,7 +127,7 @@ void Manager::initXi()
{
try
{
- PointerDevice *p = new PointerDevice(currDevice, dpy, root, this);
+ PointerDevice *p = new PointerDevice(currDevice, x11, this);
pointers.push_back(p);
} catch (DeviceError* e)
@@ -147,7 +150,7 @@ void Manager::initXi()
*/
void Manager::initMPGXlib()
{
- MPXInit(dpy);
+ MPXInit(x11->dpy);
}
/**
@@ -155,7 +158,7 @@ void Manager::initMPGXlib()
*/
void Manager::takedown()
{
- XCloseDisplay(dpy);
+ XCloseDisplay(x11->dpy);
}
/**
@@ -184,7 +187,7 @@ void Manager::queryInitial()
it++;
}
- XSync(dpy, False);
+ XSync(x11->dpy, False);
}
/**
@@ -199,22 +202,23 @@ vector<WMWindow*> Manager::queryWindows()
unsigned int childcount, clientchildcount;
vector<WMWindow*> windowList;
- XQueryTree(dpy, root, &rootWindow, &parent, &children, &childcount);
+ XQueryTree(x11->dpy, x11->root, &rootWindow, &parent, &children,
+ &childcount);
// for each window found we query whether the window is a WM window, just
// to be sure. If the window isn't, it is a new client window.
for (unsigned int i = 0; i < childcount; i++)
{
- XQueryTree(dpy, children[i], &rootWindow, &parent, &clientChildren,
- &clientchildcount);
+ XQueryTree(x11->dpy, children[i], &rootWindow, &parent,
+ &clientChildren, &clientchildcount);
XFree(clientChildren);
- if (parent != root || isWMWindow(children[i]))
+ if (parent != x11->root || isWMWindow(children[i]))
{
continue;
}
- WMWindow* win = new WMWindow(this, children[i], dpy, root);
+ WMWindow* win = new WMWindow(this, children[i], x11);
windowList.push_back(win);
}
XFree(children);
@@ -228,9 +232,6 @@ vector<WMWindow*> Manager::queryWindows()
*/
bool Manager::isWMWindow(Window win)
{
- if (isCursorWindow(win))
- return true;
-
WMWindow* window = windowToWMWindow(win);
if (window)
return true;
@@ -240,9 +241,6 @@ bool Manager::isWMWindow(Window win)
bool Manager::isWMDecoration(Window win)
{
- if (isCursorWindow(win))
- return true;
-
WMWindow* window = windowToWMWindow(win);
if (window && !window->isClientWindow(win))
return true;
@@ -251,24 +249,6 @@ bool Manager::isWMDecoration(Window win)
}
/**
- * @return true if the given window is a cursor window.
- */
-bool Manager::isCursorWindow(Window win)
-{
- vector<PointerDevice*>::const_iterator it =pointers.begin();
-
- while (it != pointers.end())
- {
- if ((*it)->isCursor(win))
- return true;
-
- it++;
-
- }
- return false;
-}
-
-/**
* @returns A pointer to the WMWindow this window belongs to.
*/
WMWindow* Manager::windowToWMWindow(Window w)
@@ -286,45 +266,14 @@ WMWindow* Manager::windowToWMWindow(Window w)
return NULL;
}
-/**
- * Raises the cursor windows to the top of the stack.
- */
-void Manager::raiseCursors()
-{
- vector<PointerDevice*>::const_iterator it = pointers.begin();
-
- while(it != pointers.end())
- {
- (*it)->raise();
- it++;
- }
-}
-
/**
- * Hides the system cursor by using a empty set of graphics as cursor icon.
+ * Hides the system cursor by moving it to the corner of the screen.
*/
void Manager::hideCursor()
{
- // this code is taken from a slashdot post, supposedly from the mythtv
- // source code.
- /*
- Cursor no_ptr;
- Pixmap bm_no;
- XColor black, dummy;
- Colormap colormap;
- static char no_data[] = { 0,0,0,0,0,0,0,0 }; //{ 1,1,1,1,1,1,1,1 };
-
- colormap = DefaultColormap(dpy, screen);
- XAllocNamedColor(dpy, colormap, "black", &black, &dummy);
- bm_no = XCreateBitmapFromData(dpy, root, no_data, 8, 8);
- no_ptr = XCreatePixmapCursor(dpy, bm_no, bm_no, &black, &black, 0, 0);
-
- XDefineCursor(dpy, root, no_ptr);
- XFreeCursor(dpy, no_ptr);
- */
- XWarpPointer(dpy, None, None, 0, 0, 0, 0, 1000, 1000);
+ XWarpPointer(x11->dpy, None, None, 0, 0, 0, 0, 1000, 1000);
}
@@ -337,7 +286,7 @@ void Manager::loop()
while(!stop)
{
- XNextEvent(dpy, &ev);
+ XNextEvent(x11->dpy, &ev);
switch(ev.type)
{
/* WM events */
@@ -365,7 +314,7 @@ void Manager::loop()
case ConfigureNotify:
break;
case Expose:
- if (ev.xexpose.window == root)
+ if (ev.xexpose.window == x11->root)
paintBackground(&(ev.xexpose));
else
{
@@ -400,14 +349,14 @@ void Manager::handleCreateNotify(XCreateWindowEvent* ev)
return;
}
- if (ev->parent != root)
+ if (ev->parent != x11->root)
{
TRACE(" -- No action, parent is not root\n");
return;
}
try {
- WMWindow* w = new WMWindow(this, ev->window, dpy, root);
+ WMWindow* w = new WMWindow(this, ev->window, x11);
w->decorate();
windows.push_back(w);
} catch (XError err)
@@ -432,7 +381,6 @@ void Manager::handleMapRequest(XMapEvent* ev)
}
w->mapAll();
- raiseCursors();
// In some cases we miss the PID. If we haven't got it yet, try to get it
// now.
@@ -480,7 +428,7 @@ void Manager::handleReparentNotify(XReparentEvent* ev)
{
TRACE("ReparentNotify for client %x. Now on parent %x.\n", (unsigned int)ev->window, (unsigned int)ev->parent);
- XMapWindow(dpy, ev->window);
+ XMapWindow(x11->dpy, ev->window);
WMWindow* w = windowToWMWindow(ev->window);
@@ -492,7 +440,7 @@ void Manager::handleReparentNotify(XReparentEvent* ev)
if (w->getState() == IsViewable)
w->mapAll();
- XFlush(dpy);
+ XFlush(x11->dpy);
}
void Manager::handleDestroyNotify(XDestroyWindowEvent* ev)
@@ -540,7 +488,7 @@ void Manager::handleDestroyNotify(XDestroyWindowEvent* ev)
} else
{
w->tagForDestruction();
- XDestroyWindow(dpy, w->container);
+ XDestroyWindow(x11->dpy, w->container);
TRACE(" - client tagged for destruction.\n");
}
@@ -569,7 +517,7 @@ void Manager::handleUnmapNotify(XUnmapEvent* ev)
return;
}
- XUnmapWindow(dpy, w->container);
+ XUnmapWindow(x11->dpy, w->container);
}
@@ -614,12 +562,6 @@ void Manager::handleMotionEvent(XDeviceMotionEvent* mev)
TRACE("DeviceMotionEvent for device %s on window %x\n", dev->getName().c_str(), (int)mev->window);
TRACE("-- subwindow is %x\n", (int)mev->subwindow);
- // move cursor window
-#ifdef RENDER_CURSOR
- XMoveWindow(dpy, dev->getCursorWin(), mev->x_root + 1, mev->y_root
- + 1);
-#endif
-
// There may be a drag event.
if (dev->isDragging())
dev->dragTo(mev->x_root, mev->y_root);
@@ -662,7 +604,6 @@ void Manager::handleButtonPress(XDeviceButtonEvent* bev)
if (wmwindow->isWindowBar(bev->window))
{
wmwindow->raise();
- raiseCursors();
if (dev->dragOn(wmwindow, bev->x, bev->y))
TRACE(" - Drag on for %x\n", (int)bev->window);
wmwindow->changeOwnership(dev);
@@ -671,7 +612,6 @@ void Manager::handleButtonPress(XDeviceButtonEvent* bev)
if (wmwindow->isResizeBar(bev->window))
{
wmwindow->raise();
- raiseCursors();
}
if (wmwindow->isResizeButton(bev->window))
@@ -803,7 +743,7 @@ bool Manager::hasShapeExtension()
if (!queried)
{
int eventop, errorop;
- hasShape = XShapeQueryExtension(dpy, &eventop, &errorop);
+ hasShape = XShapeQueryExtension(x11->dpy, &eventop, &errorop);
if (!hasShape)
ERR("No shape extension. Will not use pretty cursors.\n");
@@ -820,9 +760,9 @@ void Manager::paintBackground(XExposeEvent* ev)
{
if (background != NULL)
{
- XPutImage(dpy, root, root_gc, background, ev->x, ev->y, ev->x, ev->y, ev->width, ev->height);
+ XPutImage(x11->dpy, x11->root, root_gc, background, ev->x, ev->y, ev->x, ev->y, ev->width, ev->height);
} else
- XFillRectangle(dpy, root, root_gc, ev->x, ev->y, ev->width,
+ XFillRectangle(x11->dpy, x11->root, root_gc, ev->x, ev->y, ev->width,
ev->height);
}
diff --git a/src/Manager.h b/src/Manager.h
index c8540bf..071bb26 100644
--- a/src/Manager.h
+++ b/src/Manager.h
@@ -1,4 +1,4 @@
-/* $Id: Manager.h,v 1.10 2006/08/11 07:17:11 whot Exp $ */
+/* $Id: Manager.h,v 1.11 2006/10/03 09:37:37 whot Exp $ */
/*--
--*/
@@ -14,6 +14,7 @@
#include<stdio.h>
#include<Magick++.h>
#include "logger.h"
+#include "XConn.h"
#include "Config.h"
#include "WMWindow.h"
#include "PointerDevice.h"
@@ -26,14 +27,13 @@ using namespace std;
class WMWindow;
class PointerDevice;
+int MPWM_ErrorHandler(Display* dpy, XErrorEvent* ev);
class Manager
{
private:
Config* config;
- Display* dpy;
- Window root;
+ XConn* x11;
GC root_gc;
- int screen;
vector<WMWindow*> windows;
vector<PointerDevice*> pointers;
@@ -61,8 +61,6 @@ class Manager
vector<WMWindow*> queryWindows();
bool isWMWindow(Window win);
bool isWMDecoration(Window win);
- bool isCursorWindow(Window win);
- void raiseCursors();
void hideCursor();
void paintBackground(XExposeEvent* ev);
WMWindow* windowToWMWindow(Window w);
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index 61ae6fe..07f9fdf 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -1,15 +1,15 @@
-/* $Id: Overlay.cpp,v 1.5 2006/06/23 04:33:16 whot Exp $ */
+/* $Id: Overlay.cpp,v 1.6 2006/10/03 09:37:37 whot Exp $ */
/*--
--*/
#include "Overlay.h"
-Overlay::Overlay(Manager* manager, WMWindow* client, Display* dpy)
+Overlay::Overlay(Manager* manager, WMWindow* client, XConn* x11)
{
this->client = client;
this->manager = manager;
- this->dpy = dpy;
+ this->x11 = x11;
this->width = client->width;
this->height = client->height;
@@ -42,26 +42,26 @@ void Overlay::initWindows()
layer->dev = manager->idToPointerDevice(no_layers);
- layer->win = XCreateSimpleWindow(dpy, client->container, 0,
+ layer->win = XCreateSimpleWindow(x11->dpy, client->container, 0,
Config::getInstance()->windowBarHeight, width, height, 0,
CopyFromParent, layer->dev->getColor());
- layer->mask = XCreatePixmap(dpy, client->container, width, height, 1);
+ layer->mask = XCreatePixmap(x11->dpy, client->container, width, height, 1);
- layer->canvas = XCreateGC(dpy, layer->mask, GCForeground | GCLineWidth
+ layer->canvas = XCreateGC(x11->dpy, layer->mask, GCForeground | GCLineWidth
| GCLineStyle, &layer->gcvals);
layer->lastX = layer->lastY = 0;
layer->visible = false;
- XFillRectangle(dpy, layer->mask, layer->canvas, 0, 0, width, height);
- XSetForeground(dpy, layer->canvas, 1);
- XShapeCombineMask(dpy, layer->win,
+ XFillRectangle(x11->dpy, layer->mask, layer->canvas, 0, 0, width, height);
+ XSetForeground(x11->dpy, layer->canvas, 1);
+ XShapeCombineMask(x11->dpy, layer->win,
ShapeBounding, 0, 0,
layer->mask, ShapeSet);
layers.push_back(layer);
}
- XFlush(dpy);
+ XFlush(x11->dpy);
}
@@ -73,14 +73,14 @@ void Overlay::toggle(int id)
if (!layers[id]->visible)
{
TRACE("Overlay on\n");
- XMapRaised(dpy, layers[id]->win);
+ XMapRaised(x11->dpy, layers[id]->win);
layers[id]->visible = !layers[id]->visible;
MPXACLAddDenyDevices(client->getClientWindow(), &id, 1);
} else
{
TRACE("Overlay off\n");
- XUnmapWindow(dpy, layers[id]->win);
+ XUnmapWindow(x11->dpy, layers[id]->win);
layers[id]->visible = !layers[id]->visible;
MPXACLDelDenyDevices(client->getClientWindow(), &id, 1);
}
@@ -134,7 +134,7 @@ bool Overlay::handleMotionEvent(XDeviceMotionEvent* mev, PointerDevice* dev)
{
layer->gcvals.foreground = 1;
layer->gcvals.line_width = Config::getInstance()->drawLineWidth;
- XChangeGC(dpy, layers[mev->deviceid]->canvas,
+ XChangeGC(x11->dpy, layers[mev->deviceid]->canvas,
GCForeground | GCLineWidth, &layer->gcvals);
}
} else if (mev->device_state & Button3Mask)
@@ -143,20 +143,20 @@ bool Overlay::handleMotionEvent(XDeviceMotionEvent* mev, PointerDevice* dev)
{
layer->gcvals.foreground = 0;
layer->gcvals.line_width = Config::getInstance()->eraseLineWidth;
- XChangeGC(dpy, layers[mev->deviceid]->canvas,
+ XChangeGC(x11->dpy, layers[mev->deviceid]->canvas,
GCForeground | GCLineWidth, &layer->gcvals);
}
}
- XDrawLine(dpy, layer->mask, layer->canvas, layer->lastX, layer->lastY,
+ XDrawLine(x11->dpy, layer->mask, layer->canvas, layer->lastX, layer->lastY,
mev->x, mev->y);
layer->lastX = mev->x;
layer->lastY = mev->y;
- XShapeCombineMask(dpy, layer->win, ShapeBounding, 0, 0, layer->mask,
+ XShapeCombineMask(x11->dpy, layer->win, ShapeBounding, 0, 0, layer->mask,
ShapeSet);
- XFlush(dpy);
+ XFlush(x11->dpy);
TRACE("Line to %d/%d\n", layer->lastX, layer->lastY);
return true;
}
@@ -177,9 +177,9 @@ void Overlay::handlePressEvent(XDeviceButtonEvent* bev)
gcvals.foreground = 0;
} else return;
- XChangeGC(dpy, layers[bev->deviceid]->canvas,
+ XChangeGC(x11->dpy, layers[bev->deviceid]->canvas,
GCForeground | GCLineWidth, &gcvals);
- XFlush(dpy);
+ XFlush(x11->dpy);
layers[bev->deviceid]->lastX = bev->x;
layers[bev->deviceid]->lastY = bev->y;
@@ -227,17 +227,17 @@ void Overlay::resize(int width, int height)
OverlayLayer* layer = *it;
- XConfigureWindow(dpy, layer->win, CWWidth | CWHeight, &wc);
- Pixmap newmask = XCreatePixmap(dpy, layer->win, width, height, 1);
- GC newcanvas = XCreateGC(dpy, newmask, GCForeground | GCLineWidth | GCLineStyle, &gcvals);
+ XConfigureWindow(x11->dpy, layer->win, CWWidth | CWHeight, &wc);
+ Pixmap newmask = XCreatePixmap(x11->dpy, layer->win, width, height, 1);
+ GC newcanvas = XCreateGC(x11->dpy, newmask, GCForeground | GCLineWidth | GCLineStyle, &gcvals);
- XFillRectangle(dpy, newmask, newcanvas, 0, 0, width, height);
- XSetForeground(dpy, newcanvas, 1);
+ XFillRectangle(x11->dpy, newmask, newcanvas, 0, 0, width, height);
+ XSetForeground(x11->dpy, newcanvas, 1);
- XCopyArea(dpy, layer->mask, newmask, newcanvas, 0, 0, this->width, this->height, 0, 0);
+ XCopyArea(x11->dpy, layer->mask, newmask, newcanvas, 0, 0, this->width, this->height, 0, 0);
- XFreePixmap(dpy, layer->mask);
- XFreeGC(dpy, layer->canvas);
+ XFreePixmap(x11->dpy, layer->mask);
+ XFreeGC(x11->dpy, layer->canvas);
layer->mask = newmask;
layer->canvas = newcanvas;
@@ -245,7 +245,7 @@ void Overlay::resize(int width, int height)
}
- XFlush(dpy);
+ XFlush(x11->dpy);
this->width = width;
this->height = height;
TRACE("Overlay resized to %d/%d\n", width, height);
@@ -253,11 +253,11 @@ void Overlay::resize(int width, int height)
void Overlay::clean(int id)
{
- XSetForeground(dpy, layers[id]->canvas, 0);
- XFillRectangle(dpy, layers[id]->mask, layers[id]->canvas, 0, 0, width, height);
- XSetForeground(dpy, layers[id]->canvas, 1);
- XShapeCombineMask(dpy, layers[id]->win, ShapeBounding, 0, 0, layers[id]->mask,
+ XSetForeground(x11->dpy, layers[id]->canvas, 0);
+ XFillRectangle(x11->dpy, layers[id]->mask, layers[id]->canvas, 0, 0, width, height);
+ XSetForeground(x11->dpy, layers[id]->canvas, 1);
+ XShapeCombineMask(x11->dpy, layers[id]->win, ShapeBounding, 0, 0, layers[id]->mask,
ShapeSet);
- XFlush(dpy);
+ XFlush(x11->dpy);
}
diff --git a/src/Overlay.h b/src/Overlay.h
index 2c619e1..ee85099 100644
--- a/src/Overlay.h
+++ b/src/Overlay.h
@@ -1,4 +1,4 @@
-/* $Id: Overlay.h,v 1.4 2006/06/16 07:36:54 whot Exp $ */
+/* $Id: Overlay.h,v 1.5 2006/10/03 09:37:37 whot Exp $ */
/*--
--*/
@@ -14,6 +14,7 @@
#include<utility>
#include "logger.h"
#include "WMWindow.h"
+#include "XConn.h"
using namespace std;
@@ -37,7 +38,7 @@ class Overlay
private:
vector<OverlayLayer*> layers;
- Display* dpy;
+ XConn* x11;
WMWindow* client;
Manager* manager;
@@ -46,7 +47,7 @@ class Overlay
public:
- Overlay(Manager* manager, WMWindow* client, Display* dpy);
+ Overlay(Manager* manager, WMWindow* client, XConn* x11);
~Overlay();
void initWindows();
void toggle(int id);
diff --git a/src/PointerDevice.cpp b/src/PointerDevice.cpp
index b8e572f..e077384 100644
--- a/src/PointerDevice.cpp
+++ b/src/PointerDevice.cpp
@@ -1,10 +1,9 @@
-/* $Id: PointerDevice.cpp,v 1.10 2006/06/21 08:13:15 whot Exp $ */
+/* $Id: PointerDevice.cpp,v 1.11 2006/10/03 09:37:37 whot Exp $ */
/*--
--*/
#include "PointerDevice.h"
-#include "cursor.h"
int PointerDevice::XI_MotionNotify;
int PointerDevice::XI_ButtonPress;
@@ -12,25 +11,23 @@ int PointerDevice::XI_ButtonRelease;
int PointerDevice::counter = 0;
-PointerDevice::PointerDevice(XDeviceInfo* dev, Display* dpy, Window root, Manager* manager)
+PointerDevice::PointerDevice(XDeviceInfo* dev, XConn* x11, Manager* manager)
{
- XDevice* d = XOpenDevice(dpy, dev->id);
+ XDevice* d = XOpenDevice(x11->dpy, dev->id);
if (!d)
throw new DeviceError(DeviceError::OPEN_FAILED);
+ this->x11 = x11;
this->pointerID = PointerDevice::counter++;
TRACE("Creating pointer %d\n", pointerID);
this->name = string(dev->name);
this->id = dev->id;
this->dev = d;
- this->dpy = dpy;
this->dragWindow = NULL;
this->resizeWindow = NULL;
- this->root = root;
-
XEventClass motion, press, release;
DeviceMotionNotify(d, XI_MotionNotify, motion);
@@ -49,49 +46,13 @@ PointerDevice::PointerDevice(XDeviceInfo* dev, Display* dpy, Window root, Manage
evclasses[XI_ButtonPress] = press;
evclasses[XI_ButtonRelease] = release;
- XSelectExtensionEvent(dpy, root, &motion, 1);
+ XSelectExtensionEvent(x11->dpy, x11->root, &motion, 1);
color = Config::getInstance()->cursorColor(pointerID);
-#ifdef RENDER_CURSOR
- win = XCreateSimpleWindow(dpy, root, 0, 0, cursor_width, cursor_height, 0,
- 0, color);
-
- // check for XShapeExtension
- if (manager->hasShapeExtension())
- {
- Pixmap pixmap = XCreateBitmapFromData(dpy, win, (const char*)cursor_bits, cursor_width, cursor_height);
- Pixmap pmask = XCreateBitmapFromData(dpy, win, (const char*)cursor_mask_bits, cursor_width, cursor_height);
- XShapeCombineMask(dpy, win, ShapeClip, 0, 0, pixmap, ShapeSet);
- XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, pmask, ShapeSet);
- }
-#else
- // no cursor rendering by the WM
- win = XCreateSimpleWindow(dpy, root, 0, 0, 1, 1, 0,
- 0, Config::getInstance()->cursorColor(pointerID));
-#endif
-
- XMapRaised(dpy, win);
-
TRACE("Device %d (%s) initialised\n", (unsigned int)dev->id, dev->name);
}
/**
- * @return true if the window is the cursor's window.
- */
-bool PointerDevice::isCursor(Window win)
-{
- return win == this->win;
-}
-
-/**
- * Raises this cursor window to the top of the stack.
- */
-void PointerDevice::raise()
-{
- XRaiseWindow(dpy, win);
-}
-
-/**
* Move the client's window to the given position.
*/
void PointerDevice::dragTo(int x, int y)
@@ -115,7 +76,7 @@ void PointerDevice::dragOff()
dragOffset[0] = dragOffset[1] = 0;
XEventClass motion = evclasses[XI_MotionNotify];
- XSelectExtensionEvent(dpy, root, &motion, 1);
+ XSelectExtensionEvent(x11->dpy, x11->root, &motion, 1);
}
bool PointerDevice::isDragging()
@@ -144,7 +105,7 @@ bool PointerDevice::dragOn(WMWindow* win, int x, int y)
// in case we get out of the window we still need to catch the release
XEventClass classes[2] = {evclasses[XI_MotionNotify], evclasses[XI_ButtonRelease]};
- XSelectExtensionEvent(dpy, root, classes, 2);
+ XSelectExtensionEvent(x11->dpy, x11->root, classes, 2);
return true;
}
@@ -169,7 +130,7 @@ bool PointerDevice::resizeOn(WMWindow* win, Window button, int x, int y)
// in case we get out of the window we still need to catch the release
XEventClass classes[2] = {evclasses[XI_MotionNotify], evclasses[XI_ButtonRelease]};
- XSelectExtensionEvent(dpy, root, classes, 2);
+ XSelectExtensionEvent(x11->dpy, x11->root, classes, 2);
return true;
}
@@ -189,7 +150,7 @@ void PointerDevice::resizeOff()
resizeOffset[0] = resizeOffset[1] = 0;
XEventClass motion = evclasses[XI_MotionNotify];
- XSelectExtensionEvent(dpy, root, &motion, 1);
+ XSelectExtensionEvent(x11->dpy, x11->root, &motion, 1);
}
bool PointerDevice::isResizing()
@@ -221,22 +182,22 @@ void PointerDevice::setWMEvents(WMWindow* window)
classes[1] = evclasses[XI_ButtonPress];
classes[2] = evclasses[XI_ButtonRelease];
- XSelectExtensionEvent(dpy, window->getWindowBar(), &classes[0], 3);
- XSelectExtensionEvent(dpy, window->getResizeBar(), &classes[0], 3);
- XSelectExtensionEvent(dpy, window->getButtonClose(), &classes[1], 1);
- XSelectExtensionEvent(dpy, window->getButtonFloor(), &classes[1], 1);
- XSelectExtensionEvent(dpy, window->getButtonOverlay(), &classes[1], 1);
+ XSelectExtensionEvent(x11->dpy, window->getWindowBar(), &classes[0], 3);
+ XSelectExtensionEvent(x11->dpy, window->getResizeBar(), &classes[0], 3);
+ XSelectExtensionEvent(x11->dpy, window->getButtonClose(), &classes[1], 1);
+ XSelectExtensionEvent(x11->dpy, window->getButtonFloor(), &classes[1], 1);
+ XSelectExtensionEvent(x11->dpy, window->getButtonOverlay(), &classes[1], 1);
- XFlush(dpy);
+ XFlush(x11->dpy);
TRACE("Events set on windows %x, %x, %x\n", (int)window->getWindowBar(),
(int)window->getButtonClose(), (int)window->getButtonFloor());
TRACE(" -- events are %d, %d, %d\n", (int)classes[0], (int)classes[1],
(int)classes[2]);
- XSelectExtensionEvent(dpy, window->getResizeBtNE(), &classes[1], 1);
- XSelectExtensionEvent(dpy, window->getResizeBtNW(), &classes[1], 1);
- XSelectExtensionEvent(dpy, window->getResizeBtSE(), &classes[1], 1);
- XSelectExtensionEvent(dpy, window->getResizeBtSW(), &classes[1], 1);
+ XSelectExtensionEvent(x11->dpy, window->getResizeBtNE(), &classes[1], 1);
+ XSelectExtensionEvent(x11->dpy, window->getResizeBtNW(), &classes[1], 1);
+ XSelectExtensionEvent(x11->dpy, window->getResizeBtSE(), &classes[1], 1);
+ XSelectExtensionEvent(x11->dpy, window->getResizeBtSW(), &classes[1], 1);
}
/**
@@ -245,5 +206,5 @@ void PointerDevice::setWMEvents(WMWindow* window)
void PointerDevice::setButtonPressEventMask(Window win)
{
XEventClass evclass = evclasses[XI_ButtonPress];
- XSelectExtensionEvent(dpy, win, &evclass, 1);
+ XSelectExtensionEvent(x11->dpy, win, &evclass, 1);
}
diff --git a/src/PointerDevice.h b/src/PointerDevice.h
index 62fe4ab..01ba3c6 100644
--- a/src/PointerDevice.h
+++ b/src/PointerDevice.h
@@ -1,4 +1,4 @@
-/* $Id: PointerDevice.h,v 1.8 2006/06/21 08:13:15 whot Exp $ */
+/* $Id: PointerDevice.h,v 1.9 2006/10/03 09:37:37 whot Exp $ */
/*--
--*/
@@ -14,6 +14,7 @@
#include "Config.h"
#include "logger.h"
#include "WMWindow.h"
+#include "XConn.h"
using namespace std;
@@ -30,14 +31,12 @@ class PointerDevice
static int counter;
private:
int pointerID;
+ XConn* x11;
int id;
string name;
map<int, XEventClass> evclasses;
XDevice* dev;
- Window win;
- Window root;
- Display* dpy;
WMWindow* dragWindow;
int dragOffset[2];
@@ -49,12 +48,10 @@ class PointerDevice
long color;
public:
- PointerDevice(XDeviceInfo* device, Display* dpy, Window root, Manager* manager);
- bool isCursor(Window win);
+ PointerDevice(XDeviceInfo* device, XConn* x11, Manager* manager);
void raise();
int getID() { return id; }
string getName() { return name; }
- Window getCursorWin() { return win; }
bool isDragging();
bool dragOn(WMWindow* win, int x, int y);
diff --git a/src/WMWindow.cpp b/src/WMWindow.cpp
index bb604c0..4d197b1 100644
--- a/src/WMWindow.cpp
+++ b/src/WMWindow.cpp
@@ -1,4 +1,4 @@
-/* $Id: WMWindow.cpp,v 1.18 2006/08/11 07:17:11 whot Exp $ */
+/* $Id: WMWindow.cpp,v 1.19 2006/10/03 09:37:37 whot Exp $ */
/*--
--*/
@@ -21,11 +21,10 @@ int X_GetWindowAttributesErrorHandler(Display *dpy, XErrorEvent* err)
-WMWindow::WMWindow(Manager* manager, Window w, Display* dpy, Window root)
+WMWindow::WMWindow(Manager* manager, Window w, XConn* x11)
{
XWindowAttributes attr;
- this->dpy = dpy;
- this->root = root;
+ this->x11 = x11;
this->manager = manager;
this->exception = false;
this->process = NULL;
@@ -40,9 +39,9 @@ WMWindow::WMWindow(Manager* manager, Window w, Display* dpy, Window root)
// has been unmapped (firefox does that), then throw an exception and stop
// the constructor.
XSetErrorHandler(X_GetWindowAttributesErrorHandler);
- XGetWindowAttributes(dpy, w, &attr);
- XSync(dpy, False);
- XSetErrorHandler(NULL);
+ XGetWindowAttributes(x11->dpy, w, &attr);
+ XSync(x11->dpy, False);
+ XSetErrorHandler(MPWM_ErrorHandler);
errorwindow = NULL;
if (exception)
@@ -61,8 +60,8 @@ WMWindow::WMWindow(Manager* manager, Window w, Display* dpy, Window root)
x = (x < 0) ? 0 : x;
y = (y < 0) ? 0 : y;
- int dpywidth = DisplayWidth(dpy, DefaultScreen(dpy));
- int dpyheight = DisplayHeight(dpy, DefaultScreen(dpy));
+ int dpywidth = x11->width;
+ int dpyheight = x11->height;
x = (x > (dpywidth - width)) ? dpywidth - width : x;
y = (y > (dpyheight - height)) ? dpyheight - height : y;
@@ -151,21 +150,21 @@ bool WMWindow::isFloorControlWindow(Window win)
void WMWindow::decorate()
{
- XSelectInput(dpy, client, ColormapChangeMask | EnterWindowMask |
+ XSelectInput(x11->dpy, client, ColormapChangeMask | EnterWindowMask |
PropertyChangeMask | FocusChangeMask);
- XFlush(dpy);
+ XFlush(x11->dpy);
TRACE("decorating window %x\n", (unsigned int)client);
int totalHeight = height + Config::getInstance()->windowBarHeight +
Config::getInstance()->resizeBarHeight;
- container = XCreateSimpleWindow(dpy, root, x, y, width,
+ container = XCreateSimpleWindow(x11->dpy, x11->root, x, y, width,
totalHeight, 0, 0,
Config::getInstance()->containerBG);
TRACE(" - container %x\n", (unsigned int)container);
- windowBar = XCreateSimpleWindow(dpy, container, 0, 0, width,
+ windowBar = XCreateSimpleWindow(x11->dpy, container, 0, 0, width,
Config::getInstance()->windowBarHeight, 0, 0,
Config::getInstance()->windowBarBG);
@@ -176,7 +175,7 @@ void WMWindow::decorate()
Util::ImageFromFile(Config::getInstance()->imgTitlebar);
if (img)
{
- XImage* ximage = Util::ImageToXImage(dpy, DefaultScreen(dpy), img);
+ XImage* ximage = Util::ImageToXImage(x11->dpy, x11->screen, img);
if (!ximage)
{
@@ -187,11 +186,11 @@ void WMWindow::decorate()
XGCValues vals;
long mask = 0;
- windowbarGC = XCreateGC(dpy, windowBar, mask, &vals);
+ windowbarGC = XCreateGC(x11->dpy, windowBar, mask, &vals);
windowBarImg = ximage;
- XPutImage(dpy, windowBar, windowbarGC, windowBarImg, 0, 0, 0, 0, windowBarImg->width, windowBarImg->height);
+ XPutImage(x11->dpy, windowBar, windowbarGC, windowBarImg, 0, 0, 0, 0, windowBarImg->width, windowBarImg->height);
- XSelectInput(dpy, windowBar, ExposureMask);
+ XSelectInput(x11->dpy, windowBar, ExposureMask);
free(img);
}
}
@@ -200,7 +199,7 @@ void WMWindow::decorate()
TRACE(" - windowBar %x\n", (unsigned int)windowBar);
- btClose = XCreateSimpleWindow(dpy, windowBar, width -
+ btClose = XCreateSimpleWindow(x11->dpy, windowBar, width -
Config::getInstance()->buttonCloseX,
Config::getInstance()->buttonCloseY,
Config::getInstance()->buttonCloseWidth,
@@ -209,7 +208,7 @@ void WMWindow::decorate()
TRACE(" - btClose %x\n", (unsigned int)btClose);
- btFloor = XCreateSimpleWindow(dpy, windowBar, width -
+ btFloor = XCreateSimpleWindow(x11->dpy, windowBar, width -
Config::getInstance()->buttonFloorX,
Config::getInstance()->buttonFloorY,
Config::getInstance()->buttonFloorWidth,
@@ -219,7 +218,7 @@ void WMWindow::decorate()
TRACE(" - btFloor %x\n", (unsigned int)btFloor);
- btOwner = XCreateSimpleWindow(dpy, windowBar, width -
+ btOwner = XCreateSimpleWindow(x11->dpy, windowBar, width -
Config::getInstance()->buttonOwnerX,
Config::getInstance()->buttonOwnerY,
Config::getInstance()->buttonOwnerWidth,
@@ -228,7 +227,7 @@ void WMWindow::decorate()
TRACE(" - btOwner %x\n", (unsigned int)btOwner);
- btOverlay = XCreateSimpleWindow(dpy, windowBar, width -
+ btOverlay = XCreateSimpleWindow(x11->dpy, windowBar, width -
Config::getInstance()->buttonOverlayX,
Config::getInstance()->buttonOverlayY,
Config::getInstance()->buttonOverlayWidth,
@@ -240,7 +239,7 @@ void WMWindow::decorate()
img = Util::ImageFromFile(Config::getInstance()->imgBtClose);
if(img)
{
- XImage* ximage = Util::ImageToXImage(dpy, DefaultScreen(dpy), img);
+ XImage* ximage = Util::ImageToXImage(x11->dpy, x11->screen, img);
if (!ximage)
{
@@ -251,11 +250,11 @@ void WMWindow::decorate()
XGCValues vals;
long mask = 0;
- btCloseGC = XCreateGC(dpy, btClose, mask, &vals);
+ btCloseGC = XCreateGC(x11->dpy, btClose, mask, &vals);
btCloseImg = ximage;
- XPutImage(dpy, btClose, btCloseGC, btCloseImg, 0, 0, 0, 0, btCloseImg->width, btCloseImg->height);
+ XPutImage(x11->dpy, btClose, btCloseGC, btCloseImg, 0, 0, 0, 0, btCloseImg->width, btCloseImg->height);
- XSelectInput(dpy, btClose, ExposureMask);
+ XSelectInput(x11->dpy, btClose, ExposureMask);
free(img);
}
}
@@ -263,7 +262,7 @@ void WMWindow::decorate()
img = Util::ImageFromFile(Config::getInstance()->imgBtFloor);
if(img)
{
- XImage* ximage = Util::ImageToXImage(dpy, DefaultScreen(dpy), img);
+ XImage* ximage = Util::ImageToXImage(x11->dpy, x11->screen, img);
if (!ximage)
{
@@ -274,11 +273,11 @@ void WMWindow::decorate()
XGCValues vals;
long mask = 0;
- btFloorGC = XCreateGC(dpy, btFloor, mask, &vals);
+ btFloorGC = XCreateGC(x11->dpy, btFloor, mask, &vals);
btFloorImg = ximage;
- XPutImage(dpy, btFloor, btFloorGC, btFloorImg, 0, 0, 0, 0, btFloorImg->width, btFloorImg->height);
+ XPutImage(x11->dpy, btFloor, btFloorGC, btFloorImg, 0, 0, 0, 0, btFloorImg->width, btFloorImg->height);
- XSelectInput(dpy, btFloor, ExposureMask);
+ XSelectInput(x11->dpy, btFloor, ExposureMask);
free(img);
}
}
@@ -286,7 +285,7 @@ void WMWindow::decorate()
img = Util::ImageFromFile(Config::getInstance()->imgBtOverlay);
if(img)
{
- XImage* ximage = Util::ImageToXImage(dpy, DefaultScreen(dpy), img);
+ XImage* ximage = Util::ImageToXImage(x11->dpy, x11->screen, img);
if (!ximage)
{
@@ -297,16 +296,16 @@ void WMWindow::decorate()
XGCValues vals;
long mask = 0;
- btOverlayGC = XCreateGC(dpy, btOverlay, mask, &vals);
+ btOverlayGC = XCreateGC(x11->dpy, btOverlay, mask, &vals);
btOverlayImg = ximage;
- XPutImage(dpy, btOverlay, btOverlayGC, btOverlayImg, 0, 0, 0, 0, btOverlayImg->width, btOverlayImg->height);
+ XPutImage(x11->dpy, btOverlay, btOverlayGC, btOverlayImg, 0, 0, 0, 0, btOverlayImg->width, btOverlayImg->height);
- XSelectInput(dpy, btOverlay, ExposureMask);
+ XSelectInput(x11->dpy, btOverlay, ExposureMask);
free(img);
}
}
- resizeBar = XCreateSimpleWindow(dpy, container, 0,
+ resizeBar = XCreateSimpleWindow(x11->dpy, container, 0,
height + Config::getInstance()->windowBarHeight + 1,
width,
Config::getInstance()->resizeBarHeight,
@@ -319,7 +318,7 @@ void WMWindow::decorate()
img = Util::ImageFromFile(Config::getInstance()->imgResizebar);
if (img)
{
- XImage* ximage = Util::ImageToXImage(dpy, DefaultScreen(dpy), img);
+ XImage* ximage = Util::ImageToXImage(x11->dpy, x11->screen, img);
if (!ximage)
{
@@ -330,34 +329,34 @@ void WMWindow::decorate()
XGCValues vals;
long mask = 0;
- resizebarGC = XCreateGC(dpy, resizeBar, mask, &vals);
+ resizebarGC = XCreateGC(x11->dpy, resizeBar, mask, &vals);
resizeBarImg = ximage;
- XPutImage(dpy, resizeBar, resizebarGC, resizeBarImg, 0, 0, 0, 0, resizeBarImg->width, resizeBarImg->height);
+ XPutImage(x11->dpy, resizeBar, resizebarGC, resizeBarImg, 0, 0, 0, 0, resizeBarImg->width, resizeBarImg->height);
- XSelectInput(dpy, resizeBar, ExposureMask);
+ XSelectInput(x11->dpy, resizeBar, ExposureMask);
free(img);
}
}
- resizeBtNE = XCreateSimpleWindow(dpy, windowBar, width -
+ resizeBtNE = XCreateSimpleWindow(x11->dpy, windowBar, width -
Config::getInstance()->resizeButtonWidth,
0, Config::getInstance()->resizeButtonWidth,
Config::getInstance()->resizeButtonHeight,
0, 0, Config::getInstance()->resizeButtonBG);
- resizeBtNW = XCreateSimpleWindow(dpy, windowBar,
+ resizeBtNW = XCreateSimpleWindow(x11->dpy, windowBar,
0, 0, Config::getInstance()->resizeButtonWidth,
Config::getInstance()->resizeButtonHeight,
0, 0, Config::getInstance()->resizeButtonBG);
- resizeBtSE = XCreateSimpleWindow(dpy, resizeBar, width -
+ resizeBtSE = XCreateSimpleWindow(x11->dpy, resizeBar, width -
Config::getInstance()->resizeButtonWidth,
0, Config::getInstance()->resizeButtonWidth,
Config::getInstance()->resizeButtonHeight,
0, 0, Config::getInstance()->resizeButtonBG);
- resizeBtSW = XCreateSimpleWindow(dpy, resizeBar,
+ resizeBtSW = XCreateSimpleWindow(x11->dpy, resizeBar,
0, 0, Config::getInstance()->resizeButtonWidth,
Config::getInstance()->resizeButtonHeight,
0, 0, Config::getInstance()->resizeButtonBG);
@@ -367,13 +366,13 @@ void WMWindow::decorate()
img = Util::ImageFromFile(Config::getInstance()->imgResizeButton);
if (img)
{
- XImage* ximageNW = Util::ImageToXImage(dpy, DefaultScreen(dpy), img);
+ XImage* ximageNW = Util::ImageToXImage(x11->dpy, x11->screen, img);
img->flop();
- XImage* ximageNE = Util::ImageToXImage(dpy, DefaultScreen(dpy), img);
+ XImage* ximageNE = Util::ImageToXImage(x11->dpy, x11->screen, img);
img->rotate(180);
- XImage* ximageSW = Util::ImageToXImage(dpy, DefaultScreen(dpy), img);
+ XImage* ximageSW = Util::ImageToXImage(x11->dpy, x11->screen, img);
img->flop();
- XImage* ximageSE = Util::ImageToXImage(dpy, DefaultScreen(dpy), img);
+ XImage* ximageSE = Util::ImageToXImage(x11->dpy, x11->screen, img);
if (!(ximageNE && ximageSE && ximageSW && ximageNW))
{
@@ -393,55 +392,55 @@ void WMWindow::decorate()
XGCValues vals;
long mask = 0;
- resizeBtNEGC = XCreateGC(dpy, resizeBtNE, mask, &vals);
- resizeBtSEGC = XCreateGC(dpy, resizeBtSE, mask, &vals);
- resizeBtSWGC = XCreateGC(dpy, resizeBtSW, mask, &vals);
- resizeBtNWGC = XCreateGC(dpy, resizeBtNW, mask, &vals);
+ resizeBtNEGC = XCreateGC(x11->dpy, resizeBtNE, mask, &vals);
+ resizeBtSEGC = XCreateGC(x11->dpy, resizeBtSE, mask, &vals);
+ resizeBtSWGC = XCreateGC(x11->dpy, resizeBtSW, mask, &vals);
+ resizeBtNWGC = XCreateGC(x11->dpy, resizeBtNW, mask, &vals);
resizeBtNEImg = ximageNE;
resizeBtSEImg = ximageSE;
resizeBtSWImg = ximageSW;
resizeBtNWImg = ximageNW;
- XPutImage(dpy, resizeBtNE, resizeBtNEGC, resizeBtNEImg, 0, 0, 0,
+ XPutImage(x11->dpy, resizeBtNE, resizeBtNEGC, resizeBtNEImg, 0, 0, 0,
0, Config::getInstance()->resizeButtonWidth,
Config::getInstance()->resizeButtonHeight);
- XPutImage(dpy, resizeBtNW, resizeBtNWGC, resizeBtNWImg, 0, 0, 0,
+ XPutImage(x11->dpy, resizeBtNW, resizeBtNWGC, resizeBtNWImg, 0, 0, 0,
0, Config::getInstance()->resizeButtonWidth,
Config::getInstance()->resizeButtonHeight);
- XPutImage(dpy, resizeBtSW, resizeBtSWGC, resizeBtSWImg, 0, 0, 0,
+ XPutImage(x11->dpy, resizeBtSW, resizeBtSWGC, resizeBtSWImg, 0, 0, 0,
0, Config::getInstance()->resizeButtonWidth,
Config::getInstance()->resizeButtonHeight);
- XPutImage(dpy, resizeBtSE, resizeBtSEGC, resizeBtSEImg, 0, 0, 0,
+ XPutImage(x11->dpy, resizeBtSE, resizeBtSEGC, resizeBtSEImg, 0, 0, 0,
0, Config::getInstance()->resizeButtonWidth,
Config::getInstance()->resizeButtonHeight);
- XSelectInput(dpy, resizeBtNE, ExposureMask);
- XSelectInput(dpy, resizeBtSE, ExposureMask);
- XSelectInput(dpy, resizeBtNW, ExposureMask);
- XSelectInput(dpy, resizeBtSW, ExposureMask);
+ XSelectInput(x11->dpy, resizeBtNE, ExposureMask);
+ XSelectInput(x11->dpy, resizeBtSE, ExposureMask);
+ XSelectInput(x11->dpy, resizeBtNW, ExposureMask);
+ XSelectInput(x11->dpy, resizeBtSW, ExposureMask);
free(img);
}
}
- overlay = new Overlay(manager, this, dpy);
+ overlay = new Overlay(manager, this, x11);
XSetWindowAttributes attr;
attr.override_redirect = False;
- XChangeWindowAttributes(dpy, container, CWOverrideRedirect, &attr);
+ XChangeWindowAttributes(x11->dpy, container, CWOverrideRedirect, &attr);
- XMapWindow(dpy, btFloor);
- XMapWindow(dpy, btClose);
- XMapWindow(dpy, btOwner);
- XMapWindow(dpy, btOverlay);
- XMapWindow(dpy, windowBar);
- XMapWindow(dpy, resizeBar);
- XMapWindow(dpy, resizeBtSE);
- XMapWindow(dpy, resizeBtNE);
- XMapWindow(dpy, resizeBtSW);
- XMapWindow(dpy, resizeBtNW);
- XFlush(dpy);
+ XMapWindow(x11->dpy, btFloor);
+ XMapWindow(x11->dpy, btClose);
+ XMapWindow(x11->dpy, btOwner);
+ XMapWindow(x11->dpy, btOverlay);
+ XMapWindow(x11->dpy, windowBar);
+ XMapWindow(x11->dpy, resizeBar);
+ XMapWindow(x11->dpy, resizeBtSE);
+ XMapWindow(x11->dpy, resizeBtNE);
+ XMapWindow(x11->dpy, resizeBtSW);
+ XMapWindow(x11->dpy, resizeBtNW);
+ XFlush(x11->dpy);
}
/**
@@ -459,7 +458,7 @@ void WMWindow::reconfigure(XConfigureRequestEvent* ev)
move(x, y);
TRACE(" - Configured client %x\n", (unsigned int)client);
- XFlush(dpy);
+ XFlush(x11->dpy);
}
@@ -469,11 +468,11 @@ void WMWindow::reconfigure(XConfigureRequestEvent* ev)
*/
void WMWindow::manage()
{
- XAddToSaveSet(dpy, client);
- XSync(dpy, False);
- XReparentWindow(dpy, client, container, 0, Config::getInstance()->windowBarHeight);
+ XAddToSaveSet(x11->dpy, client);
+ XSync(x11->dpy, False);
+ XReparentWindow(x11->dpy, client, container, 0, Config::getInstance()->windowBarHeight);
- XSelectInput(dpy, container, SubstructureRedirectMask |
+ XSelectInput(x11->dpy, container, SubstructureRedirectMask |
SubstructureNotifyMask | ExposureMask);
vector<PointerDevice*>* pointers = manager->getPointers();
@@ -493,7 +492,7 @@ void WMWindow::manage()
*/
void WMWindow::move(int x, int y)
{
- XMoveWindow(dpy, container, x, y);
+ XMoveWindow(x11->dpy, container, x, y);
this->x = x;
this->y = y;
@@ -501,18 +500,18 @@ void WMWindow::move(int x, int y)
void WMWindow::mapAll()
{
- XMapWindow(dpy, client);
- XMapWindow(dpy, windowBar);
- XMapWindow(dpy, resizeBar);
- XMapWindow(dpy, btClose);
- XMapWindow(dpy, btFloor);
- XMapWindow(dpy, btOwner);
- XMapWindow(dpy, btOverlay);
- XMapWindow(dpy, container);
- XMapWindow(dpy, resizeBtSE);
- XMapWindow(dpy, resizeBtNE);
- XMapWindow(dpy, resizeBtSW);
- XMapWindow(dpy, resizeBtNW);
+ XMapWindow(x11->dpy, client);
+ XMapWindow(x11->dpy, windowBar);
+ XMapWindow(x11->dpy, resizeBar);
+ XMapWindow(x11->dpy, btClose);
+ XMapWindow(x11->dpy, btFloor);
+ XMapWindow(x11->dpy, btOwner);
+ XMapWindow(x11->dpy, btOverlay);
+ XMapWindow(x11->dpy, container);
+ XMapWindow(x11->dpy, resizeBtSE);
+ XMapWindow(x11->dpy, resizeBtNE);
+ XMapWindow(x11->dpy, resizeBtSW);
+ XMapWindow(x11->dpy, resizeBtNW);
setState(IsViewable);
}
@@ -628,7 +627,7 @@ void WMWindow::resizeAbsolute(int posx, int posy, int w, int h)
wc.width = width;
wc.height = height;
- XConfigureWindow(dpy, client, mask, &wc);
+ XConfigureWindow(x11->dpy, client, mask, &wc);
wc.width = width;
wc.height = height + Config::getInstance()->windowBarHeight +
@@ -647,49 +646,49 @@ void WMWindow::resizeAbsolute(int posx, int posy, int w, int h)
y = posy;
}
- XConfigureWindow(dpy, container, mask, &wc);
+ XConfigureWindow(x11->dpy, container, mask, &wc);
mask = CWWidth | CWHeight;
wc.height = Config::getInstance()->windowBarHeight;
- XConfigureWindow(dpy, windowBar, mask, &wc);
+ XConfigureWindow(x11->dpy, windowBar, mask, &wc);
// shift resize bar to bottom
wc.y = Config::getInstance()->windowBarHeight + height;
wc.width = width;
mask = CWY | CWWidth;
- XConfigureWindow(dpy, resizeBar, mask, &wc);
+ XConfigureWindow(x11->dpy, resizeBar, mask, &wc);
// shift the buttons to the right place
wc.x = width - Config::getInstance()->buttonCloseX;
wc.y = Config::getInstance()->buttonCloseY;
mask = CWX | CWY;
- XConfigureWindow(dpy, btClose, mask, &wc);
+ XConfigureWindow(x11->dpy, btClose, mask, &wc);
wc.x = width - Config::getInstance()->buttonFloorX;
wc.y = Config::getInstance()->buttonFloorY;
mask = CWX | CWY;
- XConfigureWindow(dpy, btFloor, mask, &wc);
+ XConfigureWindow(x11->dpy, btFloor, mask, &wc);
wc.x = width - Config::getInstance()->buttonOwnerX;
wc.y = Config::getInstance()->buttonOwnerY;
mask = CWX | CWY;
- XConfigureWindow(dpy, btOwner, mask, &wc);
+ XConfigureWindow(x11->dpy, btOwner, mask, &wc);
wc.x = width - Config::getInstance()->buttonOverlayX;
wc.y = Config::getInstance()->buttonOverlayY;
mask = CWX | CWY;
- XConfigureWindow(dpy, btOverlay, mask, &wc);
+ XConfigureWindow(x11->dpy, btOverlay, mask, &wc);
// shift resize buttons to right place
wc.x = width - Config::getInstance()->resizeButtonWidth;
mask = CWX;
- XConfigureWindow(dpy, resizeBtSE, mask, &wc);
+ XConfigureWindow(x11->dpy, resizeBtSE, mask, &wc);
wc.x = width - Config::getInstance()->resizeButtonWidth;
mask = CWX;
- XConfigureWindow(dpy, resizeBtNE, mask, &wc);
- XFlush(dpy);
+ XConfigureWindow(x11->dpy, resizeBtNE, mask, &wc);
+ XFlush(x11->dpy);
overlay->resize(width, height);
@@ -700,10 +699,10 @@ void WMWindow::resizeAbsolute(int posx, int posy, int w, int h)
void WMWindow::destroy()
{
- XUnmapWindow(dpy, container);
- XUnmapWindow(dpy, client);
- XDestroyWindow(dpy, client);
- XDestroyWindow(dpy, container);
+ XUnmapWindow(x11->dpy, container);
+ XUnmapWindow(x11->dpy, client);
+ XDestroyWindow(x11->dpy, client);
+ XDestroyWindow(x11->dpy, container);
if (process)
process->removeWindow(this);
tagForDestruction();
@@ -765,7 +764,7 @@ bool WMWindow::release(PointerDevice* dev)
void WMWindow::raise()
{
- XRaiseWindow(dpy, container);
+ XRaiseWindow(x11->dpy, container);
}
@@ -774,7 +773,7 @@ void WMWindow::extractPID()
if (process)
return;
- Atom atom_pid = XInternAtom(dpy, "_CLIENT_PID", True);
+ Atom atom_pid = XInternAtom(x11->dpy, "_CLIENT_PID", True);
if (!atom_pid)
{
ERR("Don't want to create _CLIENT_PID.\n");
@@ -787,7 +786,7 @@ void WMWindow::extractPID()
unsigned char* prop_return;
- XGetWindowProperty(dpy, client, atom_pid, 0, 4, False, XA_INTEGER, &type_return, &format_return, &nitems_return, &bytes_after, &prop_return);
+ XGetWindowProperty(x11->dpy, client, atom_pid, 0, 4, False, XA_INTEGER, &type_return, &format_return, &nitems_return, &bytes_after, &prop_return);
if (nitems_return != 4)
{
ERR("Cannot get _CLIENT_PID. Use modified Xlib.\n");
@@ -828,49 +827,49 @@ void WMWindow::recolor()
if (dev == NULL)
return;
- XSetWindowBackground(dpy, btOwner,
+ XSetWindowBackground(x11->dpy, btOwner,
Config::getInstance()->cursorColor(dev->getID()));
- XClearWindow(dpy, btOwner);
- XFlush(dpy);
+ XClearWindow(x11->dpy, btOwner);
+ XFlush(x11->dpy);
}
void WMWindow::expose(XExposeEvent* ev)
{
if (ev->window == windowBar)
{
- XPutImage(dpy, windowBar, windowbarGC, windowBarImg, ev->x, ev->y,
+ XPutImage(x11->dpy, windowBar, windowbarGC, windowBarImg, ev->x, ev->y,
ev->x, ev->y, ev->width, ev->height);
} else if (ev->window == resizeBtNE)
{
- XPutImage(dpy, resizeBtNE, resizeBtNEGC, resizeBtNEImg, ev->x, ev->y,
+ XPutImage(x11->dpy, resizeBtNE, resizeBtNEGC, resizeBtNEImg, ev->x, ev->y,
ev->x, ev->y, ev->width, ev->height);
} else if(ev->window == resizeBtSE)
{
- XPutImage(dpy, resizeBtSE, resizeBtSEGC, resizeBtSEImg, ev->x, ev->y,
+ XPutImage(x11->dpy, resizeBtSE, resizeBtSEGC, resizeBtSEImg, ev->x, ev->y,
ev->x, ev->y, ev->width, ev->height);
} else if(ev->window == resizeBtNW)
{
- XPutImage(dpy, resizeBtNW, resizeBtNWGC, resizeBtNWImg, ev->x, ev->y,
+ XPutImage(x11->dpy, resizeBtNW, resizeBtNWGC, resizeBtNWImg, ev->x, ev->y,
ev->x, ev->y, ev->width, ev->height);
} else if(ev->window == resizeBtSW)
{
- XPutImage(dpy, resizeBtSW, resizeBtSWGC, resizeBtSWImg, ev->x, ev->y,
+ XPutImage(x11->dpy, resizeBtSW, resizeBtSWGC, resizeBtSWImg, ev->x, ev->y,
ev->x, ev->y, ev->width, ev->height);
} else if(ev->window == resizeBar)
{
- XPutImage(dpy, resizeBar, resizebarGC, resizeBarImg, ev->x, ev->y,
+ XPutImage(x11->dpy, resizeBar, resizebarGC, resizeBarImg, ev->x, ev->y,
ev->x, ev->y, ev->width, ev->height);
} else if(ev->window == btClose)
{
- XPutImage(dpy, btClose, btCloseGC, btCloseImg, ev->x, ev->y,
+ XPutImage(x11->dpy, btClose, btCloseGC, btCloseImg, ev->x, ev->y,
ev->x, ev->y, ev->width, ev->height);
} else if(ev->window == btFloor)
{
- XPutImage(dpy, btFloor, btFloorGC, btFloorImg, ev->x, ev->y,
+ XPutImage(x11->dpy, btFloor, btFloorGC, btFloorImg, ev->x, ev->y,
ev->x, ev->y, ev->width, ev->height);
} else if(ev->window == btOverlay)
{
- XPutImage(dpy, btOverlay, btOverlayGC, btOverlayImg, ev->x, ev->y,
+ XPutImage(x11->dpy, btOverlay, btOverlayGC, btOverlayImg, ev->x, ev->y,
ev->x, ev->y, ev->width, ev->height);
}
}
@@ -920,7 +919,7 @@ void WMWindow::toggleFloorControl()
{
if (!fcgui)
{
- fcgui = new FloorControl(manager, this, dpy);
+ fcgui = new FloorControl(manager, this, x11);
fcgui->init();
fcgui->display();
} else
diff --git a/src/WMWindow.h b/src/WMWindow.h
index 8f24408..bfdfa40 100644
--- a/src/WMWindow.h
+++ b/src/WMWindow.h
@@ -1,4 +1,4 @@
-/* $Id: WMWindow.h,v 1.12 2006/06/21 08:13:15 whot Exp $ */
+/* $Id: WMWindow.h,v 1.13 2006/10/03 09:37:38 whot Exp $ */
/*--
--*/
@@ -17,6 +17,7 @@
#include "Process.h"
#include "Overlay.h"
#include "FloorControl.h"
+#include "XConn.h"
using namespace std;
@@ -35,8 +36,7 @@ class WMWindow
{
private:
Manager* manager;
- Display* dpy;
- Window root;
+ XConn* x11;
Process* process;
@@ -98,7 +98,7 @@ class WMWindow
FloorControl* fcgui;
public:
- WMWindow(Manager* manager, Window client_window, Display* dpy, Window root);
+ WMWindow(Manager* manager, Window client_window, XConn* x11);
~WMWindow();
bool hasWindow(Window window);
bool isWindowBar(Window window);
diff --git a/src/XConn.cpp b/src/XConn.cpp
new file mode 100644
index 0000000..2faa8eb
--- /dev/null
+++ b/src/XConn.cpp
@@ -0,0 +1,38 @@
+/* $Id: XConn.cpp,v 1.1 2006/10/03 09:37:38 whot Exp $ */
+
+#include "XConn.h"
+#include "XError.h"
+
+/*
+ * Connect to the given X Server and get all default settings.
+ */
+XConn::XConn(char* host)
+{
+ dpy = XOpenDisplay(host);
+ if (!dpy)
+ throw XError(XError::NO_DISPLAY);
+ getDefaults();
+}
+
+
+/**
+ * Get most used default settings and fill member variables.
+ */
+void XConn::getDefaults()
+{
+ screen = DefaultScreen(dpy);
+ vis = DefaultVisual(dpy, screen);
+ black = BlackPixel(dpy, screen);
+ white = WhitePixel(dpy, screen);
+ root = RootWindow(dpy, screen);
+ depth = DefaultDepth(dpy, screen);
+ cmap = DefaultColormap(dpy, screen);
+ width = DisplayWidth(dpy, screen);
+ height = DisplayHeight(dpy, screen);
+}
+
+
+XConn::~XConn()
+{
+ XCloseDisplay(dpy);
+}
diff --git a/src/XConn.h b/src/XConn.h
new file mode 100644
index 0000000..27e40fd
--- /dev/null
+++ b/src/XConn.h
@@ -0,0 +1,29 @@
+#ifndef __XCONN_H__
+#define __XCONN_H__
+#include <X11/Xlib.h>
+
+class XConn {
+ public:
+ Display* dpy;
+ int screen;
+ Visual* vis;
+ long black;
+ long white;
+ Window root;
+ int depth;
+ Colormap cmap;
+ int width;
+ int height;
+
+ public:
+ /* Connect to given X Server, fill with default variables */
+ XConn(char* display);
+
+ ~XConn();
+
+ private:
+ void connect(char* display);
+ void getDefaults();
+};
+
+#endif
diff --git a/src/cursor.h b/src/cursor.h
deleted file mode 100644
index 5cd557c..0000000
--- a/src/cursor.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef __CURSOR_H_
-#define __CURSOR_H_
-/* blatantly stolen from wm-mp */
-
-#define cursor_width 16
-#define cursor_height 16
-#define cursor_x_hot 1
-#define cursor_y_hot 1
-
-static unsigned char cursor_bits[] = {
- 0x00, 0x00, 0x06, 0x00, 0x1e, 0x00, 0x7c, 0x00, 0xfc, 0x01, 0xf8, 0x07,
- 0xf8, 0x1f, 0xf0, 0x07, 0xf0, 0x03, 0xe0, 0x07, 0xe0, 0x0e, 0x40, 0x1c,
- 0x40, 0x38, 0x00, 0x70, 0x00, 0x20, 0x00, 0x00};
-
-#define cursor_mask_width 16
-#define cursor_mask_height 16
-static unsigned char cursor_mask_bits[] = {
- 0x07, 0x00, 0x1f, 0x00, 0x7f, 0x00, 0xfe, 0x01, 0xfe, 0x07, 0xfc, 0x1f,
- 0xfc, 0x3f, 0xf8, 0x1f, 0xf8, 0x07, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x3e,
- 0xe0, 0x7c, 0x40, 0xf8, 0x00, 0x70, 0x00, 0x20};
-#endif
-