1
0
Fork 0

clutter: Unconditionalize a few X11 extensions

We now require xcomposite, xkb, xi 2.2, at least at compile time.
This commit is contained in:
Jonas Ådahl 2018-05-24 17:34:48 +02:00
parent 3e03d1e38e
commit 0067f78155
6 changed files with 56 additions and 181 deletions

View file

@ -42,13 +42,8 @@
#include "xsettings/xsettings-common.h"
#if HAVE_XCOMPOSITE
#include <X11/extensions/Xcomposite.h>
#endif
#if HAVE_XINPUT_2
#include <X11/extensions/XInput2.h>
#endif
#include <cogl/cogl.h>
#include <cogl/cogl-xlib.h>
@ -241,7 +236,6 @@ clutter_backend_x11_create_device_manager (ClutterBackendX11 *backend_x11)
ClutterEventTranslator *translator;
ClutterBackend *backend;
#ifdef HAVE_XINPUT_2
if (clutter_enable_xinput)
{
int event_base, first_event, first_error;
@ -270,7 +264,6 @@ clutter_backend_x11_create_device_manager (ClutterBackendX11 *backend_x11)
}
if (backend_x11->device_manager == NULL)
#endif /* HAVE_XINPUT_2 */
{
CLUTTER_NOTE (BACKEND, "Creating Core device manager");
backend_x11->has_xinput = FALSE;
@ -517,14 +510,12 @@ static const GOptionEntry entries[] =
G_OPTION_ARG_NONE, &clutter_synchronise,
N_("Make X calls synchronous"), NULL
},
#ifdef HAVE_XINPUT_2
{
"disable-xinput", 0,
G_OPTION_FLAG_REVERSE,
G_OPTION_ARG_NONE, &clutter_enable_xinput,
N_("Disable XInput support"), NULL
},
#endif /* HAVE_XINPUT_2 */
{ NULL }
};
@ -1218,7 +1209,6 @@ clutter_x11_get_input_devices (void)
gboolean
clutter_x11_has_xinput (void)
{
#ifdef HAVE_XINPUT_2
ClutterBackend *backend = clutter_get_default_backend ();
if (backend == NULL)
@ -1234,9 +1224,6 @@ clutter_x11_has_xinput (void)
}
return CLUTTER_BACKEND_X11 (backend)->has_xinput;
#else
return FALSE;
#endif
}
/**
@ -1250,7 +1237,6 @@ clutter_x11_has_xinput (void)
gboolean
clutter_x11_has_composite_extension (void)
{
#if HAVE_XCOMPOSITE
static gboolean have_composite = FALSE, done_check = FALSE;
int error = 0, event = 0;
Display *dpy;
@ -1281,9 +1267,6 @@ clutter_x11_has_composite_extension (void)
done_check = TRUE;
return have_composite;
#else
return FALSE;
#endif /* HAVE_XCOMPOSITE */
}
/**

View file

@ -199,7 +199,6 @@ translate_device_classes (Display *xdisplay,
(XIValuatorClassInfo *) class_info);
break;
#ifdef HAVE_XINPUT_2_2
case XIScrollClass:
{
XIScrollClassInfo *scroll_info = (XIScrollClassInfo *) class_info;
@ -223,7 +222,6 @@ translate_device_classes (Display *xdisplay,
scroll_info->increment);
}
break;
#endif /* HAVE_XINPUT_2_2 */
default:
break;
@ -237,7 +235,6 @@ is_touch_device (XIAnyClassInfo **classes,
ClutterInputDeviceType *device_type,
guint *n_touch_points)
{
#ifdef HAVE_XINPUT_2_2
guint i;
for (i = 0; i < n_classes; i++)
@ -261,7 +258,6 @@ is_touch_device (XIAnyClassInfo **classes,
return TRUE;
}
}
#endif
return FALSE;
}
@ -771,11 +767,9 @@ get_event_stage (ClutterEventTranslator *translator,
case XI_ButtonPress:
case XI_ButtonRelease:
case XI_Motion:
#ifdef HAVE_XINPUT_2_2
case XI_TouchBegin:
case XI_TouchUpdate:
case XI_TouchEnd:
#endif /* HAVE_XINPUT_2_2 */
{
XIDeviceEvent *xev = (XIDeviceEvent *) xi_event;
@ -1037,7 +1031,6 @@ clutter_device_manager_xi2_select_stage_events (ClutterDeviceManager *manager,
XISetMask (mask, XI_Enter);
XISetMask (mask, XI_Leave);
#ifdef HAVE_XINPUT_2_2
/* enable touch event support if we're running on XInput 2.2 */
if (backend_x11->xi_minor >= 2)
{
@ -1045,7 +1038,6 @@ clutter_device_manager_xi2_select_stage_events (ClutterDeviceManager *manager,
XISetMask (mask, XI_TouchUpdate);
XISetMask (mask, XI_TouchEnd);
}
#endif /* HAVE_XINPUT_2_2 */
xi_event_mask.deviceid = XIAllMasterDevices;
xi_event_mask.mask = mask;
@ -1472,11 +1464,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
"invalid",
event->scroll.x,
event->scroll.y,
#ifdef HAVE_XINPUT_2_2
(xev->flags & XIPointerEmulated) ? "yes" : "no"
#else
"no"
#endif
);
break;
@ -1522,11 +1510,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
event->button.x,
event->button.y,
event->button.axes != NULL ? "yes" : "no",
#ifdef HAVE_XINPUT_2_2
(xev->flags & XIPointerEmulated) ? "yes" : "no"
#else
"no"
#endif
);
break;
}
@ -1534,10 +1518,8 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
if (source_device != NULL && device->stage != NULL)
_clutter_input_device_set_stage (source_device, device->stage);
#ifdef HAVE_XINPUT_2_2
if (xev->flags & XIPointerEmulated)
_clutter_event_set_pointer_emulated (event, TRUE);
#endif /* HAVE_XINPUT_2_2 */
if (xi_event->evtype == XI_ButtonPress)
_clutter_stage_x11_set_user_time (stage_x11, event->button.time);
@ -1627,10 +1609,8 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
if (source_device != NULL && device->stage != NULL)
_clutter_input_device_set_stage (source_device, device->stage);
#ifdef HAVE_XINPUT_2_2
if (xev->flags & XIPointerEmulated)
_clutter_event_set_pointer_emulated (event, TRUE);
#endif /* HAVE_XINPUT_2_2 */
CLUTTER_NOTE (EVENT, "motion: win:0x%x device:%d '%s' (x:%.2f, y:%.2f, axes:%s)",
(unsigned int) stage_x11->xwin,
@ -1644,7 +1624,6 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
}
break;
#ifdef HAVE_XINPUT_2_2
case XI_TouchBegin:
{
XIDeviceEvent *xev = (XIDeviceEvent *) xi_event;
@ -1756,7 +1735,6 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
retval = CLUTTER_TRANSLATE_QUEUE;
}
break;
#endif /* HAVE_XINPUT_2_2 */
case XI_Enter:
case XI_Leave:

View file

@ -31,10 +31,7 @@
#include "clutter-private.h"
#include <X11/Xatom.h>
#ifdef HAVE_XKB
#include <X11/XKBlib.h>
#endif
typedef struct _ClutterKeymapX11Class ClutterKeymapX11Class;
typedef struct _DirectionCacheEntry DirectionCacheEntry;
@ -71,7 +68,6 @@ struct _ClutterKeymapX11
PangoDirection current_direction;
#ifdef HAVE_XKB
XkbDescPtr xkb_desc;
int xkb_event_base;
guint xkb_map_serial;
@ -79,7 +75,6 @@ struct _ClutterKeymapX11
guint current_cache_serial;
DirectionCacheEntry group_direction_cache[4];
int current_group;
#endif
guint caps_lock_state : 1;
guint num_lock_state : 1;
@ -110,8 +105,6 @@ G_DEFINE_TYPE_WITH_CODE (ClutterKeymapX11, clutter_keymap_x11, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_EVENT_TRANSLATOR,
clutter_event_translator_iface_init));
#ifdef HAVE_XKB
/* code adapted from gdk/x11/gdkkeys-x11.c - update_modmap */
static void
update_modmap (Display *display,
@ -214,9 +207,7 @@ get_xkb (ClutterKeymapX11 *keymap_x11)
return keymap_x11->xkb_desc;
}
#endif /* HAVE_XKB */
#ifdef HAVE_XKB
static void
update_locked_mods (ClutterKeymapX11 *keymap_x11,
gint locked_mods)
@ -242,9 +233,7 @@ update_locked_mods (ClutterKeymapX11 *keymap_x11,
g_signal_emit_by_name (keymap_x11->backend, "key-lock-changed");
#endif
}
#endif /* HAVE_XKB */
#ifdef HAVE_XKB
/* the code to retrieve the keymap direction and cache it
* is taken from GDK:
* gdk/x11/gdkkeys-x11.c
@ -345,13 +334,11 @@ get_direction_from_cache (ClutterKeymapX11 *keymap_x11,
return direction;
}
#endif /* HAVE_XKB */
static void
update_direction (ClutterKeymapX11 *keymap_x11,
int group)
{
#ifdef HAVE_XKB
XkbDescPtr xkb = get_xkb (keymap_x11);
Atom group_atom;
@ -363,7 +350,6 @@ update_direction (ClutterKeymapX11 *keymap_x11,
keymap_x11->current_group_atom = group_atom;
keymap_x11->has_direction = TRUE;
}
#endif /* HAVE_XKB */
}
static void
@ -371,15 +357,12 @@ clutter_keymap_x11_constructed (GObject *gobject)
{
ClutterKeymapX11 *keymap_x11 = CLUTTER_KEYMAP_X11 (gobject);
ClutterBackendX11 *backend_x11;
gint xkb_major = XkbMajorVersion;
gint xkb_minor = XkbMinorVersion;
g_assert (keymap_x11->backend != NULL);
backend_x11 = CLUTTER_BACKEND_X11 (keymap_x11->backend);
#ifdef HAVE_XKB
{
gint xkb_major = XkbMajorVersion;
gint xkb_minor = XkbMinorVersion;
if (XkbLibraryVersion (&xkb_major, &xkb_minor))
{
xkb_major = XkbMajorVersion;
@ -418,8 +401,6 @@ clutter_keymap_x11_constructed (GObject *gobject)
}
}
}
#endif /* HAVE_XKB */
}
static void
clutter_keymap_x11_set_property (GObject *gobject,
@ -450,12 +431,10 @@ clutter_keymap_x11_finalize (GObject *gobject)
keymap = CLUTTER_KEYMAP_X11 (gobject);
translator = CLUTTER_EVENT_TRANSLATOR (keymap);
#ifdef HAVE_XKB
_clutter_backend_remove_event_translator (keymap->backend, translator);
if (keymap->xkb_desc != NULL)
XkbFreeKeyboard (keymap->xkb_desc, XkbAllComponentsMask, True);
#endif
G_OBJECT_CLASS (clutter_keymap_x11_parent_class)->finalize (gobject);
}
@ -503,7 +482,6 @@ clutter_keymap_x11_translate_event (ClutterEventTranslator *translator,
retval = CLUTTER_TRANSLATE_CONTINUE;
#ifdef HAVE_XKB
if (xevent->type == keymap_x11->xkb_event_base)
{
XkbEvent *xkb_event = (XkbEvent *) xevent;
@ -530,7 +508,6 @@ clutter_keymap_x11_translate_event (ClutterEventTranslator *translator,
break;
}
}
#endif /* HAVE_XKB */
return retval;
}
@ -545,11 +522,7 @@ gint
_clutter_keymap_x11_get_key_group (ClutterKeymapX11 *keymap,
ClutterModifierType state)
{
#ifdef HAVE_XKB
return XkbGroupForCoreState (state);
#else
return 0;
#endif /* HAVE_XKB */
}
gboolean
@ -606,7 +579,6 @@ _clutter_keymap_x11_translate_key_state (ClutterKeymapX11 *keymap,
backend_x11 = CLUTTER_BACKEND_X11 (keymap->backend);
#ifdef HAVE_XKB
if (backend_x11->use_xkb)
{
XkbDescRec *xkb = get_xkb (keymap);
@ -622,7 +594,6 @@ _clutter_keymap_x11_translate_key_state (ClutterKeymapX11 *keymap,
retval = 0;
}
else
#endif /* HAVE_XKB */
retval = translate_keysym (keymap, hardware_keycode);
if (mods_p)
@ -644,7 +615,6 @@ _clutter_keymap_x11_get_is_modifier (ClutterKeymapX11 *keymap,
if (keycode < keymap->min_keycode || keycode > keymap->max_keycode)
return FALSE;
#ifdef HAVE_XKB
if (CLUTTER_BACKEND_X11 (keymap->backend)->use_xkb)
{
XkbDescRec *xkb = get_xkb (keymap);
@ -652,7 +622,6 @@ _clutter_keymap_x11_get_is_modifier (ClutterKeymapX11 *keymap,
if (xkb->map->modmap && xkb->map->modmap[keycode] != 0)
return TRUE;
}
#endif /* HAVE_XKB */
return FALSE;
}
@ -662,7 +631,6 @@ _clutter_keymap_x11_get_direction (ClutterKeymapX11 *keymap)
{
g_return_val_if_fail (CLUTTER_IS_KEYMAP_X11 (keymap), PANGO_DIRECTION_NEUTRAL);
#ifdef HAVE_XKB
if (CLUTTER_BACKEND_X11 (keymap->backend)->use_xkb)
{
if (!keymap->has_direction)
@ -677,7 +645,6 @@ _clutter_keymap_x11_get_direction (ClutterKeymapX11 *keymap)
return keymap->current_direction;
}
else
#endif
return PANGO_DIRECTION_NEUTRAL;
}
@ -687,7 +654,6 @@ clutter_keymap_x11_get_entries_for_keyval (ClutterKeymapX11 *keymap_x11,
ClutterKeymapKey **keys,
gint *n_keys)
{
#ifdef HAVE_XKB
if (CLUTTER_BACKEND_X11 (keymap_x11->backend)->use_xkb)
{
XkbDescRec *xkb = get_xkb (keymap_x11);
@ -760,7 +726,6 @@ clutter_keymap_x11_get_entries_for_keyval (ClutterKeymapX11 *keymap_x11,
return *n_keys > 0;
}
else
#endif
{
return FALSE;
}
@ -771,7 +736,6 @@ clutter_keymap_x11_latch_modifiers (ClutterKeymapX11 *keymap_x11,
uint32_t level,
gboolean enable)
{
#ifdef HAVE_XKB
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (keymap_x11->backend);
uint32_t modifiers[] = {
0,
@ -794,7 +758,6 @@ clutter_keymap_x11_latch_modifiers (ClutterKeymapX11 *keymap_x11,
XkbLatchModifiers (clutter_x11_get_default_display (),
XkbUseCoreKbd, modifiers[level],
value);
#endif
}
static uint32_t

View file

@ -57,10 +57,7 @@
#include <cogl/winsys/cogl-texture-pixmap-x11.h>
#include <X11/extensions/Xdamage.h>
#if HAVE_XCOMPOSITE
#include <X11/extensions/Xcomposite.h>
#endif
enum
{
@ -960,7 +957,6 @@ clutter_x11_texture_pixmap_set_window (ClutterX11TexturePixmap *texture,
if (dpy == NULL)
return;
#if HAVE_XCOMPOSITE
priv = texture->priv;
if (priv->window == window && automatic == priv->window_redirect_automatic)
@ -1024,8 +1020,6 @@ clutter_x11_texture_pixmap_set_window (ClutterX11TexturePixmap *texture,
attr.width, attr.height,
attr.override_redirect);
g_object_unref (texture);
#endif /* HAVE_XCOMPOSITE */
}
static void

View file

@ -283,13 +283,11 @@ AS_IF([test "x$SUPPORT_X11" = "x1"],
[AC_MSG_ERROR([not found])]
)
# XCOMPOSITE (optional)
# XCOMPOSITE (required)
AC_MSG_CHECKING([for XCOMPOSITE extension >= $XCOMPOSITE_REQ_VERSION])
PKG_CHECK_EXISTS([xcomposite >= $XCOMPOSITE_REQ_VERSION], [have_xcomposite=yes], [have_xcomposite=no])
AS_IF([test "x$have_xcomposite" = "xyes"],
[
AC_DEFINE(HAVE_XCOMPOSITE, [1], [Define to 1 if we have the XCOMPOSITE X extension])
X11_LIBS="$X11_LIBS -lXcomposite"
X11_PC_FILES="$X11_PC_FILES xcomposite >= $XCOMPOSITE_REQ_VERSION"
X11_EXTS="$X11_EXTS xcomposite"
@ -333,45 +331,17 @@ AS_IF([test "x$SUPPORT_X11" = "x1"],
CPPFLAGS="$clutter_save_CPPFLAGS"
LIBS="$clutter_save_LIBS"
# XI (optional)
AC_ARG_ENABLE([xinput],
[AS_HELP_STRING([--enable-xinput], [Use the XI X extension])],
[],
[enable_xinput=yes])
AS_IF([test "x$enable_xinput" = "xyes"],
[
PKG_CHECK_EXISTS([xi], [have_xinput=yes], [have_xinput=no])
],
[
have_xinput=no
])
AS_CASE([$have_xinput],
[yes],
[
PKG_CHECK_EXISTS([xi], [have_xinput=yes], AC_MSG_ERROR([XI support not found]))
AC_CHECK_HEADERS([X11/extensions/XInput2.h],
[
have_xinput2=yes
AC_DEFINE([HAVE_XINPUT_2],
[1],
[Define to 1 if XI2 is available])
])
clutter_save_LIBS="$LIBS"
LIBS="$LIBS -lXi"
[],
AC_MSG_ERROR([XI2 not found]))
AC_CHECK_FUNC([XIAllowTouchEvents],
[
AC_CHECK_MEMBER([XIScrollClassInfo.number],
[
have_xinput_2_2=yes
AC_DEFINE([HAVE_XINPUT_2_2], [1], [Define to 1 if XInput 2.2 is available])
],
[have_xinput_2_2=no],
[[#include <X11/extensions/XInput2.h>]])])
[],
AC_MSG_ERROR([XIScrollClasSInfo.number member missing in XI2]),
[[#include <X11/extensions/XInput2.h>]])
])
LIBS="$clutter_save_LIBS"
X11_LIBS="$X11_LIBS $XINPUT_LIBS"
@ -380,14 +350,6 @@ AS_IF([test "x$SUPPORT_X11" = "x1"],
AS_IF([test "x$have_xinput_2_2" = "xyes"],
[X11_EXTS="$X11_EXTS xi2.2"],
[X11_EXTS="$X11_EXTS xi2.0"])
],
[no],
[have_xinput2=no],
[*],
[AC_MSG_ERROR([Invalid argument for --enable-xinput])]
)
# XKB
clutter_save_CPPFLAGS="$CPPFLAGS"
@ -396,14 +358,9 @@ AS_IF([test "x$SUPPORT_X11" = "x1"],
clutter_save_LIBS="$LIBS"
LIBS="$LIBS $X11_LIBS"
have_xkb=no
AC_CHECK_FUNC([XkbQueryExtension],
[
AC_DEFINE(HAVE_XKB, 1, [Define to use XKB extension])
have_xkb=yes
X11_EXTS="$X11_EXTS xkb"
])
[],
[AC_MSG_ERROR([XKB support not found])])
CPPFLAGS="$clutter_save_CPPFLAGS"
LIBS="$clutter_save_LIBS"

View file

@ -21,7 +21,7 @@
#include <clutter/clutter.h>
#if defined CLUTTER_WINDOWING_X11 && HAVE_XINPUT_2_2
#ifdef CLUTTER_WINDOWING_X11
#include <stdio.h>
#include <string.h>
@ -355,12 +355,12 @@ error:
return 0;
}
#endif /* defined CLUTTER_WINDOWING_X11 && HAVE_XINPUT_2_2 */
#endif /* CLUTTER_WINDOWING_X11 */
static void
events_touch (void)
{
#if defined CLUTTER_WINDOWING_X11 && HAVE_XINPUT_2_2
#ifdef CLUTTER_WINDOWING_X11
ClutterActor *stage;
State state;
@ -384,7 +384,7 @@ events_touch (void)
g_print ("end result: %s\n", state.pass ? "pass" : "FAIL");
g_assert (state.pass);
#endif /* defined CLUTTER_WINDOWING_X11 && HAVE_XINPUT_2_2 */
#endif /* CLUTTER_WINDOWING_X11 */
}
CLUTTER_TEST_SUITE (