clutter/actor: Make has_pointer a counter instead of a bool
Somewhat long overdue... We've been supporting more than a single pointer for quite a long time now, let's make sure things don't break if two pointer devices enter the same ClutterActor: Count the number of pointers an actor has instead of using a simple boolean value. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2348>
This commit is contained in:
parent
069e18c09d
commit
f4416fa662
@ -808,6 +808,8 @@ struct _ClutterActorPrivate
|
|||||||
GList *stage_views;
|
GList *stage_views;
|
||||||
GList *grabs;
|
GList *grabs;
|
||||||
|
|
||||||
|
unsigned int n_pointers;
|
||||||
|
|
||||||
/* bitfields: KEEP AT THE END */
|
/* bitfields: KEEP AT THE END */
|
||||||
|
|
||||||
/* fixed position and sizes */
|
/* fixed position and sizes */
|
||||||
@ -827,7 +829,6 @@ struct _ClutterActorPrivate
|
|||||||
guint clip_to_allocation : 1;
|
guint clip_to_allocation : 1;
|
||||||
guint enable_model_view_transform : 1;
|
guint enable_model_view_transform : 1;
|
||||||
guint enable_paint_unmapped : 1;
|
guint enable_paint_unmapped : 1;
|
||||||
guint has_pointer : 1;
|
|
||||||
guint has_key_focus : 1;
|
guint has_key_focus : 1;
|
||||||
guint propagated_one_redraw : 1;
|
guint propagated_one_redraw : 1;
|
||||||
guint paint_volume_valid : 1;
|
guint paint_volume_valid : 1;
|
||||||
@ -1708,7 +1709,7 @@ clutter_actor_real_unmap (ClutterActor *self)
|
|||||||
*/
|
*/
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_MAPPED]);
|
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_MAPPED]);
|
||||||
|
|
||||||
if (priv->has_pointer)
|
if (priv->n_pointers > 0)
|
||||||
{
|
{
|
||||||
ClutterActor *stage = _clutter_actor_get_stage_internal (self);
|
ClutterActor *stage = _clutter_actor_get_stage_internal (self);
|
||||||
|
|
||||||
@ -5426,7 +5427,7 @@ clutter_actor_get_property (GObject *object,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_HAS_POINTER:
|
case PROP_HAS_POINTER:
|
||||||
g_value_set_boolean (value, priv->has_pointer);
|
g_value_set_boolean (value, priv->n_pointers > 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_LAYOUT_MANAGER:
|
case PROP_LAYOUT_MANAGER:
|
||||||
@ -12485,7 +12486,7 @@ clutter_actor_set_reactive (ClutterActor *actor,
|
|||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (actor), obj_props[PROP_REACTIVE]);
|
g_object_notify_by_pspec (G_OBJECT (actor), obj_props[PROP_REACTIVE]);
|
||||||
|
|
||||||
if (!CLUTTER_ACTOR_IS_REACTIVE (actor) && priv->has_pointer)
|
if (!CLUTTER_ACTOR_IS_REACTIVE (actor) && priv->n_pointers > 0)
|
||||||
{
|
{
|
||||||
ClutterActor *stage = _clutter_actor_get_stage_internal (actor);
|
ClutterActor *stage = _clutter_actor_get_stage_internal (actor);
|
||||||
|
|
||||||
@ -12508,7 +12509,7 @@ clutter_actor_set_reactive (ClutterActor *actor,
|
|||||||
parent = parent->priv->parent;
|
parent = parent->priv->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent && parent->priv->has_pointer)
|
if (parent && parent->priv->n_pointers > 0)
|
||||||
{
|
{
|
||||||
ClutterActor *stage = _clutter_actor_get_stage_internal (actor);
|
ClutterActor *stage = _clutter_actor_get_stage_internal (actor);
|
||||||
|
|
||||||
@ -14716,12 +14717,21 @@ _clutter_actor_set_has_pointer (ClutterActor *self,
|
|||||||
{
|
{
|
||||||
ClutterActorPrivate *priv = self->priv;
|
ClutterActorPrivate *priv = self->priv;
|
||||||
|
|
||||||
if (priv->has_pointer != has_pointer)
|
if (has_pointer)
|
||||||
{
|
{
|
||||||
priv->has_pointer = has_pointer;
|
g_assert (CLUTTER_IS_STAGE (self) || CLUTTER_ACTOR_IS_MAPPED (self));
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_HAS_POINTER]);
|
priv->n_pointers++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_assert (priv->n_pointers > 0);
|
||||||
|
|
||||||
|
priv->n_pointers--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priv->n_pointers == 0 || priv->n_pointers == 1)
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), obj_props[PROP_HAS_POINTER]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -14792,7 +14802,7 @@ clutter_actor_has_pointer (ClutterActor *self)
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
|
||||||
|
|
||||||
return self->priv->has_pointer;
|
return self->priv->n_pointers > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user