[mutter/gbsneto/screencast-improvements: 8/8] screen-cast-monitor-stream-src: Watch monitors using MetaStageWatch



commit db2f0d47b7f22a7d64199ddb4708740fb0778023
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Mon Jun 17 21:49:45 2019 -0300

    screen-cast-monitor-stream-src: Watch monitors using MetaStageWatch
    
    This uses the API introduced by the previous commit. By watching specific
    monitors directly, and not whole stage views, we avoid showing artifacts
    on multi-monitor setups.
    
    Fixes https://gitlab.gnome.org/GNOME/mutter/issues/424
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/623

 src/backends/meta-screen-cast-monitor-stream-src.c | 65 +++++++++++++++-------
 1 file changed, 44 insertions(+), 21 deletions(-)
---
diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c 
b/src/backends/meta-screen-cast-monitor-stream-src.c
index cb9823148..5bbc1e569 100644
--- a/src/backends/meta-screen-cast-monitor-stream-src.c
+++ b/src/backends/meta-screen-cast-monitor-stream-src.c
@@ -32,6 +32,7 @@
 #include "backends/meta-monitor.h"
 #include "backends/meta-screen-cast-monitor-stream.h"
 #include "backends/meta-screen-cast-session.h"
+#include "backends/meta-stage-private.h"
 #include "clutter/clutter.h"
 #include "clutter/clutter-mutter.h"
 #include "core/boxes-private.h"
@@ -42,8 +43,9 @@ struct _MetaScreenCastMonitorStreamSrc
 
   gboolean cursor_bitmap_invalid;
 
-  gulong actors_painted_handler_id;
-  gulong paint_handler_id;
+  MetaStageWatch *paint_watch;
+  MetaStageWatch *after_paint_watch;
+
   gulong cursor_moved_handler_id;
   gulong cursor_changed_handler_id;
 };
@@ -113,10 +115,11 @@ meta_screen_cast_monitor_stream_src_get_specs (MetaScreenCastStreamSrc *src,
 }
 
 static void
-stage_painted (ClutterActor                   *actor,
-               MetaScreenCastMonitorStreamSrc *monitor_src)
+stage_painted (MetaStage        *stage,
+               ClutterStageView *view,
+               gpointer          user_data)
 {
-  MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
+  MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (user_data);
 
   meta_screen_cast_stream_src_maybe_record_frame (src);
 }
@@ -245,12 +248,28 @@ meta_screen_cast_monitor_stream_src_enable (MetaScreenCastStreamSrc *src)
   MetaScreenCastMonitorStreamSrc *monitor_src =
     META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
   MetaBackend *backend = get_backend (monitor_src);
+  MetaRenderer *renderer = meta_backend_get_renderer (backend);
   MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
+  MetaRendererView *view;
+  MetaMonitor *monitor;
+  MetaLogicalMonitor *logical_monitor;
+  MetaStage *meta_stage;
+  ClutterStageView *stage_view;
   ClutterStage *stage;
   MetaScreenCastStream *stream;
 
   stream = meta_screen_cast_stream_src_get_stream (src);
   stage = get_stage (monitor_src);
+  meta_stage = META_STAGE (stage);
+  monitor = get_monitor (monitor_src);
+  logical_monitor = meta_monitor_get_logical_monitor (monitor);
+  view = meta_renderer_get_view_from_logical_monitor (renderer,
+                                                      logical_monitor);
+
+  if (view)
+    stage_view = CLUTTER_STAGE_VIEW (view);
+  else
+    stage_view = NULL;
 
   switch (meta_screen_cast_stream_get_cursor_mode (stream))
     {
@@ -265,17 +284,21 @@ meta_screen_cast_monitor_stream_src_enable (MetaScreenCastStreamSrc *src)
                                 monitor_src);
       /* Intentional fall-through */
     case META_SCREEN_CAST_CURSOR_MODE_HIDDEN:
-      monitor_src->actors_painted_handler_id =
-        g_signal_connect (stage, "actors-painted",
-                          G_CALLBACK (stage_painted),
-                          monitor_src);
+      monitor_src->paint_watch =
+        meta_stage_watch_view (meta_stage,
+                               stage_view,
+                               META_STAGE_WATCH_AFTER_ACTOR_PAINT,
+                               stage_painted,
+                               monitor_src);
       break;
     case META_SCREEN_CAST_CURSOR_MODE_EMBEDDED:
       inhibit_hw_cursor (monitor_src);
-      monitor_src->paint_handler_id =
-        g_signal_connect_after (stage, "paint",
-                                G_CALLBACK (stage_painted),
-                                monitor_src);
+      monitor_src->paint_watch =
+        meta_stage_watch_view (meta_stage,
+                               stage_view,
+                               META_STAGE_WATCH_AFTER_PAINT,
+                               stage_painted,
+                               monitor_src);
       break;
     }
 
@@ -290,21 +313,21 @@ meta_screen_cast_monitor_stream_src_disable (MetaScreenCastStreamSrc *src)
   MetaBackend *backend = get_backend (monitor_src);
   MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend);
   ClutterStage *stage;
+  MetaStage *meta_stage;
 
   stage = get_stage (monitor_src);
+  meta_stage = META_STAGE (stage);
 
-  if (monitor_src->actors_painted_handler_id)
+  if (monitor_src->paint_watch)
     {
-      g_signal_handler_disconnect (stage,
-                                   monitor_src->actors_painted_handler_id);
-      monitor_src->actors_painted_handler_id = 0;
+      meta_stage_remove_watch (meta_stage, monitor_src->paint_watch);
+      monitor_src->paint_watch = NULL;
     }
 
-  if (monitor_src->paint_handler_id)
+  if (monitor_src->after_paint_watch)
     {
-      g_signal_handler_disconnect (stage,
-                                   monitor_src->paint_handler_id);
-      monitor_src->paint_handler_id = 0;
+      meta_stage_remove_watch (meta_stage, monitor_src->after_paint_watch);
+      monitor_src->after_paint_watch = NULL;
       uninhibit_hw_cursor (monitor_src);
     }
 


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