backend: Unify the event initialization

Input backends are, in some cases, independent from the windowing system
backends; we can initialize input handling using a model similar to what
we use for windowing backends, including an environment variable and
compile-/run-time checks.

This model allows us to remove the backend-specific init_events(), and
use a generic implementation directly inside the base ClutterBackend
class, thus further reducing the backend-specific code that every
platform has to implement.

This requires some minor surgery to every single backend, to make sure
that the function exposed to initialize the event loop is similar and
performs roughly the same operations.
This commit is contained in:
Emmanuele Bassi 2011-11-03 17:53:54 +00:00
parent 84d208b2c6
commit adb6ffbd0e
14 changed files with 206 additions and 303 deletions

View File

@ -55,6 +55,23 @@
#include <cogl/cogl.h>
#ifdef CLUTTER_INPUT_X11
#include "x11/clutter-backend-x11.h"
#endif
#ifdef CLUTTER_INPUT_WIN32
#include "win32/clutter-backend-win32.h"
#endif
#ifdef CLUTTER_INPUT_OSX
#include "osx/clutter-backend-osx.h"
#endif
#ifdef CLUTTER_INPUT_EVDEV
#include "evdev/clutter-device-manager-evdev.h"
#endif
#ifdef CLUTTER_INPUT_TSLIB
/* XXX - should probably warn, here */
#include "tslib/clutter-event-tslib.h"
#endif
G_DEFINE_ABSTRACT_TYPE (ClutterBackend, clutter_backend, G_TYPE_OBJECT);
#define DEFAULT_FONT_NAME "Sans 10"
@ -243,6 +260,70 @@ clutter_backend_real_redraw (ClutterBackend *backend,
_clutter_stage_window_redraw (impl);
}
static void
clutter_backend_real_init_events (ClutterBackend *backend)
{
const char *input_backend = NULL;
input_backend = g_getenv ("CLUTTER_INPUT_BACKEND");
if (input_backend != NULL)
input_backend = g_intern_string (input_backend);
#ifdef CLUTTER_INPUT_X11
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_X11) &&
(input_backend == NULL || input_backend == I_(CLUTTER_INPUT_X11)))
{
_clutter_backend_x11_events_init (backend);
}
else
#endif
#ifdef CLUTTER_INPUT_OSX
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_OSX) &&
(input_backend == NULL || input_backend == I_(CLUTTER_INPUT_OSX)))
{
_clutter_backend_osx_events_init (backend);
}
#endif
#ifdef CLUTTER_INPUT_WIN32
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_WIN32) &&
(input_backend == NULL || input_backend == I_(CLUTTER_INPUT_WIN32)))
{
_clutter_backend_win32_events_init (backend);
}
else
#endif
#ifdef CLUTTER_INPUT_GDK
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_GDK) &&
(input_backend == NULL || input_backend == I_(CLUTTER_INPUT_GDK)))
{
_clutter_backend_gdk_events_init (backend);
}
else
#endif
#ifdef CLUTTER_INPUT_EVDEV
/* Evdev can be used regardless of the windowing system */
if (input_backend != NULL &&
strcmp (input_backend, CLUTTER_INPUT_EVDEV) == 0)
{
_clutter_events_evdev_init (backend);
}
else
#endif
#ifdef CLUTTER_INPUT_TSLIB
/* Tslib can be used regardless of the windowing system */
if (input_backend != NULL &&
strcmp (input_backend, CLUTTER_INPUT_TSLIB) == 0)
{
_clutter_events_tslib_init (backend);
}
else
#endif
if (input_backend != NULL)
g_error ("Unrecognized input backend '%s'", input_backend);
else
g_error ("Unknown input backend");
}
static gboolean
clutter_backend_real_translate_event (ClutterBackend *backend,
gpointer native,
@ -339,6 +420,7 @@ clutter_backend_class_init (ClutterBackendClass *klass)
klass->resolution_changed = clutter_backend_real_resolution_changed;
klass->font_changed = clutter_backend_real_font_changed;
klass->init_events = clutter_backend_real_init_events;
klass->translate_event = clutter_backend_real_translate_event;
klass->ensure_context = clutter_backend_real_ensure_context;
klass->redraw = clutter_backend_real_redraw;
@ -591,8 +673,7 @@ _clutter_backend_init_events (ClutterBackend *backend)
g_assert (CLUTTER_IS_BACKEND (backend));
klass = CLUTTER_BACKEND_GET_CLASS (backend);
if (klass->init_events)
klass->init_events (backend);
klass->init_events (backend);
}
gfloat

View File

@ -88,31 +88,6 @@ clutter_backend_egl_native_get_device_manager (ClutterBackend *backend)
return backend_egl_native->device_manager;
}
static void
clutter_backend_egl_native_init_events (ClutterBackend *backend)
{
const char *input_backend = NULL;
input_backend = g_getenv ("CLUTTER_INPUT_BACKEND");
#ifdef HAVE_EVDEV
if (input_backend != NULL &&
strcmp (input_backend, CLUTTER_EVDEV_INPUT_BACKEND) == 0)
_clutter_events_evdev_init (CLUTTER_BACKEND (backend));
else
#endif
#ifdef HAVE_TSLIB
if (input_backend != NULL &&
strcmp (input_backend, CLUTTER_TSLIB_INPUT_BACKEND) == 0)
_clutter_events_tslib_init (CLUTTER_BACKEND (backend));
else
#endif
if (input_backend != NULL)
g_error ("Unrecognized input backend '%s'", input_backend);
else
g_error ("Unknown input backend");
}
static void
clutter_backend_egl_native_dispose (GObject *gobject)
{
@ -249,7 +224,6 @@ clutter_backend_egl_native_class_init (ClutterBackendEglNativeClass *klass)
gobject_class->dispose = clutter_backend_egl_native_dispose;
backend_class->get_device_manager = clutter_backend_egl_native_get_device_manager;
backend_class->init_events = clutter_backend_egl_native_init_events;
backend_class->create_stage = clutter_backend_egl_native_create_stage;
backend_class->create_context = clutter_backend_egl_native_create_context;
}

View File

@ -182,14 +182,20 @@ _clutter_backend_gdk_post_parse (ClutterBackend *backend,
error);
}
static void
clutter_backend_gdk_init_events (ClutterBackend *backend)
gdk_event_handler (GdkEvent *event,
gpointer user_data)
{
clutter_gdk_handle_event (event);
}
void
_clutter_backend_gdk_events_init (ClutterBackend *backend)
{
CLUTTER_NOTE (EVENT, "initialising the event loop");
if (!disable_event_retrieval)
_clutter_backend_gdk_events_init (backend);
gdk_event_handler_set (gdk_event_handler, NULL, NULL);
}
static void
@ -206,17 +212,6 @@ clutter_backend_gdk_finalize (GObject *gobject)
static void
clutter_backend_gdk_dispose (GObject *gobject)
{
ClutterBackendGdk *backend_gdk = CLUTTER_BACKEND_GDK (gobject);
ClutterStageManager *stage_manager;
CLUTTER_NOTE (BACKEND, "Disposing the of stages");
stage_manager = clutter_stage_manager_get_default ();
g_object_unref (stage_manager);
CLUTTER_NOTE (BACKEND, "Removing the event source");
_clutter_backend_gdk_events_uninit (CLUTTER_BACKEND (backend_gdk));
G_OBJECT_CLASS (clutter_backend_gdk_parent_class)->dispose (gobject);
}
@ -384,7 +379,6 @@ clutter_backend_gdk_class_init (ClutterBackendGdkClass *klass)
gobject_class->finalize = clutter_backend_gdk_finalize;
backend_class->post_parse = _clutter_backend_gdk_post_parse;
backend_class->init_events = clutter_backend_gdk_init_events;
backend_class->get_features = clutter_backend_gdk_get_features;
backend_class->get_device_manager = clutter_backend_gdk_get_device_manager;
backend_class->copy_event_data = clutter_backend_gdk_copy_event_data;

View File

@ -64,9 +64,9 @@ struct _ClutterBackendGdkClass
GType _clutter_backend_gdk_get_type (void) G_GNUC_CONST;
void _clutter_backend_gdk_events_init (ClutterBackend *backend);
void _clutter_backend_gdk_events_uninit (ClutterBackend *backend);
void _clutter_backend_gdk_update_setting (ClutterBackendGdk *backend, const gchar *name);
void _clutter_backend_gdk_update_setting (ClutterBackendGdk *backend,
const gchar *name);
G_END_DECLS

View File

@ -43,27 +43,6 @@
#include <glib.h>
static void
gdk_event_handler (GdkEvent *event,
gpointer user_data)
{
clutter_gdk_handle_event (event);
}
void
_clutter_backend_gdk_events_init (ClutterBackend *backend)
{
gdk_event_handler_set (gdk_event_handler, NULL, NULL);
CLUTTER_NOTE (EVENT, "GDK event handler set");
}
void
_clutter_backend_gdk_events_uninit (ClutterBackend *backend)
{
gdk_event_handler_set (NULL, NULL, NULL);
}
/**
* clutter_gdk_handle_event:
* @event: a #GdkEvent

View File

@ -28,6 +28,7 @@
#include "clutter-device-manager-osx.h"
#include "clutter-shader.h"
#include "clutter-stage-osx.h"
#include "clutter-event-loop-osx.h"
#include "clutter-debug.h"
#include "clutter-private.h"
@ -37,6 +38,8 @@
#import <AppKit/AppKit.h>
#define clutter_backend_osx_get_type _clutter_backend_osx_get_type
G_DEFINE_TYPE (ClutterBackendOSX, clutter_backend_osx, CLUTTER_TYPE_BACKEND)
/*************************************************************************/
@ -112,8 +115,8 @@ clutter_backend_osx_get_device_manager (ClutterBackend *backend)
return backend_osx->device_manager;
}
static void
clutter_backend_osx_init_events (ClutterBackend *backend)
void
_clutter_backend_osx_events_init (ClutterBackend *backend)
{
ClutterBackendOSX *backend_osx = CLUTTER_BACKEND_OSX (backend);
@ -123,7 +126,8 @@ clutter_backend_osx_init_events (ClutterBackend *backend)
CLUTTER_NOTE (BACKEND, "init_events");
clutter_backend_osx_create_device_manager (backend_osx);
_clutter_events_osx_init ();
_clutter_osx_event_loop_init ();
}
static gboolean
@ -250,6 +254,5 @@ clutter_backend_osx_class_init (ClutterBackendOSXClass *klass)
backend_class->create_stage = clutter_backend_osx_create_stage;
backend_class->create_context = clutter_backend_osx_create_context;
backend_class->ensure_context = clutter_backend_osx_ensure_context;
backend_class->init_events = clutter_backend_osx_init_events;
backend_class->get_device_manager = clutter_backend_osx_get_device_manager;
}

View File

@ -30,7 +30,7 @@
G_BEGIN_DECLS
#define CLUTTER_TYPE_BACKEND_OSX (clutter_backend_osx_get_type())
#define CLUTTER_TYPE_BACKEND_OSX (_clutter_backend_osx_get_type())
#define CLUTTER_BACKEND_OSX(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),CLUTTER_TYPE_BACKEND_OSX,ClutterBackendOSX))
#define CLUTTER_BACKEND_OSX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),CLUTTER_TYPE_BACKEND_OSX,ClutterBackend))
#define CLUTTER_IS_BACKEND_OSX(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),CLUTTER_TYPE_BACKEND_OSX))
@ -54,7 +54,9 @@ struct _ClutterBackendOSXClass
ClutterBackendClass parent_class;
};
GType clutter_backend_osx_get_type (void) G_GNUC_CONST;
GType _clutter_backend_osx_get_type (void) G_GNUC_CONST;
void _clutter_backend_osx_events_init (ClutterBackend *backend);
G_END_DECLS

View File

@ -38,8 +38,6 @@
#include "clutter-private.h"
#include "clutter-stage-private.h"
#include "clutter-event-loop-osx.h"
#define WHEEL_DELTA 1
/*************************************************************************/
@ -491,15 +489,3 @@ _clutter_event_osx_put (NSEvent *nsevent,
else
clutter_event_free (event);
}
void
_clutter_events_osx_init (void)
{
_clutter_osx_event_loop_init ();
}
void
_clutter_events_osx_uninit (void)
{
g_assert_not_reached ();
}

View File

@ -499,11 +499,6 @@ clutter_backend_wayland_redraw (ClutterBackend *backend,
_clutter_stage_wayland_redraw (CLUTTER_STAGE_WAYLAND (impl), stage);
}
static void
clutter_backend_wayland_init_events (ClutterBackend *backend)
{
}
static void
clutter_backend_wayland_finalize (GObject *gobject)
{
@ -628,7 +623,6 @@ _clutter_backend_wayland_class_init (ClutterBackendWaylandClass *klass)
backend_class->pre_parse = clutter_backend_wayland_pre_parse;
backend_class->post_parse = clutter_backend_wayland_post_parse;
backend_class->get_features = clutter_backend_wayland_get_features;
backend_class->init_events = clutter_backend_wayland_init_events;
backend_class->create_stage = clutter_backend_wayland_create_stage;
backend_class->create_context = clutter_backend_wayland_create_context;
backend_class->redraw = clutter_backend_wayland_redraw;

View File

@ -1,32 +0,0 @@
/* An OpenGL based 'interactive canvas' library.
* Authored By Matthew Allum <mallum@openedhand.com>
* Copyright (C) 2006-2007 OpenedHand
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*
*/
#ifndef __CLUTTER_BACKEND_PRIVATE_X11_H__
#define __CLUTTER_BACKEND_PRIVATE_X11_H__
G_BEGIN_DECLS
void _clutter_backend_x11_events_init (ClutterBackend *backend);
void _clutter_backend_x11_events_uninit (ClutterBackend *backend);
G_END_DECLS
#endif

View File

@ -411,12 +411,6 @@ _clutter_backend_x11_post_parse (ClutterBackend *backend,
g_object_set (settings, "font-dpi", (int) dpi * 1024, NULL);
/* create the device manager */
clutter_backend_x11_create_device_manager (backend_x11);
/* register keymap */
clutter_backend_x11_create_keymap (backend_x11);
/* create XSETTINGS client */
backend_x11->xsettings =
_clutter_xsettings_client_new (backend_x11->xdpy,
@ -461,14 +455,46 @@ _clutter_backend_x11_post_parse (ClutterBackend *backend,
error);
}
static void
clutter_backend_x11_init_events (ClutterBackend *backend)
void
_clutter_backend_x11_events_init (ClutterBackend *backend)
{
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
CLUTTER_NOTE (EVENT, "initialising the event loop");
/* the event source is optional */
if (!_no_xevent_retrieval)
_clutter_backend_x11_events_init (backend);
{
GSource *source;
source = _clutter_x11_event_source_new (backend_x11);
/* default priority for events
*
* XXX - at some point we'll have a common EventSource API that
* is created by the backend, and this code will most likely go
* into the default implementation of ClutterBackend
*/
g_source_set_priority (source, CLUTTER_PRIORITY_EVENTS);
/* attach the source to the default context, and transfer the
* ownership to the GMainContext itself
*/
g_source_attach (source, NULL);
g_source_unref (source);
backend_x11->event_source = source;
}
/* create the device manager; we need this because we can effectively
* choose between core+XI1 and XI2 input events
*/
clutter_backend_x11_create_device_manager (backend_x11);
/* register keymap; unless we create a generic Keymap object, I'm
* afraid this will have to stay
*/
clutter_backend_x11_create_keymap (backend_x11);
}
static const GOptionEntry entries[] =
@ -528,17 +554,6 @@ clutter_backend_x11_finalize (GObject *gobject)
static void
clutter_backend_x11_dispose (GObject *gobject)
{
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (gobject);
ClutterStageManager *stage_manager;
CLUTTER_NOTE (BACKEND, "Disposing the of stages");
stage_manager = clutter_stage_manager_get_default ();
g_object_unref (stage_manager);
CLUTTER_NOTE (BACKEND, "Removing the event source");
_clutter_backend_x11_events_uninit (CLUTTER_BACKEND (backend_x11));
G_OBJECT_CLASS (clutter_backend_x11_parent_class)->dispose (gobject);
}
@ -825,7 +840,6 @@ clutter_backend_x11_class_init (ClutterBackendX11Class *klass)
backend_class->pre_parse = _clutter_backend_x11_pre_parse;
backend_class->post_parse = _clutter_backend_x11_post_parse;
backend_class->init_events = clutter_backend_x11_init_events;
backend_class->add_options = clutter_backend_x11_add_options;
backend_class->get_features = clutter_backend_x11_get_features;
backend_class->get_device_manager = clutter_backend_x11_get_device_manager;

View File

@ -116,34 +116,27 @@ struct _ClutterBackendX11Class
ClutterBackendCoglClass parent_class;
};
void _clutter_backend_x11_events_init (ClutterBackend *backend);
void _clutter_backend_x11_events_uninit (ClutterBackend *backend);
GType _clutter_backend_x11_get_type (void) G_GNUC_CONST;
void _clutter_backend_x11_events_init (ClutterBackend *backend);
GSource * _clutter_x11_event_source_new (ClutterBackendX11 *backend_x11);
/* Private to glx/eglx backends */
XVisualInfo *
_clutter_backend_x11_get_visual_info (ClutterBackendX11 *backend_x11);
XVisualInfo * _clutter_backend_x11_get_visual_info (ClutterBackendX11 *backend_x11);
void
_clutter_x11_select_events (Window xwin);
void _clutter_x11_select_events (Window xwin);
ClutterEventX11 *
_clutter_event_x11_new (void);
ClutterEventX11 * _clutter_event_x11_new (void);
ClutterEventX11 * _clutter_event_x11_copy (ClutterEventX11 *event_x11);
void _clutter_event_x11_free (ClutterEventX11 *event_x11);
ClutterEventX11 *
_clutter_event_x11_copy (ClutterEventX11 *event_x11);
void
_clutter_event_x11_free (ClutterEventX11 *event_x11);
gboolean
_clutter_x11_input_device_translate_screen_coord (ClutterInputDevice *device,
gint stage_root_x,
gint stage_root_y,
guint index_,
gdouble value,
gdouble *axis_value);
gboolean _clutter_x11_input_device_translate_screen_coord (ClutterInputDevice *device,
gint stage_root_x,
gint stage_root_y,
guint index_,
gdouble value,
gdouble *axis_value);
G_END_DECLS

View File

@ -67,7 +67,8 @@ struct _ClutterEventSource
{
GSource source;
ClutterBackend *backend;
ClutterBackendX11 *backend;
GPollFD event_poll_fd;
};
@ -100,8 +101,6 @@ static gboolean clutter_event_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data);
static GList *event_sources = NULL;
static GSourceFuncs event_funcs = {
clutter_event_prepare,
clutter_event_check,
@ -109,150 +108,33 @@ static GSourceFuncs event_funcs = {
NULL
};
static GSource *
clutter_event_source_new (ClutterBackend *backend)
GSource *
_clutter_x11_event_source_new (ClutterBackendX11 *backend_x11)
{
GSource *source = g_source_new (&event_funcs, sizeof (ClutterEventSource));
ClutterEventSource *event_source = (ClutterEventSource *) source;
event_source->backend = backend;
return source;
}
static gboolean
check_xpending (ClutterBackend *backend)
{
return XPending (CLUTTER_BACKEND_X11 (backend)->xdpy);
}
#if 0
static gboolean
xembed_send_message (ClutterBackendX11 *backend_x11,
Window window,
long message,
long detail,
long data1,
long data2)
{
XEvent ev;
memset (&ev, 0, sizeof (ev));
ev.xclient.type = ClientMessage;
ev.xclient.window = window;
ev.xclient.message_type = backend_x11->atom_XEMBED;
ev.xclient.format = 32;
ev.xclient.data.l[0] = CurrentTime;
ev.xclient.data.l[1] = message;
ev.xclient.data.l[2] = detail;
ev.xclient.data.l[3] = data1;
ev.xclient.data.l[4] = data2;
clutter_x11_trap_x_errors ();
XSendEvent (backend_x11->xdpy, window, False, NoEventMask, &ev);
XSync (backend_x11->xdpy, False);
if (clutter_x11_untrap_x_errors ())
return False;
return True;
}
static void
xembed_set_info (ClutterBackendX11 *backend_x11,
Window window,
gint flags)
{
gint32 list[2];
list[0] = MAX_SUPPORTED_XEMBED_VERSION;
list[1] = XEMBED_MAPPED;
XChangeProperty (backend_x11->xdpy, window,
backend_x11->atom_XEMBED_INFO,
backend_x11->atom_XEMBED_INFO, 32,
PropModeReplace, (unsigned char *) list, 2);
}
#endif
void
_clutter_backend_x11_events_init (ClutterBackend *backend)
{
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
GSource *source;
ClutterEventSource *event_source;
int connection_number;
GSource *source;
gchar *name;
connection_number = ConnectionNumber (backend_x11->xdpy);
CLUTTER_NOTE (EVENT, "Connection number: %d", connection_number);
source = backend_x11->event_source = clutter_event_source_new (backend);
source = g_source_new (&event_funcs, sizeof (ClutterEventSource));
event_source = (ClutterEventSource *) source;
g_source_set_priority (source, CLUTTER_PRIORITY_EVENTS);
name = g_strdup_printf ("Clutter X11 Event (connection: %d)",
connection_number);
g_source_set_name (source, name);
g_free (name);
event_source->backend = backend_x11;
event_source->event_poll_fd.fd = connection_number;
event_source->event_poll_fd.events = G_IO_IN;
event_sources = g_list_prepend (event_sources, event_source);
g_source_add_poll (source, &event_source->event_poll_fd);
g_source_set_can_recurse (source, TRUE);
g_source_attach (source, NULL);
}
void
_clutter_backend_x11_events_uninit (ClutterBackend *backend)
{
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
if (backend_x11->event_source)
{
CLUTTER_NOTE (EVENT, "Destroying the event source");
event_sources = g_list_remove (event_sources,
backend_x11->event_source);
g_source_destroy (backend_x11->event_source);
g_source_unref (backend_x11->event_source);
backend_x11->event_source = NULL;
}
}
static void
events_queue (ClutterBackend *backend)
{
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
Display *xdisplay = backend_x11->xdpy;
ClutterEvent *event;
XEvent xevent;
while (!clutter_events_pending () && XPending (xdisplay))
{
XNextEvent (xdisplay, &xevent);
event = clutter_event_new (CLUTTER_NOTHING);
#ifdef HAVE_XGE
XGetEventData (xdisplay, &xevent.xcookie);
#endif
if (_clutter_backend_translate_event (backend, &xevent, event))
_clutter_event_push (event, FALSE);
else
clutter_event_free (event);
#ifdef HAVE_XGE
XFreeEventData (xdisplay, &xevent.xcookie);
#endif
}
return source;
}
/**
@ -357,13 +239,13 @@ static gboolean
clutter_event_prepare (GSource *source,
gint *timeout)
{
ClutterBackend *backend = ((ClutterEventSource *) source)->backend;
ClutterBackendX11 *backend = ((ClutterEventSource *) source)->backend;
gboolean retval;
clutter_threads_enter ();
*timeout = -1;
retval = (clutter_events_pending () || check_xpending (backend));
retval = (clutter_events_pending () || XPending (backend->xdpy));
clutter_threads_leave ();
@ -374,13 +256,13 @@ static gboolean
clutter_event_check (GSource *source)
{
ClutterEventSource *event_source = (ClutterEventSource *) source;
ClutterBackend *backend = event_source->backend;
ClutterBackendX11 *backend = event_source->backend;
gboolean retval;
clutter_threads_enter ();
if (event_source->event_poll_fd.revents & G_IO_IN)
retval = (clutter_events_pending () || check_xpending (backend));
retval = (clutter_events_pending () || XPending (backend->xdpy));
else
retval = FALSE;
@ -389,12 +271,41 @@ clutter_event_check (GSource *source)
return retval;
}
static void
events_queue (ClutterBackendX11 *backend_x11)
{
ClutterBackend *backend = CLUTTER_BACKEND (backend_x11);
Display *xdisplay = backend_x11->xdpy;
ClutterEvent *event;
XEvent xevent;
while (!clutter_events_pending () && XPending (xdisplay))
{
XNextEvent (xdisplay, &xevent);
event = clutter_event_new (CLUTTER_NOTHING);
#ifdef HAVE_XGE
XGetEventData (xdisplay, &xevent.xcookie);
#endif
if (_clutter_backend_translate_event (backend, &xevent, event))
_clutter_event_push (event, FALSE);
else
clutter_event_free (event);
#ifdef HAVE_XGE
XFreeEventData (xdisplay, &xevent.xcookie);
#endif
}
}
static gboolean
clutter_event_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
{
ClutterBackend *backend = ((ClutterEventSource *) source)->backend;
ClutterBackendX11 *backend = ((ClutterEventSource *) source)->backend;
ClutterEvent *event;
clutter_threads_enter ();

View File

@ -468,10 +468,12 @@ CLUTTER_CONFIG_DEFINES=
# windowing systems
AS_IF([test "x$SUPPORT_X11" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
#define CLUTTER_WINDOWING_X11 \"x11\""])
#define CLUTTER_WINDOWING_X11 \"x11\"
#define CLUTTER_INPUT_X11 \"x11\""])
AS_IF([test "x$SUPPORT_GDK" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
#define CLUTTER_WINDOWING_GDK \"gdk\""])
#define CLUTTER_WINDOWING_GDK \"gdk\"
#define CLUTTER_INPUT_GDK \"gdk\""])
AS_IF([test "x$SUPPORT_GLX" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
#define CLUTTER_WINDOWING_GLX \"glx\""])
@ -483,10 +485,12 @@ AS_IF([test "x$SUPPORT_WAYLAND" = "x1"],
#define CLUTTER_WINDOWING_WAYLAND \"wayland\""])
AS_IF([test "x$SUPPORT_OSX" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
#define CLUTTER_WINDOWING_OSX \"osx\""])
#define CLUTTER_WINDOWING_OSX \"osx\"
#define CLUTTER_INPUT_OSX \"osx\""])
AS_IF([test "x$SUPPORT_WIN32" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
#define CLUTTER_WINDOWING_WIN32 \"win32\""])
#define CLUTTER_WINDOWING_WIN32 \"win32\"
#define CLUTTER_INPUT_WIN32 \"win32\""])
AS_IF([test "x$SUPPORT_EGL_PLATFORM_GDL" = "x1"],
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
#define CLUTTER_WINDOWING_CEX100 \"cex100\""])