From 5f182dc0d38393b5b0877901fe096f2ad05b4a28 Mon Sep 17 00:00:00 2001 From: Leonhard Date: Mon, 25 Sep 2023 13:28:09 +0200 Subject: [PATCH 1/4] Prototype use of Meta.WaylandClient --- src/PantheonShell.vala | 37 +++++++++++++++++++++++++++++++++++++ src/WindowManager.vala | 2 ++ src/meson.build | 1 + 3 files changed, 40 insertions(+) create mode 100644 src/PantheonShell.vala diff --git a/src/PantheonShell.vala b/src/PantheonShell.vala new file mode 100644 index 000000000..1a273e018 --- /dev/null +++ b/src/PantheonShell.vala @@ -0,0 +1,37 @@ +public class Gala.PantheonShell : Object { + private Meta.Display display; + private Meta.WaylandClient dock_client; + + private static PantheonShell instance; + + public static PantheonShell get_default () requires (instance != null) { + return instance; + } + + public static void init (Meta.Display display) { + instance = new PantheonShell (); + instance.initialize (display); + } + + public void initialize (Meta.Display display) { + this.display = display; + display.window_created.connect ((window) => { + if (dock_client != null && dock_client.owns_window (window)) { + setup_dock_window (window); + } + }); + + var subprocess_launcher = new GLib.SubprocessLauncher (NONE); + try { + dock_client = new Meta.WaylandClient (subprocess_launcher); + dock_client.spawn (display, null, "io.elementary.dock"); + } catch (Error e) { + warning ("Failed to create dock client: %s", e.message); + } + } + + private void setup_dock_window (Meta.Window window) { + window.stick (); + window.move_frame (false, 0, 0); + } +} diff --git a/src/WindowManager.vala b/src/WindowManager.vala index e194da418..5f839fd30 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -364,6 +364,8 @@ namespace Gala { plugin_manager.load_waiting_plugins (); + PantheonShell.init (display); + return false; }); diff --git a/src/meson.build b/src/meson.build index 6177a4299..4f81dc5e6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -9,6 +9,7 @@ gala_bin_sources = files( 'Main.vala', 'MediaFeedback.vala', 'NotificationStack.vala', + 'PantheonShell.vala', 'PluginManager.vala', 'ScreenSaverManager.vala', 'ScreenshotManager.vala', From 0751798ed9ed35edd2db6e9f0642196d09068aab Mon Sep 17 00:00:00 2001 From: Leonhard Date: Mon, 25 Sep 2023 14:56:09 +0200 Subject: [PATCH 2/4] It works --- src/PantheonShell.vala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/PantheonShell.vala b/src/PantheonShell.vala index 1a273e018..e09863f47 100644 --- a/src/PantheonShell.vala +++ b/src/PantheonShell.vala @@ -24,14 +24,18 @@ public class Gala.PantheonShell : Object { var subprocess_launcher = new GLib.SubprocessLauncher (NONE); try { dock_client = new Meta.WaylandClient (subprocess_launcher); - dock_client.spawn (display, null, "io.elementary.dock"); + string[] args = {"io.elementary.dock"}; + dock_client.spawnv (display, args); } catch (Error e) { warning ("Failed to create dock client: %s", e.message); } } private void setup_dock_window (Meta.Window window) { - window.stick (); - window.move_frame (false, 0, 0); + // window.stick (); + window.shown.connect (() => { + window.move_frame (false, 0, 0); + window.move_to_monitor (display.get_primary_monitor ()); + }); } } From 293ee8eec113e982e6a461590d1347cdc763cb27 Mon Sep 17 00:00:00 2001 From: Leonhard Date: Mon, 25 Sep 2023 15:50:29 +0200 Subject: [PATCH 3/4] Keep dock above --- src/PantheonShell.vala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/PantheonShell.vala b/src/PantheonShell.vala index e09863f47..6a2a98de8 100644 --- a/src/PantheonShell.vala +++ b/src/PantheonShell.vala @@ -32,10 +32,16 @@ public class Gala.PantheonShell : Object { } private void setup_dock_window (Meta.Window window) { - // window.stick (); + window.notify["above"].connect (() => { + if (!window.above) { + window.make_above (); + } + }); + window.shown.connect (() => { window.move_frame (false, 0, 0); window.move_to_monitor (display.get_primary_monitor ()); + window.make_above (); }); } } From 6a1088b06306ae6ec39498ea499f5dd0ac8e2173 Mon Sep 17 00:00:00 2001 From: Leonhard Date: Mon, 25 Sep 2023 16:08:18 +0200 Subject: [PATCH 4/4] Cleanup --- src/PantheonShell.vala | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/PantheonShell.vala b/src/PantheonShell.vala index 6a2a98de8..d186a7e23 100644 --- a/src/PantheonShell.vala +++ b/src/PantheonShell.vala @@ -1,20 +1,19 @@ public class Gala.PantheonShell : Object { - private Meta.Display display; - private Meta.WaylandClient dock_client; + public static void init (Meta.Display display) requires (instance == null) { + instance = new PantheonShell (display); + } - private static PantheonShell instance; + private static PantheonShell? instance = null; - public static PantheonShell get_default () requires (instance != null) { - return instance; - } + public Meta.Display display { get; construct; } + + private Meta.WaylandClient dock_client; - public static void init (Meta.Display display) { - instance = new PantheonShell (); - instance.initialize (display); + private PantheonShell (Meta.Display display) { + Object (display: display); } - public void initialize (Meta.Display display) { - this.display = display; + construct { display.window_created.connect ((window) => { if (dock_client != null && dock_client.owns_window (window)) { setup_dock_window (window);