summaryrefslogtreecommitdiff
path: root/Userland/Applets
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-07-31 17:19:19 +0200
committerAndreas Kling <kling@serenityos.org>2022-08-01 10:29:53 +0200
commit419e986dccb95d185b2468f016e69c8f39c03b9d (patch)
treed91ed102db783071bb89a1aef065e17d083094e7 /Userland/Applets
parent88624343766fa06c656160e176e09af122d78a87 (diff)
downloadserenity-419e986dccb95d185b2468f016e69c8f39c03b9d.zip
WorkspacePicker: Hide tray applet entirely when there's only 1 workspace
Instead of collapsing to a 1x1 applet, we now hide the applet window entirely, which stops it from taking up space in the system tray.
Diffstat (limited to 'Userland/Applets')
-rw-r--r--Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp9
-rw-r--r--Userland/Applets/WorkspacePicker/main.cpp31
2 files changed, 25 insertions, 15 deletions
diff --git a/Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp b/Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp
index 84ac440f6e..6a1992f6bc 100644
--- a/Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp
+++ b/Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp
@@ -113,15 +113,6 @@ private:
DesktopStatusWindow::DesktopStatusWindow()
{
- GUI::Desktop::the().on_receive_screen_rects([&](GUI::Desktop&) {
- auto& desktop = GUI::Desktop::the();
- if (desktop.workspace_rows() == 1 && desktop.workspace_columns() == 1)
- resize(0, 0);
- else
- resize(28, 16);
-
- update();
- });
set_window_type(GUI::WindowType::Applet);
set_has_alpha_channel(true);
m_widget = &set_main_widget<DesktopStatusWidget>();
diff --git a/Userland/Applets/WorkspacePicker/main.cpp b/Userland/Applets/WorkspacePicker/main.cpp
index abdb378182..c2ba80a94b 100644
--- a/Userland/Applets/WorkspacePicker/main.cpp
+++ b/Userland/Applets/WorkspacePicker/main.cpp
@@ -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();
}