git: 57c50ac3760e - main - x11-toolkits/gtk30: backport 2 patches for wayland

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Fri, 03 Dec 2021 07:45:06 UTC
The branch main has been updated by bapt:

URL: https://cgit.FreeBSD.org/ports/commit/?id=57c50ac3760e5c07f08ae8bd808685a5ddee521f

commit 57c50ac3760e5c07f08ae8bd808685a5ddee521f
Author:     Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2021-12-03 07:42:23 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2021-12-03 07:45:02 +0000

    x11-toolkits/gtk30: backport 2 patches for wayland
    
    Those 2 patches are fixing a bug shown by firefox under wayland:
    when running a wayland desktop with dual screen and different settings
    for the 2 screens, the combobox were not functionnal if firefox is on
    the second screen.
---
 x11-toolkits/gtk30/Makefile                        |  4 ++
 ...k-if-size-changed-before-hiding-a-surface.patch | 59 ++++++++++++++++++++++
 ...-Ignore-wl_output-globals-not-bound-by-us.patch | 34 +++++++++++++
 3 files changed, 97 insertions(+)

diff --git a/x11-toolkits/gtk30/Makefile b/x11-toolkits/gtk30/Makefile
index 8e3848ad6844..fa9d290eac86 100644
--- a/x11-toolkits/gtk30/Makefile
+++ b/x11-toolkits/gtk30/Makefile
@@ -4,6 +4,7 @@
 
 PORTNAME=	gtk
 PORTVERSION=	3.24.30
+PORTREVISION=	1
 CATEGORIES=	x11-toolkits
 MASTER_SITES=	GNOME/sources/gtk+/${PORTVERSION:C/^([0-9]+\.[0-9]+).*/\1/}
 PKGNAMESUFFIX=	3
@@ -13,6 +14,9 @@ DIST_SUBDIR=	gnome
 MAINTAINER=	desktop@FreeBSD.org
 COMMENT=	Gimp Toolkit for X11 GUI (current stable version)
 
+EXTRA_PATCHES=	${FILESDIR}/0001-Check-if-size-changed-before-hiding-a-surface.patch:-p1 \
+		${FILESDIR}/0001-Ignore-wl_output-globals-not-bound-by-us.patch:-p1
+
 LICENSE=	LGPL20
 
 PORTSCOUT=	limit:1,even
diff --git a/x11-toolkits/gtk30/files/0001-Check-if-size-changed-before-hiding-a-surface.patch b/x11-toolkits/gtk30/files/0001-Check-if-size-changed-before-hiding-a-surface.patch
new file mode 100644
index 000000000000..578464e41f15
--- /dev/null
+++ b/x11-toolkits/gtk30/files/0001-Check-if-size-changed-before-hiding-a-surface.patch
@@ -0,0 +1,59 @@
+From 23c7e6e13bbe2c6b736e817f501dc0dd5b242787 Mon Sep 17 00:00:00 2001
+From: Ronan Pigott <rpigott@berkeley.edu>
+Date: Mon, 13 Sep 2021 17:14:14 -0700
+Subject: [PATCH] Check if size changed before hiding a surface
+
+Commit 68188fc948 introduces a workaround for clients that try to
+change the size of a popup after it is created, but inadvertently
+introduces an infinite loop of surface creation when the popup enters
+two or more wl_outputs with different scales on creation.
+
+This commit checks if the size actually changed before applying the
+workaround and avoids the loop.
+---
+ gdk/wayland/gdkwindow-wayland.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
+index 1e82dcae3e..5d300a94ce 100644
+--- a/gdk/wayland/gdkwindow-wayland.c
++++ b/gdk/wayland/gdkwindow-wayland.c
+@@ -1199,6 +1199,7 @@ gdk_wayland_window_maybe_configure (GdkWindow *window,
+   GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+   gboolean is_xdg_popup;
+   gboolean is_visible;
++  gboolean size_changed;
+ 
+   impl->unconfigured_width = calculate_width_without_margin (window, width);
+   impl->unconfigured_height = calculate_height_without_margin (window, height);
+@@ -1206,9 +1207,8 @@ gdk_wayland_window_maybe_configure (GdkWindow *window,
+   if (should_inhibit_resize (window))
+     return;
+ 
+-  if (window->width == width &&
+-      window->height == height &&
+-      impl->scale == scale)
++  size_changed = (window->width != width || window->height != height);
++  if (!size_changed && impl->scale == scale)
+     return;
+ 
+   /* For xdg_popup using an xdg_positioner, there is a race condition if
+@@ -1222,6 +1222,7 @@ gdk_wayland_window_maybe_configure (GdkWindow *window,
+ 
+   if (is_xdg_popup &&
+       is_visible &&
++      size_changed &&
+       !impl->initial_configure_received &&
+       !impl->configuring_popup)
+     gdk_window_hide (window);
+@@ -1230,6 +1231,7 @@ gdk_wayland_window_maybe_configure (GdkWindow *window,
+ 
+   if (is_xdg_popup &&
+       is_visible &&
++      size_changed &&
+       !impl->initial_configure_received &&
+       !impl->configuring_popup)
+     gdk_window_show (window);
+-- 
+2.33.1
+
diff --git a/x11-toolkits/gtk30/files/0001-Ignore-wl_output-globals-not-bound-by-us.patch b/x11-toolkits/gtk30/files/0001-Ignore-wl_output-globals-not-bound-by-us.patch
new file mode 100644
index 000000000000..1391d2e38458
--- /dev/null
+++ b/x11-toolkits/gtk30/files/0001-Ignore-wl_output-globals-not-bound-by-us.patch
@@ -0,0 +1,34 @@
+From 9a4e32892896ce1d0a92f413845f6f7f18f9b456 Mon Sep 17 00:00:00 2001
+From: Ronan Pigott <rpigott@berkeley.edu>
+Date: Sat, 11 Sep 2021 17:22:12 -0700
+Subject: [PATCH] Ignore wl_output globals not bound by us
+
+Gdk doesn't know the scale of output globals it didn't bind. This
+keeps them from entering the output list and triggering erroneous
+changes in surface scales.
+---
+ gdk/wayland/gdkwindow-wayland.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
+index 2d7c42bd7a..1e82dcae3e 100644
+--- a/gdk/wayland/gdkwindow-wayland.c
++++ b/gdk/wayland/gdkwindow-wayland.c
+@@ -1520,6 +1520,14 @@ surface_enter (void              *data,
+ {
+   GdkWindow *window = GDK_WINDOW (data);
+   GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
++  GdkWaylandDisplay *display_wayland =
++    GDK_WAYLAND_DISPLAY (gdk_window_get_display (window));
++  gboolean output_is_unmanaged;
++
++  output_is_unmanaged =
++    _gdk_wayland_screen_get_output_scale (display_wayland->screen, output) == 0;
++  if (output_is_unmanaged)
++    return;
+ 
+   GDK_NOTE (EVENTS,
+             g_message ("surface enter, window %p output %p", window, output));
+-- 
+2.33.1
+