[mutter/wip/carlosg/grabs-pt1: 12/13] clutter: Integrate ClutterSeat grabs into ClutterGrab
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/grabs-pt1: 12/13] clutter: Integrate ClutterSeat grabs into ClutterGrab
- Date: Tue, 23 Nov 2021 11:29:00 +0000 (UTC)
commit 9fb38b4ed8b074ee335cb128d97a7d44833e3bc5
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 | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index bbd57d905f..85ebec59d9 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"
@@ -3757,6 +3758,18 @@ clutter_stage_grab (ClutterStage *stage,
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), NULL);
+ if (!priv->grabs)
+ {
+ 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);
+ if (!clutter_seat_grab (seat, clutter_get_current_event_time ()))
+ return NULL;
+ }
+
grab = g_new0 (ClutterGrab, 1);
grab->stage = stage;
grab->actor = actor;
@@ -3801,6 +3814,17 @@ clutter_stage_unlink_grab (ClutterStage *stage,
clutter_actor_detach_grab (grab->actor, 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 ());
+ }
+
grab->next = NULL;
grab->prev = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]