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.
This commit is contained in:
networkException 2022-07-22 22:33:45 +02:00 committed by Linus Groh
parent b3f8734e22
commit 7d177b7210
Notes: sideshowbarker 2024-07-17 08:38:53 +09:00

View File

@ -1,6 +1,7 @@
/*
* Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
* Copyright (c) 2022, Jakob-Niklas See <git@nwex.de>
*
* 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);
}