+2008-07-01 Matthew Allum <mallum@openedhand.com>
+
+ * 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 <pippin@o-hand.com>
- 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.
/* 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;
{
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()
{
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[] =
void
clutter_x11_set_display (Display *xdpy)
{
- if (!xdpy)
- return;
-
- if (!backend_singleton)
+ if (backend_singleton && backend_singleton->xdpy)
{
- /*
- * This creates the singleton objects
- */
- clutter_context_get_default ();
+ g_critical ("Display connection already exists. You can only call "
+ "clutter_x11_set_display() once before clutter_init()\n");
+ return;
+ }
- if (!backend_singleton)
- {
- g_critical ("X11 backend could not be initialised.");
- return;
- }
+ _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;
}
- if (backend_singleton->xdpy)
+ _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_critical ("Display connection already exists. You can only call "
- "clutter_x11_set_display() once before clutter_init()\n");
- return;
+ g_warning ("clutter_x11_disable_event_retrieval should "
+ "be called before clutter_init");
+ return;
}
- backend_singleton->xdpy = xdpy;
+ _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;
}
/**
return;
}
+ if (!_enable_xinput)
+ {
+ CLUTTER_NOTE (BACKEND, "Not enabling XInput");
+ return;
+ }
+
context = clutter_context_get_default ();
backend_singleton->have_xinput = TRUE;
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);
}
}
-#ifdef USE_XINPUT
+#if 0 /* See XInput keyboard comment below USE_XINPUT */
static void
convert_xdevicekey_to_xkey (XDeviceKeyEvent *xkev, 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)