[gtk: 1/2] x11: Fix handling of `RRScreenChangeNotify`/`RRNotify` events




commit 9e5a501c73c0cc5492b490ab9975743f816f1982
Author: Ian Douglas Scott <idscott system76 com>
Date:   Fri Aug 27 17:57:01 2021 -0700

    x11: Fix handling of `RRScreenChangeNotify`/`RRNotify` events
    
    It seems these are sent with `xwindow` set to the root window, so this
    was failing to find a surface and get the screen from that.
    
    I'm not sure if there's a reason not to get the screen this way
    elsewhere in the function, but it seems this should be correct.
    
    This fixes the behavior of `gdk_x11_display_get_monitors()`, which
    wasn't correctly changing when monitors were added or removed. For
    instance, this python code was always showing the same number of
    monitors when one was turned off and on, but updates correctly with this
    change applied:
    
    ```python
    import gi
    gi.require_version("GLib", "2.0")
    gi.require_version("Gdk", "4.0")
    gi.require_version("Gtk", "4.0")
    from gi.repository import GLib, Gdk, Gtk
    
    def f():
        print(len(Gdk.Display.get_default().get_monitors()))
        return True
    GLib.timeout_add_seconds(1, f)
    
    GLib.MainLoop().run()
    ```

 gdk/x11/gdkdisplay-x11.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 33a3648f4e..a03690c788 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -1037,8 +1037,8 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
       if (xevent->type - display_x11->xrandr_event_base == RRScreenChangeNotify ||
           xevent->type - display_x11->xrandr_event_base == RRNotify)
        {
-          if (x11_screen)
-            _gdk_x11_screen_size_changed (x11_screen, xevent);
+          if (display_x11->screen)
+            _gdk_x11_screen_size_changed (display_x11->screen, xevent);
        }
       else
 #endif


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