gdk: Add ::enter/leave-monitor signals

These are useful to keep track of what monitors a window is on.
This commit is contained in:
Matthias Clasen 2017-11-28 22:36:17 -05:00
parent 64b0c63190
commit 3ee18b88b9
2 changed files with 60 additions and 0 deletions

View File

@ -185,6 +185,11 @@ gboolean gdk_surface_handle_event (GdkEvent *event);
GdkSeat * gdk_surface_get_seat_from_event (GdkSurface *surface,
GdkEvent *event);
void gdk_surface_enter_monitor (GdkSurface *surface,
GdkMonitor *monitor);
void gdk_surface_leave_monitor (GdkSurface *surface,
GdkMonitor *monitor);
/*****************************************
* Interfaces provided by windowing code *
*****************************************/
@ -296,6 +301,7 @@ void gdk_surface_get_geometry (GdkSurface *surface,
GdkGLContext *gdk_surface_get_shared_data_gl_context (GdkSurface *surface);
/*
* GdkSeatGrabPrepareFunc:
* @seat: the #GdkSeat being grabbed

View File

@ -76,6 +76,8 @@ enum {
SIZE_CHANGED,
RENDER,
EVENT,
ENTER_MONITOR,
LEAVE_MONITOR,
LAST_SIGNAL
};
@ -532,6 +534,44 @@ gdk_surface_class_init (GdkSurfaceClass *klass)
g_signal_set_va_marshaller (signals[EVENT],
G_OBJECT_CLASS_TYPE (object_class),
_gdk_marshal_BOOLEAN__BOXEDv);
/**
* GdkSurface::enter-montor:
* @surface: the #GdkSurface
* @monitor: the monitor
*
* Emitted when @surface starts being present on the monitor.
*/
signals[ENTER_MONITOR] =
g_signal_new (g_intern_static_string ("enter-monitor"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL,
NULL,
NULL,
G_TYPE_NONE,
1,
GDK_TYPE_MONITOR);
/**
* GdkSurface::leave-montor:
* @surface: the #GdkSurface
* @monitor: the monitor
*
* Emitted when @surface stops being present on the monitor.
*/
signals[LEAVE_MONITOR] =
g_signal_new (g_intern_static_string ("leave-monitor"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
0,
NULL,
NULL,
NULL,
G_TYPE_NONE,
1,
GDK_TYPE_MONITOR);
}
static void
@ -3035,3 +3075,17 @@ gdk_surface_get_seat_from_event (GdkSurface *surface,
}
return gdk_display_get_default_seat (surface->display);
}
void
gdk_surface_enter_monitor (GdkSurface *surface,
GdkMonitor *monitor)
{
g_signal_emit (surface, signals[ENTER_MONITOR], 0, monitor);
}
void
gdk_surface_leave_monitor (GdkSurface *surface,
GdkMonitor *monitor)
{
g_signal_emit (surface, signals[LEAVE_MONITOR], 0, monitor);
}