Skip to content

Commit

Permalink
WindowManager: launch panel as subprocess (#727)
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit authored May 15, 2024
1 parent e354389 commit 3e8daa4
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
49 changes: 49 additions & 0 deletions compositor/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,59 @@ namespace GreeterCompositor {
Idle.add (() => {
// let the session manager move to the next phase
display.get_context ().notify_ready ();
start_command.begin ({ "io.elementary.wingpanel", "-g" });
return GLib.Source.REMOVE;
});
}

private async void start_command (string[] command) {
if (Meta.Util.is_wayland_compositor ()) {
yield start_wayland (command);
} else {
yield start_x (command);
}
}

private async void start_wayland (string[] command) {
unowned Meta.Display display = get_display ();
var subprocess_launcher = new GLib.SubprocessLauncher (GLib.SubprocessFlags.INHERIT_FDS);
try {
Meta.WaylandClient daemon_client;
#if HAS_MUTTER44
daemon_client = new Meta.WaylandClient (display.get_context (), subprocess_launcher);
#else
daemon_client = new Meta.WaylandClient (subprocess_launcher);
#endif
var subprocess = daemon_client.spawnv (display, command);

yield subprocess.wait_async ();

//Restart the daemon if it crashes
Timeout.add_seconds (1, () => {
start_wayland.begin (command);
return Source.REMOVE;
});
} catch (Error e) {
warning ("Failed to create greeter client: %s", e.message);
return;
}
}

private async void start_x (string[] command) {
try {
var subprocess = new Subprocess.newv (command, GLib.SubprocessFlags.INHERIT_FDS);
yield subprocess.wait_async ();

//Restart the daemon if it crashes
Timeout.add_seconds (1, () => {
start_x.begin (command);
return Source.REMOVE;
});
} catch (Error e) {
warning ("Failed to create greeter subprocess with x: %s", e.message);
}
}

public uint32[] get_all_xids () {
unowned Meta.Display display = get_display ();

Expand Down
7 changes: 0 additions & 7 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public int main (string[] args) {
settings_daemon.start ();

Greeter.SubprocessSupervisor compositor;
Greeter.SubprocessSupervisor wingpanel;

try {
compositor = new Greeter.SubprocessSupervisor ({"io.elementary.greeter-compositor"});
Expand All @@ -46,12 +45,6 @@ public int main (string[] args) {
var window = new Greeter.MainWindow ();
window.show_all ();

try {
wingpanel = new Greeter.SubprocessSupervisor ({"io.elementary.wingpanel", "-g"});
} catch (Error e) {
critical (e.message);
}

Gtk.main ();

return 0;
Expand Down

0 comments on commit 3e8daa4

Please sign in to comment.