DesktopPicker: Add mouse wheel control

This lets us use scroll wheel up/down to move between columns and
shift + scroll wheel up/down to move between rows.
This commit is contained in:
LuK1337 2021-07-19 19:00:33 +02:00 committed by Ali Mohammad Pur
parent 137d716495
commit de09a92bf8

View file

@ -67,6 +67,25 @@ public:
GUI::WindowManagerServerConnection::the().async_set_virtual_desktop(row, col);
}
virtual void mousewheel_event(GUI::MouseEvent& event) override
{
auto& desktop = GUI::Desktop::the();
auto col = current_col();
auto row = current_row();
auto vcols = desktop.virtual_desktop_columns();
auto vrows = desktop.virtual_desktop_rows();
auto direction = event.wheel_delta() < 0 ? 1 : -1;
if (event.modifiers() & Mod_Shift)
col = abs((int)col + direction) % vcols;
else
row = abs((int)row + direction) % vrows;
GUI::WindowManagerServerConnection::the().async_set_virtual_desktop(row, col);
}
unsigned current_row() const { return m_current_row; }
void set_current_row(unsigned row) { m_current_row = row; }
unsigned current_col() const { return m_current_col; }