[Bf-blender-cvs] [9d188740834] master: Fix window flickering when moving windows between monitors in Wayland

Campbell Barton noreply at git.blender.org
Tue Oct 25 17:02:58 CEST 2022


Commit: 9d188740834017992967a9b91286e2e9b366edd3
Author: Campbell Barton
Date:   Wed Oct 26 01:58:06 2022 +1100
Branches: master
https://developer.blender.org/rB9d188740834017992967a9b91286e2e9b366edd3

Fix window flickering when moving windows between monitors in Wayland

Moving widows between monitors with different scale set could flicker
in a feedback loop because the bounds of the window resizing could
cause the bounds of the windows to overlap different monitors.

Now the window is resized immediately, instead of letting the change
to the windows surface scale resize the window.

===================================================================

M	intern/ghost/intern/GHOST_WindowWayland.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp
index edcbcc14a37..6ee1fb8b27f 100644
--- a/intern/ghost/intern/GHOST_WindowWayland.cpp
+++ b/intern/ghost/intern/GHOST_WindowWayland.cpp
@@ -1041,12 +1041,23 @@ bool GHOST_WindowWayland::outputs_changed_update_scale()
   bool changed = false;
 
   if (scale_next != scale_curr) {
-    /* Unlikely but possible there is a pending size change is set. */
-    window_->size_pending[0] = (window_->size_pending[0] / scale_curr) * scale_next;
-    window_->size_pending[1] = (window_->size_pending[1] / scale_curr) * scale_next;
-
     window_->scale = scale_next;
     wl_surface_set_buffer_scale(window_->wl_surface, scale_next);
+
+    /* It's important to resize the window immediately, to avoid the window changing size
+     * and flickering in a constant feedback loop (in some bases). */
+    if ((window_->size_pending[0] != 0) && (window_->size_pending[1] != 0)) {
+      /* Unlikely but possible there is a pending size change is set. */
+      window_->size[0] = window_->size_pending[0];
+      window_->size[1] = window_->size_pending[1];
+      window_->size_pending[0] = 0;
+      window_->size_pending[1] = 0;
+    }
+    window_->size[0] = (window_->size[0] / scale_curr) * scale_next;
+    window_->size[1] = (window_->size[1] / scale_curr) * scale_next;
+    wl_egl_window_resize(window_->egl_window, UNPACK2(window_->size), 0, 0);
+    window_->ghost_window->notify_size();
+
     changed = true;
   }



More information about the Bf-blender-cvs mailing list