[gtk/wip/matthiasc/monitor-signals: 9389/9389] wayland: emit ::enter/leave-monitor



commit 209398d736cc3a9af79b2f236453079fcc24dff4
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Nov 28 22:37:42 2017 -0500

    wayland: emit ::enter/leave-monitor
    
    These signals directly mirror the surface_enter/leave events
    of the Wayland protocol, so this is very staightforward.

 gdk/wayland/gdkdisplay-wayland.c |  7 +++++++
 gdk/wayland/gdkprivate-wayland.h |  2 ++
 gdk/wayland/gdksurface-wayland.c | 10 ++++++++++
 3 files changed, 19 insertions(+)
---
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index dc8c52f305..e30acdad1b 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -2539,6 +2539,13 @@ get_monitor_for_output (GdkWaylandDisplay *display_wayland,
   return NULL;
 }
 
+GdkMonitor *
+gdk_wayland_display_get_monitor_for_output (GdkDisplay       *display,
+                                            struct wl_output *output)
+{
+  return (GdkMonitor *)get_monitor_for_output (GDK_WAYLAND_DISPLAY (display), output);
+}
+
 static void
 gdk_wayland_display_remove_output (GdkWaylandDisplay *display_wayland,
                                    guint32            id)
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index 13dbd221e0..99fa9b5d4b 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -163,6 +163,8 @@ guint32 gdk_wayland_display_get_output_scale (GdkWaylandDisplay *display_wayland
                                               struct wl_output  *output);
 struct wl_output *gdk_wayland_display_get_wl_output (GdkDisplay *display,
                                                      int         monitor_num);
+GdkMonitor *gdk_wayland_display_get_monitor_for_output (GdkDisplay       *display,
+                                                        struct wl_output *output);
 
 void _gdk_wayland_surface_set_grab_seat (GdkSurface      *surface,
                                         GdkSeat        *seat);
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 06de4fa500..82fae79e8e 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -1201,6 +1201,8 @@ surface_enter (void              *data,
 {
   GdkSurface *surface = GDK_SURFACE (data);
   GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
+  GdkDisplay *display = gdk_surface_get_display (surface);
+  GdkMonitor *monitor;
 
   GDK_DISPLAY_NOTE (gdk_surface_get_display (surface), EVENTS,
             g_message ("surface enter, surface %p output %p", surface, output));
@@ -1208,6 +1210,9 @@ surface_enter (void              *data,
   impl->display_server.outputs = g_slist_prepend (impl->display_server.outputs, output);
 
   gdk_wayland_surface_update_scale (surface);
+
+  monitor = gdk_wayland_display_get_monitor_for_output (display, output);
+  gdk_surface_enter_monitor (surface, monitor);
 }
 
 static void
@@ -1217,6 +1222,8 @@ surface_leave (void              *data,
 {
   GdkSurface *surface = GDK_SURFACE (data);
   GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface);
+  GdkDisplay *display = gdk_surface_get_display (surface);
+  GdkMonitor *monitor;
 
   GDK_DISPLAY_NOTE (gdk_surface_get_display (surface), EVENTS,
             g_message ("surface leave, surface %p output %p", surface, output));
@@ -1225,6 +1232,9 @@ surface_leave (void              *data,
 
   if (impl->display_server.outputs)
     gdk_wayland_surface_update_scale (surface);
+
+  monitor = gdk_wayland_display_get_monitor_for_output (display, output);
+  gdk_surface_leave_monitor (surface, monitor);
 }
 
 static const struct wl_surface_listener surface_listener = {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]