From 6a980793c6b7f66c698a8426d92763827d73958e Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Mon, 22 Dec 2008 13:11:59 +0000 Subject: [PATCH] Return something reasonable from clutter_x11_handle_event() Instead of returning CLUTTER_X11_FILTER_CONTINUE always from clutter_x11_handle_event() return CLUTTER_X11_FILTER_REMOVE if the event was on a stage and translated to a ClutterEvent. Signed-off-by: Emmanuele Bassi --- clutter/x11/clutter-event-x11.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/clutter/x11/clutter-event-x11.c b/clutter/x11/clutter-event-x11.c index 1a00c3824..06e27e766 100644 --- a/clutter/x11/clutter-event-x11.c +++ b/clutter/x11/clutter-event-x11.c @@ -843,8 +843,13 @@ events_queue (ClutterBackend *backend) * This function processes a single X event; it can be used to hook * into external X event retrieval (for example that done by GDK). * - * Return value: #ClutterX11FilterReturn indicating what the caller - * should do with the original event. + * Return value: #ClutterX11FilterReturn. %CLUTTER_X11_FILTER_REMOVE + * indicates that Clutter has internally handled the event and the + * caller should do no further processing. %CLUTTER_X11_FILTER_CONTINUE + * indicates that Clutter is either not interested in the event, + * or has used the event to update internal state without taking + * any exclusive action. %CLUTTER_X11_FILTER_TRANSLATE will not + * occur. * * Since: 0.8 */ @@ -854,6 +859,18 @@ clutter_x11_handle_event (XEvent *xevent) ClutterBackend *backend; ClutterEvent *event; ClutterMainContext *clutter_context; + ClutterX11FilterReturn result; + + /* The return values here are someone approximate; we return + * CLUTTER_X11_FILTER_REMOVE if and only if a clutter event is + * generated for the event. This mostly, but not entirely, + * corresponds to whether other event processing should be + * excluded. As long as the stage window is not shared with another + * toolkit it should be safe, and never return + * %CLUTTER_X11_FILTER_REMOVE when more processing is needed. + */ + + result = CLUTTER_X11_FILTER_CONTINUE; clutter_threads_enter (); @@ -865,11 +882,13 @@ clutter_x11_handle_event (XEvent *xevent) if (event_translate (backend, event, xevent)) { /* push directly here to avoid copy of queue_put */ + result = CLUTTER_X11_FILTER_REMOVE; g_queue_push_head (clutter_context->events_queue, event); } else { clutter_event_free (event); + goto out; } event = clutter_event_get (); @@ -881,9 +900,10 @@ clutter_x11_handle_event (XEvent *xevent) clutter_event_free (event); } + out: clutter_threads_leave (); - return CLUTTER_X11_FILTER_CONTINUE; + return result; } static gboolean