From 7d177b72101938d086c29a262610e4069f959209 Mon Sep 17 00:00:00 2001 From: networkException Date: Fri, 22 Jul 2022 22:33:45 +0200 Subject: [PATCH] WorkspacePicker: Immediately update active workspace on click or scroll This patch makes the picker applet react instantly to a click on a workspace or scroll on the widget, instead of waiting for an event from WindowServer and as such until the switching animation has ended. This synchronises the switching with the overlay shown. Note that WindowServer events will still get handled in case the workspace were to be updated from somewhere else. --- .../Applets/WorkspacePicker/DesktopStatusWindow.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp b/Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp index 51bc541c36..84ac440f6e 100644 --- a/Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp +++ b/Userland/Applets/WorkspacePicker/DesktopStatusWindow.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2021, Peter Elliott * Copyright (c) 2022, the SerenityOS developers. + * Copyright (c) 2022, Jakob-Niklas See * * SPDX-License-Identifier: BSD-2-Clause */ @@ -62,8 +63,13 @@ public: auto column = event.x() / (base_rect.width() + gap()); // Handle case where divider is clicked. - if (rect_for_desktop(row, column).contains(event.position())) + if (rect_for_desktop(row, column).contains(event.position())) { GUI::ConnectionToWindowManagerServer::the().async_set_workspace(row, column); + + set_current_row(row); + set_current_column(column); + update(); + } } virtual void mousewheel_event(GUI::MouseEvent& event) override @@ -82,6 +88,10 @@ public: else row = abs((int)row + direction) % workspace_rows; + set_current_row(row); + set_current_column(column); + update(); + GUI::ConnectionToWindowManagerServer::the().async_set_workspace(row, column); }