Commit cdf4fda9 authored by Jonas Dreßler's avatar Jonas Dreßler
Browse files

stage: Mark stage as active on wayland when it has key-focus

The "activate" and "deactivate" signals on ClutterStage are used by
Cally to track the key-focus when the user is interacting with shell UI.
key-focus only gets tracked while the stage is activated.

Wayland has no concept of the stage receiving focus or not, so right now
the activation state is bound to whether there's a focus_window in
meta_display_sync_wayland_input_focus(). Since display->focus_window is
set pretty much all the time, this effectively binds activation state to
whether the stage holds a grab or not. This is almost good enough, but
it misses cases where key-focus is on the stage without a grab, for
example when keyboard-navigating the panel after using Ctrl+Alt+Tab.

It seems to make more sense to bind the activation state to whether
key-focus is set to an actor or to NULL, so let's do that instead.
parent 6e458f94
Pipeline #390425 waiting for manual action with stages
......@@ -316,6 +316,22 @@ meta_stage_class_init (MetaStageClass *klass)
static void
key_focus_actor_changed (ClutterStage *stage,
GParamSpec *param,
gpointer user_data)
ClutterActor *key_focus = clutter_stage_get_key_focus (stage);
/* If there's no explicit key focus, clutter_stage_get_key_focus()
* returns the stage.
if (key_focus == CLUTTER_ACTOR (stage))
key_focus = NULL;
meta_stage_set_active (META_STAGE (stage), key_focus != NULL);
static void
meta_stage_init (MetaStage *stage)
......@@ -323,6 +339,13 @@ meta_stage_init (MetaStage *stage)
for (i = 0; i < N_WATCH_MODES; i++)
stage->watchers[i] = g_ptr_array_new_with_free_func (g_free);
if (meta_is_wayland_compositor ())
g_signal_connect (stage,
G_CALLBACK (key_focus_actor_changed), NULL);
ClutterActor *
......@@ -1438,7 +1438,6 @@ meta_display_sync_wayland_input_focus (MetaDisplay *display)
meta_topic (META_DEBUG_FOCUS, "Focus change has no effect, because there is no matching wayland surface");
meta_stage_set_active (stage, focus_window == NULL);
meta_wayland_compositor_set_input_focus (compositor, focus_window);
clutter_stage_repick_device (CLUTTER_STAGE (stage),
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment