[Bf-blender-cvs] [fdcbad37be9] master: Fix window creation with Hi-DPI exiting under Wayland

Campbell Barton noreply at git.blender.org
Tue Jan 10 06:36:29 CET 2023


Commit: fdcbad37be96572ff138591444e6bba2f2aae921
Author: Campbell Barton
Date:   Tue Jan 10 16:27:11 2023 +1100
Branches: master
https://developer.blender.org/rBfdcbad37be96572ff138591444e6bba2f2aae921

Fix window creation with Hi-DPI exiting under Wayland

Wayland requires the windows surface size is divisible by the surface
scale. This wasn't guaranteed when creating new temporary windows.

This meant opening the preferences could exit Blender with an error
with Hi-DPI configurations.

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

M	intern/ghost/intern/GHOST_WindowWayland.cpp

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

diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp
index 5957e992436..9c179a6394f 100644
--- a/intern/ghost/intern/GHOST_WindowWayland.cpp
+++ b/intern/ghost/intern/GHOST_WindowWayland.cpp
@@ -797,11 +797,6 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system,
   window_->ghost_window = this;
   window_->ghost_system = system;
 
-  window_->frame.size[0] = int32_t(width);
-  window_->frame.size[1] = int32_t(height);
-
-  window_->is_dialog = is_dialog;
-
   /* NOTE(@campbellbarton): The scale set here to avoid flickering on startup.
    * When all monitors use the same scale (which is quite common) there aren't any problems.
    *
@@ -813,6 +808,16 @@ GHOST_WindowWayland::GHOST_WindowWayland(GHOST_SystemWayland *system,
    * avoiding a large window flashing before it's made smaller. */
   window_->scale = outputs_max_scale_or_default(system_->outputs(), 1, &window_->scale_fractional);
 
+  window_->frame.size[0] = int32_t(width);
+  window_->frame.size[1] = int32_t(height);
+
+  /* The window surface must be rounded to the scale,
+   * failing to do so causes the WAYLAND-server to close the window immediately. */
+  window_->frame.size[0] = (window_->frame.size[0] / window_->scale) * window_->scale;
+  window_->frame.size[1] = (window_->frame.size[1] / window_->scale) * window_->scale;
+
+  window_->is_dialog = is_dialog;
+
   /* Window surfaces. */
   window_->wl_surface = wl_compositor_create_surface(system_->wl_compositor());
   ghost_wl_surface_tag(window_->wl_surface);



More information about the Bf-blender-cvs mailing list