[x11] Simplify the XInput support
Instead of using a specific function to check whether the X server supports the XInput extension we can use the generic Xlib function XQueryExtension(). This cuts down the extra checks inside the configure.ac and simplifies the code inside clutter_x11_register_xinput().
This commit is contained in:
parent
21608fe5f7
commit
cb4e5c9083
@ -644,8 +644,9 @@ _clutter_x11_register_xinput ()
|
|||||||
XDevice *xdevice = NULL;
|
XDevice *xdevice = NULL;
|
||||||
|
|
||||||
XInputClassInfo *xclass_info = NULL;
|
XInputClassInfo *xclass_info = NULL;
|
||||||
XExtensionVersion *ext;
|
|
||||||
|
|
||||||
|
gint opcode, event, error;
|
||||||
|
gint res;
|
||||||
gint num_devices = 0;
|
gint num_devices = 0;
|
||||||
gint num_events = 0;
|
gint num_events = 0;
|
||||||
gint i = 0, j = 0;
|
gint i = 0, j = 0;
|
||||||
@ -672,21 +673,15 @@ _clutter_x11_register_xinput ()
|
|||||||
|
|
||||||
context = _clutter_context_get_default ();
|
context = _clutter_context_get_default ();
|
||||||
|
|
||||||
backend_singleton->have_xinput = TRUE;
|
|
||||||
|
|
||||||
#if defined(HAVE_XQUERY_INPUT_VERSION)
|
|
||||||
ext = XQueryInputVersion (backend_singleton->xdpy, XI_2_Major, XI_2_Minor);
|
|
||||||
#elif defined(HAVE_XGET_EXTENSION_VERSION)
|
|
||||||
ext = XGetExtensionVersion (backend_singleton->xdpy, INAME);
|
|
||||||
#else
|
|
||||||
g_critical ("XInput does not have XGetExtensionVersion nor "
|
|
||||||
"XQueryInputVersion");
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!ext || (ext == (XExtensionVersion*) NoSuchExtension))
|
|
||||||
{
|
|
||||||
backend_singleton->have_xinput = FALSE;
|
backend_singleton->have_xinput = FALSE;
|
||||||
|
|
||||||
|
/* is the XInput extension available? */
|
||||||
|
res = XQueryExtension (backend_singleton->xdpy, "XInputExtension",
|
||||||
|
&opcode, &event,
|
||||||
|
&error);
|
||||||
|
if (!res)
|
||||||
|
{
|
||||||
|
CLUTTER_NOTE (BACKEND, "X Input extension not available");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,15 +692,12 @@ _clutter_x11_register_xinput ()
|
|||||||
CLUTTER_NOTE (BACKEND, "%d XINPUT devices found", num_devices);
|
CLUTTER_NOTE (BACKEND, "%d XINPUT devices found", num_devices);
|
||||||
|
|
||||||
if (num_devices == 0)
|
if (num_devices == 0)
|
||||||
{
|
|
||||||
backend_singleton->have_xinput = FALSE;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < num_devices; i++)
|
for (i = 0; i < num_devices; i++)
|
||||||
{
|
{
|
||||||
num_events = 0;
|
|
||||||
info = xdevices + i;
|
info = xdevices + i;
|
||||||
|
num_events = 0;
|
||||||
|
|
||||||
CLUTTER_NOTE (BACKEND, "Considering %li with type %d",
|
CLUTTER_NOTE (BACKEND, "Considering %li with type %d",
|
||||||
info->id,
|
info->id,
|
||||||
@ -713,11 +705,11 @@ _clutter_x11_register_xinput ()
|
|||||||
|
|
||||||
/* Only want 'raw' devices themselves not virtual ones */
|
/* Only want 'raw' devices themselves not virtual ones */
|
||||||
if (info->use == IsXExtensionPointer ||
|
if (info->use == IsXExtensionPointer ||
|
||||||
/*info->use == IsXExtensionKeyboard || XInput is broken */
|
/*info->use == IsXExtensionKeyboard || XInput 1.x is broken */
|
||||||
info->use == IsXExtensionDevice)
|
info->use == IsXExtensionDevice)
|
||||||
{
|
{
|
||||||
clutter_x11_trap_x_errors ();
|
clutter_x11_trap_x_errors ();
|
||||||
xdevice = XOpenDevice (x11b->xdpy, info->id);
|
xdevice = XOpenDevice (backend_singleton->xdpy, info->id);
|
||||||
if (clutter_x11_untrap_x_errors () || xdevice == NULL)
|
if (clutter_x11_untrap_x_errors () || xdevice == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -734,11 +726,12 @@ _clutter_x11_register_xinput ()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* XInput is broken for keyboards: */
|
/* XInput 1.x is broken for keyboards: */
|
||||||
case IsXExtensionKeyboard:
|
case IsXExtensionKeyboard:
|
||||||
device->device.type = CLUTTER_KEYBOARD_DEVICE;
|
device->device.type = CLUTTER_KEYBOARD_DEVICE;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case IsXExtensionDevice:
|
case IsXExtensionDevice:
|
||||||
device->device.device_type = CLUTTER_EXTENSION_DEVICE;
|
device->device.device_type = CLUTTER_EXTENSION_DEVICE;
|
||||||
break;
|
break;
|
||||||
@ -751,8 +744,8 @@ _clutter_x11_register_xinput ()
|
|||||||
device->device.previous_y = -1;
|
device->device.previous_y = -1;
|
||||||
device->device.previous_button_number = -1;
|
device->device.previous_button_number = -1;
|
||||||
|
|
||||||
device->xdevice = xdevice;
|
|
||||||
device->num_events = 0;
|
device->num_events = 0;
|
||||||
|
device->xdevice = xdevice;
|
||||||
|
|
||||||
CLUTTER_NOTE (BACKEND, "Registering XINPUT device with XID: %li",
|
CLUTTER_NOTE (BACKEND, "Registering XINPUT device with XID: %li",
|
||||||
xdevice->device_id);
|
xdevice->device_id);
|
||||||
@ -769,7 +762,7 @@ _clutter_x11_register_xinput ()
|
|||||||
switch (xclass_info->input_class)
|
switch (xclass_info->input_class)
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
/* XInput is broken for keyboards: */
|
/* XInput 1.x is broken for keyboards: */
|
||||||
case KeyClass:
|
case KeyClass:
|
||||||
DeviceKeyPress (xdevice,
|
DeviceKeyPress (xdevice,
|
||||||
x11b->event_types[CLUTTER_X11_XINPUT_KEY_PRESS_EVENT],
|
x11b->event_types[CLUTTER_X11_XINPUT_KEY_PRESS_EVENT],
|
||||||
@ -809,7 +802,7 @@ _clutter_x11_register_xinput ()
|
|||||||
|
|
||||||
device->num_events = num_events;
|
device->num_events = num_events;
|
||||||
|
|
||||||
input_devices = g_slist_append (input_devices, device);
|
input_devices = g_slist_prepend (input_devices, device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -824,17 +817,20 @@ _clutter_x11_register_xinput ()
|
|||||||
*/
|
*/
|
||||||
g_warning ("No usuable XInput pointing devices found");
|
g_warning ("No usuable XInput pointing devices found");
|
||||||
|
|
||||||
backend_singleton->have_xinput = FALSE;
|
|
||||||
|
|
||||||
for (l = input_devices; l != NULL; l = l->next)
|
for (l = input_devices; l != NULL; l = l->next)
|
||||||
g_slice_free (ClutterX11XInputDevice, l->data);
|
g_slice_free (ClutterX11XInputDevice, l->data);
|
||||||
|
|
||||||
g_slist_free (input_devices);
|
g_slist_free (input_devices);
|
||||||
context->input_devices = NULL;
|
context->input_devices = NULL;
|
||||||
}
|
|
||||||
else
|
|
||||||
context->input_devices = input_devices;
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* store the list of input devices */
|
||||||
|
context->input_devices = g_slist_reverse (input_devices);
|
||||||
|
|
||||||
|
/* why yes, we are awesome */
|
||||||
|
backend_singleton->have_xinput = TRUE;
|
||||||
#endif /* HAVE_XINPUT */
|
#endif /* HAVE_XINPUT */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
41
configure.ac
41
configure.ac
@ -521,49 +521,8 @@ AS_IF([test "x$clutterbackend" = "xglx" || test "x$clutterbackend" = "xeglx"],
|
|||||||
[
|
[
|
||||||
AC_DEFINE(HAVE_XINPUT, 1, Use the XINPUT X extension)
|
AC_DEFINE(HAVE_XINPUT, 1, Use the XINPUT X extension)
|
||||||
|
|
||||||
# ugh, this is insane
|
|
||||||
AC_TRY_COMPILE([#include <X11/extensions/XInput.h>],
|
|
||||||
[
|
|
||||||
XExtensionVersion *res;
|
|
||||||
res = XGetExtensionVersion (NULL, INAME);
|
|
||||||
],
|
|
||||||
[have_xget_extension_version=yes],
|
|
||||||
[have_xget_extension_version=no])
|
|
||||||
|
|
||||||
AC_TRY_COMPILE([#include <X11/extensions/XInput.h>],
|
|
||||||
[
|
|
||||||
XExtensionVersion *res;
|
|
||||||
res = XQueryInputVersion (NULL, XI_2_Major, XI_2_Minor);
|
|
||||||
],
|
|
||||||
[have_xquery_input_version=yes],
|
|
||||||
[have_xquery_input_version=no])
|
|
||||||
|
|
||||||
AS_IF([test "x$have_xget_extension_version" = "xyes"],
|
|
||||||
[
|
|
||||||
AC_DEFINE([HAVE_XGET_EXTENSION_VERSION],
|
|
||||||
[1],
|
|
||||||
[Define to 1 if we have XGetExtensionVersion])
|
|
||||||
])
|
|
||||||
|
|
||||||
#Seems some distros ship with the header but not the symbol
|
|
||||||
really_have_xinput_query_version=no
|
|
||||||
AS_IF([test "x$have_xquery_input_version" = "xyes"],
|
|
||||||
[
|
|
||||||
AC_CHECK_LIB(Xi, [XQueryInputVersion],
|
|
||||||
[really_have_xinput_query_version=yes],
|
|
||||||
[])
|
|
||||||
])
|
|
||||||
|
|
||||||
AS_IF([test "x$really_have_xquery_input_version" = "xyes"],
|
|
||||||
[
|
|
||||||
AC_DEFINE([HAVE_XQUERY_INPUT_VERSION],
|
|
||||||
[1],
|
|
||||||
[Define to 1 if we have XQueryInputVersion])
|
|
||||||
])
|
|
||||||
|
|
||||||
X11_LIBS="$X11_LIBS -lXi"
|
X11_LIBS="$X11_LIBS -lXi"
|
||||||
X11_PC_FILES="$X11_PC_FILES xi"
|
X11_PC_FILES="$X11_PC_FILES xi"
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
[no],
|
[no],
|
||||||
|
Loading…
Reference in New Issue
Block a user