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).
This commit is contained in:
Jehan 2026-02-09 14:04:44 +01:00
parent f08eff5cda
commit 3d707b42e4

View file

@ -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);
}
/**