display: Add vfunc for get_monitor_at_window
Some backends (namely Wayland) do not support global coordinates so using the window position to determine the monitor will always fail on such backends. In such cases, the backend itself might be better suited to identify the monitor a given window resides on. Add a vfunc get_monitor_at_window() to the display class so that we can use the backend to retrieve the monitor, if the backend implements it. https://bugzilla.gnome.org/show_bug.cgi?id=766566
This commit is contained in:
parent
fa9f22eec4
commit
d288a134a4
@ -2692,9 +2692,20 @@ gdk_display_get_monitor_at_window (GdkDisplay *display,
|
|||||||
int n_monitors, i;
|
int n_monitors, i;
|
||||||
int area = 0;
|
int area = 0;
|
||||||
GdkMonitor *best = NULL;
|
GdkMonitor *best = NULL;
|
||||||
|
GdkWindowImplClass *impl_class;
|
||||||
|
GdkDisplayClass *class;
|
||||||
|
|
||||||
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
|
||||||
|
|
||||||
|
class = GDK_DISPLAY_GET_CLASS (display);
|
||||||
|
if (class->get_monitor_at_window)
|
||||||
|
{
|
||||||
|
best = class->get_monitor_at_window (display, window);
|
||||||
|
|
||||||
|
if (best)
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
|
||||||
gdk_window_get_geometry (window, &win.x, &win.y, &win.width, &win.height);
|
gdk_window_get_geometry (window, &win.x, &win.y, &win.width, &win.height);
|
||||||
gdk_window_get_origin (window, &win.x, &win.y);
|
gdk_window_get_origin (window, &win.x, &win.y);
|
||||||
|
|
||||||
|
@ -246,6 +246,8 @@ struct _GdkDisplayClass
|
|||||||
GdkMonitor * (*get_monitor) (GdkDisplay *display,
|
GdkMonitor * (*get_monitor) (GdkDisplay *display,
|
||||||
int index);
|
int index);
|
||||||
GdkMonitor * (*get_primary_monitor) (GdkDisplay *display);
|
GdkMonitor * (*get_primary_monitor) (GdkDisplay *display);
|
||||||
|
GdkMonitor * (*get_monitor_at_window) (GdkDisplay *display,
|
||||||
|
GdkWindow *window);
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
void (*opened) (GdkDisplay *display);
|
void (*opened) (GdkDisplay *display);
|
||||||
|
Loading…
Reference in New Issue
Block a user