[mutter/wip/carlosg/grabs-pt1: 14/17] clutter: Integrate ClutterSeat grabs into ClutterGrab




commit 5186803742fa28d3876db0c6a8d4dab34f5580bd
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Oct 28 17:05:44 2021 +0200

    clutter: Integrate ClutterSeat grabs into ClutterGrab
    
    As ClutterGrab is a stack, the backend only cares about some grab
    existing currently or not. Make it sure that we grab whenever we
    go to >=1 grabs, and ungrab whenever we go to <1.

 clutter/clutter/clutter-stage.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 51d3fa4e79..d7ffc6c12f 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -62,6 +62,7 @@
 #include "clutter-paint-volume-private.h"
 #include "clutter-pick-context-private.h"
 #include "clutter-private.h"
+#include "clutter-seat-private.h"
 #include "clutter-stage-manager-private.h"
 #include "clutter-stage-private.h"
 #include "clutter-stage-view-private.h"
@@ -3767,6 +3768,17 @@ clutter_grab (ClutterStage *stage,
   clutter_actor_attach_grab (actor, grab);
   clutter_stage_notify_grab (stage, grab, grab->next);
 
+  if (!grab->next)
+    {
+      ClutterMainContext *context;
+      ClutterSeat *seat;
+
+      /* First grab in the chain, trigger a backend grab too */
+      context = _clutter_context_get_default ();
+      seat = clutter_backend_get_default_seat (context->backend);
+      clutter_seat_grab (seat, clutter_get_current_event_time ());
+    }
+
   return grab;
 }
 
@@ -3795,6 +3807,17 @@ clutter_ungrab (ClutterStage *stage,
 
   clutter_actor_detach_grab (grab->actor, grab);
   g_free (grab);
+
+  if (!priv->grabs)
+    {
+      ClutterMainContext *context;
+      ClutterSeat *seat;
+
+      /* This was the last remaining grab, trigger a backend ungrab */
+      context = _clutter_context_get_default ();
+      seat = clutter_backend_get_default_seat (context->backend);
+      clutter_seat_ungrab (seat, clutter_get_current_event_time ());
+    }
 }
 
 ClutterActor *


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