From b9911e7d269d31861d8749d2cdca9c6c69cd4f14 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Tue, 18 Jun 2024 08:39:53 +0200 Subject: src/: Re-introduce having a window manager (metacity this time, with keybindings disabled). Make having it conifugrable via GSettings. --- .../org.ArcticaProject.arctica-greeter.gschema.xml | 8 +++ src/arctica-greeter.vala | 66 ++++++++++++++++++++++ src/settings.vala | 1 + 3 files changed, 75 insertions(+) diff --git a/data/org.ArcticaProject.arctica-greeter.gschema.xml b/data/org.ArcticaProject.arctica-greeter.gschema.xml index e42c606..2546206 100644 --- a/data/org.ArcticaProject.arctica-greeter.gschema.xml +++ b/data/org.ArcticaProject.arctica-greeter.gschema.xml @@ -117,6 +117,14 @@ 'Noto Sans 11' Font to use. + + + + + + 'metacity' + If at all and if yes, which window manager to use. + true Whether to antialias Xft fonts. diff --git a/src/arctica-greeter.vala b/src/arctica-greeter.vala index e7a049d..119f3af 100644 --- a/src/arctica-greeter.vala +++ b/src/arctica-greeter.vala @@ -1278,6 +1278,7 @@ public class ArcticaGreeter : Object Pid atspi_pid = 0; Pid nmapplet_pid = 0; + Pid windowmanager_pid = 0; if (!do_test_mode) { @@ -1421,6 +1422,55 @@ public class ArcticaGreeter : Object activate_upower(); + string wm = AGSettings.get_string (AGSettings.KEY_WINDOW_MANAGER); + if (wm == "metacity") + { + try + { + string[] argv; + + Shell.parse_argv (wm, out argv); + Process.spawn_async (null, + argv, + null, + SpawnFlags.SEARCH_PATH, + null, + out windowmanager_pid); + debug ("Launched '%s' WM. PID: %d", wm, windowmanager_pid); + } + catch (Error e) + { + warning ("Error starting the '%s' Window Manager: %s", wm, e.message); + } + + Timeout.add (50, () => + { + try + { + string[] argv; + Pid wm_message_pid = 0; + + Shell.parse_argv ("%s-message disable-keybindings".printf(wm), out argv); + + Process.spawn_sync (null, + argv, + null, + SpawnFlags.SEARCH_PATH, + null, + null, + null, + null); + debug ("Launched '%s-message disable-keybindings' command", wm); + return false; + } + catch (Error e) + { + warning ("Error during '%s-message disable-keybindings' command call: %s", wm, e.message); + return true; + } + }); + } + greeter.greeter_ready.connect (() => { debug ("Showing greeter"); greeter.show (); @@ -1514,6 +1564,22 @@ public class ArcticaGreeter : Object debug ("GeoClue-2.0 agent terminated with signal %d", Process.term_sig (status)); geoclueagent_pid = 0; } + + if (windowmanager_pid != 0) + { +#if VALA_0_40 + Posix.kill (windowmanager_pid, Posix.Signal.TERM); +#else + Posix.kill (windowmanager_pid, Posix.SIGTERM); +#endif + int status; + Posix.waitpid (windowmanager_pid, out status, 0); + if (Process.if_exited (status)) + debug ("Marco Window Manager exited with return value %d", Process.exit_status (status)); + else + debug ("Marco Window Manager terminated with signal %d", Process.term_sig (status)); + windowmanager_pid = 0; + } } gsettings_mate_desktop_interface.set_int ("window-scaling-factor", wsf_orig); diff --git a/src/settings.vala b/src/settings.vala index 6bdfe5d..bb95c9f 100644 --- a/src/settings.vala +++ b/src/settings.vala @@ -43,6 +43,7 @@ public class AGSettings : Object public const string KEY_CURSOR_THEME_NAME = "cursor-theme-name"; public const string KEY_CURSOR_THEME_SIZE = "cursor-theme-size"; public const string KEY_FONT_NAME = "font-name"; + public const string KEY_WINDOW_MANAGER = "window-manager"; public const string KEY_XFT_ANTIALIAS = "xft-antialias"; public const string KEY_XFT_DPI = "xft-dpi"; public const string KEY_XFT_HINTSTYLE = "xft-hintstyle"; -- cgit v1.2.3