Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WindowManager: launch panel as subprocess #727

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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