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
This commit is contained in:
David Redondo 2023-02-10 09:47:43 +01:00 committed by Vlad Zahorodnii
parent e909234244
commit cc4d99aea4
2 changed files with 7 additions and 9 deletions

View file

@ -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;
}

View file

@ -17,12 +17,10 @@ static const QHash<uint32_t, Qt::MouseButton> 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},