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

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