diff --git a/ChangeLog b/ChangeLog index 5c39a409e..fe7f01af4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,19 @@ +2008-07-01 Matthew Allum + + * clutter/glx/clutter-stage-glx.c: + * clutter/x11/clutter-backend-x11.c: + * clutter/x11/clutter-backend-x11.h: + * clutter/x11/clutter-event-x11.c: + * clutter/x11/clutter-x11.h: + * tests/test-devices.c: + Disable use of XInput and add an explicit clutter_x11_enable_xinput + to enable it. + Also fix up the x11 pre-init calls to not need g_type_init. + 2008-07-01 Øyvind Kolås - Bug 1013 - Per device grabs are not obeyed in pointer device propagation. + Bug 1013 - Per device grabs are not obeyed in pointer device + propagation. * clutter/clutter-event.c: (clutter_event_get_device_id): swap arguments of g_return_val_if_fail around. diff --git a/clutter/glx/clutter-stage-glx.c b/clutter/glx/clutter-stage-glx.c index 12c396530..8c5af3fb3 100644 --- a/clutter/glx/clutter-stage-glx.c +++ b/clutter/glx/clutter-stage-glx.c @@ -180,7 +180,7 @@ clutter_stage_glx_realize (ClutterActor *actor) mask, &xattr); } - if (!backend_x11->no_xevent_retrieval) + if (clutter_x11_has_event_retrieval()) { if (clutter_x11_has_xinput()) { diff --git a/clutter/x11/clutter-backend-x11.c b/clutter/x11/clutter-backend-x11.c index b2a36646a..b8362f91d 100644 --- a/clutter/x11/clutter-backend-x11.c +++ b/clutter/x11/clutter-backend-x11.c @@ -86,6 +86,11 @@ static const guint n_atom_names = G_N_ELEMENTS (atom_names); /* singleton object */ static ClutterBackendX11 *backend_singleton = NULL; +/* various flags corresponding to pre init setup calls */ +static gboolean _no_xevent_retrieval = FALSE; +static gboolean _enable_xinput = FALSE; +static Display *_foreign_dpy = NULL; + /* options */ static gchar *clutter_display_name = NULL; static gint clutter_screen = 0; @@ -120,6 +125,8 @@ clutter_backend_x11_post_parse (ClutterBackend *backend, { ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend); + if (_foreign_dpy) + backend_x11->xdpy = _foreign_dpy; /* * Only open connection if not already set by prior call to * clutter_x11_set_display() @@ -210,7 +217,8 @@ clutter_backend_x11_init_events (ClutterBackend *backend) { CLUTTER_NOTE (EVENT, "initialising the event loop"); - _clutter_backend_x11_events_init (backend); + if (!_no_xevent_retrieval) + _clutter_backend_x11_events_init (backend); } static const GOptionEntry entries[] = @@ -411,31 +419,77 @@ clutter_x11_get_default_display (void) void clutter_x11_set_display (Display *xdpy) { - if (!xdpy) - return; - - if (!backend_singleton) - { - /* - * This creates the singleton objects - */ - clutter_context_get_default (); - - if (!backend_singleton) - { - g_critical ("X11 backend could not be initialised."); - return; - } - } - - if (backend_singleton->xdpy) + if (backend_singleton && backend_singleton->xdpy) { g_critical ("Display connection already exists. You can only call " "clutter_x11_set_display() once before clutter_init()\n"); return; } - backend_singleton->xdpy = xdpy; + _foreign_dpy= xdpy; +} + +/** + * clutter_x11_enable_xinput: + * + * Enables the use of the XInput extension if present on connected + * XServer and support built into Clutter. XInput allows for multiple + * pointing devices to be used. This must be called before + * clutter_init(). + * + * You should use #clutter_x11_has_xinput to see if support was enabled. + * + * Since: 0.8 + */ +void +clutter_x11_enable_xinput () +{ + if (backend_singleton != NULL) + { + g_warning ("clutter_x11_enable_xinput should " + "be called before clutter_init"); + return; + } + + _enable_xinput = TRUE; +} + +/** + * clutter_x11_disable_event_retrieval + * + * Disables retrieval of X events in the main loop. Use to create event-less + * canvas or in conjunction with clutter_x11_handle_event. + * + * This function can only be called before calling clutter_init(). + * + * Since: 0.8 + */ +void +clutter_x11_disable_event_retrieval (void) +{ + if (backend_singleton != NULL) + { + g_warning ("clutter_x11_disable_event_retrieval should " + "be called before clutter_init"); + return; + } + + _no_xevent_retrieval = TRUE; +} + +/** + * clutter_x11_has_event_retrieval + * + * Queries the X11 backend to check if event collection has been disabled. + * + * Return value: TRUE if event retrival has been disabled. FALSE otherwise. + * + * Since: 0.8 + */ +gboolean +clutter_x11_has_event_retrieval (void) +{ + return !_no_xevent_retrieval; } /** @@ -581,6 +635,12 @@ _clutter_x11_register_xinput () return; } + if (!_enable_xinput) + { + CLUTTER_NOTE (BACKEND, "Not enabling XInput"); + return; + } + context = clutter_context_get_default (); backend_singleton->have_xinput = TRUE; diff --git a/clutter/x11/clutter-backend-x11.h b/clutter/x11/clutter-backend-x11.h index 2642c010b..d14cccfc8 100644 --- a/clutter/x11/clutter-backend-x11.h +++ b/clutter/x11/clutter-backend-x11.h @@ -67,8 +67,6 @@ struct _ClutterBackendX11 GSource *event_source; GSList *event_filters; - gboolean no_xevent_retrieval; - /* props */ Atom atom_NET_WM_PING; Atom atom_NET_WM_STATE; diff --git a/clutter/x11/clutter-event-x11.c b/clutter/x11/clutter-event-x11.c index 793edf879..1a00c3824 100644 --- a/clutter/x11/clutter-event-x11.c +++ b/clutter/x11/clutter-event-x11.c @@ -168,9 +168,6 @@ _clutter_backend_x11_events_init (ClutterBackend *backend) ClutterEventSource *event_source; int connection_number; - if (backend_x11->no_xevent_retrieval) - return; - connection_number = ConnectionNumber (backend_x11->xdpy); CLUTTER_NOTE (EVENT, "Connection number: %d", connection_number); @@ -221,7 +218,7 @@ set_user_time (ClutterBackendX11 *backend_x11, } } -#ifdef USE_XINPUT +#if 0 /* See XInput keyboard comment below USE_XINPUT */ static void convert_xdevicekey_to_xkey (XDeviceKeyEvent *xkev, XEvent *xevent) { @@ -889,29 +886,6 @@ clutter_x11_handle_event (XEvent *xevent) return CLUTTER_X11_FILTER_CONTINUE; } -/** - * clutter_x11_disable_event_retrieval - * - * Disables retrieval of X events in the main loop. Use to create event-less - * canvas or in conjunction with clutter_x11_handle_event. - * - * This function can only be called before calling clutter_init(). - * - * Since: 0.8 - */ -void -clutter_x11_disable_event_retrieval (void) -{ - ClutterBackendX11 *backend; - ClutterMainContext *clutter_context; - - clutter_context = clutter_context_get_default (); - backend = CLUTTER_BACKEND_X11 (clutter_context->backend); - - backend->no_xevent_retrieval = TRUE; -} - - static gboolean clutter_event_prepare (GSource *source, gint *timeout) diff --git a/clutter/x11/clutter-x11.h b/clutter/x11/clutter-x11.h index 1cdb3188a..b1c151604 100644 --- a/clutter/x11/clutter-x11.h +++ b/clutter/x11/clutter-x11.h @@ -120,6 +120,8 @@ ClutterX11FilterReturn clutter_x11_handle_event (XEvent *xevent); void clutter_x11_disable_event_retrieval (void); +gboolean clutter_x11_has_event_retrieval (void); + ClutterStage *clutter_x11_get_stage_from_window (Window win); GSList* @@ -128,6 +130,9 @@ clutter_x11_get_input_devices (void); ClutterX11InputDeviceType clutter_x11_get_input_device_type (ClutterX11XInputDevice *device); +void +clutter_x11_enable_xinput (); + gboolean clutter_x11_has_xinput (void); diff --git a/tests/test-devices.c b/tests/test-devices.c index a691247af..78f384076 100644 --- a/tests/test-devices.c +++ b/tests/test-devices.c @@ -32,6 +32,7 @@ main (int argc, char **argv) TestDevicesApp *app = NULL; ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; + clutter_x11_enable_xinput (); clutter_init (&argc, &argv); app = g_new0 (TestDevicesApp, 1); @@ -49,6 +50,9 @@ main (int argc, char **argv) stage_devices = clutter_x11_get_input_devices (); + if (stage_devices == NULL) + g_error ("No extended input devices found."); + do { if (stage_devices)