diff --git a/src/backends/meta-eis-viewport.c b/src/backends/meta-eis-viewport.c index 74533a83d..84962b71a 100644 --- a/src/backends/meta-eis-viewport.c +++ b/src/backends/meta-eis-viewport.c @@ -20,11 +20,26 @@ #include "backends/meta-eis-viewport.h" +enum +{ + VIEWPORT_CHANGED, + + N_SIGNALS +}; + +static guint signals[N_SIGNALS]; + G_DEFINE_INTERFACE (MetaEisViewport, meta_eis_viewport, G_TYPE_OBJECT) static void meta_eis_viewport_default_init (MetaEisViewportInterface *iface) { + signals[VIEWPORT_CHANGED] = + g_signal_new ("viewport-changed", + G_TYPE_FROM_INTERFACE (iface), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 0); } gboolean @@ -78,3 +93,9 @@ meta_eis_viewport_transform_coordinate (MetaEisViewport *viewport, out_x, out_y); } + +void +meta_eis_viewport_notify_changed (MetaEisViewport *viewport) +{ + g_signal_emit (viewport, signals[VIEWPORT_CHANGED], 0); +} diff --git a/src/backends/meta-eis-viewport.h b/src/backends/meta-eis-viewport.h index 20fde137a..5b7e558d6 100644 --- a/src/backends/meta-eis-viewport.h +++ b/src/backends/meta-eis-viewport.h @@ -68,3 +68,5 @@ gboolean meta_eis_viewport_transform_coordinate (MetaEisViewport *viewport, double y, double *out_x, double *out_y); + +void meta_eis_viewport_notify_changed (MetaEisViewport *viewport); diff --git a/src/backends/meta-eis.c b/src/backends/meta-eis.c index e51e9582a..a1b35f787 100644 --- a/src/backends/meta-eis.c +++ b/src/backends/meta-eis.c @@ -315,18 +315,29 @@ meta_eis_get_device_types (MetaEis *eis) return eis->device_types; } +static void +on_viewport_changed (MetaEisViewport *viewport, + MetaEis *eis) +{ + g_signal_emit (eis, signals[VIEWPORTS_CHANGED], 0); +} + void meta_eis_add_viewport (MetaEis *eis, MetaEisViewport *viewport) { eis->viewports = g_list_append (eis->viewports, viewport); g_signal_emit (eis, signals[VIEWPORTS_CHANGED], 0); + + g_signal_connect (viewport, "viewport-changed", + G_CALLBACK (on_viewport_changed), eis); } void meta_eis_remove_viewport (MetaEis *eis, MetaEisViewport *viewport) { + g_signal_handlers_disconnect_by_func (viewport, on_viewport_changed, eis); eis->viewports = g_list_remove (eis->viewports, viewport); g_signal_emit (eis, signals[VIEWPORTS_CHANGED], 0); } @@ -335,6 +346,16 @@ void meta_eis_take_viewports (MetaEis *eis, GList *viewports) { + GList *l; + + for (l = viewports; l; l = l->next) + { + MetaEisViewport *viewport = l->data; + + g_signal_connect (viewport, "viewport-changed", + G_CALLBACK (on_viewport_changed), eis); + } + eis->viewports = g_list_concat (eis->viewports, viewports); g_signal_emit (eis, signals[VIEWPORTS_CHANGED], 0); } @@ -342,6 +363,15 @@ meta_eis_take_viewports (MetaEis *eis, void meta_eis_remove_all_viewports (MetaEis *eis) { + GList *l; + + for (l = eis->viewports; l; l = l->next) + { + MetaEisViewport *viewport = l->data; + + g_signal_handlers_disconnect_by_func (viewport, on_viewport_changed, eis); + } + g_clear_pointer (&eis->viewports, g_list_free); g_signal_emit (eis, signals[VIEWPORTS_CHANGED], 0); } diff --git a/src/backends/meta-screen-cast-virtual-stream-src.c b/src/backends/meta-screen-cast-virtual-stream-src.c index 94e5425b6..2047485f9 100644 --- a/src/backends/meta-screen-cast-virtual-stream-src.c +++ b/src/backends/meta-screen-cast-virtual-stream-src.c @@ -22,6 +22,7 @@ #include "backends/meta-crtc-mode.h" #include "backends/meta-cursor-tracker-private.h" +#include "backends/meta-eis-viewport.h" #include "backends/meta-monitor.h" #include "backends/meta-output.h" #include "backends/meta-screen-cast-session.h" @@ -243,10 +244,13 @@ on_monitors_changed (MetaMonitorManager *monitor_manager, { MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (virtual_src); MetaStage *stage = META_STAGE (stage_from_src (src)); + MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src); meta_stage_remove_watch (stage, virtual_src->watch); virtual_src->watch = NULL; add_watch (virtual_src); + + meta_eis_viewport_notify_changed (META_EIS_VIEWPORT (stream)); } static void