mirror of
https://github.com/brl/mutter.git
synced 2024-12-27 05:12:15 +00:00
clutter/stage: Add is-grabbed property
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3185>
This commit is contained in:
parent
587c31b611
commit
03ee48094e
@ -164,6 +164,8 @@ enum
|
||||
PROP_PERSPECTIVE,
|
||||
PROP_TITLE,
|
||||
PROP_KEY_FOCUS,
|
||||
PROP_IS_GRABBED,
|
||||
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
@ -1226,6 +1228,10 @@ clutter_stage_get_property (GObject *gobject,
|
||||
g_value_set_object (value, priv->key_focused_actor);
|
||||
break;
|
||||
|
||||
case PROP_IS_GRABBED:
|
||||
g_value_set_boolean (value, !!priv->topmost_grab);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
@ -1412,6 +1418,17 @@ clutter_stage_class_init (ClutterStageClass *klass)
|
||||
CLUTTER_PARAM_READWRITE |
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* ClutterStage:is-grabbed:
|
||||
*
|
||||
* %TRUE if there is currently an active grab on the stage.
|
||||
*/
|
||||
obj_props[PROP_IS_GRABBED] =
|
||||
g_param_spec_boolean ("is-grabbed", NULL, NULL,
|
||||
FALSE,
|
||||
CLUTTER_PARAM_READABLE |
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
|
||||
|
||||
/**
|
||||
@ -3898,6 +3915,7 @@ clutter_stage_grab_full (ClutterStage *stage,
|
||||
{
|
||||
ClutterStagePrivate *priv;
|
||||
ClutterGrab *grab;
|
||||
gboolean was_grabbed;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), NULL);
|
||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), NULL);
|
||||
@ -3924,6 +3942,8 @@ clutter_stage_grab_full (ClutterStage *stage,
|
||||
grab->prev = NULL;
|
||||
grab->next = priv->topmost_grab;
|
||||
|
||||
was_grabbed = !!priv->topmost_grab;
|
||||
|
||||
if (priv->topmost_grab)
|
||||
priv->topmost_grab->prev = grab;
|
||||
|
||||
@ -3945,6 +3965,9 @@ clutter_stage_grab_full (ClutterStage *stage,
|
||||
clutter_actor_attach_grab (actor, grab);
|
||||
clutter_stage_notify_grab (stage, grab, grab->next);
|
||||
|
||||
if (was_grabbed != !!priv->topmost_grab)
|
||||
g_object_notify_by_pspec (G_OBJECT (stage), obj_props[PROP_IS_GRABBED]);
|
||||
|
||||
return grab;
|
||||
}
|
||||
|
||||
@ -3991,6 +4014,7 @@ clutter_stage_unlink_grab (ClutterStage *stage,
|
||||
{
|
||||
ClutterStagePrivate *priv = stage->priv;
|
||||
ClutterGrab *prev, *next;
|
||||
gboolean was_grabbed;
|
||||
|
||||
/* This grab is already detached */
|
||||
if (!grab->prev && !grab->next && priv->topmost_grab != grab)
|
||||
@ -4004,6 +4028,8 @@ clutter_stage_unlink_grab (ClutterStage *stage,
|
||||
if (next)
|
||||
next->prev = prev;
|
||||
|
||||
was_grabbed = !!priv->topmost_grab;
|
||||
|
||||
if (priv->topmost_grab == grab)
|
||||
{
|
||||
/* This is the active grab */
|
||||
@ -4026,6 +4052,9 @@ clutter_stage_unlink_grab (ClutterStage *stage,
|
||||
priv->grab_state = CLUTTER_GRAB_STATE_NONE;
|
||||
}
|
||||
|
||||
if (was_grabbed != !!priv->topmost_grab)
|
||||
g_object_notify_by_pspec (G_OBJECT (stage), obj_props[PROP_IS_GRABBED]);
|
||||
|
||||
if (G_UNLIKELY (clutter_debug_flags & CLUTTER_DEBUG_GRABS))
|
||||
{
|
||||
unsigned int n_grabs = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user