[gtk-osx] Gtk3, macOS12 CGContextConvertSizeToDeviceSpace returns negative height.



commit 34b30ae7d52b509c8bf76c696cadaa75d43db342
Author: John Ralls <jralls ceridwen us>
Date:   Thu Oct 14 12:52:53 2021 -0700

    Gtk3, macOS12 CGContextConvertSizeToDeviceSpace returns negative height.

 jhbuildrc-gtk-osx                       |  1 +
 modulesets-stable/gtk-osx.modules       |  1 +
 modulesets-unstable/gtk-osx.modules     |  2 +-
 patches/gtk+-scale-absolute-value.patch | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 35 insertions(+), 1 deletion(-)
---
diff --git a/jhbuildrc-gtk-osx b/jhbuildrc-gtk-osx
index e498cf52..155d5078 100644
--- a/jhbuildrc-gtk-osx
+++ b/jhbuildrc-gtk-osx
@@ -611,6 +611,7 @@ if not _ran_recursively and _gtk_osx_prompt_prefix:
 # Note that this will break if there's an undetected python3 build and
 # the built python is a different major + minor version from the
 # virtenv one.
+print('\n'.join(modules))
 if 'python3' in modules or 'meta-gtk-osx-python3' in modules:
     os.environ['PYTHON'] = os.path.join(prefix, 'bin', 'python3')
     module_extra_env['pkg-config'] = {'PYTHON':sys.executable}
diff --git a/modulesets-stable/gtk-osx.modules b/modulesets-stable/gtk-osx.modules
index d5b678ba..27970cb5 100644
--- a/modulesets-stable/gtk-osx.modules
+++ b/modulesets-stable/gtk-osx.modules
@@ -299,6 +299,7 @@
     <branch module="gtk+/3.24/gtk+-3.24.30.tar.xz" version="3.24.30"
             hash="sha256:ba75bfff320ad1f4cfbee92ba813ec336322cc3c660d406aad014b07087a3ba9">
       <patch file="Quartz-version-detection-for-macOS-12.patch" strip="1"/>
+      <patch file="gtk+-scale-absolute-value.patch" strip="1"/>
     </branch>
     <dependencies>
       <dep package="glib"/>
diff --git a/modulesets-unstable/gtk-osx.modules b/modulesets-unstable/gtk-osx.modules
index a3bf9628..d10f65f4 100644
--- a/modulesets-unstable/gtk-osx.modules
+++ b/modulesets-unstable/gtk-osx.modules
@@ -256,7 +256,7 @@
   </autotools>
 
   <meson id="gtk+-4.0"
-             mesonargs="-Dquartz-backend=true -Dx11-backend=false -Dmedia=none">
+             mesonargs="-Dquartz-backend=true -Dx11-backend=false -Dmedia-gstreamer=disabled">
     <branch module="gtk" checkoutdir="gtk-4.0"/>
     <dependencies>
       <dep package="glib"/>
diff --git a/patches/gtk+-scale-absolute-value.patch b/patches/gtk+-scale-absolute-value.patch
new file mode 100644
index 00000000..d0a49a13
--- /dev/null
+++ b/patches/gtk+-scale-absolute-value.patch
@@ -0,0 +1,32 @@
+From 36315cbe2b3c9d1c1b7508d9494a251eddbc4452 Mon Sep 17 00:00:00 2001
+From: John Ralls <jralls ceridwen us>
+Date: Thu, 14 Oct 2021 12:41:05 -0700
+Subject: [PATCH] [quartz]Use the absolute value of Scale values for
+ CGContextScaleSCM
+
+In macOS-12.sdk CGContextConverSizeToDeviceSpace returns a negative
+height and passing that to CGContextScaleCTM in turn causes the cairo
+surface to draw outside the window where it can't be seen. Passing the
+absolute values of the scale factors fixes the display on macOS 12 without
+affecting earlier macOS versions.
+---
+ gdk/quartz/gdkwindow-quartz.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
+index 1a3389bb32..a5c5c31945 100644
+--- a/gdk/quartz/gdkwindow-quartz.c
++++ b/gdk/quartz/gdkwindow-quartz.c
+@@ -183,8 +183,7 @@ gdk_window_impl_quartz_get_context (GdkWindowImplQuartz *window_impl,
+    * in gdk_quartz_ref_cairo_surface () */
+   scale = CGContextConvertSizeToDeviceSpace (cg_context,
+                                              CGSizeMake (1.0, 1.0));
+-  CGContextScaleCTM (cg_context, 1.0 / scale.width, 1.0 / scale.height);
+-
++  CGContextScaleCTM (cg_context, 1.0 / fabs(scale.width), 1.0 / fabs(scale.height));
+   return cg_context;
+ }
+ 
+-- 
+2.30.1 (Apple Git-130)
+


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