summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-05-13 14:07:01 +1000
committerPeter Hutterer <peter.hutterer@redhat.com>2009-05-13 09:26:19 -0400
commit3a8c82c9857f288fa341534fb400cc398f40206b (patch)
tree6030f86f678b4570151cdf805a7d37798e6b9c0c
parentff835630657886912641840d48a64c8d72c442f5 (diff)
rebase to xi2
-rw-r--r--configure.ac2
-rw-r--r--src/DockApp.cpp2
-rw-r--r--src/DockApp.h4
-rw-r--r--src/DockItem.h4
-rw-r--r--src/DockKeyboard.cpp2
-rw-r--r--src/DockKeyboard.h2
-rw-r--r--src/DockProcess.cpp2
-rw-r--r--src/DockProcess.h2
-rw-r--r--src/KeyboardDevice.cpp9
-rw-r--r--src/KeyboardDevice.h5
-rw-r--r--src/Manager.cpp169
-rw-r--r--src/Manager.h17
-rw-r--r--src/PointerDevice.cpp146
-rw-r--r--src/PointerDevice.h13
14 files changed, 168 insertions, 211 deletions
diff --git a/configure.ac b/configure.ac
index 4b2770a..eb34617 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,7 +15,7 @@ AC_CHECK_PROG([XCURSORGEN],[xcursorgen],[`which xcursorgen`])
# XSetClientPointer is only in the MPX aware lib, so we're all good if it
# exists.
AC_CHECK_LIB([Xi], [XSetClientPointer])
-PKG_CHECK_MODULES(MPWM, x11 xext xi xcursor cairo)
+PKG_CHECK_MODULES(MPWM, x11 xext [xi >= 1.2.9] xcursor cairo [inputproto >= 1.9.99.8])
AC_SUBST(MPWM_LIBS)
diff --git a/src/DockApp.cpp b/src/DockApp.cpp
index e2b0287..da2de47 100644
--- a/src/DockApp.cpp
+++ b/src/DockApp.cpp
@@ -34,7 +34,7 @@ void DockApp::setup()
XFlush(x11->dpy);
}
-void DockApp::handleButtonEvent(PointerDevice* ptr, XDeviceButtonEvent* ev)
+void DockApp::handleButtonEvent(PointerDevice* ptr, XIDeviceEvent* ev)
{
system(app);
}
diff --git a/src/DockApp.h b/src/DockApp.h
index 92e9633..9003930 100644
--- a/src/DockApp.h
+++ b/src/DockApp.h
@@ -4,7 +4,7 @@
#define __DOCKAPP_H__
#include <X11/Xlib.h>
-#include <X11/extensions/XInput.h>
+#include <X11/extensions/XInput2.h>
#include "XConn.h"
#include "DockItem.h"
#include "PointerDevice.h"
@@ -17,7 +17,7 @@ class DockApp : public DockItem
public:
DockApp(XConn* x11, const char* app, char* imgfile);
- void handleButtonEvent(PointerDevice* ptr, XDeviceButtonEvent* ev);
+ void handleButtonEvent(PointerDevice* ptr, XIDeviceEvent* ev);
void setup();
};
diff --git a/src/DockItem.h b/src/DockItem.h
index cb57212..e8ee311 100644
--- a/src/DockItem.h
+++ b/src/DockItem.h
@@ -4,7 +4,7 @@
#define __DOCKITEM_H__
#include <X11/Xlib.h>
-#include <X11/extensions/XInput.h>
+#include <X11/extensions/XInput2.h>
#include "XConn.h"
class PointerDevice;
@@ -21,7 +21,7 @@ class DockItem
void initGUI(Window parent, int x, int y, int width, int height);
bool hasWindow(Window win);
void handleExpose(XExposeEvent *ev);
- virtual void handleButtonEvent(PointerDevice* ptr, XDeviceButtonEvent* ev) = 0;
+ virtual void handleButtonEvent(PointerDevice* ptr, XIDeviceEvent* ev) = 0;
virtual void setup() = 0;
virtual ~DockItem();
Window getButton() { return button; }
diff --git a/src/DockKeyboard.cpp b/src/DockKeyboard.cpp
index a5c786f..56c5564 100644
--- a/src/DockKeyboard.cpp
+++ b/src/DockKeyboard.cpp
@@ -31,7 +31,7 @@ void DockKeyboard::setup()
}
void DockKeyboard::handleButtonEvent(PointerDevice* ptr,
- XDeviceButtonEvent* ev)
+ XIDeviceEvent* ev)
{
TRACE("Pairing %s with %s\n", ptr->getName().c_str(), kbd->getName().c_str());
//XChangePointerKeyboardPairing(x11->dpy, ptr->getDevice(), kbd->getDevice());
diff --git a/src/DockKeyboard.h b/src/DockKeyboard.h
index cb9497f..5a8e475 100644
--- a/src/DockKeyboard.h
+++ b/src/DockKeyboard.h
@@ -15,7 +15,7 @@ class DockKeyboard : public DockItem
public:
DockKeyboard(XConn* x11, KeyboardDevice* kbd);
- void handleButtonEvent(PointerDevice* ptr, XDeviceButtonEvent* ev);
+ void handleButtonEvent(PointerDevice* ptr, XIDeviceEvent* ev);
void setup();
};
diff --git a/src/DockProcess.cpp b/src/DockProcess.cpp
index ca8c8eb..c281afd 100644
--- a/src/DockProcess.cpp
+++ b/src/DockProcess.cpp
@@ -37,7 +37,7 @@ void DockProcess::setup()
XFlush(x11->dpy);
}
-void DockProcess::handleButtonEvent(PointerDevice* ptr, XDeviceButtonEvent* ev)
+void DockProcess::handleButtonEvent(PointerDevice* ptr, XIDeviceEvent* ev)
{
client->setMinimize(false);
dock->removeProcess(this);
diff --git a/src/DockProcess.h b/src/DockProcess.h
index addd97d..5a77503 100644
--- a/src/DockProcess.h
+++ b/src/DockProcess.h
@@ -22,7 +22,7 @@ class DockProcess : public DockItem
public:
DockProcess(XConn* x11, WMWindow* client, Dock* dock);
- void handleButtonEvent(PointerDevice* ptr, XDeviceButtonEvent* ev);
+ void handleButtonEvent(PointerDevice* ptr, XIDeviceEvent* ev);
void setup();
};
diff --git a/src/KeyboardDevice.cpp b/src/KeyboardDevice.cpp
index 3cfaac3..05a1e1f 100644
--- a/src/KeyboardDevice.cpp
+++ b/src/KeyboardDevice.cpp
@@ -3,17 +3,12 @@
int KeyboardDevice::counter = 0;
-KeyboardDevice::KeyboardDevice(XDeviceInfo* dev, XConn* x11, Manager* manager)
+KeyboardDevice::KeyboardDevice(XIDeviceInfo* dev, XConn* x11, Manager* manager)
{
- XDevice* d = XOpenDevice(x11->dpy, dev->id);
-
- if (!d)
- throw new DeviceError(DeviceError::OPEN_FAILED);
this->x11 = x11;
this->kbdID = KeyboardDevice::counter++;
this->name = string(dev->name);
- this->id = dev->id;
- this->dev = d;
+ this->id = dev->deviceid;
this->paired = NULL;
TRACE("Keyboard %d (%s) initialised\n", kbdID, dev->name);
}
diff --git a/src/KeyboardDevice.h b/src/KeyboardDevice.h
index ed0ded9..1cdd6e1 100644
--- a/src/KeyboardDevice.h
+++ b/src/KeyboardDevice.h
@@ -2,7 +2,7 @@
#define __KEYBOARDDEVICE_H__
#include<X11/Xlib.h>
-#include<X11/extensions/XInput.h>
+#include<X11/extensions/XInput2.h>
#include<string>
#include<vector>
#include "DeviceError.h"
@@ -28,10 +28,9 @@ class KeyboardDevice
PointerDevice* paired;
public:
- KeyboardDevice(XDeviceInfo* device, XConn* x11, Manager* manager);
+ KeyboardDevice(XIDeviceInfo* device, XConn* x11, Manager* manager);
int getID() { return id; }
string getName() { return name; }
- XDevice* getDevice() { return dev; }
void setPaired(PointerDevice* ptr) { paired = ptr; }
PointerDevice* getPaired() { return paired; }
};
diff --git a/src/Manager.cpp b/src/Manager.cpp
index a2783ef..f7a6be1 100644
--- a/src/Manager.cpp
+++ b/src/Manager.cpp
@@ -117,22 +117,21 @@ void Manager::initX11(char* display)
*/
void Manager::initXi()
{
- XDeviceInfo* devices;
+ XIDeviceInfo* devices;
int devicecount;
- XQueryInputVersion(x11->dpy, XI_2_Major, XI_2_Minor);
- devices = XListInputDevices(x11->dpy, &devicecount);
+ devices = XIQueryDevice(x11->dpy, XIAllMasterDevices, &devicecount);
if (devicecount <= 0)
throw new DeviceError(DeviceError::NO_DEVICES);
while(devicecount)
{
- XDeviceInfo* currDevice;
+ XIDeviceInfo* currDevice;
currDevice = &devices[--devicecount];
/* ignore slave devices, only masters are interesting */
- if ((currDevice->use == IsXPointer))
+ if ((currDevice->use == XIMasterPointer))
{
try
{
@@ -143,25 +142,13 @@ void Manager::initXi()
{
ERR("%s\n", e->message.c_str());
}
- } else if ((currDevice->use == IsXKeyboard))
+ } else if ((currDevice->use == XIMasterKeyboard))
{
try
{
KeyboardDevice *k = new KeyboardDevice(currDevice, x11, this);
keyboards.push_back(k);
- /* run through classes, find attach class to get the
- paried pointer.*/
- XAnyClassPtr any = currDevice->inputclassinfo;
- for (int i = 0; i < currDevice->num_classes; i++) {
- switch(any->c_class)
- {
- case AttachClass:
- XAttachInfoPtr att = (XAttachInfoPtr)any;
- k->setPaired(idToPointerDevice(att->attached));
- break;
- }
- any = (XAnyClassPtr) ((char *) any + any->length);
- }
+ k->setPaired(idToPointerDevice(currDevice->attachment));
} catch (DeviceError* e)
{
ERR("%s\n", e->message.c_str());
@@ -170,9 +157,7 @@ void Manager::initXi()
}
dock->setPointerEvents(&pointers);
- XFreeDeviceList(devices);
-
- XSelectExtensionEvent(x11->dpy, x11->root, &x11->presence_class, 1);
+ XIFreeDeviceInfo(devices);
}
/**
@@ -346,7 +331,7 @@ void Manager::loop()
break;
/* XInput device events */
default:
- handleOtherEvents(&ev);
+ handleOtherEvents((XIEvent*)&ev);
break;
}
}
@@ -532,30 +517,33 @@ void Manager::handleUnmapNotify(XUnmapEvent* ev)
* @param ev The event gathered in the X event loop.
*/
-void Manager::handleOtherEvents(XEvent *ev)
+void Manager::handleOtherEvents(XIEvent *ev)
{
- if (ev->type == PointerDevice::XI_MotionNotify)
+ if (ev->type != GenericEvent)
+ return;
+
+ if (ev->evtype == XI_Motion)
{
- handleMotionEvent((XDeviceMotionEvent*)ev);
- } else if (ev->type == PointerDevice::XI_ButtonPress)
+ handleMotionEvent((XIDeviceEvent*)ev);
+ } else if (ev->evtype == XI_ButtonPress)
{
- handleButtonPress((XDeviceButtonEvent*)ev);
- } else if (ev->type == PointerDevice::XI_ButtonRelease)
+ handleButtonPress((XIDeviceEvent*)ev);
+ } else if (ev->evtype == XI_ButtonRelease)
{
- handleButtonRelease((XDeviceButtonEvent*)ev);
- } else if (ev->type == EnterNotify || ev->type == LeaveNotify)
+ handleButtonRelease((XIDeviceEvent*)ev);
+ } else if (ev->evtype == XI_Enter || ev->evtype == XI_Leave)
{
- handleEnterLeaveNotify(&ev->xcrossing);
- } else if (ev->type == x11->XI_presence)
+ handleEnterLeaveNotify((XIEnterEvent*)ev);
+ } else if (ev->evtype == XI_HierarchyChanged)
{
- handlePresenceNotify((XDevicePresenceNotifyEvent*)ev);
+ handlePresenceNotify((XIHierarchyEvent*)ev);
}
}
/**
* Handles all Input Extension motion events.
*/
-void Manager::handleMotionEvent(XDeviceMotionEvent* mev)
+void Manager::handleMotionEvent(XIDeviceEvent* mev)
{
time = mev->time;
@@ -569,8 +557,9 @@ void Manager::handleMotionEvent(XDeviceMotionEvent* mev)
// There may be a drag event.
if (dev->isDragging())
- dev->dragTo(mev->x_root, mev->y_root);
+ dev->dragTo(mev->root_x, mev->root_y);
+#if 0
// Resizing is slow. We check if there are other events in the queue cos
// if there are, we don't resize.
if (dev->isResizing())
@@ -591,19 +580,21 @@ void Manager::handleMotionEvent(XDeviceMotionEvent* mev)
} else
dev->resizeTo(mev->x_root, mev->y_root);
}
+#endif
- WMWindow* win = xyToWMWindow(mev->x_root, mev->y_root);
+#if 0
+ WMWindow* win = xyToWMWindow(mev->root_x, mev->root_y);
if (win && win->hasOverlay())
win->handleOverlayMotion(mev,
idToPointerDevice(mev->deviceid));
-
+#endif
}
/**
* Handles all InputExtension button presses.
*/
-void Manager::handleButtonPress(XDeviceButtonEvent* bev)
+void Manager::handleButtonPress(XIDeviceEvent* bev)
{
time = bev->time;
@@ -616,74 +607,71 @@ void Manager::handleButtonPress(XDeviceButtonEvent* bev)
}
TRACE("DeviceButtonPress for device %s on %d/%d\n",
- dev->getName().c_str(), bev->x_root, bev->y_root);
+ dev->getName().c_str(), bev->root_x, bev->root_y);
- DockItem* di = dock->getDockItem(bev->window);
+ DockItem* di = dock->getDockItem(bev->event);
if (di)
{
di->handleButtonEvent(dev, bev);
return;
}
- WMWindow* wmwindow = windowToWMWindow(bev->window);
+ WMWindow* wmwindow = windowToWMWindow(bev->event);
if (!wmwindow)
{
- ERR(" - WMWindow not found for %x\n", (int)bev->window);
+ ERR(" - WMWindow not found for %x\n", (int)bev->event);
return;
}
- if (wmwindow->isResizeBar(bev->window) ||
- wmwindow->isWindowBar(bev->window) ||
- wmwindow->isClientWindow(bev->window))
+ if (wmwindow->isResizeBar(bev->event) ||
+ wmwindow->isWindowBar(bev->event) ||
+ wmwindow->isClientWindow(bev->event))
{
- XSetClientPointer(x11->dpy, wmwindow->getClientWindow(),
- dev->getDevice());
+ XISetClientPointer(x11->dpy, wmwindow->getClientWindow(), dev->getID());
vector<KeyboardDevice*>::const_iterator it = keyboards.begin();
while(it != keyboards.end())
{
if ((*it)->getPaired() == dev)
- XSetDeviceFocus(x11->dpy, (*it)->getDevice(),
- wmwindow->getClientWindow(), PointerRoot, CurrentTime);
+ XISetFocus(x11->dpy, (*it)->getID(),
+ wmwindow->getClientWindow(), PointerRoot);
it++;
}
- if (wmwindow->isClientWindow(bev->window))
+ if (wmwindow->isClientWindow(bev->event))
{
- XSetClientPointer(x11->dpy, wmwindow->getClientWindow(),
- dev->getDevice());
+ XISetClientPointer(x11->dpy, wmwindow->getClientWindow(),
+ dev->getID());
}
else
raiseWindow(wmwindow);
}
- if (wmwindow->isWindowBar(bev->window))
+ if (wmwindow->isWindowBar(bev->event))
{
- if (dev->dragOn(wmwindow, bev->x, bev->y))
- TRACE(" - Drag on for %x\n", (int)bev->window);
+ if (dev->dragOn(wmwindow, bev->event_x, bev->event_y))
+ TRACE(" - Drag on for %x\n", (int)bev->event);
wmwindow->changeOwnership(dev);
}
- if (wmwindow->isResizeButton(bev->window))
+ if (wmwindow->isResizeButton(bev->event))
{
- if (dev->resizeOn(wmwindow, bev->window, bev->x_root, bev->y_root))
- TRACE(" - Resize on for %x\n", (int)bev->window);
+ if (dev->resizeOn(wmwindow, bev->event, bev->root_x, bev->root_y))
+ TRACE(" - Resize on for %x\n", (int)bev->event);
}
- if (wmwindow->isButtonMinimize(bev->window))
+ if (wmwindow->isButtonMinimize(bev->event))
{
wmwindow->setMinimize(true);
dock->appendProcess(wmwindow);
dock->setPointerEvents(&pointers);
}
- XAllowDeviceEvents(x11->dpy, dev->getDevice(),
- ReplayThisDevice, CurrentTime);
- XAllowDeviceEvents(x11->dpy, dev->getDevice(),
- AsyncOtherDevices, CurrentTime);
+ XIAllowEvents(x11->dpy, dev->getID(), XIReplayDevice, CurrentTime);
+/* FIXME XIAllowEvents(x11->dpy, dev->getID(), XIAsyncOtherDevices, CurrentTime); */
}
-void Manager::handleButtonRelease(XDeviceButtonEvent* bev)
+void Manager::handleButtonRelease(XIDeviceEvent* bev)
{
time = bev->time;
@@ -696,8 +684,8 @@ void Manager::handleButtonRelease(XDeviceButtonEvent* bev)
}
TRACE("DeviceButtonRelease for device %s\n", dev->getName().c_str());
- TRACE("--- release has window %x\n", (int)bev->window);
- TRACE("--- release has subwindow %x\n", (int)bev->subwindow);
+ TRACE("--- release has window %x\n", (int)bev->event);
+ TRACE("--- release has subwindow %x\n", (int)bev->child);
if (dev->isResizing())
@@ -708,27 +696,29 @@ void Manager::handleButtonRelease(XDeviceButtonEvent* bev)
}
// check for button clicks
- WMWindow* win = windowToWMWindow(bev->window);
+ WMWindow* win = windowToWMWindow(bev->event);
if (win == NULL)
{
- ERR(" - WMWindow for %x not found\n", (int)bev->window);
+ ERR(" - WMWindow for %x not found\n", (int)bev->event);
return;
}
- if (win->isButtonClose(bev->window))
+ if (win->isButtonClose(bev->event))
{
win->destroy();
return;
}
- if (win->isButtonOverlay(bev->subwindow))
+#if 0
+ if (win->isButtonOverlay(bev->child))
{
if (bev->device_state & Button1Mask)
win->toggleOverlay(bev->deviceid);
else if (bev->device_state & Button3Mask)
win->clearOverlay(bev->deviceid);
}
+#endif
if (dev->isDragging())
{
@@ -738,12 +728,14 @@ void Manager::handleButtonRelease(XDeviceButtonEvent* bev)
}
}
-void Manager::handleEnterLeaveNotify(XCrossingEvent* ev)
+void Manager::handleEnterLeaveNotify(XIEnterEvent* ev)
{
}
-void Manager::handlePresenceNotify(XDevicePresenceNotifyEvent* ev)
+void Manager::handlePresenceNotify(XIHierarchyEvent* ev)
{
+ /* FIXME */
+#if 0
TRACE("Device presence event\n");
/* whoohey, the events don't have any useful data. query the device list
* again and see if we spot something new.
@@ -764,18 +756,6 @@ void Manager::handlePresenceNotify(XDevicePresenceNotifyEvent* ev)
PointerDevice *p = new PointerDevice(current, x11,
this);
pointers.push_back(p);
- // add new events to all windows.
- vector<WMWindow*>::const_iterator it = windows.begin();
- while(it != windows.end())
- {
- p->setWMEvents(*it);
- it++;
- }
-
- dock->setPointerEvents(&pointers);
-
-
-
} catch (DeviceError* e)
{
ERR("%s\n", e->message.c_str());
@@ -791,7 +771,8 @@ void Manager::handlePresenceNotify(XDevicePresenceNotifyEvent* ev)
{
KeyboardDevice *k = new KeyboardDevice(current, x11, this);
keyboards.push_back(k);
- dock->setPointerEvents(&pointers);
+ /* FIXME */
+#if 0
/* run through classes, find attach class to get the
paried pointer.*/
XAnyClassPtr any = current->inputclassinfo;
@@ -805,6 +786,7 @@ void Manager::handlePresenceNotify(XDevicePresenceNotifyEvent* ev)
}
any = (XAnyClassPtr) ((char *) any + any->length);
}
+#endif
} catch (DeviceError* e)
{
@@ -816,6 +798,7 @@ void Manager::handlePresenceNotify(XDevicePresenceNotifyEvent* ev)
}
XFreeDeviceList(devices);
+#endif
}
@@ -918,13 +901,15 @@ WMWindow* Manager::xyToWMWindow(int x, int y)
*/
void Manager::setButtonPressMask(Window win)
{
- vector<PointerDevice*>::iterator it = pointers.begin();
+ XIEventMask mask;
+ unsigned char bits[4] = {0};
- while(it != pointers.end())
- {
- (*it)->setButtonPressEventMask(win);
- it++;
- }
+ mask.mask = bits;
+ mask.mask_len = sizeof(bits);
+ mask.deviceid = XIAllMasterDevices;
+ SetBit(bits, XI_ButtonPress);
+
+ XISelectEvents(x11->dpy, win, &mask, 1);
}
void Manager::raiseWindow(WMWindow* wmwindow)
diff --git a/src/Manager.h b/src/Manager.h
index 3f717a7..5f90e50 100644
--- a/src/Manager.h
+++ b/src/Manager.h
@@ -7,7 +7,7 @@
#define __MANAGER_H__
#include<X11/Xlib.h>
#include<X11/Xutil.h>
-#include<X11/extensions/XInput.h>
+#include<X11/extensions/XInput2.h>
#include<X11/extensions/shape.h>
#include<vector>
#include<map>
@@ -22,6 +22,9 @@
#include "XError.h"
#include "Dock.h"
+#define BitIsOn(ptr, bit) (((unsigned char *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))
+#define SetBit(ptr, bit) (((unsigned char *) (ptr))[(bit)>>3] |= (1 << ((bit) & 7)))
+
using namespace std;
class WMWindow;
class PointerDevice;
@@ -86,13 +89,13 @@ class Manager
void handleReparentNotify(XReparentEvent* ev);
void handleDestroyNotify(XDestroyWindowEvent* ev);
void handleUnmapNotify(XUnmapEvent* ev);
- void handleOtherEvents(XEvent *ev);
- void handleMotionEvent(XDeviceMotionEvent* mev);
- void handleButtonPress(XDeviceButtonEvent* bev);
- void handleButtonRelease(XDeviceButtonEvent* bev);
+ void handleOtherEvents(XIEvent *ev);
+ void handleMotionEvent(XIDeviceEvent* mev);
+ void handleButtonPress(XIDeviceEvent* bev);
+ void handleButtonRelease(XIDeviceEvent* bev);
void handlePropertyNotify(XPropertyEvent* pev);
- void handleEnterLeaveNotify(XCrossingEvent* ev);
- void handlePresenceNotify(XDevicePresenceNotifyEvent* ev);
+ void handleEnterLeaveNotify(XIEnterEvent* ev);
+ void handlePresenceNotify(XIHierarchyEvent* ev);
};
diff --git a/src/PointerDevice.cpp b/src/PointerDevice.cpp
index a4629ae..90228e5 100644
--- a/src/PointerDevice.cpp
+++ b/src/PointerDevice.cpp
@@ -7,57 +7,28 @@
#include <X11/Xcursor/Xcursor.h>
#include <stdlib.h>
-int PointerDevice::XI_MotionNotify;
-int PointerDevice::XI_ButtonPress;
-int PointerDevice::XI_ButtonRelease;
-
int PointerDevice::counter = 0;
-PointerDevice::PointerDevice(XDeviceInfo* dev, XConn* x11, Manager* manager)
+PointerDevice::PointerDevice(XIDeviceInfo* dev, XConn* x11, Manager* manager)
{
- 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->id = dev->deviceid;
this->dragWindow = NULL;
this->resizeWindow = NULL;
- XEventClass motion, press, release;
-
- DeviceMotionNotify(d, XI_MotionNotify, motion);
- TRACE("XI_MotionNotify is %d\n", (int)XI_MotionNotify);
- TRACE("Motion class is %d\n", (int)motion);
-
- DeviceButtonPress(d, XI_ButtonPress, press);
- TRACE("XI_ButtonPress is %d\n", (int)XI_ButtonPress);
- TRACE("ButtonPress class is %d\n", (int)press);
-
- DeviceButtonRelease(d, XI_ButtonRelease, release);
- TRACE("XI_ButtonRelease is %d\n", (int)XI_ButtonRelease);
- TRACE("ButtonRelease class is %d\n", (int)release);
-
- evclasses[XI_MotionNotify] = motion;
- evclasses[XI_ButtonPress] = press;
- evclasses[XI_ButtonRelease] = release;
-
- XSelectExtensionEvent(x11->dpy, x11->root, &motion, 1);
color = Config::getInstance()->cursorColor(pointerID);
- generatePointerImage(dev->id);
+ generatePointerImage(dev->deviceid);
Cursor cursor = XcursorFilenameLoadCursor(x11->dpy, "/tmp/.mpwm_pointer.cur");
- XDefineDeviceCursor(x11->dpy, d, x11->root, cursor);
+ XIDefineCursor(x11->dpy, dev->deviceid, x11->root, cursor);
- TRACE("Device %d (%s) initialised\n",
- (unsigned int)dev->id, dev->name);
+ TRACE("Device %d (%s) initialised\n",
+ (unsigned int)dev->deviceid, dev->name);
}
/**
@@ -83,9 +54,7 @@ void PointerDevice::dragOff()
dragWindow = NULL;
dragOffset[0] = dragOffset[1] = 0;
- XEventClass motion = evclasses[XI_MotionNotify];
- XSelectExtensionEvent(x11->dpy, x11->root, &motion, 1);
- XUngrabDevice(x11->dpy, this->dev, CurrentTime);
+ XIUngrabDevice(x11->dpy, this->id, CurrentTime);
TRACE("Ungrabbing device.\n");
XFlush(x11->dpy);
@@ -108,18 +77,23 @@ bool PointerDevice::dragOn(WMWindow* win, int x, int y)
ERR("NULL window given for drag\n");
return false;
}
-
+
if (win->setController(this))
{
+ XIEventMask mask;
+ unsigned char bits[4] = {0};
+
+ mask.mask_len = sizeof(bits);
+ mask.deviceid = this->id;
+ mask.mask = bits;
+ SetBit(bits, XI_ButtonPress);
+
dragWindow = win;
dragOffset[0] = x;
dragOffset[1] = 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(x11->dpy, x11->root, classes, 2);
- XGrabDevice(x11->dpy, this->dev, win->getWindowBar(), True, 2,
- classes, GrabModeAsync, GrabModeAsync, CurrentTime);
+
+ XIGrabDevice(x11->dpy, this->id, win->getWindowBar(), CurrentTime,
+ None, GrabModeAsync, GrabModeAsync, True, &mask);
return true;
}
@@ -141,12 +115,18 @@ bool PointerDevice::resizeOn(WMWindow* win, Window button, int x, int y)
resizeOffset[0] = x;
resizeOffset[1] = y;
resizeButton = button;
-
- XEventClass classes[3] = {evclasses[XI_MotionNotify],
- evclasses[XI_ButtonPress],
- evclasses[XI_ButtonRelease]};
- XGrabDevice(x11->dpy, this->dev, win->getWindowBar(),
- True, 3, classes, GrabModeAsync, GrabModeAsync, CurrentTime);
+ XIEventMask mask;
+ unsigned char bits[4] = {0};
+
+ mask.mask_len = sizeof(bits);
+ mask.deviceid = this->id;
+ mask.mask = bits;
+ SetBit(bits, XI_ButtonPress);
+ SetBit(bits, XI_ButtonRelease);
+ SetBit(bits, XI_Motion);
+
+ XIGrabDevice(x11->dpy, this->id, win->getWindowBar(), CurrentTime,
+ None, GrabModeAsync, GrabModeAsync, True, &mask);
return true;
}
@@ -165,7 +145,7 @@ void PointerDevice::resizeOff()
resizeWindow = NULL;
resizeOffset[0] = resizeOffset[1] = 0;
- XUngrabDevice(x11->dpy, this->dev, CurrentTime);
+ XIUngrabDevice(x11->dpy, this->id, CurrentTime);
}
bool PointerDevice::isResizing()
@@ -192,48 +172,52 @@ void PointerDevice::resizeTo(int x, int y)
*/
void PointerDevice::setWMEvents(WMWindow* window)
{
- XEventClass classes[3];
+ XIEventMask mask;
+ unsigned char bits[4] = {0};
+ int modifiers = 0;
+
+ mask.mask = bits;
+ mask.mask_len = sizeof(bits);
+ mask.deviceid = XIAllMasterDevices;
+ SetBit(bits, XI_ButtonPress);
+
+ XISelectEvents(x11->dpy, window->getButtonMinimize(), &mask, 1);
+ XISelectEvents(x11->dpy, window->getButtonOverlay(), &mask, 1);
+ XISelectEvents(x11->dpy, window->getResizeBtNE(), &mask, 1);
+ XISelectEvents(x11->dpy, window->getResizeBtNW(), &mask, 1);
+ XISelectEvents(x11->dpy, window->getResizeBtSE(), &mask, 1);
+ XISelectEvents(x11->dpy, window->getResizeBtSW(), &mask, 1);
+
+ SetBit(bits, XI_ButtonRelease);
+ XISelectEvents(x11->dpy, window->getButtonClose(), &mask, 1);
+ XISelectEvents(x11->dpy, window->getButtonFloor(), &mask, 1);
- classes[0] = evclasses[XI_MotionNotify];
- classes[1] = evclasses[XI_ButtonPress];
- classes[2] = evclasses[XI_ButtonRelease];
+ SetBit(bits, XI_Motion);
+ XISelectEvents(x11->dpy, window->getWindowBar(), &mask, 1);
- XSelectExtensionEvent(x11->dpy, window->getWindowBar(), &classes[0], 3);
- //XSelectExtensionEvent(x11->dpy, window->getResizeBar(), &classes[0], 3);
- XSelectExtensionEvent(x11->dpy, window->getButtonClose(), &classes[1], 2);
- XSelectExtensionEvent(x11->dpy, window->getButtonFloor(), &classes[1], 2);
- XSelectExtensionEvent(x11->dpy, window->getButtonOverlay(), &classes[1], 1);
- XSelectExtensionEvent(x11->dpy, window->getButtonMinimize(), &classes[1], 1);
+ //XSelectExtensionEvent(x11->dpy, window->getResizeBar(), &classes[0], 3);
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(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);
- XGrabDeviceButton(x11->dpy, dev, Button1, AnyModifier,
- NULL, window->getClientWindow(), False,
- 0, NULL, GrabModeSync, GrabModeSync);
+ XIGrabButton(x11->dpy, this->id, Button1, window->getClientWindow(),
+ None, GrabModeSync, GrabModeAsync, False, &mask, 1,
+ &modifiers);
}
void PointerDevice::setDockEvents(Window win)
{
- XEventClass evclass = evclasses[XI_ButtonPress];
- XSelectExtensionEvent(x11->dpy, win, &evclass, 1);
-}
+ XIEventMask mask;
+ unsigned char bits[4] = {0};
-/**
- * Sets the ButtonPressEvent mask for the given window.
- */
-void PointerDevice::setButtonPressEventMask(Window win)
-{
- XEventClass evclass = evclasses[XI_ButtonPress];
- XSelectExtensionEvent(x11->dpy, win, &evclass, 1);
+ mask.mask = bits;
+ mask.mask_len = sizeof(bits);
+ mask.deviceid = XIAllMasterDevices;
+ SetBit(bits, XI_ButtonPress);
+
+ XISelectEvents(x11->dpy, win, &mask, 1);
}
void PointerDevice::generatePointerImage(int number){
diff --git a/src/PointerDevice.h b/src/PointerDevice.h
index ce97b84..e49bb08 100644
--- a/src/PointerDevice.h
+++ b/src/PointerDevice.h
@@ -7,7 +7,7 @@
#define __POINTERDEVICE_H__
#include<X11/Xlib.h>
-#include<X11/extensions/XInput.h>
+#include<X11/extensions/XInput2.h>
#include<map>
#include<string>
#include<sstream>
@@ -25,10 +25,6 @@ class Manager;
class PointerDevice
{
public:
- static int XI_MotionNotify;
- static int XI_ButtonPress;
- static int XI_ButtonRelease;
-
static int counter;
private:
int pointerID;
@@ -36,8 +32,6 @@ class PointerDevice
int id;
string name;
- map<int, XEventClass> evclasses;
- XDevice* dev;
WMWindow* dragWindow;
int dragOffset[2];
@@ -49,11 +43,10 @@ class PointerDevice
long color;
public:
- PointerDevice(XDeviceInfo* device, XConn* x11, Manager* manager);
+ PointerDevice(XIDeviceInfo* device, XConn* x11, Manager* manager);
void raise();
int getID() { return id; }
string getName() { return name; }
- XDevice* getDevice() { return dev; }
bool isDragging();
bool dragOn(WMWindow* win, int x, int y);
@@ -69,8 +62,6 @@ class PointerDevice
void setDockEvents(Window win);
long getColor() { return color; }
- void setButtonPressEventMask(Window win);
-
private:
void generatePointerImage(int number);
};