From f63359251ac567393dbcf916db770674aabd36b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 5 May 2021 15:28:46 +0200 Subject: [PATCH] gdk/wayland: Take transform into account when setting physical size --- ...sform-into-account-when-setting-phys.patch | 47 +++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 48 insertions(+) create mode 100644 debian/patches/gdk-wayland-Take-transform-into-account-when-setting-phys.patch diff --git a/debian/patches/gdk-wayland-Take-transform-into-account-when-setting-phys.patch b/debian/patches/gdk-wayland-Take-transform-into-account-when-setting-phys.patch new file mode 100644 index 0000000000..1087c615f9 --- /dev/null +++ b/debian/patches/gdk-wayland-Take-transform-into-account-when-setting-phys.patch @@ -0,0 +1,47 @@ +From: =?utf-8?q?Guido_G=C3=BCnther?= +Date: Wed, 5 May 2021 13:59:26 +0200 +Subject: gdk/wayland: Take transform into account when setting physical size + +Width and height of a GdkMonitor are derived via wl_output which +talks about physical dimensions of a device and compositors usually +implement this as the untransformed values (e.g. weston, wlroots). + +Since the GTK client has no way to figure out if a monitor was rotated, +transform the physical dimensions according to the applied wayland +transform to have the physical dimensions match the logical ones. + +Mutter flips the physical dimensions itself but doesn't announce the +transform so this shouldn't break anything there. + +Upstream-Reference: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/3515 +--- + gdk/wayland/gdkscreen-wayland.c | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +diff --git a/gdk/wayland/gdkscreen-wayland.c b/gdk/wayland/gdkscreen-wayland.c +index 084c1e3..d122834 100644 +--- a/gdk/wayland/gdkscreen-wayland.c ++++ b/gdk/wayland/gdkscreen-wayland.c +@@ -1630,7 +1630,21 @@ output_handle_geometry (void *data, + + monitor->x = x; + monitor->y = y; +- gdk_monitor_set_physical_size (GDK_MONITOR (monitor), physical_width, physical_height); ++ ++ switch (transform) ++ { ++ case WL_OUTPUT_TRANSFORM_90: ++ case WL_OUTPUT_TRANSFORM_270: ++ case WL_OUTPUT_TRANSFORM_FLIPPED_90: ++ case WL_OUTPUT_TRANSFORM_FLIPPED_270: ++ gdk_monitor_set_physical_size (GDK_MONITOR (monitor), ++ physical_height, physical_width); ++ break; ++ default: ++ gdk_monitor_set_physical_size (GDK_MONITOR (monitor), ++ physical_width, physical_height); ++ } ++ + gdk_monitor_set_subpixel_layout (GDK_MONITOR (monitor), subpixel); + gdk_monitor_set_manufacturer (GDK_MONITOR (monitor), make); + gdk_monitor_set_model (GDK_MONITOR (monitor), model); diff --git a/debian/patches/series b/debian/patches/series index 8f5a7071cb..7b9b2998e7 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -39,3 +39,4 @@ printunixdialog-Adapt-for-phones.patch window-Disable-window-dragging-on-phones.patch events-Compress-touch-update-events.patch librem5-Make-GtkShortcutsWindow-adaptive.patch +gdk-wayland-Take-transform-into-account-when-setting-phys.patch -- GitLab