Advance Wayland and KDE package bring-up
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2022 David Redondo <kde@david-redondo.de>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
||||
*/
|
||||
|
||||
#include "mousebuttons.h"
|
||||
#include <QHash>
|
||||
#include <linux/input-event-codes.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
static const QHash<uint32_t, Qt::MouseButton> s_buttonToQtMouseButton = {
|
||||
{BTN_LEFT, Qt::LeftButton},
|
||||
{BTN_MIDDLE, Qt::MiddleButton},
|
||||
{BTN_RIGHT, Qt::RightButton},
|
||||
// in QtWayland mapped like that
|
||||
{BTN_SIDE, Qt::ExtraButton1},
|
||||
{BTN_EXTRA, Qt::ExtraButton2},
|
||||
{BTN_FORWARD, Qt::ExtraButton3},
|
||||
{BTN_BACK, Qt::ExtraButton4},
|
||||
{BTN_TASK, Qt::ExtraButton5},
|
||||
{0x118, Qt::ExtraButton6},
|
||||
{0x119, Qt::ExtraButton7},
|
||||
{0x11a, Qt::ExtraButton8},
|
||||
{0x11b, Qt::ExtraButton9},
|
||||
{0x11c, Qt::ExtraButton10},
|
||||
{0x11d, Qt::ExtraButton11},
|
||||
{0x11e, Qt::ExtraButton12},
|
||||
{0x11f, Qt::ExtraButton13},
|
||||
};
|
||||
|
||||
uint32_t qtMouseButtonToButton(Qt::MouseButton button)
|
||||
{
|
||||
return s_buttonToQtMouseButton.key(button);
|
||||
}
|
||||
|
||||
Qt::MouseButton buttonToQtMouseButton(uint32_t button)
|
||||
{
|
||||
// all other values get mapped to ExtraButton24
|
||||
// this is actually incorrect but doesn't matter in our usage
|
||||
// KWin internally doesn't use these high extra buttons anyway
|
||||
// it's only needed for recognizing whether buttons are pressed
|
||||
// if multiple buttons are mapped to the value the evaluation whether
|
||||
// buttons are pressed is correct and that's all we care about.
|
||||
return s_buttonToQtMouseButton.value(button, Qt::ExtraButton24);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user