clutter/stage: Track is_active
Instead of doing that in both MetaStage & CallyStage. This allows ClutterStage to also emits the relavant acessibility bits directly without having a roundtrip through Cally Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3917>
This commit is contained in:
parent
fb02197b4f
commit
7571ae6f05
6 changed files with 51 additions and 144 deletions
|
@ -20,7 +20,7 @@
|
|||
|
||||
/**
|
||||
* CallyStage:
|
||||
*
|
||||
*
|
||||
* Implementation of the ATK interfaces for a #ClutterStage
|
||||
*
|
||||
* #CallyStage implements the required ATK interfaces for [class@Clutter.Stage]
|
||||
|
@ -44,18 +44,10 @@ static AtkStateSet* cally_stage_ref_state_set (AtkObject *obj);
|
|||
/* AtkWindow */
|
||||
static void cally_stage_window_interface_init (AtkWindowIface *iface);
|
||||
|
||||
/* Auxiliary */
|
||||
static void cally_stage_activate_cb (ClutterStage *stage,
|
||||
gpointer data);
|
||||
static void cally_stage_deactivate_cb (ClutterStage *stage,
|
||||
gpointer data);
|
||||
|
||||
typedef struct _CallyStagePrivate
|
||||
{
|
||||
/* NULL means that the stage will receive the focus */
|
||||
ClutterActor *key_focus;
|
||||
|
||||
gboolean active;
|
||||
} CallyStagePrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (CallyStage,
|
||||
|
@ -78,9 +70,6 @@ cally_stage_class_init (CallyStageClass *klass)
|
|||
static void
|
||||
cally_stage_init (CallyStage *cally_stage)
|
||||
{
|
||||
CallyStagePrivate *priv = cally_stage_get_instance_private (cally_stage);
|
||||
|
||||
priv->active = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,7 +106,7 @@ cally_stage_notify_key_focus_cb (ClutterStage *stage,
|
|||
AtkObject *new = NULL;
|
||||
CallyStagePrivate *priv = cally_stage_get_instance_private (self);
|
||||
|
||||
if (priv->active == FALSE)
|
||||
if (!clutter_stage_is_active (stage))
|
||||
return;
|
||||
|
||||
key_focus = clutter_stage_get_key_focus (stage);
|
||||
|
@ -185,8 +174,6 @@ cally_stage_real_initialize (AtkObject *obj,
|
|||
|
||||
stage = CLUTTER_STAGE (CALLY_GET_CLUTTER_ACTOR (obj));
|
||||
|
||||
g_signal_connect (stage, "activate", G_CALLBACK (cally_stage_activate_cb), obj);
|
||||
g_signal_connect (stage, "deactivate", G_CALLBACK (cally_stage_deactivate_cb), obj);
|
||||
g_signal_connect (stage, "notify::key-focus",
|
||||
G_CALLBACK (cally_stage_notify_key_focus_cb), obj);
|
||||
|
||||
|
@ -199,11 +186,9 @@ cally_stage_ref_state_set (AtkObject *obj)
|
|||
CallyStage *cally_stage = NULL;
|
||||
AtkStateSet *state_set = NULL;
|
||||
ClutterStage *stage = NULL;
|
||||
CallyStagePrivate *priv;
|
||||
|
||||
g_return_val_if_fail (CALLY_IS_STAGE (obj), NULL);
|
||||
cally_stage = CALLY_STAGE (obj);
|
||||
priv = cally_stage_get_instance_private (cally_stage);
|
||||
|
||||
state_set = ATK_OBJECT_CLASS (cally_stage_parent_class)->ref_state_set (obj);
|
||||
stage = CLUTTER_STAGE (CALLY_GET_CLUTTER_ACTOR (cally_stage));
|
||||
|
@ -211,7 +196,7 @@ cally_stage_ref_state_set (AtkObject *obj)
|
|||
if (stage == NULL)
|
||||
return state_set;
|
||||
|
||||
if (priv->active)
|
||||
if (clutter_stage_is_active (stage))
|
||||
atk_state_set_add_state (state_set, ATK_STATE_ACTIVE);
|
||||
|
||||
return state_set;
|
||||
|
@ -223,44 +208,3 @@ cally_stage_window_interface_init (AtkWindowIface *iface)
|
|||
{
|
||||
/* At this moment AtkWindow is just about signals */
|
||||
}
|
||||
|
||||
/* Auxiliary */
|
||||
static void
|
||||
cally_stage_activate_cb (ClutterStage *stage,
|
||||
gpointer data)
|
||||
{
|
||||
CallyStage *cally_stage = NULL;
|
||||
CallyStagePrivate *priv;
|
||||
|
||||
g_return_if_fail (CALLY_IS_STAGE (data));
|
||||
|
||||
cally_stage = CALLY_STAGE (data);
|
||||
priv = cally_stage_get_instance_private (cally_stage);
|
||||
|
||||
priv->active = TRUE;
|
||||
|
||||
atk_object_notify_state_change (ATK_OBJECT (cally_stage),
|
||||
ATK_STATE_ACTIVE, TRUE);
|
||||
|
||||
g_signal_emit_by_name (cally_stage, "activate", 0);
|
||||
}
|
||||
|
||||
static void
|
||||
cally_stage_deactivate_cb (ClutterStage *stage,
|
||||
gpointer data)
|
||||
{
|
||||
CallyStage *cally_stage = NULL;
|
||||
CallyStagePrivate *priv;
|
||||
|
||||
g_return_if_fail (CALLY_IS_STAGE (data));
|
||||
|
||||
cally_stage = CALLY_STAGE (data);
|
||||
priv = cally_stage_get_instance_private (cally_stage);
|
||||
|
||||
priv->active = FALSE;
|
||||
|
||||
atk_object_notify_state_change (ATK_OBJECT (cally_stage),
|
||||
ATK_STATE_ACTIVE, FALSE);
|
||||
|
||||
g_signal_emit_by_name (cally_stage, "deactivate", 0);
|
||||
}
|
||||
|
|
|
@ -138,6 +138,7 @@ typedef struct _ClutterStagePrivate
|
|||
GPtrArray *all_active_gestures;
|
||||
|
||||
guint actor_needs_immediate_relayout : 1;
|
||||
gboolean is_active;
|
||||
} ClutterStagePrivate;
|
||||
|
||||
enum
|
||||
|
@ -156,8 +157,6 @@ static GParamSpec *obj_props[PROP_LAST] = { NULL, };
|
|||
|
||||
enum
|
||||
{
|
||||
ACTIVATE,
|
||||
DEACTIVATE,
|
||||
DELETE_EVENT,
|
||||
BEFORE_UPDATE,
|
||||
PREPARE_FRAME,
|
||||
|
@ -630,16 +629,47 @@ clutter_stage_emit_key_focus_event (ClutterStage *stage,
|
|||
g_object_notify_by_pspec (G_OBJECT (stage), obj_props[PROP_KEY_FOCUS]);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_real_activate (ClutterStage *stage)
|
||||
gboolean
|
||||
clutter_stage_is_active (ClutterStage *stage)
|
||||
{
|
||||
clutter_stage_emit_key_focus_event (stage, TRUE);
|
||||
ClutterStagePrivate *priv;
|
||||
|
||||
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
|
||||
|
||||
priv = clutter_stage_get_instance_private (stage);
|
||||
|
||||
return priv->is_active;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_real_deactivate (ClutterStage *stage)
|
||||
void
|
||||
clutter_stage_set_active (ClutterStage *stage,
|
||||
gboolean is_active)
|
||||
{
|
||||
clutter_stage_emit_key_focus_event (stage, FALSE);
|
||||
ClutterStagePrivate *priv;
|
||||
AtkObject *accessible;
|
||||
|
||||
g_return_if_fail (CLUTTER_IS_STAGE (stage));
|
||||
|
||||
priv = clutter_stage_get_instance_private (stage);
|
||||
|
||||
if (priv->is_active == is_active)
|
||||
return;
|
||||
|
||||
priv->is_active = is_active;
|
||||
accessible = clutter_actor_get_accessible (CLUTTER_ACTOR (stage));
|
||||
if (accessible)
|
||||
{
|
||||
atk_object_notify_state_change (accessible,
|
||||
ATK_STATE_ACTIVE,
|
||||
priv->is_active);
|
||||
/* Emit AtkWindow signals */
|
||||
if (priv->is_active)
|
||||
g_signal_emit_by_name (accessible, "activate", 0);
|
||||
else
|
||||
g_signal_emit_by_name (accessible, "deactivate", 0);
|
||||
}
|
||||
|
||||
clutter_stage_emit_key_focus_event (stage, is_active);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1368,35 +1398,6 @@ clutter_stage_class_init (ClutterStageClass *klass)
|
|||
|
||||
g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
|
||||
|
||||
/**
|
||||
* ClutterStage::activate:
|
||||
* @stage: the stage which was activated
|
||||
*
|
||||
* The signal is emitted when the stage receives key focus
|
||||
* from the underlying window system.
|
||||
*/
|
||||
stage_signals[ACTIVATE] =
|
||||
g_signal_new (I_("activate"),
|
||||
G_TYPE_FROM_CLASS (gobject_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (ClutterStageClass, activate),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
/**
|
||||
* ClutterStage::deactivate:
|
||||
* @stage: the stage which was deactivated
|
||||
*
|
||||
* The signal is emitted when the stage loses key focus
|
||||
* from the underlying window system.
|
||||
*/
|
||||
stage_signals[DEACTIVATE] =
|
||||
g_signal_new (I_("deactivate"),
|
||||
G_TYPE_FROM_CLASS (gobject_class),
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET (ClutterStageClass, deactivate),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/**
|
||||
* ClutterStage::before-update:
|
||||
* @stage: the #ClutterStage
|
||||
|
@ -1571,9 +1572,6 @@ clutter_stage_class_init (ClutterStageClass *klass)
|
|||
0,
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
klass->activate = clutter_stage_real_activate;
|
||||
klass->deactivate = clutter_stage_real_deactivate;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -58,9 +58,6 @@ struct _ClutterStageClass
|
|||
|
||||
/*< public >*/
|
||||
/* signals */
|
||||
void (* activate) (ClutterStage *stage);
|
||||
void (* deactivate) (ClutterStage *stage);
|
||||
|
||||
void (* before_paint) (ClutterStage *stage,
|
||||
ClutterStageView *view,
|
||||
ClutterFrame *frame);
|
||||
|
@ -253,4 +250,11 @@ gboolean clutter_stage_pointing_input_foreach (ClutterStage *sel
|
|||
ClutterStageInputForeachFunc func,
|
||||
gpointer user_data);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
gboolean clutter_stage_is_active (ClutterStage *stage);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
void clutter_stage_set_active (ClutterStage *stage,
|
||||
gboolean is_active);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -57,9 +57,6 @@ void meta_stage_update_cursor_overlay (MetaStage *stag
|
|||
void meta_overlay_set_visible (MetaOverlay *overlay,
|
||||
gboolean is_visible);
|
||||
|
||||
void meta_stage_set_active (MetaStage *stage,
|
||||
gboolean is_active);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaStageWatch * meta_stage_watch_view (MetaStage *stage,
|
||||
ClutterStageView *view,
|
||||
|
|
|
@ -63,7 +63,6 @@ struct _MetaStage
|
|||
GPtrArray *watchers[N_WATCH_MODES];
|
||||
|
||||
GList *overlays;
|
||||
gboolean is_active;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (MetaStage, meta_stage, CLUTTER_TYPE_STAGE);
|
||||
|
@ -273,26 +272,6 @@ meta_stage_paint_view (ClutterStage *stage,
|
|||
META_STAGE_WATCH_AFTER_PAINT);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_stage_activate (ClutterStage *actor)
|
||||
{
|
||||
MetaStage *stage = META_STAGE (actor);
|
||||
|
||||
CLUTTER_STAGE_CLASS (meta_stage_parent_class)->activate (actor);
|
||||
|
||||
stage->is_active = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_stage_deactivate (ClutterStage *actor)
|
||||
{
|
||||
MetaStage *stage = META_STAGE (actor);
|
||||
|
||||
CLUTTER_STAGE_CLASS (meta_stage_parent_class)->deactivate (actor);
|
||||
|
||||
stage->is_active = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
on_power_save_changed (MetaMonitorManager *monitor_manager,
|
||||
MetaPowerSaveChangeReason reason,
|
||||
|
@ -314,8 +293,6 @@ meta_stage_class_init (MetaStageClass *klass)
|
|||
|
||||
actor_class->paint = meta_stage_paint;
|
||||
|
||||
stage_class->activate = meta_stage_activate;
|
||||
stage_class->deactivate = meta_stage_deactivate;
|
||||
stage_class->before_paint = meta_stage_before_paint;
|
||||
stage_class->paint_view = meta_stage_paint_view;
|
||||
}
|
||||
|
@ -333,7 +310,7 @@ key_focus_actor_changed (ClutterStage *stage,
|
|||
if (key_focus == CLUTTER_ACTOR (stage))
|
||||
key_focus = NULL;
|
||||
|
||||
meta_stage_set_active (META_STAGE (stage), key_focus != NULL);
|
||||
clutter_stage_set_active (stage, key_focus != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -474,19 +451,6 @@ meta_overlay_set_visible (MetaOverlay *overlay,
|
|||
queue_redraw_for_overlay (overlay->stage, overlay);
|
||||
}
|
||||
|
||||
void
|
||||
meta_stage_set_active (MetaStage *stage,
|
||||
gboolean is_active)
|
||||
{
|
||||
if (stage->is_active == is_active)
|
||||
return;
|
||||
|
||||
if (is_active)
|
||||
g_signal_emit_by_name (CLUTTER_STAGE (stage), "activate");
|
||||
else
|
||||
g_signal_emit_by_name (CLUTTER_STAGE (stage), "deactivate");
|
||||
}
|
||||
|
||||
MetaStageWatch *
|
||||
meta_stage_watch_view (MetaStage *stage,
|
||||
ClutterStageView *view,
|
||||
|
|
|
@ -754,11 +754,11 @@ meta_stage_x11_handle_event (MetaStageX11 *stage_x11,
|
|||
break;
|
||||
|
||||
case FocusIn:
|
||||
meta_stage_set_active ((MetaStage *) stage_impl->wrapper, TRUE);
|
||||
clutter_stage_set_active (stage_impl->wrapper, TRUE);
|
||||
break;
|
||||
|
||||
case FocusOut:
|
||||
meta_stage_set_active ((MetaStage *) stage_impl->wrapper, FALSE);
|
||||
clutter_stage_set_active (stage_impl->wrapper, FALSE);
|
||||
break;
|
||||
|
||||
case Expose:
|
||||
|
|
Loading…
Reference in a new issue