summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2007-10-16 18:40:15 +0930
committerPeter Hutterer <peter@cs.unisa.edu.au>2007-10-16 18:40:15 +0930
commit299573f4617c3b5599bb65069e96d050277b9471 (patch)
treec196b5cd9a35466985e7782bfe06d1c2c5e161d0
parent5fe9bfd23f17b84c3afaa82f75a7c517c9f8e0d3 (diff)
dix: add AllocMasterDevice for creation of new master devices.
Devices are initiated pretty much the same as the core devices.
-rw-r--r--dix/devices.c66
-rw-r--r--include/input.h4
2 files changed, 70 insertions, 0 deletions
diff --git a/dix/devices.c b/dix/devices.c
index 3e5405b54..ef5ebf94d 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2374,3 +2374,69 @@ NextFreePointerDevice()
return dev;
return NULL;
}
+/**
+ * Create a new master device (== one pointer, one keyboard device).
+ * Only allocates the devices, you will need to call ActivateDevice() and
+ * EnableDevice() manually.
+ */
+int
+AllocMasterDevice(char* name, DeviceIntPtr* ptr, DeviceIntPtr* keybd)
+{
+ DeviceIntPtr pointer;
+ DeviceIntPtr keyboard;
+
+ pointer = AddInputDevice(CorePointerProc, TRUE);
+ if (!pointer)
+ return BadAlloc;
+
+ pointer->name = xcalloc(strlen(name) + strlen("-ptr") + 1, sizeof(char));
+ strcpy(pointer->name, name);
+ strcat(pointer->name, "-ptr");
+
+#ifdef XKB
+ pointer->public.processInputProc = ProcessOtherEvent;
+ pointer->public.realInputProc = ProcessOtherEvent;
+ if (!noXkbExtension)
+ XkbSetExtension(pointer, ProcessPointerEvent);
+#else
+ pointer->public.processInputProc = ProcessPointerEvent;
+ pointer->public.realInputProc = ProcessPointerEvent;
+#endif
+ pointer->deviceGrab.ActivateGrab = ActivatePointerGrab;
+ pointer->deviceGrab.DeactivateGrab = DeactivatePointerGrab;
+ pointer->coreEvents = TRUE;
+ pointer->spriteInfo->spriteOwner = TRUE;
+
+ pointer->u.lastSlave = NULL;
+ pointer->isMaster = TRUE;
+
+ keyboard = AddInputDevice(CoreKeyboardProc, TRUE);
+ if (!keyboard)
+ return BadAlloc;
+
+ keyboard->name = xcalloc(strlen(name) + strlen("-keybd") + 1, sizeof(char));
+ strcpy(keyboard->name, name);
+ strcat(keyboard->name, "-keybd");
+
+#ifdef XKB
+ keyboard->public.processInputProc = ProcessOtherEvent;
+ keyboard->public.realInputProc = ProcessOtherEvent;
+ if (!noXkbExtension)
+ XkbSetExtension(keyboard, ProcessKeyboardEvent);
+#else
+ keyboard->public.processInputProc = ProcessKeyboardEvent;
+ keyboard->public.realInputProc = ProcessKeyboardEvent;
+#endif
+ keyboard->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
+ keyboard->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
+ keyboard->coreEvents = TRUE;
+ keyboard->spriteInfo->spriteOwner = FALSE;
+
+ keyboard->u.lastSlave = NULL;
+ keyboard->isMaster = TRUE;
+
+ *ptr = pointer;
+ *keybd = keyboard;
+
+ return Success;
+}
diff --git a/include/input.h b/include/input.h
index a176bbab7..d6a38e639 100644
--- a/include/input.h
+++ b/include/input.h
@@ -477,6 +477,10 @@ extern Bool UnregisterPairingClient(ClientPtr client);
extern DeviceIntPtr GuessFreePointerDevice(void);
extern DeviceIntPtr NextFreePointerDevice(void);
+extern int AllocMasterDevice(char* name,
+ DeviceIntPtr* ptr,
+ DeviceIntPtr* keybd);
+
/* Window/device based access control */
extern Bool ACRegisterClient(ClientPtr client);
extern Bool ACUnregisterClient(ClientPtr client);