[gimp] Issue #5322: [Wayland] broken splash size.



commit 7e6ced5c99c531038a2e5bec212823e96acd7e9c
Author: Jehan <jehan girinstud io>
Date:   Sun Oct 25 00:41:32 2020 +0200

    Issue #5322: [Wayland] broken splash size.
    
    This is not a fix, only an extra-ugly workaround so that at the very
    least we don't end up with a splash screen taking the whole display on
    Wayland.
    
    Basically by setting 1/3 as the max splash size, a Wayland desktop with
    no scale ratio will have a splash taking a third of the screen while it
    would take 2/3 of the screen with a scale ratio of ×2 (of course, it
    will still be very broken with a scale ratio of ×3 but are there
    displays needing such high scaling?). The real fix will be when GTK/GDK
    fix their API so that it returns what the docs says it should (i.e. a
    size in "application pixels" not "device pixels"), as it does on X11,
    Windows, macOS… Then we won't create random max size and we will be able
    to properly control our splash size.
    
    Note that this neither fixes nor works around the position issue on
    Wayland (in my case, the splash was just always on top-left of the
    display).

 app/gui/splash.c | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/app/gui/splash.c b/app/gui/splash.c
index 18f0595a66..a9ab59b3d3 100644
--- a/app/gui/splash.c
+++ b/app/gui/splash.c
@@ -21,6 +21,9 @@
 
 #include <gegl.h>
 #include <gtk/gtk.h>
+#ifdef GDK_WINDOWING_WAYLAND
+#include <gdk/gdkwayland.h>
+#endif
 
 #include "libgimpbase/gimpbase.h"
 #include "libgimpmath/gimpmath.h"
@@ -123,8 +126,34 @@ splash_create (Gimp       *gimp,
 
   gdk_monitor_get_workarea (monitor, &workarea);
 
-  max_width  = workarea.width  / 2;
-  max_height = workarea.height / 2;
+#ifdef GDK_WINDOWING_WAYLAND
+  if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
+    {
+      /* This is completely extra ugly. Basically we cannot rely on
+       * gdk_monitor_get_workarea() on Wayland because the application
+       * cannot get trustworthy values. Indeed it is supposed to return
+       * a value in "application pixels" not "device pixels", in other
+       * words already inverse-scaled value. It turns out that on
+       * Wayland, under some conditions (but maybe not even all the
+       * time? I'm still unclear if there are conditions where returned
+       * value is properly scaled), it returns the device dimensions.
+       * E.g. on high-density display x2, making a splash for half the
+       * value, we ended up actually with the size of the whole display.
+       * This is why I special-case Wayland with a max of a third of the
+       * work area so that it would end up 2/3 maximum (at least not
+       * filling the screen!).
+       * This is ugly but for now I don't see the right solution. FIXME!
+       * See #5322.
+       */
+      max_width  = workarea.width  / 3;
+      max_height = workarea.height / 3;
+    }
+  else
+#endif
+    {
+      max_width  = workarea.width  / 2;
+      max_height = workarea.height / 2;
+    }
   pixbuf = splash_image_load (gimp, max_width, max_height, be_verbose);
 
   if (! pixbuf)


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