[mutter/gnome-3-34] x11-display: Don't unset the X11 focused window after setting one



commit 1f56514e40855293b59eccf58ae6acf7bf37181e
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date:   Thu Oct 31 06:36:52 2019 +0000

    x11-display: Don't unset the X11 focused window after setting one
    
    When using DesktopIcons extension and clicking in an icon, gnome-shell
    starts an infinite loop caused by the first focus change that may trigger
    on X11 a focus in/out event that leads to stage activation/deactivation
    which never ends.
    
    This happens because as part of meta_x11_display_set_input_focus_xwindow()
    to focus the X11 stage window, we unset the display focus, but this also
    causes to request the X11 display to unset the focus since we convolute by
    calling meta_x11_display_set_input_focus() with no window, that leads to
    focusing the no_focus_window and then a focus-in / focus-out dance that the
    shell amplifies in order to give back the focus to the stage.
    
    In order to fix this, mimic what meta_display_set_input_focus() does, but
    without updating the X11 display, and so without implicitly calling
    meta_x11_display_set_input_focus(), stopping the said convolution and
    properly focusing the requested xwindow.
    Also ensure that we're not doing this when using an older timestamp, since
    this check isn't performed anymore.
    
    Fixes https://gitlab.gnome.org/GNOME/mutter/issues/896
    Fixes https://gitlab.gnome.org/GNOME/mutter/issues/899
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/909
    
    
    (cherry picked from commit efe5bed5b4a8706fc796dfd7dc07562a866c12ed)

 src/x11/meta-x11-display.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index 1aebaa961..c05f1ab28 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -1928,10 +1928,15 @@ meta_x11_display_set_input_focus_xwindow (MetaX11Display *x11_display,
 {
   gulong serial;
 
+  if (meta_display_timestamp_too_old (x11_display->display, &timestamp))
+    return;
+
   serial = XNextRequest (x11_display->xdisplay);
   meta_x11_display_set_input_focus_internal (x11_display, window, timestamp);
   meta_x11_display_update_focus_window (x11_display, window, serial, TRUE);
-  meta_display_unset_input_focus (x11_display->display, timestamp);
+  meta_display_update_focus_window (x11_display->display, NULL);
+  meta_display_remove_autoraise_callback (x11_display->display);
+  x11_display->display->last_focus_time = timestamp;
 }
 
 static MetaX11DisplayLogicalMonitorData *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]