From cc4d99aea4948c10c159328ff15f6783ae974eeb Mon Sep 17 00:00:00 2001 From: David Redondo Date: Fri, 10 Feb 2023 09:47:43 +0100 Subject: [PATCH] Fix button to Qt::MouseButton mapping Even though the names seem to match, QtWayland maps button values to enum values in ascendung order (as it does on X11). The wrong mapping is usually not a problem because we send the native button events to clients. However when the Qt names or values are used for communication between KWin and a client this leads to misunderstandings. BUG:465463 FIXED-IN:5.27.1 --- autotests/libinput/mock_libinput.cpp | 8 ++++---- src/mousebuttons.cpp | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/autotests/libinput/mock_libinput.cpp b/autotests/libinput/mock_libinput.cpp index 198293a274..380d150b88 100644 --- a/autotests/libinput/mock_libinput.cpp +++ b/autotests/libinput/mock_libinput.cpp @@ -347,12 +347,12 @@ int libinput_device_pointer_has_button(struct libinput_device *device, uint32_t return device->supportedButtons.testFlag(Qt::ExtraButton1); case BTN_EXTRA: return device->supportedButtons.testFlag(Qt::ExtraButton2); - case BTN_BACK: - return device->supportedButtons.testFlag(Qt::BackButton); case BTN_FORWARD: - return device->supportedButtons.testFlag(Qt::ForwardButton); + return device->supportedButtons.testFlag(Qt::ExtraButton3); + case BTN_BACK: + return device->supportedButtons.testFlag(Qt::ExtraButton4); case BTN_TASK: - return device->supportedButtons.testFlag(Qt::TaskButton); + return device->supportedButtons.testFlag(Qt::ExtraButton5); default: return 0; } diff --git a/src/mousebuttons.cpp b/src/mousebuttons.cpp index bb2d1d8a1c..4f67de26c2 100644 --- a/src/mousebuttons.cpp +++ b/src/mousebuttons.cpp @@ -17,12 +17,10 @@ static const QHash s_buttonToQtMouseButton = { {BTN_RIGHT, Qt::RightButton}, // in QtWayland mapped like that {BTN_SIDE, Qt::ExtraButton1}, - // in QtWayland mapped like that {BTN_EXTRA, Qt::ExtraButton2}, - {BTN_BACK, Qt::BackButton}, - {BTN_FORWARD, Qt::ForwardButton}, - {BTN_TASK, Qt::TaskButton}, - // mapped like that in QtWayland + {BTN_FORWARD, Qt::ExtraButton3}, + {BTN_BACK, Qt::ExtraButton4}, + {BTN_TASK, Qt::ExtraButton5}, {0x118, Qt::ExtraButton6}, {0x119, Qt::ExtraButton7}, {0x11a, Qt::ExtraButton8},