|
@@ -18,6 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
|
TRY(Core::System::pledge("stdio recvfd sendfd rpath unix"));
|
|
|
|
|
|
auto app = TRY(GUI::Application::try_create(arguments));
|
|
|
+ app->set_quit_when_last_window_deleted(false);
|
|
|
|
|
|
// We need to obtain the WM connection here as well before the pledge shortening.
|
|
|
GUI::ConnectionToWindowManagerServer::the();
|
|
@@ -26,15 +27,33 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|
|
|
|
|
auto window = TRY(DesktopStatusWindow::try_create());
|
|
|
window->set_title("WorkspacePicker");
|
|
|
+ window->resize(28, 16);
|
|
|
|
|
|
auto& desktop = GUI::Desktop::the();
|
|
|
- if (desktop.workspace_rows() == 1 && desktop.workspace_columns() == 1)
|
|
|
- window->resize(0, 0);
|
|
|
- else
|
|
|
- window->resize(28, 16);
|
|
|
|
|
|
- window->show();
|
|
|
- window->make_window_manager(WindowServer::WMEventMask::WorkspaceChanges);
|
|
|
+ auto hide_tray_icon = [&] {
|
|
|
+ window->hide();
|
|
|
+ };
|
|
|
+
|
|
|
+ auto show_tray_icon = [&] {
|
|
|
+ if (!window->is_visible()) {
|
|
|
+ window->show();
|
|
|
+ window->make_window_manager(WindowServer::WMEventMask::WorkspaceChanges);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ if (desktop.workspace_rows() != 1 || desktop.workspace_columns() != 1) {
|
|
|
+ show_tray_icon();
|
|
|
+ }
|
|
|
+
|
|
|
+ desktop.on_receive_screen_rects([&](auto&) {
|
|
|
+ if (desktop.workspace_rows() == 1 && desktop.workspace_columns() == 1) {
|
|
|
+ hide_tray_icon();
|
|
|
+ } else {
|
|
|
+ window->update();
|
|
|
+ show_tray_icon();
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
return app->exec();
|
|
|
}
|