diff --git a/Userland/Demos/Mouse/main.cpp b/Userland/Demos/Mouse/main.cpp index 30ddda64e5..b679482698 100644 --- a/Userland/Demos/Mouse/main.cpp +++ b/Userland/Demos/Mouse/main.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2021, Idan Horowitz * * SPDX-License-Identifier: BSD-2-Clause */ @@ -15,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -70,12 +72,16 @@ public: painter.stroke_path(path, Color::Black, 1); - if (m_buttons & GUI::MouseButton::Left) { + auto primary_secondary_switched = GUI::WindowServerConnection::the().get_buttons_switched(); + auto primary_pressed = m_buttons & GUI::MouseButton::Left; + auto secondary_pressed = m_buttons & GUI::MouseButton::Right; + + if (primary_secondary_switched ? secondary_pressed : primary_pressed) { painter.fill_rect({ 31, 21, 34, 44 }, Color::Blue); painter.draw_triangle({ 30, 21 }, { 65, 21 }, { 65, 12 }, Color::Blue); } - if (m_buttons & GUI::MouseButton::Right) { + if (primary_secondary_switched ? primary_pressed : secondary_pressed) { painter.fill_rect({ 96, 21, 34, 44 }, Color::Blue); painter.draw_triangle({ 96, 12 }, { 96, 21 }, { 132, 21 }, Color::Blue); }