summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Xext/xtest.c10
-rw-r--r--Xi/xichangehierarchy.c84
-rw-r--r--dix/devices.c42
-rw-r--r--include/input.h5
4 files changed, 64 insertions, 77 deletions
diff --git a/Xext/xtest.c b/Xext/xtest.c
index 32abe2a81..4f5c5275c 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -56,7 +56,6 @@
extern int DeviceValuator;
extern int DeviceMotionNotify;
-extern DevPrivateKey XTstDevicePrivateKey;
#ifdef PANORAMIX
#include "panoramiX.h"
@@ -299,14 +298,7 @@ ProcXTestFakeInput(ClientPtr client)
return BadValue;
}
- /* When faking core events through XTest, we always fake through the
- * virtual test device.
- */
- for(it = inputInfo.devices; it ; it = it->next )
- if( !IsMaster(it) && it->u.master == dev &&
- dixLookupPrivate(&it->devPrivates, XTstDevicePrivateKey ))
- break;
- dev= it;
+ dev = GetXtstDevice(dev);
}
/* If the event has a time set, wait for it to pass */
diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
index 137c20914..656515bfd 100644
--- a/Xi/xichangehierarchy.c
+++ b/Xi/xichangehierarchy.c
@@ -186,8 +186,9 @@ ProcXIChangeHierarchy(ClientPtr client)
if (!c->send_core)
ptr->coreEvents = keybd->coreEvents = FALSE;
- /* Allocate virtual slave devices for xtest events */
- rc = AllocXtstDevice(client, name, &xtstptr, &xtstkeybd);
+ /* Allocate virtual slave devices for xtest events */
+ rc = AllocXtstDevice(client, name, &xtstptr, &xtstkeybd,
+ ptr, keybd);
if (rc != Success)
{
@@ -231,7 +232,6 @@ ProcXIChangeHierarchy(ClientPtr client)
case XIRemoveMaster:
{
xXIRemoveMasterInfo* r = (xXIRemoveMasterInfo*)any;
- DeviceIntPtr xtstdevice;
if (r->return_mode != XIAttachToMaster &&
r->return_mode != XIFloating)
@@ -257,69 +257,33 @@ ProcXIChangeHierarchy(ClientPtr client)
goto unwind;
}
- for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next )
- if (IsXtstDevice(xtstdevice, ptr))
- break;
- rc = dixLookupDevice(&xtstptr, xtstdevice->id, client,
+ ptr = GetMaster(ptr, MASTER_POINTER);
+ rc = dixLookupDevice(&ptr,
+ ptr->id,
+ client,
+ DixDestroyAccess);
+ if (rc != Success)
+ goto unwind;
+ keybd = GetMaster(ptr, MASTER_KEYBOARD);
+ rc = dixLookupDevice(&keybd,
+ keybd->id,
+ client,
DixDestroyAccess);
if (rc != Success)
goto unwind;
- /* find keyboards to destroy */
- if (IsPointerDevice(ptr))
- {
- rc = dixLookupDevice(&keybd,
- ptr->spriteInfo->paired->id,
- client,
- DixDestroyAccess);
- if (rc != Success)
- goto unwind;
-
- }
- else
- {
- keybd = ptr;
- rc = dixLookupDevice(&ptr,
- keybd->spriteInfo->paired->id,
- client,
- DixDestroyAccess);
- if (rc != Success)
- goto unwind;
-
- }
-
- /* handle xtst pointer / keyboard slave devices */
- if ( IsPointerDevice(xtstptr))
- {
- /* Search the matching keyboard */
- for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next )
- if(IsKeyboardDevice(xtstdevice) && IsXtstDevice(xtstdevice, keybd))
- break;
-
- rc = dixLookupDevice(&xtstkeybd,
- xtstdevice->id,
- client,
- DixDestroyAccess);
-
- if (rc != Success)
- goto unwind;
- }
- else
- {
- xtstkeybd = xtstptr;
- /* Search the matching pointer */
- for(xtstdevice = inputInfo.devices; xtstdevice ; xtstdevice = xtstdevice->next )
- if(IsPointerDevice(xtstdevice) && IsXtstDevice(xtstdevice, ptr))
- break;
- rc = dixLookupDevice(&xtstptr,
- xtstdevice->id,
- client,
- DixDestroyAccess);
+ xtstptr = GetXtstDevice(ptr);
+ rc = dixLookupDevice(&xtstptr, xtstptr->id, client,
+ DixDestroyAccess);
+ if (rc != Success)
+ goto unwind;
- if (rc != Success)
- goto unwind;
- }
+ xtstkeybd = GetXtstDevice(keybd);
+ rc = dixLookupDevice(&xtstkeybd, xtstkeybd->id, client,
+ DixDestroyAccess);
+ if (rc != Success)
+ goto unwind;
/* Disabling sends the devices floating, reattach them if
* desired. */
diff --git a/dix/devices.c b/dix/devices.c
index 2d776577c..b7f21927f 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -639,8 +639,8 @@ InitCoreDevices(void)
is a slave device to inputInfo master devices
*/
if(AllocXtstDevice(serverClient, "Virtual core",
- &vxtstpointer,
- &vxtstkeyboard) != Success)
+ &vxtstpointer, &vxtstkeyboard,
+ inputInfo.pointer, inputInfo.keyboard) != Success)
FatalError("Failed to allocate XTst devices");
if (ActivateDevice(vxtstpointer, TRUE) != Success ||
@@ -2570,7 +2570,8 @@ AllocDevicePair (ClientPtr client, char* name,
* still need to be called.
*/
int AllocXtstDevice (ClientPtr client, char* name,
- DeviceIntPtr* ptr, DeviceIntPtr* keybd)
+ DeviceIntPtr* ptr, DeviceIntPtr* keybd,
+ DeviceIntPtr master_ptr, DeviceIntPtr master_keybd)
{
int retval;
int len = strlen(name);
@@ -2581,8 +2582,8 @@ int AllocXtstDevice (ClientPtr client, char* name,
retval = AllocDevicePair( client, xtstname, ptr, keybd, FALSE);
if ( retval == Success ){
- dixSetPrivate(&((*ptr)->devPrivates), XTstDevicePrivateKey, (void *)True );
- dixSetPrivate(&((*keybd)->devPrivates), XTstDevicePrivateKey,(void *)True);
+ dixSetPrivate(&((*ptr)->devPrivates), XTstDevicePrivateKey, (void *)master_ptr->id);
+ dixSetPrivate(&((*keybd)->devPrivates), XTstDevicePrivateKey, (void *)master_keybd->id);
}
xfree( xtstname );
@@ -2599,6 +2600,33 @@ int AllocXtstDevice (ClientPtr client, char* name,
BOOL
IsXtstDevice(DeviceIntPtr dev, DeviceIntPtr master)
{
- return (!IsMaster(dev) && (!master || dev->u.master == master) &&
- ( dixLookupPrivate(&dev->devPrivates, XTstDevicePrivateKey) != NULL));
+ int mid;
+ void *tmp; /* shut up, gcc! */
+
+ if (IsMaster(dev))
+ return FALSE;
+
+ tmp = dixLookupPrivate(&dev->devPrivates, XTstDevicePrivateKey);
+ mid = (int)tmp;
+
+ return (!master || mid == master->id);
}
+
+/**
+ * @return The X Test virtual device for the given master.
+ */
+DeviceIntPtr
+GetXtstDevice(DeviceIntPtr master)
+{
+ DeviceIntPtr it;
+
+ for (it = inputInfo.devices; it; it = it->next)
+ {
+ if (IsXtstDevice(it, master))
+ return it;
+ }
+
+ /* This only happens if master is a slave device. don't do that */
+ return NULL;
+}
+
diff --git a/include/input.h b/include/input.h
index 1dfbbff0b..40ba660f1 100644
--- a/include/input.h
+++ b/include/input.h
@@ -496,8 +496,11 @@ extern int change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *map,
extern int AllocXtstDevice(ClientPtr client,
char* name,
DeviceIntPtr* ptr,
- DeviceIntPtr* keybd);
+ DeviceIntPtr* keybd,
+ DeviceIntPtr master_ptr,
+ DeviceIntPtr master_keybd);
extern BOOL IsXtstDevice(DeviceIntPtr dev, DeviceIntPtr master);
+extern DeviceIntPtr GetXtstDevice(DeviceIntPtr master);
/* misc event helpers */
extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);