diff options
author | Peter Hutterer <peter.hutterer@redhat.com> | 2009-05-13 09:08:54 -0400 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@redhat.com> | 2009-05-13 09:26:21 -0400 |
commit | 5aaae6b0510fa14ef18a6f06c229f5614e2e9e3c (patch) | |
tree | 48f1bbfb15e0a49cf243ddb66c4972644a74f097 | |
parent | d61b5b62d40756ebddb133943dbbc1e946bc6424 (diff) |
Manager: handle hierarchy events instead of presence events.
-rw-r--r-- | src/Manager.cpp | 90 | ||||
-rw-r--r-- | src/Manager.h | 2 |
2 files changed, 43 insertions, 49 deletions
diff --git a/src/Manager.cpp b/src/Manager.cpp index 5c8bc5d..49779d6 100644 --- a/src/Manager.cpp +++ b/src/Manager.cpp @@ -142,6 +142,16 @@ void Manager::initXi() dock->setPointerEvents(&pointers); XIFreeDeviceInfo(devices); + + XIEventMask mask; + unsigned char bits[4] = {0}; + + mask.mask = bits; + mask.mask_len = sizeof(bits); + mask.deviceid = XIAllDevices; + SetBit(bits, XI_HierarchyChanged); + + XISelectEvents(x11->dpy, x11->root, &mask, 1); } /** @@ -511,7 +521,7 @@ void Manager::handleOtherEvents(XIEvent *ev) handleEnterLeaveNotify((XIEnterEvent*)ev); } else if (ev->evtype == XI_HierarchyChanged) { - handlePresenceNotify((XIHierarchyEvent*)ev); + handleHierarchyEvent((XIHierarchyEvent*)ev); } } @@ -707,73 +717,57 @@ void Manager::handleEnterLeaveNotify(XIEnterEvent* ev) { } -void Manager::handlePresenceNotify(XIHierarchyEvent* ev) +void Manager::handleHierarchyEvent(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. - */ - XDeviceInfo* devices; - int ndevices; - devices = XListInputDevices(x11->dpy, &ndevices); - while(ndevices) - { - XDeviceInfo* current; - current = &devices[--ndevices]; - if (!idToPointerDevice(current->id)) + TRACE("Device hierarchy event\n"); + + if (!(ev->flags & XIMasterAdded)) + return; + + XIHierarchyInfo *info = ev->info; + + while(ev->num_devices--) + { + if (info->flags & XIMasterAdded) { - TRACE("New device '%s' id %d\n", current->name, (int)current->id); - if (current->use == IsXPointer) + int count = 0; + XIDeviceInfo *dev = XIQueryDevice(x11->dpy, info->deviceid, &count); + if (count != 1) { - try { - PointerDevice *p = new PointerDevice(current, x11, - this); + ERR("Hierarchy event: count should be 1\n"); + return; + } + + if ((dev->use == XIMasterPointer)) + { + try + { + PointerDevice *p = new PointerDevice(dev, x11, this); pointers.push_back(p); + } catch (DeviceError* e) { ERR("%s\n", e->message.c_str()); } - } - } - - if (!idToKeyboardDevice(current->id)) - { - if (current->use == IsXKeyboard) + } else if ((dev->use == XIMasterKeyboard)) { try { - KeyboardDevice *k = new KeyboardDevice(current, x11, this); + KeyboardDevice *k = new KeyboardDevice(dev, x11, this); keyboards.push_back(k); - /* FIXME */ -#if 0 - /* run through classes, find attach class to get the - paried pointer.*/ - XAnyClassPtr any = current->inputclassinfo; - for (int i = 0; i < current->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); - } -#endif - + k->setPaired(idToPointerDevice(dev->attachment)); } catch (DeviceError* e) { ERR("%s\n", e->message.c_str()); } } - + XIFreeDeviceInfo(dev); } + + info++; } - XFreeDeviceList(devices); -#endif + XIFreeEventData((XIEvent*)ev); } diff --git a/src/Manager.h b/src/Manager.h index 5f90e50..53f16f0 100644 --- a/src/Manager.h +++ b/src/Manager.h @@ -95,7 +95,7 @@ class Manager void handleButtonRelease(XIDeviceEvent* bev); void handlePropertyNotify(XPropertyEvent* pev); void handleEnterLeaveNotify(XIEnterEvent* ev); - void handlePresenceNotify(XIHierarchyEvent* ev); + void handleHierarchyEvent(XIHierarchyEvent* ev); }; |