xserver: Branch 'master' - 5 commits

Peter Hutterer whot at kemper.freedesktop.org
Wed Aug 26 21:26:40 PDT 2009


 Xext/xtest.c                   |  144 ++++++++++++++++++++++++++++++++++++++++-
 Xi/xichangehierarchy.c         |   66 +++++++++---------
 Xi/xiproperty.c                |    2 
 dix/devices.c                  |  135 --------------------------------------
 hw/xfree86/common/xf86Helper.c |    7 -
 hw/xfree86/common/xf86Xinput.h |    3 
 include/input.h                |    7 +
 include/xserver-properties.h   |    4 -
 test/Makefile.am               |    3 
 test/xtest.c                   |  116 +++++++++++++++++++++++++++++++++
 10 files changed, 303 insertions(+), 184 deletions(-)

New commits:
commit 2fba2eac0b4c8d07bdf7bea20ef75ff579621728
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Aug 24 11:23:23 2009 +1000

    test: add a few tests for xtest device initialization.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/test/Makefile.am b/test/Makefile.am
index df08b5b..09932a5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,6 +1,6 @@
 if UNITTESTS
 SUBDIRS= . xi2
-check_PROGRAMS = xkb input
+check_PROGRAMS = xkb input xtest
 check_LTLIBRARIES = libxservertest.la
 
 TESTS=$(check_PROGRAMS)
@@ -11,6 +11,7 @@ TEST_LDADD=libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) $(GLIB_LIBS)
 
 xkb_LDADD=$(TEST_LDADD)
 input_LDADD=$(TEST_LDADD)
+xtest_LDADD=$(TEST_LDADD)
 
 libxservertest_la_LIBADD = \
             $(XSERVER_LIBS) \
diff --git a/test/xtest.c b/test/xtest.c
new file mode 100644
index 0000000..572f5d2
--- /dev/null
+++ b/test/xtest.c
@@ -0,0 +1,116 @@
+/**
+ * Copyright © 2009 Red Hat, Inc.
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),
+ *  to deal in the Software without restriction, including without limitation
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ *  and/or sell copies of the Software, and to permit persons to whom the
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice (including the next
+ *  paragraph) shall be included in all copies or substantial portions of the
+ *  Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ *  DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+#include <stdint.h>
+#include <X11/Xatom.h>
+#include "input.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "exevents.h"
+#include "xserver-properties.h"
+
+#include <glib.h>
+
+/**
+ */
+
+/* from Xext/xtest.c */
+extern DeviceIntPtr xtestpointer, xtestkeyboard;
+
+/* Needed for the screen setup, otherwise we crash during sprite initialization */
+static Bool device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) { return TRUE; }
+
+static void xtest_init_devices(void)
+{
+    ScreenRec screen;
+
+    /* random stuff that needs initialization */
+    memset(&screen, 0, sizeof(screen));
+    screenInfo.arraySize = MAXSCREENS;
+    screenInfo.numScreens = 1;
+    screenInfo.screens[0] = &screen;
+    screen.myNum = 0;
+    screen.id = 100;
+    screen.width = 640;
+    screen.height = 480;
+    screen.DeviceCursorInitialize = device_cursor_init;
+    dixResetPrivates();
+    InitAtoms();
+
+    /* this also inits the xtest devices */
+    InitCoreDevices();
+
+    g_assert(xtestpointer);
+    g_assert(xtestkeyboard);
+    g_assert(IsXTestDevice(xtestpointer, NULL));
+    g_assert(IsXTestDevice(xtestkeyboard, NULL));
+    g_assert(IsXTestDevice(xtestpointer, inputInfo.pointer));
+    g_assert(IsXTestDevice(xtestkeyboard, inputInfo.keyboard));
+    g_assert(GetXTestDevice(inputInfo.pointer) == xtestpointer);
+    g_assert(GetXTestDevice(inputInfo.keyboard) == xtestkeyboard);
+}
+
+/**
+ * Each xtest devices has a property attached marking it. This property
+ * cannot be changed.
+ */
+static void xtest_properties(void)
+{
+    int rc;
+    char value = 1;
+    XIPropertyValuePtr prop;
+    Atom xtest_prop = XIGetKnownProperty(XI_PROP_XTEST_DEVICE);
+
+    rc = XIGetDeviceProperty(xtestpointer, xtest_prop, &prop);
+    g_assert(rc == Success);
+    g_assert(prop);
+
+    rc = XIGetDeviceProperty(xtestkeyboard, xtest_prop, &prop);
+    g_assert(rc == Success);
+    g_assert(prop != NULL);
+
+    rc = XIChangeDeviceProperty(xtestpointer, xtest_prop,
+                                XA_INTEGER, 8, PropModeReplace, 1, &value, FALSE);
+    g_assert(rc == BadAccess);
+    rc = XIChangeDeviceProperty(xtestkeyboard, xtest_prop,
+                                XA_INTEGER, 8, PropModeReplace, 1, &value, FALSE);
+    g_assert(rc == BadAccess);
+}
+
+
+
+int main(int argc, char** argv)
+{
+    g_test_init(&argc, &argv,NULL);
+    g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id=");
+
+    g_test_add_func("/dix/xtest/init", xtest_init_devices);
+    g_test_add_func("/dix/xtest/properties", xtest_properties);
+
+    return g_test_run();
+}
+
+
commit 903c3db1d1685bd855dceed9e7b92890743663e1
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Aug 24 09:48:00 2009 +1000

    Xext: rename Xtst* to XTest*
    
    This patch corrects a misnaming of XTest-related functions.
    
    The extension itself announces itself as XTEST. Xtst is the library name
    itself, but all library functions are prefixed by XTest. Same with the
    naming in the server.
    
    - Rename all *Xtst* functions to *XTest* for consistency with the library
      and in-server API.
    - Rename the "Xtst device" property to "XTEST device" for consistency with
      the extension naming.
    - Rename the device naming to "<master device name> XTEST device". The
      default xtest devices become "Virtual core XTEST pointer" and "Virtual
      core XTEST keyboard".
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xext/xtest.c b/Xext/xtest.c
index 6c59952..0400062 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -63,20 +63,20 @@ extern int DeviceValuator;
 static EventListPtr xtest_evlist;
 
 /* Used to store if a device is an XTest Virtual device */
-static int XTstDevicePrivateKeyIndex;
-DevPrivateKey XTstDevicePrivateKey = &XTstDevicePrivateKeyIndex;
+static int XTestDevicePrivateKeyIndex;
+DevPrivateKey XTestDevicePrivateKey = &XTestDevicePrivateKeyIndex;
 
 /**
- * vxtstpointer
+ * xtestpointer
  * is the virtual pointer for XTest. It is the first slave
  * device of the VCP.
- * vxtstkeyboard
+ * xtestkeyboard
  * is the virtual keyboard for XTest. It is the first slave
  * device of the VCK
  *
  * Neither of these devices can be deleted.
  */
-DeviceIntPtr vxtstpointer, vxtstkeyboard;
+DeviceIntPtr xtestpointer, xtestkeyboard;
 
 #ifdef PANORAMIX
 #include "panoramiX.h"
@@ -341,7 +341,7 @@ ProcXTestFakeInput(ClientPtr client)
                 return BadValue;
         }
 
-        dev = GetXtstDevice(dev);
+        dev = GetXTestDevice(dev);
     }
 
     /* If the event has a time set, wait for it to pass */
@@ -590,30 +590,30 @@ SProcXTestDispatch (ClientPtr client)
  */
 void InitXTestDevices(void)
 {
-    if(AllocXtstDevice(serverClient, "Virtual core",
-                       &vxtstpointer, &vxtstkeyboard,
+    if(AllocXTestDevice(serverClient, "Virtual core",
+                       &xtestpointer, &xtestkeyboard,
                        inputInfo.pointer, inputInfo.keyboard) != Success)
-        FatalError("Failed to allocate XTst devices");
+        FatalError("Failed to allocate XTest devices");
 
-    if (ActivateDevice(vxtstpointer, TRUE) != Success ||
-        ActivateDevice(vxtstkeyboard, TRUE) != Success)
-        FatalError("Failed to activate xtst core devices.");
-    if (!EnableDevice(vxtstpointer, TRUE) ||
-        !EnableDevice(vxtstkeyboard, TRUE))
-        FatalError("Failed to enable xtst core devices.");
+    if (ActivateDevice(xtestpointer, TRUE) != Success ||
+        ActivateDevice(xtestkeyboard, TRUE) != Success)
+        FatalError("Failed to activate XTest core devices.");
+    if (!EnableDevice(xtestpointer, TRUE) ||
+        !EnableDevice(xtestkeyboard, TRUE))
+        FatalError("Failed to enable XTest core devices.");
 
-    AttachDevice(NULL, vxtstpointer, inputInfo.pointer);
-    AttachDevice(NULL, vxtstkeyboard, inputInfo.keyboard);
+    AttachDevice(NULL, xtestpointer, inputInfo.pointer);
+    AttachDevice(NULL, xtestkeyboard, inputInfo.keyboard);
 }
 
 /**
- * Don't allow changing the Xtst property.
+ * Don't allow changing the XTest property.
  */
 static int
-DeviceSetXtstProperty(DeviceIntPtr dev, Atom property,
+DeviceSetXTestProperty(DeviceIntPtr dev, Atom property,
                       XIPropertyValuePtr prop, BOOL checkonly)
 {
-    if (property == XIGetKnownProperty(XI_PROP_XTST_DEVICE))
+    if (property == XIGetKnownProperty(XI_PROP_XTEST_DEVICE))
         return BadAccess;
 
     return Success;
@@ -626,36 +626,36 @@ DeviceSetXtstProperty(DeviceIntPtr dev, Atom property,
  * This only creates the pair, Activate/Enable Device
  * still need to be called.
  */
-int AllocXtstDevice (ClientPtr client, char* name,
+int AllocXTestDevice (ClientPtr client, char* name,
                      DeviceIntPtr* ptr, DeviceIntPtr* keybd,
                      DeviceIntPtr master_ptr, DeviceIntPtr master_keybd)
 {
     int retval;
     int len = strlen(name);
-    char *xtstname = xcalloc(len + 6, 1 );
+    char *xtestname = xcalloc(len + 7, 1 );
     char dummy = 1;
 
-    strncpy( xtstname, name, len);
-    strncat( xtstname, " Xtst", 5 );
+    strncpy( xtestname, name, len);
+    strncat( xtestname, " XTEST", 6 );
 
-    retval = AllocDevicePair( client, xtstname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE);
+    retval = AllocDevicePair( client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE);
     if ( retval == Success ){
-        dixSetPrivate(&((*ptr)->devPrivates), XTstDevicePrivateKey, (void *)master_ptr->id);
-        dixSetPrivate(&((*keybd)->devPrivates), XTstDevicePrivateKey, (void *)master_keybd->id);
+        dixSetPrivate(&((*ptr)->devPrivates), XTestDevicePrivateKey, (void *)master_ptr->id);
+        dixSetPrivate(&((*keybd)->devPrivates), XTestDevicePrivateKey, (void *)master_keybd->id);
     }
 
-    xfree( xtstname );
+    xfree( xtestname );
 
-    XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTST_DEVICE),
+    XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
                            XA_INTEGER, 8, PropModeReplace, 1, &dummy,
                            FALSE);
-    XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTST_DEVICE), FALSE);
-    XIRegisterPropertyHandler(*ptr, DeviceSetXtstProperty, NULL, NULL);
-    XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTST_DEVICE),
+    XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE);
+    XIRegisterPropertyHandler(*ptr, DeviceSetXTestProperty, NULL, NULL);
+    XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
                            XA_INTEGER, 8, PropModeReplace, 1, &dummy,
                            FALSE);
-    XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTST_DEVICE), FALSE);
-    XIRegisterPropertyHandler(*keybd, DeviceSetXtstProperty, NULL, NULL);
+    XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTEST_DEVICE), FALSE);
+    XIRegisterPropertyHandler(*keybd, DeviceSetXTestProperty, NULL, NULL);
 
     return retval;
 }
@@ -667,38 +667,38 @@ int AllocXtstDevice (ClientPtr client, char* name,
  * xtest device.
  */
 BOOL
-IsXtstDevice(DeviceIntPtr dev, DeviceIntPtr master)
+IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master)
 {
-    int is_xtst = FALSE;
+    int is_XTest = FALSE;
     int mid;
     void *tmp; /* shut up, gcc! */
 
     if (IsMaster(dev))
-        return is_xtst;
+        return is_XTest;
 
-    tmp = dixLookupPrivate(&dev->devPrivates, XTstDevicePrivateKey);
+    tmp = dixLookupPrivate(&dev->devPrivates, XTestDevicePrivateKey);
     mid = (int)tmp;
 
-    /* deviceid 0 is reserved for XIAllDevices, non-zero mid means xtst
+    /* deviceid 0 is reserved for XIAllDevices, non-zero mid means XTest
      * device */
     if ((!master && mid) ||
         (master && mid == master->id))
-        is_xtst = TRUE;
+        is_XTest = TRUE;
 
-    return is_xtst;
+    return is_XTest;
 }
 
 /**
  * @return The X Test virtual device for the given master.
  */
 DeviceIntPtr
-GetXtstDevice(DeviceIntPtr master)
+GetXTestDevice(DeviceIntPtr master)
 {
     DeviceIntPtr it;
 
     for (it = inputInfo.devices; it; it = it->next)
     {
-        if (IsXtstDevice(it, master))
+        if (IsXTestDevice(it, master))
             return it;
     }
 
diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
index c123724..1a06e45 100644
--- a/Xi/xichangehierarchy.c
+++ b/Xi/xichangehierarchy.c
@@ -141,7 +141,7 @@ int SProcXIChangeHierarchy(ClientPtr client)
 int
 ProcXIChangeHierarchy(ClientPtr client)
 {
-    DeviceIntPtr ptr, keybd, xtstptr, xtstkeybd;
+    DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd;
     xXIAnyHierarchyChangeInfo *any;
     int required_len = sizeof(xXIChangeHierarchyReq);
     char n;
@@ -189,7 +189,7 @@ ProcXIChangeHierarchy(ClientPtr client)
                         ptr->coreEvents = keybd->coreEvents =  FALSE;
 
                     /* Allocate virtual slave devices for xtest events */
-                    rc = AllocXtstDevice(client, name, &xtstptr, &xtstkeybd,
+                    rc = AllocXTestDevice(client, name, &XTestptr, &XTestkeybd,
                                          ptr, keybd);
                     if (rc != Success)
                     {
@@ -203,10 +203,10 @@ ProcXIChangeHierarchy(ClientPtr client)
                     flags[ptr->id] |= XIMasterAdded;
                     flags[keybd->id] |= XIMasterAdded;
 
-                    ActivateDevice(xtstptr, FALSE);
-                    ActivateDevice(xtstkeybd, FALSE);
-                    flags[xtstptr->id] |= XISlaveAdded;
-                    flags[xtstkeybd->id] |= XISlaveAdded;
+                    ActivateDevice(XTestptr, FALSE);
+                    ActivateDevice(XTestkeybd, FALSE);
+                    flags[XTestptr->id] |= XISlaveAdded;
+                    flags[XTestkeybd->id] |= XISlaveAdded;
 
                     if (c->enable)
                     {
@@ -215,18 +215,18 @@ ProcXIChangeHierarchy(ClientPtr client)
                         flags[ptr->id] |= XIDeviceEnabled;
                         flags[keybd->id] |= XIDeviceEnabled;
 
-                        EnableDevice(xtstptr, FALSE);
-                        EnableDevice(xtstkeybd, FALSE);
-                        flags[xtstptr->id] |= XIDeviceEnabled;
-                        flags[xtstkeybd->id] |= XIDeviceEnabled;
+                        EnableDevice(XTestptr, FALSE);
+                        EnableDevice(XTestkeybd, FALSE);
+                        flags[XTestptr->id] |= XIDeviceEnabled;
+                        flags[XTestkeybd->id] |= XIDeviceEnabled;
                     }
 
                     /* Attach the XTest virtual devices to the newly
                        created master device */
-                    AttachDevice(NULL, xtstptr, ptr);
-                    AttachDevice(NULL, xtstkeybd, keybd);
-                    flags[xtstptr->id] |= XISlaveAttached;
-                    flags[xtstkeybd->id] |= XISlaveAttached;
+                    AttachDevice(NULL, XTestptr, ptr);
+                    AttachDevice(NULL, XTestkeybd, keybd);
+                    flags[XTestptr->id] |= XISlaveAttached;
+                    flags[XTestkeybd->id] |= XISlaveAttached;
 
                     xfree(name);
                 }
@@ -275,14 +275,14 @@ ProcXIChangeHierarchy(ClientPtr client)
                     if (rc != Success)
                         goto unwind;
 
-                    xtstptr = GetXtstDevice(ptr);
-                    rc = dixLookupDevice(&xtstptr, xtstptr->id, client,
+                    XTestptr = GetXTestDevice(ptr);
+                    rc = dixLookupDevice(&XTestptr, XTestptr->id, client,
                                          DixDestroyAccess);
                     if (rc != Success)
                         goto unwind;
 
-                    xtstkeybd = GetXtstDevice(keybd);
-                    rc = dixLookupDevice(&xtstkeybd, xtstkeybd->id, client,
+                    XTestkeybd = GetXTestDevice(keybd);
+                    rc = dixLookupDevice(&XTestkeybd, XTestkeybd->id, client,
                                          DixDestroyAccess);
                     if (rc != Success)
                         goto unwind;
@@ -341,26 +341,26 @@ ProcXIChangeHierarchy(ClientPtr client)
                     /* can't disable until we removed pairing */
                     keybd->spriteInfo->paired = NULL;
                     ptr->spriteInfo->paired = NULL;
-                    xtstptr->spriteInfo->paired = NULL;
-                    xtstkeybd->spriteInfo->paired = NULL;
+                    XTestptr->spriteInfo->paired = NULL;
+                    XTestkeybd->spriteInfo->paired = NULL;
 
-                    /* disable the remove the devices, xtst devices must be done first
+                    /* disable the remove the devices, XTest devices must be done first
                        else the sprites they rely on will be destroyed  */
-                    DisableDevice(xtstptr, FALSE);
-                    DisableDevice(xtstkeybd, FALSE);
+                    DisableDevice(XTestptr, FALSE);
+                    DisableDevice(XTestkeybd, FALSE);
                     DisableDevice(keybd, FALSE);
                     DisableDevice(ptr, FALSE);
-                    flags[xtstptr->id] |= XIDeviceDisabled | XISlaveDetached;
-                    flags[xtstkeybd->id] |= XIDeviceDisabled | XISlaveDetached;
+                    flags[XTestptr->id] |= XIDeviceDisabled | XISlaveDetached;
+                    flags[XTestkeybd->id] |= XIDeviceDisabled | XISlaveDetached;
                     flags[keybd->id] |= XIDeviceDisabled;
                     flags[ptr->id] |= XIDeviceDisabled;
 
-                    RemoveDevice(xtstptr, FALSE);
-                    RemoveDevice(xtstkeybd, FALSE);
+                    RemoveDevice(XTestptr, FALSE);
+                    RemoveDevice(XTestkeybd, FALSE);
                     RemoveDevice(keybd, FALSE);
                     RemoveDevice(ptr, FALSE);
-                    flags[xtstptr->id] |= XISlaveRemoved;
-                    flags[xtstkeybd->id] |= XISlaveRemoved;
+                    flags[XTestptr->id] |= XISlaveRemoved;
+                    flags[XTestkeybd->id] |= XISlaveRemoved;
                     flags[keybd->id] |= XIMasterRemoved;
                     flags[ptr->id] |= XIMasterRemoved;
                 }
@@ -381,8 +381,8 @@ ProcXIChangeHierarchy(ClientPtr client)
                         goto unwind;
                     }
 
-                    /* Don't allow changes to Xtst Devices, these are fixed */
-                    if (IsXtstDevice(ptr, NULL))
+                    /* Don't allow changes to XTest Devices, these are fixed */
+                    if (IsXTestDevice(ptr, NULL))
                     {
                         client->errorValue = c->deviceid;
                         rc = BadDevice;
@@ -410,8 +410,8 @@ ProcXIChangeHierarchy(ClientPtr client)
                         goto unwind;
                     }
 
-                    /* Don't allow changes to Xtst Devices, these are fixed */
-                    if (IsXtstDevice(ptr, NULL))
+                    /* Don't allow changes to XTest Devices, these are fixed */
+                    if (IsXTestDevice(ptr, NULL))
                     {
                         client->errorValue = c->deviceid;
                         rc = BadDevice;
diff --git a/Xi/xiproperty.c b/Xi/xiproperty.c
index 0a47e31..024dc44 100644
--- a/Xi/xiproperty.c
+++ b/Xi/xiproperty.c
@@ -51,7 +51,7 @@ static struct dev_properties
     char *name;
 } dev_properties[] = {
     {0, XI_PROP_ENABLED},
-    {0, XI_PROP_XTST_DEVICE},
+    {0, XI_PROP_XTEST_DEVICE},
     {0, XATOM_FLOAT},
     {0, ACCEL_PROP_PROFILE_NUMBER},
     {0, ACCEL_PROP_CONSTANT_DECELERATION},
diff --git a/dix/devices.c b/dix/devices.c
index 16e8987..0be3d58 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1200,7 +1200,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
     dev->last.numValuators = numAxes;
 
     if (IsMaster(dev) || /* do not accelerate master or xtest devices */
-        IsXtstDevice(dev, NULL))
+        IsXTestDevice(dev, NULL))
 	InitPointerAccelerationScheme(dev, PtrAccelNoOp);
     else
 	InitPointerAccelerationScheme(dev, PtrAccelDefault);
diff --git a/include/input.h b/include/input.h
index 34e1c69..548e58c 100644
--- a/include/input.h
+++ b/include/input.h
@@ -495,14 +495,14 @@ extern int generate_modkeymap(ClientPtr client, DeviceIntPtr dev,
                               KeyCode **modkeymap, int *max_keys_per_mod);
 extern int change_modmap(ClientPtr client, DeviceIntPtr dev, KeyCode *map,
                          int max_keys_per_mod);
-extern int AllocXtstDevice(ClientPtr client,
+extern int AllocXTestDevice(ClientPtr client,
                              char* name,
                              DeviceIntPtr* ptr,
                              DeviceIntPtr* keybd,
                              DeviceIntPtr master_ptr,
                              DeviceIntPtr master_keybd);
-extern BOOL IsXtstDevice(DeviceIntPtr dev, DeviceIntPtr master);
-extern DeviceIntPtr GetXtstDevice(DeviceIntPtr master);
+extern BOOL IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master);
+extern DeviceIntPtr GetXTestDevice(DeviceIntPtr master);
 
 /* misc event helpers */
 extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
diff --git a/include/xserver-properties.h b/include/xserver-properties.h
index 0f18dbc..626d0ad 100644
--- a/include/xserver-properties.h
+++ b/include/xserver-properties.h
@@ -32,8 +32,8 @@
 
 /* BOOL. 0 - device disabled, 1 - device enabled */
 #define XI_PROP_ENABLED      "Device Enabled"
-/* BOOL. If present, device is a virtual Xtst device */
-#define XI_PROP_XTST_DEVICE  "Xtst Device"
+/* BOOL. If present, device is a virtual XTEST device */
+#define XI_PROP_XTEST_DEVICE  "XTEST Device"
 
 /* Pointer acceleration properties */
 /* INTEGER of any format */
commit 8bfd23e144e51401e3756de9260a4811fcc59e91
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Aug 24 09:38:15 2009 +1000

    input: move XTest device initialization into Xext/xtest.c
    
    XTest devices are non-optional but nonetheless specific to the XTEST
    extension.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xext/xtest.c b/Xext/xtest.c
index c96cbf5..6c59952 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -32,6 +32,7 @@
 
 #include <X11/X.h>
 #include <X11/Xproto.h>
+#include <X11/Xatom.h>
 #include "misc.h"
 #include "os.h"
 #include "dixstruct.h"
@@ -49,6 +50,8 @@
 #include <X11/extensions/XIproto.h>
 #include "exglobals.h"
 #include "mipointer.h"
+#include "xserver-properties.h"
+#include "exevents.h"
 
 #include "modinit.h"
 
@@ -59,6 +62,22 @@ extern int DeviceValuator;
  * other's memory */
 static EventListPtr xtest_evlist;
 
+/* Used to store if a device is an XTest Virtual device */
+static int XTstDevicePrivateKeyIndex;
+DevPrivateKey XTstDevicePrivateKey = &XTstDevicePrivateKeyIndex;
+
+/**
+ * vxtstpointer
+ * is the virtual pointer for XTest. It is the first slave
+ * device of the VCP.
+ * vxtstkeyboard
+ * is the virtual keyboard for XTest. It is the first slave
+ * device of the VCK
+ *
+ * Neither of these devices can be deleted.
+ */
+DeviceIntPtr vxtstpointer, vxtstkeyboard;
+
 #ifdef PANORAMIX
 #include "panoramiX.h"
 #include "panoramiXsrv.h"
@@ -564,3 +583,126 @@ SProcXTestDispatch (ClientPtr client)
             return BadRequest;
     }
 }
+
+/**
+ * Allocate an virtual slave device for xtest events, this
+ * is a slave device to inputInfo master devices
+ */
+void InitXTestDevices(void)
+{
+    if(AllocXtstDevice(serverClient, "Virtual core",
+                       &vxtstpointer, &vxtstkeyboard,
+                       inputInfo.pointer, inputInfo.keyboard) != Success)
+        FatalError("Failed to allocate XTst devices");
+
+    if (ActivateDevice(vxtstpointer, TRUE) != Success ||
+        ActivateDevice(vxtstkeyboard, TRUE) != Success)
+        FatalError("Failed to activate xtst core devices.");
+    if (!EnableDevice(vxtstpointer, TRUE) ||
+        !EnableDevice(vxtstkeyboard, TRUE))
+        FatalError("Failed to enable xtst core devices.");
+
+    AttachDevice(NULL, vxtstpointer, inputInfo.pointer);
+    AttachDevice(NULL, vxtstkeyboard, inputInfo.keyboard);
+}
+
+/**
+ * Don't allow changing the Xtst property.
+ */
+static int
+DeviceSetXtstProperty(DeviceIntPtr dev, Atom property,
+                      XIPropertyValuePtr prop, BOOL checkonly)
+{
+    if (property == XIGetKnownProperty(XI_PROP_XTST_DEVICE))
+        return BadAccess;
+
+    return Success;
+}
+
+/**
+ * Allocate a device pair that is initialised as a slave
+ * device with properties that identify the devices as belonging
+ * to XTest subsystem.
+ * This only creates the pair, Activate/Enable Device
+ * still need to be called.
+ */
+int AllocXtstDevice (ClientPtr client, char* name,
+                     DeviceIntPtr* ptr, DeviceIntPtr* keybd,
+                     DeviceIntPtr master_ptr, DeviceIntPtr master_keybd)
+{
+    int retval;
+    int len = strlen(name);
+    char *xtstname = xcalloc(len + 6, 1 );
+    char dummy = 1;
+
+    strncpy( xtstname, name, len);
+    strncat( xtstname, " Xtst", 5 );
+
+    retval = AllocDevicePair( client, xtstname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE);
+    if ( retval == Success ){
+        dixSetPrivate(&((*ptr)->devPrivates), XTstDevicePrivateKey, (void *)master_ptr->id);
+        dixSetPrivate(&((*keybd)->devPrivates), XTstDevicePrivateKey, (void *)master_keybd->id);
+    }
+
+    xfree( xtstname );
+
+    XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTST_DEVICE),
+                           XA_INTEGER, 8, PropModeReplace, 1, &dummy,
+                           FALSE);
+    XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTST_DEVICE), FALSE);
+    XIRegisterPropertyHandler(*ptr, DeviceSetXtstProperty, NULL, NULL);
+    XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTST_DEVICE),
+                           XA_INTEGER, 8, PropModeReplace, 1, &dummy,
+                           FALSE);
+    XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTST_DEVICE), FALSE);
+    XIRegisterPropertyHandler(*keybd, DeviceSetXtstProperty, NULL, NULL);
+
+    return retval;
+}
+
+/**
+ * If master is NULL, return TRUE if the given device is an xtest device or
+ * FALSE otherwise.
+ * If master is not NULL, return TRUE if the given device is this master's
+ * xtest device.
+ */
+BOOL
+IsXtstDevice(DeviceIntPtr dev, DeviceIntPtr master)
+{
+    int is_xtst = FALSE;
+    int mid;
+    void *tmp; /* shut up, gcc! */
+
+    if (IsMaster(dev))
+        return is_xtst;
+
+    tmp = dixLookupPrivate(&dev->devPrivates, XTstDevicePrivateKey);
+    mid = (int)tmp;
+
+    /* deviceid 0 is reserved for XIAllDevices, non-zero mid means xtst
+     * device */
+    if ((!master && mid) ||
+        (master && mid == master->id))
+        is_xtst = TRUE;
+
+    return is_xtst;
+}
+
+/**
+ * @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/dix/devices.c b/dix/devices.c
index f61136c..16e8987 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -94,21 +94,7 @@ DevPrivateKey CoreDevicePrivateKey = &CoreDevicePrivateKeyIndex;
 /* Used to store classes currently not in use by an MD */
 static int UnusedClassesPrivateKeyIndex;
 DevPrivateKey UnusedClassesPrivateKey = &UnusedClassesPrivateKeyIndex;
-/* Used to store if a device is an XTest Virtual device */
-static int XTstDevicePrivateKeyIndex;
-DevPrivateKey XTstDevicePrivateKey = &XTstDevicePrivateKeyIndex;
 
-/**
- * vxtstpointer
- * is the virtual pointer for XTest. It is the first slave
- * device of the VCP.
- * vxtstkeyboard
- * is the virtual keyboard for XTest. It is the first slave
- * device of the VCK
- *
- * Neither of these devices can be deleted.
- */
-DeviceIntPtr vxtstpointer, vxtstkeyboard;
 
 static void RecalculateMasterButtons(DeviceIntPtr slave);
 
@@ -638,24 +624,7 @@ InitCoreDevices(void)
         !EnableDevice(inputInfo.keyboard, TRUE))
         FatalError("Failed to enable core devices.");
 
-    /*
-      Allocate an virtual slave device for xtest events, this
-      is a slave device to inputInfo master devices
-     */
-    if(AllocXtstDevice(serverClient, "Virtual core",
-                       &vxtstpointer, &vxtstkeyboard,
-                       inputInfo.pointer, inputInfo.keyboard) != Success)
-        FatalError("Failed to allocate XTst devices");
-
-    if (ActivateDevice(vxtstpointer, TRUE) != Success ||
-        ActivateDevice(vxtstkeyboard, TRUE) != Success)
-        FatalError("Failed to activate xtst core devices.");
-    if (!EnableDevice(vxtstpointer, TRUE) ||
-        !EnableDevice(vxtstkeyboard, TRUE))
-        FatalError("Failed to enable xtst core devices.");
-
-    AttachDevice(NULL, vxtstpointer, inputInfo.pointer);
-    AttachDevice(NULL, vxtstkeyboard, inputInfo.keyboard);
+    InitXTestDevices();
 }
 
 /**
@@ -2559,103 +2528,3 @@ AllocDevicePair (ClientPtr client, char* name,
     return Success;
 }
 
-/**
- * Don't allow changing the Xtst property.
- */
-static int
-DeviceSetXtstProperty(DeviceIntPtr dev, Atom property,
-                      XIPropertyValuePtr prop, BOOL checkonly)
-{
-    if (property == XIGetKnownProperty(XI_PROP_XTST_DEVICE))
-        return BadAccess;
-
-    return Success;
-}
-
-/**
- * Allocate a device pair that is initialised as a slave
- * device with properties that identify the devices as belonging
- * to XTest subsystem.
- * This only creates the pair, Activate/Enable Device
- * still need to be called.
- */
-int AllocXtstDevice (ClientPtr client, char* name,
-                     DeviceIntPtr* ptr, DeviceIntPtr* keybd,
-                     DeviceIntPtr master_ptr, DeviceIntPtr master_keybd)
-{
-    int retval;
-    int len = strlen(name);
-    char *xtstname = xcalloc(len + 6, 1 );
-    char dummy = 1;
-
-    strncpy( xtstname, name, len);
-    strncat( xtstname, " Xtst", 5 );
-
-    retval = AllocDevicePair( client, xtstname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE);
-    if ( retval == Success ){
-        dixSetPrivate(&((*ptr)->devPrivates), XTstDevicePrivateKey, (void *)master_ptr->id);
-        dixSetPrivate(&((*keybd)->devPrivates), XTstDevicePrivateKey, (void *)master_keybd->id);
-    }
-
-    xfree( xtstname );
-
-    XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTST_DEVICE),
-                           XA_INTEGER, 8, PropModeReplace, 1, &dummy,
-                           FALSE);
-    XISetDevicePropertyDeletable(*ptr, XIGetKnownProperty(XI_PROP_XTST_DEVICE), FALSE);
-    XIRegisterPropertyHandler(*ptr, DeviceSetXtstProperty, NULL, NULL);
-    XIChangeDeviceProperty(*keybd, XIGetKnownProperty(XI_PROP_XTST_DEVICE),
-                           XA_INTEGER, 8, PropModeReplace, 1, &dummy,
-                           FALSE);
-    XISetDevicePropertyDeletable(*keybd, XIGetKnownProperty(XI_PROP_XTST_DEVICE), FALSE);
-    XIRegisterPropertyHandler(*keybd, DeviceSetXtstProperty, NULL, NULL);
-
-    return retval;
-}
-
-/**
- * If master is NULL, return TRUE if the given device is an xtest device or
- * FALSE otherwise.
- * If master is not NULL, return TRUE if the given device is this master's
- * xtest device.
- */
-BOOL
-IsXtstDevice(DeviceIntPtr dev, DeviceIntPtr master)
-{
-    int is_xtst = FALSE;
-    int mid;
-    void *tmp; /* shut up, gcc! */
-
-    if (IsMaster(dev))
-        return is_xtst;
-
-    tmp = dixLookupPrivate(&dev->devPrivates, XTstDevicePrivateKey);
-    mid = (int)tmp;
-
-    /* deviceid 0 is reserved for XIAllDevices, non-zero mid means xtst
-     * device */
-    if ((!master && mid) ||
-        (master && mid == master->id))
-        is_xtst = TRUE;
-
-    return is_xtst;
-}
-
-/**
- * @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 d003472..34e1c69 100644
--- a/include/input.h
+++ b/include/input.h
@@ -220,6 +220,7 @@ extern void set_key_up(DeviceIntPtr pDev, int key_code, int type);
 extern int key_is_down(DeviceIntPtr pDev, int key_code, int type);
 
 extern void InitCoreDevices(void);
+extern void InitXTestDevices(void);
 
 extern _X_EXPORT DeviceIntPtr AddInputDevice(
     ClientPtr /*client*/,
commit a95f80fa914678d360f6dfd2b58926193df6ea4a
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Aug 24 09:26:56 2009 +1000

    dix: use IsXtstDevice instead of the direct key lookup.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/devices.c b/dix/devices.c
index f73b5ff..f61136c 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1231,7 +1231,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
     dev->last.numValuators = numAxes;
 
     if (IsMaster(dev) || /* do not accelerate master or xtest devices */
-	dixLookupPrivate(&dev->devPrivates, XTstDevicePrivateKey ))
+        IsXtstDevice(dev, NULL))
 	InitPointerAccelerationScheme(dev, PtrAccelNoOp);
     else
 	InitPointerAccelerationScheme(dev, PtrAccelDefault);
commit 16b7ebd7d876034edfe8f74562bd06e747879d79
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Aug 24 14:34:23 2009 +1000

    xfree86: Remove xf86GetMotionEvents from public API.
    
    This function was used as the default motion event queue API until
    including XINPUT_ABI 2 (server 1.5).
    
    This API was broken with 1883485 in May 2008 (wrong casting of parameters)
    and isn't in use by input drivers past ABI 3.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>

diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index f70b4e8..9a2468d 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -2586,10 +2586,3 @@ xf86MotionHistoryAllocate(LocalDevicePtr local)
 {
     AllocateMotionHistory(local->dev);
 }
-
-int
-xf86GetMotionEvents(DeviceIntPtr pDev, xTimecoord *buff, unsigned long start,
-                    unsigned long stop, ScreenPtr pScreen, BOOL core)
-{
-    return GetMotionHistory(pDev, buff, start, stop, pScreen, core);
-}
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index b1b88ac..aa9e9d5 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -206,9 +206,6 @@ extern _X_EXPORT InputDriverPtr xf86LookupInputDriver(const char *name);
 extern _X_EXPORT InputInfoPtr xf86LookupInput(const char *name);
 extern _X_EXPORT void xf86DeleteInput(InputInfoPtr pInp, int flags);
 extern _X_EXPORT void xf86MotionHistoryAllocate(LocalDevicePtr local);
-extern _X_EXPORT int xf86GetMotionEvents(DeviceIntPtr dev, xTimecoord *buff,
-                        unsigned long start, unsigned long stop,
-                        ScreenPtr pScreen, BOOL core);
 
 /* xf86Option.c */
 extern _X_EXPORT void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts,


More information about the xorg-commit mailing list