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.
This commit is contained in:
Matthew Allum 2008-07-01 13:41:23 +00:00
parent 6f68ae35b7
commit be160d971a
7 changed files with 105 additions and 51 deletions

View File

@ -1,6 +1,19 @@
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.

View File

@ -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())
{

View File

@ -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,6 +217,7 @@ clutter_backend_x11_init_events (ClutterBackend *backend)
{
CLUTTER_NOTE (EVENT, "initialising the event loop");
if (!_no_xevent_retrieval)
_clutter_backend_x11_events_init (backend);
}
@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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)