From 1a4ef9eb0b04866ed50ef7342ec57813c54a4b18 Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 4 Dec 2024 00:01:33 +0300 Subject: [PATCH 1/4] Wayland: start gnome-session-x11-services-ready.target --- src/WindowManager.vala | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/WindowManager.vala b/src/WindowManager.vala index a51739ce3..864ea7e0f 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -148,6 +148,42 @@ namespace Gala { display.gl_video_memory_purged.connect (() => { Meta.Background.refresh_all (); }); + +#if WITH_SYSTEMD + if (Meta.Util.is_wayland_compositor ()) { + display.init_xserver.connect ((task) => { + start_x11_services.begin (task); + return true; + }); + } +#endif + } + + private async void start_x11_services (GLib.Task task) { + try { + var session_bus = GLib.Bus.get_sync (GLib.BusType.SESSION); + session_bus.call.begin ( + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "StartUnit", + new GLib.Variant ("(ss)", "gnome-session-x11-services-ready.target", "fail"), + new GLib.VariantType ("(o)"), + GLib.DBusCallFlags.NONE, + -1, + null, + (obj, res) => { + task.return_boolean (true); + try { + session_bus.call.end (res); + } catch (Error e) { + critical (e.message); + } + } + ); + } catch (Error e) { + critical (e.message); + } } private void show_stage () { From 31a04a24751801e28a6fc7cdffa3e13b68b0047d Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 4 Dec 2024 00:05:20 +0300 Subject: [PATCH 2/4] More ifs --- src/WindowManager.vala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/WindowManager.vala b/src/WindowManager.vala index 864ea7e0f..8ec2dbdee 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -159,6 +159,7 @@ namespace Gala { #endif } +#if WITH_SYSTEMD private async void start_x11_services (GLib.Task task) { try { var session_bus = GLib.Bus.get_sync (GLib.BusType.SESSION); @@ -185,6 +186,7 @@ namespace Gala { critical (e.message); } } +#endif private void show_stage () { unowned Meta.Display display = get_display (); From 18d24a2e1b529c09a49c3911ef78ea40557b0cde Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 4 Dec 2024 13:02:29 +0300 Subject: [PATCH 3/4] Use yield --- src/WindowManager.vala | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/WindowManager.vala b/src/WindowManager.vala index 146a496c8..a1e4400c5 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -163,7 +163,7 @@ namespace Gala { private async void start_x11_services (GLib.Task task) { try { var session_bus = GLib.Bus.get_sync (GLib.BusType.SESSION); - session_bus.call.begin ( + yield session_bus.call ( "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", @@ -171,19 +171,12 @@ namespace Gala { new GLib.Variant ("(ss)", "gnome-session-x11-services-ready.target", "fail"), new GLib.VariantType ("(o)"), GLib.DBusCallFlags.NONE, - -1, - null, - (obj, res) => { - task.return_boolean (true); - try { - session_bus.call.end (res); - } catch (Error e) { - critical (e.message); - } - } + -1 ); } catch (Error e) { critical (e.message); + } finally { + task.return_boolean (true); } } #endif From 6cbb4f907ae4ffbc063beff7db5fec0f0d5adbdf Mon Sep 17 00:00:00 2001 From: lenemter Date: Wed, 4 Dec 2024 13:04:04 +0300 Subject: [PATCH 4/4] Use async get --- src/WindowManager.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WindowManager.vala b/src/WindowManager.vala index a1e4400c5..3b2d08ef3 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -162,7 +162,7 @@ namespace Gala { #if WITH_SYSTEMD private async void start_x11_services (GLib.Task task) { try { - var session_bus = GLib.Bus.get_sync (GLib.BusType.SESSION); + var session_bus = yield GLib.Bus.@get (GLib.BusType.SESSION); yield session_bus.call ( "org.freedesktop.systemd1", "/org/freedesktop/systemd1",