From 8284f3ea1bcccab8ed9303779bef686dfe141a7e Mon Sep 17 00:00:00 2001 From: Tarek Ismail Date: Thu, 5 Dec 2024 11:54:06 +0200 Subject: [PATCH] Expose focus stealing as a configurable option --- examples/miral-shell/shell_main.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/miral-shell/shell_main.cpp b/examples/miral-shell/shell_main.cpp index 640852d8f8..c08e3ca2b3 100644 --- a/examples/miral-shell/shell_main.cpp +++ b/examples/miral-shell/shell_main.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -69,7 +70,15 @@ int main(int argc, char const* argv[]) SpinnerSplash spinner; InternalClientLauncher launcher; - auto focus_stealing_prevention = FocusStealing::allow; + auto constexpr default_focus_stealing_prevention = false; + auto const to_focus_stealing = [](bool focus_stealing_prevention) + { + if (focus_stealing_prevention) + return FocusStealing::prevent; + else + return FocusStealing::allow; + }; + auto focus_stealing_prevention = to_focus_stealing(default_focus_stealing_prevention); WindowManagerOptions window_managers { add_window_manager_policy("floating", spinner, launcher, shutdown_hook, focus_stealing_prevention), @@ -141,6 +150,10 @@ int main(int argc, char const* argv[]) WaylandExtensions{}, X11Support{}, ConfigureDecorations{}, + pre_init(ConfigurationOption{[&](bool option) + { focus_stealing_prevention = to_focus_stealing(option); }, + "focus-stealing-prevention", "allow or prevent focus stealing", + default_focus_stealing_prevention}), window_managers, display_configuration_options, external_client_launcher,