From 06f5b6b3e37eb96b91b475b1e57a3f1056ab815a Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Thu, 15 Dec 2016 11:16:49 +0100 Subject: [PATCH] wayland: Preserve the event mask on the root window A window manager must select the SubstructureRedirect mask on the root window to receive the MapRequest from the X11 clients and manage the windows. Without this event mask set, a window manager won't be able to map any new window. The Wayland selection code in mutter can change/clear the event mask on the requestor window from a XSelectionRequest event when the window is not managed by mutter/gnome-shell. A rogue or simply buggy X11 client may send a XConvertSelection() on the root window and mutter will happily change/clear its own event mask on the root window, effectively turning itself into a regular X11 client unable to map any new X11 window from the other X11 clients. To avoid this, simply check that the requestor window is not the root window prior to change/clear the event mask on that window. https://bugzilla.gnome.org/show_bug.cgi?id=776128 --- src/wayland/meta-xwayland-selection.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/wayland/meta-xwayland-selection.c b/src/wayland/meta-xwayland-selection.c index a8806f17e..d2a6e9421 100644 --- a/src/wayland/meta-xwayland-selection.c +++ b/src/wayland/meta-xwayland-selection.c @@ -546,6 +546,8 @@ static WaylandSelectionData * wayland_selection_data_new (XSelectionRequestEvent *request_event, MetaWaylandCompositor *compositor) { + MetaDisplay *display = meta_get_display (); + MetaScreen *screen = display->screen; MetaWaylandDataDevice *data_device; MetaWaylandDataSource *wayland_source; MetaSelectionBridge *selection; @@ -595,7 +597,8 @@ wayland_selection_data_new (XSelectionRequestEvent *request_event, data->window = meta_display_lookup_x_window (meta_get_display (), data->request_event.requestor); - if (!data->window) + /* Do *not* change the event mask on the root window, bugger! */ + if (!data->window && data->request_event.requestor != screen->xroot) { /* Not a managed window, set the PropertyChangeMask * for INCR deletion notifications. @@ -629,10 +632,12 @@ reply_selection_request (XSelectionRequestEvent *request_event, static void wayland_selection_data_free (WaylandSelectionData *data) { - if (!data->window) - { - MetaDisplay *display = meta_get_display (); + MetaDisplay *display = meta_get_display (); + MetaScreen *screen = display->screen; + /* Do *not* change the event mask on the root window, bugger! */ + if (!data->window && data->request_event.requestor != screen->xroot) + { meta_error_trap_push (display); XSelectInput (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), data->request_event.requestor, NoEventMask);