diff --git a/src/backends/meta-stage.c b/src/backends/meta-stage.c index 107265fa6..f43f4d06e 100644 --- a/src/backends/meta-stage.c +++ b/src/backends/meta-stage.c @@ -331,6 +331,22 @@ meta_stage_class_init (MetaStageClass *klass) G_TYPE_NONE, 0); } +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) { @@ -338,6 +354,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, + "notify::key-focus", + G_CALLBACK (key_focus_actor_changed), NULL); + } } ClutterActor * diff --git a/src/core/display.c b/src/core/display.c index 5bb34a65a..fb9224416 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1443,7 +1443,6 @@ meta_display_sync_wayland_input_focus (MetaDisplay *display) else 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),