[mutter/wip/carlosg/grabs-pt1: 13/16] clutter: Integrate ClutterSeat grabs into ClutterGrab




commit 2af92849b3b97be96bc9b627c375d39e7d214c84
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 7da944ede9..88cfb44f7f 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"
@@ -3764,6 +3765,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;
 }
 
@@ -3792,6 +3804,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]