[mutter/wip/carlosg/input-in-backends: 33/48] clutter: Drop ClutterEventTranslator interface
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/input-in-backends: 33/48] clutter: Drop ClutterEventTranslator interface
- Date: Sat, 24 Aug 2019 08:59:50 +0000 (UTC)
commit e56df455ae7a7b15127abc277e199cd367cba614
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Mar 26 19:19:45 2019 +0100
clutter: Drop ClutterEventTranslator interface
We don't need that much complexity when we have a fixed set of
translators, and only one of them wants a given event.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
clutter/clutter/clutter-backend-private.h | 14 ++---
clutter/clutter/clutter-backend.c | 69 +++++------------------
clutter/clutter/clutter-event-translator.c | 38 -------------
clutter/clutter/clutter-event-translator.h | 42 --------------
clutter/clutter/meson.build | 2 -
clutter/clutter/x11/clutter-backend-x11.c | 40 ++++++-------
clutter/clutter/x11/clutter-device-manager-xi2.c | 72 ++++++++++--------------
clutter/clutter/x11/clutter-device-manager-xi2.h | 4 ++
clutter/clutter/x11/clutter-keymap-x11.c | 41 ++++----------
clutter/clutter/x11/clutter-keymap-x11.h | 4 ++
clutter/clutter/x11/clutter-stage-x11.c | 46 ++++-----------
clutter/clutter/x11/clutter-stage-x11.h | 4 ++
src/backends/x11/meta-clutter-backend-x11.c | 6 --
13 files changed, 97 insertions(+), 285 deletions(-)
---
diff --git a/clutter/clutter/clutter-backend-private.h b/clutter/clutter/clutter-backend-private.h
index 50208c3ae..37be746db 100644
--- a/clutter/clutter/clutter-backend-private.h
+++ b/clutter/clutter/clutter-backend-private.h
@@ -27,8 +27,6 @@
#include <clutter/clutter-keymap.h>
#include <clutter/clutter-stage-window.h>
-#include "clutter-event-translator.h"
-
#define CLUTTER_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND,
ClutterBackendClass))
#define CLUTTER_IS_BACKEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BACKEND))
#define CLUTTER_BACKEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_BACKEND,
ClutterBackendClass))
@@ -58,7 +56,7 @@ struct _ClutterBackend
gfloat units_per_em;
gint32 units_serial;
- GList *event_translators;
+ ClutterStageWindow *stage_window;
ClutterInputMethod *input_method;
@@ -140,13 +138,6 @@ gboolean _clutter_backend_translate_event (Clutter
gpointer native,
ClutterEvent *event);
-CLUTTER_EXPORT
-void _clutter_backend_add_event_translator (ClutterBackend *backend,
- ClutterEventTranslator *translator);
-
-void _clutter_backend_remove_event_translator (ClutterBackend *backend,
- ClutterEventTranslator *translator);
-
ClutterFeatureFlags _clutter_backend_get_features (ClutterBackend *backend);
gfloat _clutter_backend_get_units_per_em (ClutterBackend *backend,
@@ -160,6 +151,9 @@ void _clutter_backend_reset_cogl_framebuffer (Clutter
void clutter_set_allowed_drivers (const char *drivers);
+CLUTTER_EXPORT
+ClutterStageWindow * clutter_backend_get_stage_window (ClutterBackend *backend);
+
G_END_DECLS
#endif /* __CLUTTER_BACKEND_PRIVATE_H__ */
diff --git a/clutter/clutter/clutter-backend.c b/clutter/clutter/clutter-backend.c
index aa05a269f..bc7c11977 100644
--- a/clutter/clutter/clutter-backend.c
+++ b/clutter/clutter/clutter-backend.c
@@ -104,10 +104,12 @@ clutter_backend_dispose (GObject *gobject)
/* clear the events still in the queue of the main context */
_clutter_clear_events_queue ();
- /* remove all event translators */
- g_clear_pointer (&backend->event_translators, g_list_free);
-
g_clear_pointer (&backend->dummy_onscreen, cogl_object_unref);
+ if (backend->stage_window)
+ {
+ g_object_remove_weak_pointer (G_OBJECT (backend->stage_window),
+ (gpointer *) &backend->stage_window);
+ }
G_OBJECT_CLASS (clutter_backend_parent_class)->dispose (gobject);
}
@@ -586,34 +588,6 @@ clutter_backend_real_get_keymap (ClutterBackend *backend)
return backend->keymap;
}
-static gboolean
-clutter_backend_real_translate_event (ClutterBackend *backend,
- gpointer native,
- ClutterEvent *event)
-{
- GList *l;
-
- for (l = backend->event_translators;
- l != NULL;
- l = l->next)
- {
- ClutterEventTranslator *translator = l->data;
- ClutterTranslateReturn retval;
-
- retval = _clutter_event_translator_translate_event (translator,
- native,
- event);
-
- if (retval == CLUTTER_TRANSLATE_QUEUE)
- return TRUE;
-
- if (retval == CLUTTER_TRANSLATE_REMOVE)
- return FALSE;
- }
-
- return FALSE;
-}
-
static void
clutter_backend_class_init (ClutterBackendClass *klass)
{
@@ -678,7 +652,6 @@ clutter_backend_class_init (ClutterBackendClass *klass)
klass->init_events = clutter_backend_real_init_events;
klass->get_device_manager = clutter_backend_real_get_device_manager;
- klass->translate_event = clutter_backend_real_translate_event;
klass->create_context = clutter_backend_real_create_context;
klass->get_features = clutter_backend_real_get_features;
klass->get_keymap = clutter_backend_real_get_keymap;
@@ -758,6 +731,10 @@ _clutter_backend_create_stage (ClutterBackend *backend,
g_assert (CLUTTER_IS_STAGE_WINDOW (stage_window));
+ backend->stage_window = stage_window;
+ g_object_add_weak_pointer (G_OBJECT (backend->stage_window),
+ (gpointer *) &backend->stage_window);
+
return stage_window;
}
@@ -1018,28 +995,6 @@ _clutter_backend_translate_event (ClutterBackend *backend,
event);
}
-void
-_clutter_backend_add_event_translator (ClutterBackend *backend,
- ClutterEventTranslator *translator)
-{
- if (g_list_find (backend->event_translators, translator) != NULL)
- return;
-
- backend->event_translators =
- g_list_prepend (backend->event_translators, translator);
-}
-
-void
-_clutter_backend_remove_event_translator (ClutterBackend *backend,
- ClutterEventTranslator *translator)
-{
- if (g_list_find (backend->event_translators, translator) == NULL)
- return;
-
- backend->event_translators =
- g_list_remove (backend->event_translators, translator);
-}
-
/**
* clutter_backend_get_cogl_context: (skip)
* @backend: a #ClutterBackend
@@ -1187,3 +1142,9 @@ clutter_backend_get_keymap (ClutterBackend *backend)
{
return CLUTTER_BACKEND_GET_CLASS (backend)->get_keymap (backend);
}
+
+ClutterStageWindow *
+clutter_backend_get_stage_window (ClutterBackend *backend)
+{
+ return backend->stage_window;
+}
diff --git a/clutter/clutter/meson.build b/clutter/clutter/meson.build
index 674f96a6c..f8dc4337b 100644
--- a/clutter/clutter/meson.build
+++ b/clutter/clutter/meson.build
@@ -191,7 +191,6 @@ clutter_private_headers = [
'clutter-device-manager-private.h',
'clutter-easing.h',
'clutter-effect-private.h',
- 'clutter-event-translator.h',
'clutter-event-private.h',
'clutter-flatten-effect.h',
'clutter-gesture-action-private.h',
@@ -215,7 +214,6 @@ clutter_private_headers = [
clutter_nonintrospected_sources = [
'clutter-easing.c',
- 'clutter-event-translator.c',
'clutter-id-pool.c',
]
diff --git a/clutter/clutter/x11/clutter-backend-x11.c b/clutter/clutter/x11/clutter-backend-x11.c
index 33da44dfe..5866bb3b2 100644
--- a/clutter/clutter/x11/clutter-backend-x11.c
+++ b/clutter/clutter/x11/clutter-backend-x11.c
@@ -232,7 +232,6 @@ clutter_backend_x11_xsettings_notify (const char *name,
static void
clutter_backend_x11_create_device_manager (ClutterBackendX11 *backend_x11)
{
- ClutterEventTranslator *translator;
ClutterBackend *backend;
if (clutter_enable_xinput)
@@ -266,9 +265,6 @@ clutter_backend_x11_create_device_manager (ClutterBackendX11 *backend_x11)
backend = CLUTTER_BACKEND (backend_x11);
backend->device_manager = backend_x11->device_manager;
-
- translator = CLUTTER_EVENT_TRANSLATOR (backend_x11->device_manager);
- _clutter_backend_add_event_translator (backend, translator);
}
static void
@@ -290,22 +286,15 @@ clutter_backend_x11_create_keymap (ClutterBackendX11 *backend_x11)
{
if (backend_x11->keymap == NULL)
{
- ClutterEventTranslator *translator;
- ClutterBackend *backend;
-
backend_x11->keymap =
g_object_new (CLUTTER_TYPE_KEYMAP_X11,
"backend", backend_x11,
NULL);
- backend = CLUTTER_BACKEND (backend_x11);
- translator = CLUTTER_EVENT_TRANSLATOR (backend_x11->keymap);
- _clutter_backend_add_event_translator (backend, translator);
-
g_signal_connect (backend_x11->keymap,
"state-changed",
G_CALLBACK (on_keymap_state_change),
- backend->device_manager);
+ backend_x11->device_manager);
}
}
@@ -614,7 +603,8 @@ clutter_backend_x11_translate_event (ClutterBackend *backend,
ClutterEvent *event)
{
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
- ClutterBackendClass *parent_class;
+ ClutterDeviceManagerXI2 *device_manager_x11;
+ ClutterStageX11 *stage_x11;
XEvent *xevent = native;
/* X11 filter functions have a higher priority */
@@ -650,11 +640,20 @@ clutter_backend_x11_translate_event (ClutterBackend *backend,
*/
update_last_event_time (backend_x11, xevent);
- /* chain up to the parent implementation, which will handle
- * event translators
- */
- parent_class = CLUTTER_BACKEND_CLASS (clutter_backend_x11_parent_class);
- return parent_class->translate_event (backend, native, event);
+ if (clutter_keymap_x11_handle_event (backend_x11->keymap,
+ native))
+ return TRUE;
+
+ stage_x11 = CLUTTER_STAGE_X11 (clutter_backend_get_stage_window (backend));
+ if (clutter_stage_x11_translate_event (stage_x11, native, event))
+ return TRUE;
+
+ device_manager_x11 = CLUTTER_DEVICE_MANAGER_XI2 (backend_x11->device_manager);
+ if (clutter_device_manager_xi2_translate_event (device_manager_x11,
+ native, event))
+ return TRUE;
+
+ return FALSE;
}
static CoglRenderer *
@@ -779,7 +778,6 @@ clutter_backend_x11_create_stage (ClutterBackend *backend,
ClutterStage *wrapper,
GError **error)
{
- ClutterEventTranslator *translator;
ClutterStageWindow *stage;
stage = g_object_new (CLUTTER_TYPE_STAGE_X11,
@@ -787,10 +785,6 @@ clutter_backend_x11_create_stage (ClutterBackend *backend,
"wrapper", wrapper,
NULL);
- /* the X11 stage does event translation */
- translator = CLUTTER_EVENT_TRANSLATOR (stage);
- _clutter_backend_add_event_translator (backend, translator);
-
CLUTTER_NOTE (BACKEND, "X11 stage created (display:%p, screen:%d, root:%u)",
CLUTTER_BACKEND_X11 (backend)->xdpy,
CLUTTER_BACKEND_X11 (backend)->xscreen_num,
diff --git a/clutter/clutter/x11/clutter-device-manager-xi2.c
b/clutter/clutter/x11/clutter-device-manager-xi2.c
index 542845093..3a27b69e5 100644
--- a/clutter/clutter/x11/clutter-device-manager-xi2.c
+++ b/clutter/clutter/x11/clutter-device-manager-xi2.c
@@ -38,7 +38,6 @@
#include "clutter-debug.h"
#include "clutter-device-manager-private.h"
#include "clutter-event-private.h"
-#include "clutter-event-translator.h"
#include "clutter-stage-private.h"
#include "clutter-private.h"
#include "clutter-xkb-a11y-x11.h"
@@ -97,7 +96,6 @@ enum
static Atom clutter_input_axis_atoms[N_AXIS_ATOMS] = { 0, };
-static void clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface);
static void clutter_event_extender_iface_init (ClutterEventExtenderInterface *iface);
#define clutter_device_manager_xi2_get_type _clutter_device_manager_xi2_get_type
@@ -105,8 +103,6 @@ static void clutter_event_extender_iface_init (ClutterEventExtenderInterface *
G_DEFINE_TYPE_WITH_CODE (ClutterDeviceManagerXI2,
clutter_device_manager_xi2,
CLUTTER_TYPE_DEVICE_MANAGER,
- G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_EVENT_TRANSLATOR,
- clutter_event_translator_iface_init)
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_EVENT_EXTENDER,
clutter_event_extender_iface_init))
@@ -855,8 +851,8 @@ clutter_device_manager_xi2_select_events (ClutterDeviceManager *manager,
}
static ClutterStage *
-get_event_stage (ClutterEventTranslator *translator,
- XIEvent *xi_event)
+get_event_stage (ClutterDeviceManagerXI2 *manager_xi2,
+ XIEvent *xi_event)
{
Window xwindow = None;
@@ -1324,51 +1320,47 @@ handle_raw_event (ClutterDeviceManagerXI2 *manager_xi2,
}
}
-static ClutterTranslateReturn
-clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
- gpointer native,
- ClutterEvent *event)
+gboolean
+clutter_device_manager_xi2_translate_event (ClutterDeviceManagerXI2 *manager_xi2,
+ XEvent *xevent,
+ ClutterEvent *event)
{
- ClutterDeviceManagerXI2 *manager_xi2 = CLUTTER_DEVICE_MANAGER_XI2 (translator);
- ClutterTranslateReturn retval = CLUTTER_TRANSLATE_CONTINUE;
+ gboolean retval = FALSE;
ClutterBackendX11 *backend_x11;
ClutterStageX11 *stage_x11 = NULL;
ClutterStage *stage = NULL;
ClutterInputDevice *device, *source_device;
XGenericEventCookie *cookie;
XIEvent *xi_event;
- XEvent *xevent;
backend_x11 = CLUTTER_BACKEND_X11 (clutter_get_default_backend ());
- xevent = native;
-
cookie = &xevent->xcookie;
if (cookie->type != GenericEvent ||
cookie->extension != manager_xi2->opcode)
- return CLUTTER_TRANSLATE_CONTINUE;
+ return FALSE;
xi_event = (XIEvent *) cookie->data;
if (!xi_event)
- return CLUTTER_TRANSLATE_REMOVE;
+ return FALSE;
if (cookie->evtype == XI_RawMotion ||
cookie->evtype == XI_RawButtonPress ||
cookie->evtype == XI_RawButtonRelease)
{
handle_raw_event (manager_xi2, xevent);
- return CLUTTER_TRANSLATE_REMOVE;
+ return FALSE;
}
if (!(xi_event->evtype == XI_HierarchyChanged ||
xi_event->evtype == XI_DeviceChanged ||
xi_event->evtype == XI_PropertyEvent))
{
- stage = get_event_stage (translator, xi_event);
+ stage = get_event_stage (manager_xi2, xi_event);
if (stage == NULL || CLUTTER_ACTOR_IN_DESTRUCTION (stage))
- return CLUTTER_TRANSLATE_CONTINUE;
+ return FALSE;
else
stage_x11 = CLUTTER_STAGE_X11 (_clutter_stage_get_window (stage));
}
@@ -1383,7 +1375,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
translate_hierarchy_event (backend_x11, manager_xi2, xev);
}
- retval = CLUTTER_TRANSLATE_REMOVE;
+ retval = FALSE;
break;
case XI_DeviceChanged:
@@ -1406,7 +1398,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
if (source_device)
_clutter_input_device_reset_scroll_info (source_device);
}
- retval = CLUTTER_TRANSLATE_REMOVE;
+ retval = FALSE;
break;
case XI_KeyPress:
@@ -1488,7 +1480,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
if (xi_event->evtype == XI_KeyPress)
_clutter_stage_x11_set_user_time (stage_x11, event->key.time);
- retval = CLUTTER_TRANSLATE_QUEUE;
+ retval = TRUE;
}
break;
@@ -1520,11 +1512,11 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
if (xev->detail >= 4 && xev->detail <= 7)
{
- retval = CLUTTER_TRANSLATE_REMOVE;
+ retval = FALSE;
if (xi_event->evtype == XI_ButtonPress &&
translate_pad_event (event, xev, source_device))
- retval = CLUTTER_TRANSLATE_QUEUE;
+ retval = TRUE;
break;
}
@@ -1564,7 +1556,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
event->any.time,
event->pad_button.button);
- retval = CLUTTER_TRANSLATE_QUEUE;
+ retval = TRUE;
break;
}
@@ -1576,7 +1568,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
case 7:
/* we only generate Scroll events on ButtonPress */
if (xi_event->evtype == XI_ButtonRelease)
- return CLUTTER_TRANSLATE_REMOVE;
+ return FALSE;
event->scroll.type = event->type = CLUTTER_SCROLL;
@@ -1682,7 +1674,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
if (xi_event->evtype == XI_ButtonPress)
_clutter_stage_x11_set_user_time (stage_x11, event->button.time);
- retval = CLUTTER_TRANSLATE_QUEUE;
+ retval = TRUE;
}
break;
@@ -1701,7 +1693,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
event->any.stage = stage;
if (translate_pad_event (event, xev, source_device))
- retval = CLUTTER_TRANSLATE_QUEUE;
+ retval = TRUE;
break;
}
@@ -1739,7 +1731,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
event->scroll.y,
delta_x, delta_y);
- retval = CLUTTER_TRANSLATE_QUEUE;
+ retval = TRUE;
break;
}
@@ -1778,7 +1770,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
event->motion.y,
event->motion.axes != NULL ? "yes" : "no");
- retval = CLUTTER_TRANSLATE_QUEUE;
+ retval = TRUE;
}
break;
@@ -1844,7 +1836,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
event->touch.y,
event->touch.axes != NULL ? "yes" : "no");
- retval = CLUTTER_TRANSLATE_QUEUE;
+ retval = TRUE;
}
break;
@@ -1890,7 +1882,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
event->touch.y,
event->touch.axes != NULL ? "yes" : "no");
- retval = CLUTTER_TRANSLATE_QUEUE;
+ retval = TRUE;
}
break;
@@ -1926,7 +1918,7 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
"Discarding Leave for ButtonRelease "
"event off-stage");
- retval = CLUTTER_TRANSLATE_REMOVE;
+ retval = FALSE;
break;
}
@@ -1947,29 +1939,23 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
clutter_event_set_device (event, device);
clutter_event_set_source_device (event, source_device);
- retval = CLUTTER_TRANSLATE_QUEUE;
+ retval = TRUE;
}
break;
case XI_FocusIn:
case XI_FocusOut:
- retval = CLUTTER_TRANSLATE_CONTINUE;
+ retval = FALSE;
break;
case XI_PropertyEvent:
handle_property_event (manager_xi2, xi_event);
- retval = CLUTTER_TRANSLATE_CONTINUE;
+ retval = FALSE;
break;
}
return retval;
}
-static void
-clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface)
-{
- iface->translate_event = clutter_device_manager_xi2_translate_event;
-}
-
static void
clutter_device_manager_xi2_add_device (ClutterDeviceManager *manager,
ClutterInputDevice *device)
diff --git a/clutter/clutter/x11/clutter-device-manager-xi2.h
b/clutter/clutter/x11/clutter-device-manager-xi2.h
index be2575975..593a5d41c 100644
--- a/clutter/clutter/x11/clutter-device-manager-xi2.h
+++ b/clutter/clutter/x11/clutter-device-manager-xi2.h
@@ -68,6 +68,10 @@ struct _ClutterDeviceManagerXI2Class
GType _clutter_device_manager_xi2_get_type (void) G_GNUC_CONST;
+gboolean clutter_device_manager_xi2_translate_event (ClutterDeviceManagerXI2 *manager_xi2,
+ XEvent *xevent,
+ ClutterEvent *event);
+
G_END_DECLS
#endif /* __CLUTTER_DEVICE_MANAGER_XI2_H__ */
diff --git a/clutter/clutter/x11/clutter-keymap-x11.c b/clutter/clutter/x11/clutter-keymap-x11.c
index a2a0a1016..0dbb91650 100644
--- a/clutter/clutter/x11/clutter-keymap-x11.c
+++ b/clutter/clutter/x11/clutter-keymap-x11.c
@@ -27,7 +27,6 @@
#include "clutter-backend-x11.h"
#include "clutter-debug.h"
-#include "clutter-event-translator.h"
#include "clutter-private.h"
#include <X11/Xatom.h>
@@ -105,14 +104,9 @@ enum
static GParamSpec *obj_props[PROP_LAST] = { NULL, };
-static void clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface);
-
#define clutter_keymap_x11_get_type _clutter_keymap_x11_get_type
-G_DEFINE_TYPE_WITH_CODE (ClutterKeymapX11, clutter_keymap_x11,
- CLUTTER_TYPE_KEYMAP,
- G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_EVENT_TRANSLATOR,
- clutter_event_translator_iface_init));
+G_DEFINE_TYPE (ClutterKeymapX11, clutter_keymap_x11, CLUTTER_TYPE_KEYMAP)
/* code adapted from gdk/x11/gdkkeys-x11.c - update_modmap */
static void
@@ -496,12 +490,10 @@ static void
clutter_keymap_x11_finalize (GObject *gobject)
{
ClutterKeymapX11 *keymap;
- ClutterEventTranslator *translator;
GHashTableIter iter;
gpointer key, value;
keymap = CLUTTER_KEYMAP_X11 (gobject);
- translator = CLUTTER_EVENT_TRANSLATOR (keymap);
clutter_keymap_x11_refresh_reserved_keycodes (keymap);
g_hash_table_iter_init (&iter, keymap->reserved_keycodes);
@@ -514,8 +506,6 @@ clutter_keymap_x11_finalize (GObject *gobject)
g_hash_table_destroy (keymap->reserved_keycodes);
g_queue_free (keymap->available_keycodes);
- _clutter_backend_remove_event_translator (keymap->backend, translator);
-
if (keymap->xkb_desc != NULL)
XkbFreeKeyboard (keymap->xkb_desc, XkbAllComponentsMask, True);
@@ -570,21 +560,16 @@ clutter_keymap_x11_init (ClutterKeymapX11 *keymap)
keymap->available_keycodes = g_queue_new ();
}
-static ClutterTranslateReturn
-clutter_keymap_x11_translate_event (ClutterEventTranslator *translator,
- gpointer native,
- ClutterEvent *event)
+gboolean
+clutter_keymap_x11_handle_event (ClutterKeymapX11 *keymap_x11,
+ XEvent *xevent)
{
- ClutterKeymapX11 *keymap_x11 = CLUTTER_KEYMAP_X11 (translator);
- ClutterTranslateReturn retval;
- XEvent *xevent;
+ gboolean retval;
if (!keymap_x11->use_xkb)
- return CLUTTER_TRANSLATE_CONTINUE;
-
- xevent = native;
+ return FALSE;
- retval = CLUTTER_TRANSLATE_CONTINUE;
+ retval = FALSE;
if (xevent->type == keymap_x11->xkb_event_base)
{
@@ -597,7 +582,7 @@ clutter_keymap_x11_translate_event (ClutterEventTranslator *translator,
keymap_x11->current_group = XkbStateGroup (&xkb_event->state);
update_direction (keymap_x11, keymap_x11->current_group);
update_locked_mods (keymap_x11, xkb_event->state.locked_mods);
- retval = CLUTTER_TRANSLATE_REMOVE;
+ retval = TRUE;
break;
case XkbNewKeyboardNotify:
@@ -605,7 +590,7 @@ clutter_keymap_x11_translate_event (ClutterEventTranslator *translator,
CLUTTER_NOTE (EVENT, "Updating keyboard mapping");
XkbRefreshKeyboardMapping (&xkb_event->map);
keymap_x11->keymap_serial += 1;
- retval = CLUTTER_TRANSLATE_REMOVE;
+ retval = TRUE;
break;
default:
@@ -616,18 +601,12 @@ clutter_keymap_x11_translate_event (ClutterEventTranslator *translator,
{
XRefreshKeyboardMapping (&xevent->xmapping);
keymap_x11->keymap_serial += 1;
- retval = CLUTTER_TRANSLATE_REMOVE;
+ retval = TRUE;
}
return retval;
}
-static void
-clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface)
-{
- iface->translate_event = clutter_keymap_x11_translate_event;
-}
-
gint
_clutter_keymap_x11_get_key_group (ClutterKeymapX11 *keymap,
ClutterModifierType state)
diff --git a/clutter/clutter/x11/clutter-keymap-x11.h b/clutter/clutter/x11/clutter-keymap-x11.h
index 4decb44ee..8183e0a9b 100644
--- a/clutter/clutter/x11/clutter-keymap-x11.h
+++ b/clutter/clutter/x11/clutter-keymap-x11.h
@@ -63,6 +63,10 @@ gboolean clutter_keymap_x11_reserve_keycode (ClutterKeymapX11 *keymap_x11,
guint *keycode_out);
void clutter_keymap_x11_release_keycode_if_needed (ClutterKeymapX11 *keymap_x11,
guint keycode);
+
+gboolean clutter_keymap_x11_handle_event (ClutterKeymapX11 *keymap,
+ XEvent *xevent);
+
G_END_DECLS
#endif /* __CLUTTER_KEYMAP_X11_H__ */
diff --git a/clutter/clutter/x11/clutter-stage-x11.c b/clutter/clutter/x11/clutter-stage-x11.c
index 929114db8..6706494bc 100644
--- a/clutter/clutter/x11/clutter-stage-x11.c
+++ b/clutter/clutter/x11/clutter-stage-x11.c
@@ -38,7 +38,6 @@
#include "clutter-debug.h"
#include "clutter-device-manager-private.h"
#include "clutter-enum-types.h"
-#include "clutter-event-translator.h"
#include "clutter-event-private.h"
#include "clutter-feature.h"
#include "clutter-main.h"
@@ -53,8 +52,6 @@ static ClutterStageWindowInterface *clutter_stage_window_parent_iface = NULL;
static void
clutter_stage_window_iface_init (ClutterStageWindowInterface *iface);
-static void
-clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface);
static ClutterStageCogl *clutter_x11_get_stage_window_from_window (Window win);
@@ -66,9 +63,7 @@ G_DEFINE_TYPE_WITH_CODE (ClutterStageX11,
clutter_stage_x11,
CLUTTER_TYPE_STAGE_COGL,
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW,
- clutter_stage_window_iface_init)
- G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_EVENT_TRANSLATOR,
- clutter_event_translator_iface_init));
+ clutter_stage_window_iface_init));
#define _NET_WM_STATE_REMOVE 0 /* remove/unset property */
#define _NET_WM_STATE_ADD 1 /* add/set property */
@@ -705,24 +700,12 @@ clutter_stage_x11_finalize (GObject *gobject)
G_OBJECT_CLASS (clutter_stage_x11_parent_class)->finalize (gobject);
}
-static void
-clutter_stage_x11_dispose (GObject *gobject)
-{
- ClutterEventTranslator *translator = CLUTTER_EVENT_TRANSLATOR (gobject);
- ClutterBackend *backend = CLUTTER_STAGE_COGL (gobject)->backend;
-
- _clutter_backend_remove_event_translator (backend, translator);
-
- G_OBJECT_CLASS (clutter_stage_x11_parent_class)->dispose (gobject);
-}
-
static void
clutter_stage_x11_class_init (ClutterStageX11Class *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = clutter_stage_x11_finalize;
- gobject_class->dispose = clutter_stage_x11_dispose;
}
static void
@@ -831,25 +814,22 @@ clipped_redraws_cool_off_cb (void *data)
return G_SOURCE_REMOVE;
}
-static ClutterTranslateReturn
-clutter_stage_x11_translate_event (ClutterEventTranslator *translator,
- gpointer native,
- ClutterEvent *event)
+gboolean
+clutter_stage_x11_translate_event (ClutterStageX11 *stage_x11,
+ XEvent *xevent,
+ ClutterEvent *event)
{
- ClutterStageX11 *stage_x11;
ClutterStageCogl *stage_cogl;
- ClutterTranslateReturn res = CLUTTER_TRANSLATE_CONTINUE;
+ gboolean res = FALSE;
ClutterBackendX11 *backend_x11;
Window stage_xwindow;
- XEvent *xevent = native;
ClutterStage *stage;
stage_cogl = clutter_x11_get_stage_window_from_window (xevent->xany.window);
if (stage_cogl == NULL)
- return CLUTTER_TRANSLATE_CONTINUE;
+ return FALSE;
stage = stage_cogl->wrapper;
- stage_x11 = CLUTTER_STAGE_X11 (stage_cogl);
backend_x11 = CLUTTER_BACKEND_X11 (stage_cogl->backend);
stage_xwindow = stage_x11->xwin;
@@ -1008,7 +988,7 @@ clutter_stage_x11_translate_event (ClutterEventTranslator *translator,
(unsigned int) stage_xwindow);
event->any.type = CLUTTER_DESTROY_NOTIFY;
event->any.stage = stage;
- res = CLUTTER_TRANSLATE_QUEUE;
+ res = TRUE;
break;
case ClientMessage:
@@ -1020,24 +1000,18 @@ clutter_stage_x11_translate_event (ClutterEventTranslator *translator,
{
event->any.type = CLUTTER_DELETE;
event->any.stage = stage;
- res = CLUTTER_TRANSLATE_QUEUE;
+ res = TRUE;
}
break;
default:
- res = CLUTTER_TRANSLATE_CONTINUE;
+ res = FALSE;
break;
}
return res;
}
-static void
-clutter_event_translator_iface_init (ClutterEventTranslatorIface *iface)
-{
- iface->translate_event = clutter_stage_x11_translate_event;
-}
-
/**
* clutter_x11_get_stage_window: (skip)
* @stage: a #ClutterStage
diff --git a/clutter/clutter/x11/clutter-stage-x11.h b/clutter/clutter/x11/clutter-stage-x11.h
index cf3db2df7..5afadccbc 100644
--- a/clutter/clutter/x11/clutter-stage-x11.h
+++ b/clutter/clutter/x11/clutter-stage-x11.h
@@ -91,6 +91,10 @@ void _clutter_stage_x11_events_device_changed (ClutterStageX11 *stage_x11,
void _clutter_stage_x11_set_user_time (ClutterStageX11 *stage_x11,
guint32 user_time);
+gboolean clutter_stage_x11_translate_event (ClutterStageX11 *stage_x11,
+ XEvent *xevent,
+ ClutterEvent *event);
+
G_END_DECLS
#endif /* __CLUTTER_STAGE_H__ */
diff --git a/src/backends/x11/meta-clutter-backend-x11.c b/src/backends/x11/meta-clutter-backend-x11.c
index 56485ba9f..7732276ad 100644
--- a/src/backends/x11/meta-clutter-backend-x11.c
+++ b/src/backends/x11/meta-clutter-backend-x11.c
@@ -58,7 +58,6 @@ meta_clutter_backend_x11_create_stage (ClutterBackend *backend,
ClutterStage *wrapper,
GError **error)
{
- ClutterEventTranslator *translator;
ClutterStageWindow *stage;
GType stage_type;
@@ -71,11 +70,6 @@ meta_clutter_backend_x11_create_stage (ClutterBackend *backend,
"backend", backend,
"wrapper", wrapper,
NULL);
-
- /* the X11 stage does event translation */
- translator = CLUTTER_EVENT_TRANSLATOR (stage);
- _clutter_backend_add_event_translator (backend, translator);
-
return stage;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]