[mutter/wip/carlosg/grabs-pt1: 91/93] 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: 91/93] clutter: Integrate ClutterSeat grabs into ClutterGrab
- Date: Tue, 7 Dec 2021 21:33:02 +0000 (UTC)
commit 9d9750b9020703c9b3af5d0eb7622bdf96fd23a7
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-grab.h | 3 +++
clutter/clutter/clutter-stage.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
---
diff --git a/clutter/clutter/clutter-grab.h b/clutter/clutter/clutter-grab.h
index 8c87046496..5cb86baa57 100644
--- a/clutter/clutter/clutter-grab.h
+++ b/clutter/clutter/clutter-grab.h
@@ -35,4 +35,7 @@ typedef struct _ClutterGrab ClutterGrab;
CLUTTER_EXPORT
void clutter_grab_dismiss (ClutterGrab *grab);
+CLUTTER_EXPORT
+ClutterGrabState clutter_grab_get_windowing_state (ClutterGrab *grab);
+
#endif /* CLUTTER_GRAB_H */
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 7a67ae05e1..6559059e06 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"
@@ -115,6 +116,7 @@ struct _ClutterStagePrivate
ClutterActor *key_focused_actor;
ClutterGrab *grabs;
+ ClutterGrabState grab_state;
GQueue *event_queue;
@@ -3857,6 +3859,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);
+ priv->grab_state =
+ clutter_seat_grab (seat, clutter_get_current_event_time ());
+ }
+
grab = g_new0 (ClutterGrab, 1);
grab->stage = stage;
grab->actor = actor;
@@ -3901,6 +3915,18 @@ 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 ());
+ priv->grab_state = CLUTTER_GRAB_STATE_NONE;
+ }
+
grab->next = NULL;
grab->prev = NULL;
}
@@ -3914,6 +3940,14 @@ clutter_grab_dismiss (ClutterGrab *grab)
g_free (grab);
}
+ClutterGrabState
+clutter_grab_get_windowing_state (ClutterGrab *grab)
+{
+ g_return_val_if_fail (grab != NULL, CLUTTER_GRAB_STATE_NONE);
+
+ return grab->stage->priv->grab_state;
+}
+
ClutterActor *
clutter_stage_get_grab_actor (ClutterStage *stage)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]