Filter out events handled before the plugin before they get GTK+

Fix a problem where GTK+ was warning
'gdk_window_set_user_time called on non-toplevel' for every button
press and click on the mutter stage by excluding such events from
GTK+ processing.

Add a boolean return value to meta_compositor_process_event that
indicates whether the event has been handled and should be filtered
out of the event stream and for mutter, base that on the return
value of the plugin's xevent_filter vfunc.
This commit is contained in:
Owen W. Taylor 2008-11-22 13:07:32 -05:00
parent e5fc168a46
commit e083742426
6 changed files with 31 additions and 23 deletions

View File

@ -39,7 +39,7 @@ struct _MetaCompositor
void (*set_updates) (MetaCompositor *compositor, void (*set_updates) (MetaCompositor *compositor,
MetaWindow *window, MetaWindow *window,
gboolean update); gboolean update);
void (*process_event) (MetaCompositor *compositor, gboolean (*process_event) (MetaCompositor *compositor,
XEvent *event, XEvent *event,
MetaWindow *window); MetaWindow *window);
Pixmap (*get_window_pixmap) (MetaCompositor *compositor, Pixmap (*get_window_pixmap) (MetaCompositor *compositor,

View File

@ -2391,14 +2391,14 @@ process_destroy (MetaCompositorXRender *compositor,
destroy_win (compositor->display, event->window, FALSE); destroy_win (compositor->display, event->window, FALSE);
} }
static void static gboolean
process_damage (MetaCompositorXRender *compositor, process_damage (MetaCompositorXRender *compositor,
XDamageNotifyEvent *event) XDamageNotifyEvent *event)
{ {
MetaCompWindow *cw = find_window_in_display (compositor->display, MetaCompWindow *cw = find_window_in_display (compositor->display,
event->drawable); event->drawable);
if (cw == NULL) if (cw == NULL)
return; return FALSE;
repair_win (cw); repair_win (cw);
@ -2406,6 +2406,8 @@ process_damage (MetaCompositorXRender *compositor,
if (event->more == FALSE) if (event->more == FALSE)
add_repair (compositor->display); add_repair (compositor->display);
#endif #endif
return TRUE;
} }
static void static void
@ -2737,7 +2739,7 @@ xrender_free_window (MetaCompositor *compositor,
} }
#endif /* 0 */ #endif /* 0 */
static void static gboolean
xrender_process_event (MetaCompositor *compositor, xrender_process_event (MetaCompositor *compositor,
XEvent *event, XEvent *event,
MetaWindow *window) MetaWindow *window)
@ -2798,7 +2800,7 @@ xrender_process_event (MetaCompositor *compositor,
else else
{ {
meta_error_trap_pop (xrc->display, FALSE); meta_error_trap_pop (xrc->display, FALSE);
return; return FALSE;
} }
break; break;
} }
@ -2808,7 +2810,7 @@ xrender_process_event (MetaCompositor *compositor,
repair_display (xrc->display); repair_display (xrc->display);
#endif #endif
return; return FALSE;
#endif #endif
} }

View File

@ -106,14 +106,16 @@ meta_compositor_set_updates (MetaCompositor *compositor,
#endif #endif
} }
void gboolean
meta_compositor_process_event (MetaCompositor *compositor, meta_compositor_process_event (MetaCompositor *compositor,
XEvent *event, XEvent *event,
MetaWindow *window) MetaWindow *window)
{ {
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
if (compositor && compositor->process_event) if (compositor && compositor->process_event)
compositor->process_event (compositor, event, window); return compositor->process_event (compositor, event, window);
else
return FALSE;
#endif #endif
} }

View File

@ -1748,7 +1748,7 @@ clutter_cmp_set_updates (MetaCompositor *compositor,
#endif #endif
} }
static void static gboolean
clutter_cmp_process_event (MetaCompositor *compositor, clutter_cmp_process_event (MetaCompositor *compositor,
XEvent *event, XEvent *event,
MetaWindow *window) MetaWindow *window)
@ -1764,11 +1764,10 @@ clutter_cmp_process_event (MetaCompositor *compositor,
screen = meta_window_get_screen (window); screen = meta_window_get_screen (window);
info = meta_screen_get_compositor_data (screen); info = meta_screen_get_compositor_data (screen);
if (mutter_plugin_manager_xevent_filter (info->plugin_mgr, if (mutter_plugin_manager_xevent_filter (info->plugin_mgr, event))
event) == TRUE)
{ {
DEBUG_TRACE ("clutter_cmp_process_event (filtered,window==NULL)\n"); DEBUG_TRACE ("clutter_cmp_process_event (filtered,window==NULL)\n");
return; return TRUE;
} }
} }
else else
@ -1785,11 +1784,10 @@ clutter_cmp_process_event (MetaCompositor *compositor,
info = meta_screen_get_compositor_data (screen); info = meta_screen_get_compositor_data (screen);
if (mutter_plugin_manager_xevent_filter (info->plugin_mgr, if (mutter_plugin_manager_xevent_filter (info->plugin_mgr, event))
event) == TRUE)
{ {
DEBUG_TRACE ("clutter_cmp_process_event (filtered,window==NULL)\n"); DEBUG_TRACE ("clutter_cmp_process_event (filtered,window==NULL)\n");
return; return TRUE;
} }
l = l->next; l = l->next;
@ -1828,6 +1826,11 @@ clutter_cmp_process_event (MetaCompositor *compositor,
meta_error_trap_pop (xrc->display, FALSE); meta_error_trap_pop (xrc->display, FALSE);
/* The above handling is basically just "observing" the events, so we return
* FALSE to indicate that the event should not be filtered out; if we have
* GTK+ windows in the same process, GTK+ needs the ConfigureNotify event, for example.
*/
return FALSE;
#endif #endif
} }

View File

@ -2424,9 +2424,10 @@ event_callback (XEvent *event,
if (display->compositor) if (display->compositor)
{ {
meta_compositor_process_event (display->compositor, if (meta_compositor_process_event (display->compositor,
event, event,
window); window))
filter_out_event = TRUE;
} }
display->current_time = CurrentTime; display->current_time = CurrentTime;

View File

@ -73,7 +73,7 @@ void meta_compositor_set_updates (MetaCompositor *compositor,
MetaWindow *window, MetaWindow *window,
gboolean updates); gboolean updates);
void meta_compositor_process_event (MetaCompositor *compositor, gboolean meta_compositor_process_event (MetaCompositor *compositor,
XEvent *event, XEvent *event,
MetaWindow *window); MetaWindow *window);
Pixmap meta_compositor_get_window_pixmap (MetaCompositor *compositor, Pixmap meta_compositor_get_window_pixmap (MetaCompositor *compositor,