mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
[xinput] Check for the XInput entry points
Apparently, the XInput extension is using the same pkg-config file ('xi') for both the 1.x and the 2.x API, so we need to check for both the 1.x XGetExtensionVersion and the 2.x XQueryInputVersion.
This commit is contained in:
parent
876dc22633
commit
0a4a28a950
@ -39,8 +39,13 @@
|
|||||||
#include "clutter-backend-x11.h"
|
#include "clutter-backend-x11.h"
|
||||||
#include "clutter-stage-x11.h"
|
#include "clutter-stage-x11.h"
|
||||||
#include "clutter-x11.h"
|
#include "clutter-x11.h"
|
||||||
|
|
||||||
#include <X11/extensions/Xcomposite.h>
|
#include <X11/extensions/Xcomposite.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_XINPUT
|
||||||
|
#include <X11/extensions/XInput.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "../clutter-event.h"
|
#include "../clutter-event.h"
|
||||||
#include "../clutter-main.h"
|
#include "../clutter-main.h"
|
||||||
#include "../clutter-debug.h"
|
#include "../clutter-debug.h"
|
||||||
@ -53,15 +58,18 @@ G_DEFINE_TYPE (ClutterBackendX11, clutter_backend_x11, CLUTTER_TYPE_BACKEND);
|
|||||||
struct _ClutterX11XInputDevice
|
struct _ClutterX11XInputDevice
|
||||||
{
|
{
|
||||||
ClutterInputDevice device;
|
ClutterInputDevice device;
|
||||||
#ifdef USE_XINPUT
|
|
||||||
|
#ifdef HAVE_XINPUT
|
||||||
XDevice *xdevice;
|
XDevice *xdevice;
|
||||||
XEventClass xevent_list[5]; /* MAX 5 event types */
|
XEventClass xevent_list[5]; /* MAX 5 event types */
|
||||||
int num_events;
|
int num_events;
|
||||||
#endif
|
#endif
|
||||||
ClutterX11InputDeviceType type; /* FIXME: generic to ClutterInputDevice? */
|
|
||||||
|
/* FIXME: generic to ClutterInputDevice? */
|
||||||
|
ClutterX11InputDeviceType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_XINPUT
|
#ifdef HAVE_XINPUT
|
||||||
void _clutter_x11_register_xinput ();
|
void _clutter_x11_register_xinput ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -185,7 +193,7 @@ clutter_backend_x11_post_parse (ClutterBackend *backend,
|
|||||||
|
|
||||||
clutter_backend_set_resolution (backend, dpi);
|
clutter_backend_set_resolution (backend, dpi);
|
||||||
|
|
||||||
#ifdef USE_XINPUT
|
#ifdef HAVE_XINPUT
|
||||||
_clutter_x11_register_xinput ();
|
_clutter_x11_register_xinput ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -630,7 +638,7 @@ clutter_x11_remove_filter (ClutterX11FilterFunc func,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_XINPUT
|
#ifdef HAVE_XINPUT
|
||||||
|
|
||||||
void
|
void
|
||||||
_clutter_x11_register_xinput ()
|
_clutter_x11_register_xinput ()
|
||||||
@ -669,7 +677,15 @@ _clutter_x11_register_xinput ()
|
|||||||
|
|
||||||
backend_singleton->have_xinput = TRUE;
|
backend_singleton->have_xinput = TRUE;
|
||||||
|
|
||||||
ext = XGetExtensionVersion(backend_singleton->xdpy, INAME);
|
#ifdef HAVE_XGET_EXTENSION_VERSION
|
||||||
|
ext = XGetExtensionVersion (backend_singleton->xdpy, INAME);
|
||||||
|
#elif HAVE_XQUERY_INPUT_VERSION
|
||||||
|
ext = XQueryInputVersion (backend_singleton->xdpy, XI_2_Major, XI_2_Minor);
|
||||||
|
#else
|
||||||
|
g_critical ("XInput does not have XGetExtensionVersion nor "
|
||||||
|
"XQueryInputVersion");
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!ext || (ext == (XExtensionVersion*) NoSuchExtension))
|
if (!ext || (ext == (XExtensionVersion*) NoSuchExtension))
|
||||||
{
|
{
|
||||||
@ -879,7 +895,7 @@ clutter_x11_get_input_devices (void)
|
|||||||
{
|
{
|
||||||
ClutterMainContext *context;
|
ClutterMainContext *context;
|
||||||
|
|
||||||
#ifdef USE_XINPUT
|
#ifdef HAVE_XINPUT
|
||||||
if (!backend_singleton)
|
if (!backend_singleton)
|
||||||
{
|
{
|
||||||
g_critical ("X11 backend has not been initialised");
|
g_critical ("X11 backend has not been initialised");
|
||||||
@ -889,9 +905,9 @@ clutter_x11_get_input_devices (void)
|
|||||||
context = clutter_context_get_default ();
|
context = clutter_context_get_default ();
|
||||||
|
|
||||||
return context->input_devices;
|
return context->input_devices;
|
||||||
#else
|
#else /* !HAVE_XINPUT */
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif /* HAVE_XINPUT */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -923,7 +939,7 @@ clutter_x11_get_input_device_type (ClutterX11XInputDevice *device)
|
|||||||
gboolean
|
gboolean
|
||||||
clutter_x11_has_xinput (void)
|
clutter_x11_has_xinput (void)
|
||||||
{
|
{
|
||||||
#ifdef USE_XINPUT
|
#ifdef HAVE_XINPUT
|
||||||
if (!backend_singleton)
|
if (!backend_singleton)
|
||||||
{
|
{
|
||||||
g_critical ("X11 backend has not been initialised");
|
g_critical ("X11 backend has not been initialised");
|
||||||
|
@ -28,10 +28,6 @@
|
|||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
#ifdef USE_XINPUT
|
|
||||||
#include <X11/extensions/XInput.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "clutter-x11.h"
|
#include "clutter-x11.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
@ -79,10 +75,8 @@ struct _ClutterBackendX11
|
|||||||
Atom atom_NET_WM_NAME;
|
Atom atom_NET_WM_NAME;
|
||||||
Atom atom_UTF8_STRING;
|
Atom atom_UTF8_STRING;
|
||||||
|
|
||||||
#ifdef USE_XINPUT
|
int event_types[CLUTTER_X11_XINPUT_LAST_EVENT];
|
||||||
int event_types[CLUTTER_X11_XINPUT_LAST_EVENT];
|
gboolean have_xinput;
|
||||||
gboolean have_xinput;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Time last_event_time;
|
Time last_event_time;
|
||||||
};
|
};
|
||||||
@ -127,7 +121,6 @@ XVisualInfo *
|
|||||||
clutter_backend_x11_get_visual_info (ClutterBackendX11 *backend_x11,
|
clutter_backend_x11_get_visual_info (ClutterBackendX11 *backend_x11,
|
||||||
gboolean for_offscreen);
|
gboolean for_offscreen);
|
||||||
|
|
||||||
#ifdef USE_XINPUT
|
|
||||||
void
|
void
|
||||||
_clutter_x11_register_xinput (void);
|
_clutter_x11_register_xinput (void);
|
||||||
|
|
||||||
@ -136,7 +129,6 @@ _clutter_x11_unregister_xinput (void);
|
|||||||
|
|
||||||
ClutterX11XInputDevice *
|
ClutterX11XInputDevice *
|
||||||
_clutter_x11_get_device_for_xid (XID id);
|
_clutter_x11_get_device_for_xid (XID id);
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_clutter_x11_select_events (Window xwin);
|
_clutter_x11_select_events (Window xwin);
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
|
|
||||||
#ifdef USE_XINPUT
|
#ifdef HAVE_XINPUT
|
||||||
#include <X11/extensions/XInput.h>
|
#include <X11/extensions/XInput.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ set_user_time (ClutterBackendX11 *backend_x11,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* See XInput keyboard comment below USE_XINPUT */
|
#if 0 /* See XInput keyboard comment below HAVE_XINPUT */
|
||||||
static void
|
static void
|
||||||
convert_xdevicekey_to_xkey (XDeviceKeyEvent *xkev, XEvent *xevent)
|
convert_xdevicekey_to_xkey (XDeviceKeyEvent *xkev, XEvent *xevent)
|
||||||
{
|
{
|
||||||
@ -282,7 +282,7 @@ convert_xdevicekey_to_xkey (XDeviceKeyEvent *xkev, XEvent *xevent)
|
|||||||
xevent->xkey.keycode = xkev->keycode;
|
xevent->xkey.keycode = xkev->keycode;
|
||||||
xevent->xkey.same_screen = xkev->same_screen;
|
xevent->xkey.same_screen = xkev->same_screen;
|
||||||
}
|
}
|
||||||
#endif /* USE_XINPUT */
|
#endif /* HAVE_XINPUT */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
translate_key_event (ClutterBackend *backend,
|
translate_key_event (ClutterBackend *backend,
|
||||||
@ -738,7 +738,7 @@ event_translate (ClutterBackend *backend,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* XInput fun.. Needs clean up. */
|
{ /* XInput fun.. Needs clean up. */
|
||||||
#ifdef USE_XINPUT
|
#ifdef HAVE_XINPUT
|
||||||
int *ev_types = backend_x11->event_types;
|
int *ev_types = backend_x11->event_types;
|
||||||
|
|
||||||
CLUTTER_NOTE (EVENT, "XInput event type: %d", xevent->type);
|
CLUTTER_NOTE (EVENT, "XInput event type: %d", xevent->type);
|
||||||
|
@ -62,10 +62,8 @@ struct _ClutterStageX11
|
|||||||
ClutterBackendX11 *backend;
|
ClutterBackendX11 *backend;
|
||||||
ClutterStageState state;
|
ClutterStageState state;
|
||||||
|
|
||||||
#ifdef USE_XINPUT
|
int event_types[CLUTTER_X11_XINPUT_LAST_EVENT];
|
||||||
int event_types[CLUTTER_X11_XINPUT_LAST_EVENT];
|
GList *devices;
|
||||||
GList *devices;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ClutterStage *wrapper;
|
ClutterStage *wrapper;
|
||||||
};
|
};
|
||||||
|
33
configure.ac
33
configure.ac
@ -491,7 +491,38 @@ AS_IF([test "x$clutterbackend" = "xglx" || test "x$clutterbackend" = "xeglx"],
|
|||||||
|
|
||||||
[yes],
|
[yes],
|
||||||
[
|
[
|
||||||
AC_DEFINE(USE_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])
|
||||||
|
])
|
||||||
|
|
||||||
|
AS_IF([test "x$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"
|
||||||
|
Loading…
Reference in New Issue
Block a user