Commit b03784eb authored by Olivier Fourdan's avatar Olivier Fourdan

wayland: Add get_monitor_at_window to Wayland backend

Given that Wayland has no global coordinate, the only way for gdk to
retrieve the monitor a window last entered is to retrieve it from the
GdkWaylandWindow itself.

Implement the backend specific get_monitor_at_window() to return the
monitor that was last entered by the window.
parent ca77de05
......@@ -37,6 +37,7 @@
#include "gdkkeysprivate.h"
#include "gdkprivate-wayland.h"
#include "gdkglcontext-wayland.h"
#include "gdkwaylandmonitor.h"
#include "pointer-gestures-unstable-v1-client-protocol.h"
#include "tablet-unstable-v1-client-protocol.h"
......@@ -840,6 +841,31 @@ gdk_wayland_display_get_monitor (GdkDisplay *display,
return (GdkMonitor *)display_wayland->monitors->pdata[monitor_num];
static GdkMonitor *
gdk_wayland_display_get_monitor_at_window (GdkDisplay *display,
GdkWindow *window)
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
struct wl_output *output;
int i;
g_return_val_if_fail (GDK_IS_WAYLAND_WINDOW (window), NULL);
output = gdk_wayland_window_get_wl_output (window);
if (output == NULL)
return NULL;
for (i = 0; i < display_wayland->monitors->len; i++)
GdkMonitor *monitor = display_wayland->monitors->pdata[i];
if (gdk_wayland_monitor_get_wl_output (monitor) == output)
return monitor;
return NULL;
static void
gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
......@@ -894,6 +920,7 @@ gdk_wayland_display_class_init (GdkWaylandDisplayClass *class)
display_class->get_n_monitors = gdk_wayland_display_get_n_monitors;
display_class->get_monitor = gdk_wayland_display_get_monitor;
display_class->get_monitor_at_window = gdk_wayland_display_get_monitor_at_window;
static void
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment