From 3d707b42e4286c29e6485872bf4e34cb850d435e Mon Sep 17 00:00:00 2001 From: Jehan Date: Mon, 9 Feb 2026 14:04:44 +0100 Subject: [PATCH] libgimpwidgets: have gimp_widget_get_monitor() work on Wayland too. Our historical heuristic looking for the main monitor based on the position of the center point in a widget just won't work on Wayland, where reported positions are always (0, 0). This is the security policy for this protocol. Instead we must now use gdk_display_get_monitor_at_window() which is meant to do the approximation of determining the monitor a surface is in, for us. This is one step of implementing color management for Wayland (#15827), except we still need the code to get the ICC profile of a monitor (but now at least, we know which monitor we are on). --- libgimpwidgets/gimpwidgetsutils.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/libgimpwidgets/gimpwidgetsutils.c b/libgimpwidgets/gimpwidgetsutils.c index 9ef5d0ef9c..8f669fd5ae 100644 --- a/libgimpwidgets/gimpwidgetsutils.c +++ b/libgimpwidgets/gimpwidgetsutils.c @@ -373,9 +373,7 @@ gimp_label_set_attributes (GtkLabel *label, GdkMonitor * gimp_widget_get_monitor (GtkWidget *widget) { - GdkWindow *window; - GtkAllocation allocation; - gint x, y; + GdkWindow *window; g_return_val_if_fail (GTK_IS_WIDGET (widget), 0); @@ -384,19 +382,7 @@ gimp_widget_get_monitor (GtkWidget *widget) if (! window) return gimp_get_monitor_at_pointer (); - gdk_window_get_origin (window, &x, &y); - gtk_widget_get_allocation (widget, &allocation); - - if (! gtk_widget_get_has_window (widget)) - { - x += allocation.x; - y += allocation.y; - } - - x += allocation.width / 2; - y += allocation.height / 2; - - return gdk_display_get_monitor_at_point (gdk_display_get_default (), x, y); + return gdk_display_get_monitor_at_window (gdk_window_get_display (window), window); } /**