File gtk3-gdk_x11_window_get_frame_extents-with-window-borders.patch of Package gtk3

From c02fd6f0edfe460d11eaf6ceb039012971f725a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= <emilio@crisal.io>
Date: Fri, 4 Apr 2025 23:43:19 +0200
Subject: [PATCH 1/2] [gtk3] fix gdk_x11_window_get_frame_extents with window
 borders.

As per [1], width and height are inner sizes:

   Return the drawable's dimensions (width and height). For a window,
   these dimensions specify the inside size, not including the border.

The frame extents are supposed to include the border, so account for
that. The top left coordinate is already correct.

This fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1958174

[1]: https://tronche.com/gui/x/xlib/window-information/XGetGeometry.html
---
 gdk/x11/gdkwindow-x11.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index e5f5e1275d6..8ad9911aebb 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -3315,8 +3315,8 @@ gdk_x11_window_get_frame_extents (GdkWindow    *window,
             {
 	      rect->x = wx;
 	      rect->y = wy;
-	      rect->width = ww;
-	      rect->height = wh;
+	      rect->width = ww + wb * 2;
+	      rect->height = wh + wb * 2;
 	    }
 
 	  /* _NET_FRAME_EXTENTS format is left, right, top, bottom */
@@ -3388,8 +3388,8 @@ gdk_x11_window_get_frame_extents (GdkWindow    *window,
     {
       rect->x = wx;
       rect->y = wy;
-      rect->width = ww;
-      rect->height = wh;
+      rect->width = ww + wb * 2;
+      rect->height = wh + wb * 2;
     }
 
  out:
-- 
GitLab


From d9b1ace304f4ae17b50fd4788baa368b3f879f86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= <emilio@crisal.io>
Date: Sun, 6 Apr 2025 23:25:19 +0200
Subject: [PATCH 2/2] [gtk3] Make gtk_window_get_geometry account for X window
 borders sizes too.

This function cares about the inner geometry, so for consistency with
_NET_FRAME_EXTENTS-supporting WMs it should return the inner coordinates
too.

I gave this a spin on bspwm with gtk4-demo and things seemed to work
just fine, also with some applications like nautilus and so on.

Note that returning the outer size (which is the other alternative to
return something reasonable) causes cropped content on gtk3 + Firefox,
which relies on get_frame_extents - {get_origin, get_geometry size} to
compute the system margin around the window.
---
 gdk/x11/gdkwindow-x11.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 8ad9911aebb..0c59ad464ed 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -3197,9 +3197,9 @@ gdk_window_x11_get_geometry (GdkWindow *window,
 		    &root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);
       
       if (x)
-	*x = tx / impl->window_scale;
+	*x = (tx + tborder_width) / impl->window_scale;
       if (y)
-	*y = ty / impl->window_scale;
+	*y = (ty + tborder_width) / impl->window_scale;
       if (width)
 	*width = twidth / impl->window_scale;
       if (height)
-- 
GitLab

openSUSE Build Service is sponsored by