Move Xkb::LEDs enum to KWin namespace
With the LEDs enum being defined in kwinglobals.h, wayland_server.h won't need to include keyboard_input.h, which is good for compilation times and wayland_server.h will drag less stuff, e.g. QtWidgets (input.h includes QAction)
This commit is contained in:
parent
9cdd363fa1
commit
bf620fbe04
14 changed files with 38 additions and 35 deletions
|
@ -316,6 +316,8 @@ target_link_libraries(testXkb
|
||||||
Plasma::KWaylandServer
|
Plasma::KWaylandServer
|
||||||
KF5::WindowSystem
|
KF5::WindowSystem
|
||||||
|
|
||||||
|
kwineffects
|
||||||
|
|
||||||
XKB::XKB
|
XKB::XKB
|
||||||
Qt5::XkbCommonSupportPrivate
|
Qt5::XkbCommonSupportPrivate
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "cursor.h"
|
#include "cursor.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "internal_client.h"
|
#include "internal_client.h"
|
||||||
|
#include "keyboard_input.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
#include "useractions.h"
|
#include "useractions.h"
|
||||||
|
|
|
@ -503,16 +503,16 @@ void KeyboardLayoutTest::testNumLock()
|
||||||
QCOMPARE(xkb->layoutName(), QStringLiteral("English (US)"));
|
QCOMPARE(xkb->layoutName(), QStringLiteral("English (US)"));
|
||||||
|
|
||||||
// by default not set
|
// by default not set
|
||||||
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
|
QVERIFY(!xkb->leds().testFlag(LED::NumLock));
|
||||||
quint32 timestamp = 0;
|
quint32 timestamp = 0;
|
||||||
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
||||||
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
||||||
// now it should be on
|
// now it should be on
|
||||||
QVERIFY(xkb->leds().testFlag(Xkb::LED::NumLock));
|
QVERIFY(xkb->leds().testFlag(LED::NumLock));
|
||||||
// and back to off
|
// and back to off
|
||||||
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
||||||
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
||||||
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
|
QVERIFY(!xkb->leds().testFlag(LED::NumLock));
|
||||||
|
|
||||||
// let's reconfigure to enable through config
|
// let's reconfigure to enable through config
|
||||||
auto group = InputConfig::self()->inputConfig()->group("Keyboard");
|
auto group = InputConfig::self()->inputConfig()->group("Keyboard");
|
||||||
|
@ -520,22 +520,22 @@ void KeyboardLayoutTest::testNumLock()
|
||||||
group.sync();
|
group.sync();
|
||||||
xkb->reconfigure();
|
xkb->reconfigure();
|
||||||
// now it should be on
|
// now it should be on
|
||||||
QVERIFY(xkb->leds().testFlag(Xkb::LED::NumLock));
|
QVERIFY(xkb->leds().testFlag(LED::NumLock));
|
||||||
// pressing should result in it being off
|
// pressing should result in it being off
|
||||||
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
||||||
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
||||||
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
|
QVERIFY(!xkb->leds().testFlag(LED::NumLock));
|
||||||
|
|
||||||
// pressing again should enable it
|
// pressing again should enable it
|
||||||
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
||||||
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
||||||
QVERIFY(xkb->leds().testFlag(Xkb::LED::NumLock));
|
QVERIFY(xkb->leds().testFlag(LED::NumLock));
|
||||||
|
|
||||||
// now reconfigure to disable on load
|
// now reconfigure to disable on load
|
||||||
group.writeEntry("NumLock", 1);
|
group.writeEntry("NumLock", 1);
|
||||||
group.sync();
|
group.sync();
|
||||||
xkb->reconfigure();
|
xkb->reconfigure();
|
||||||
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
|
QVERIFY(!xkb->leds().testFlag(LED::NumLock));
|
||||||
}
|
}
|
||||||
|
|
||||||
WAYLANDTEST_MAIN(KeyboardLayoutTest)
|
WAYLANDTEST_MAIN(KeyboardLayoutTest)
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void ledsChanged(KWin::Xkb::LEDs);
|
void ledsChanged(KWin::LEDs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
InputRedirection *m_input;
|
InputRedirection *m_input;
|
||||||
|
|
|
@ -81,16 +81,16 @@ Connection *Connection::s_self = nullptr;
|
||||||
static ConnectionAdaptor *s_adaptor = nullptr;
|
static ConnectionAdaptor *s_adaptor = nullptr;
|
||||||
static Context *s_context = nullptr;
|
static Context *s_context = nullptr;
|
||||||
|
|
||||||
static quint32 toLibinputLEDS(Xkb::LEDs leds)
|
static quint32 toLibinputLEDS(LEDs leds)
|
||||||
{
|
{
|
||||||
quint32 libinputLeds = 0;
|
quint32 libinputLeds = 0;
|
||||||
if (leds.testFlag(Xkb::LED::NumLock)) {
|
if (leds.testFlag(LED::NumLock)) {
|
||||||
libinputLeds = libinputLeds | LIBINPUT_LED_NUM_LOCK;
|
libinputLeds = libinputLeds | LIBINPUT_LED_NUM_LOCK;
|
||||||
}
|
}
|
||||||
if (leds.testFlag(Xkb::LED::CapsLock)) {
|
if (leds.testFlag(LED::CapsLock)) {
|
||||||
libinputLeds = libinputLeds | LIBINPUT_LED_CAPS_LOCK;
|
libinputLeds = libinputLeds | LIBINPUT_LED_CAPS_LOCK;
|
||||||
}
|
}
|
||||||
if (leds.testFlag(Xkb::LED::ScrollLock)) {
|
if (leds.testFlag(LED::ScrollLock)) {
|
||||||
libinputLeds = libinputLeds | LIBINPUT_LED_SCROLL_LOCK;
|
libinputLeds = libinputLeds | LIBINPUT_LED_SCROLL_LOCK;
|
||||||
}
|
}
|
||||||
return libinputLeds;
|
return libinputLeds;
|
||||||
|
@ -775,7 +775,7 @@ void Connection::disableTouchpads()
|
||||||
toggleTouchpads();
|
toggleTouchpads();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::updateLEDs(Xkb::LEDs leds)
|
void Connection::updateLEDs(LEDs leds)
|
||||||
{
|
{
|
||||||
if (m_leds == leds) {
|
if (m_leds == leds) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include <kwinglobals.h>
|
#include <kwinglobals.h>
|
||||||
|
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "keyboard_input.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
@ -85,7 +84,7 @@ public:
|
||||||
|
|
||||||
QStringList devicesSysNames() const;
|
QStringList devicesSysNames() const;
|
||||||
|
|
||||||
void updateLEDs(KWin::Xkb::LEDs leds);
|
void updateLEDs(KWin::LEDs leds);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void keyChanged(quint32 key, KWin::InputRedirection::KeyboardKeyState, quint32 time, KWin::LibInput::Device *device);
|
void keyChanged(quint32 key, KWin::InputRedirection::KeyboardKeyState, quint32 time, KWin::LibInput::Device *device);
|
||||||
|
@ -158,7 +157,7 @@ private:
|
||||||
QVector<Device*> m_devices;
|
QVector<Device*> m_devices;
|
||||||
KSharedConfigPtr m_config;
|
KSharedConfigPtr m_config;
|
||||||
bool m_touchpadsEnabled = true;
|
bool m_touchpadsEnabled = true;
|
||||||
Xkb::LEDs m_leds;
|
LEDs m_leds;
|
||||||
|
|
||||||
KWIN_SINGLETON(Connection)
|
KWIN_SINGLETON(Connection)
|
||||||
};
|
};
|
||||||
|
|
|
@ -137,6 +137,14 @@ enum class SessionState {
|
||||||
};
|
};
|
||||||
Q_ENUM_NS(SessionState)
|
Q_ENUM_NS(SessionState)
|
||||||
|
|
||||||
|
enum class LED {
|
||||||
|
NumLock = 1 << 0,
|
||||||
|
CapsLock = 1 << 1,
|
||||||
|
ScrollLock = 1 << 2
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(LEDs, LED)
|
||||||
|
Q_FLAG_NS(LEDs)
|
||||||
|
|
||||||
inline
|
inline
|
||||||
KWIN_EXPORT xcb_connection_t *connection()
|
KWIN_EXPORT xcb_connection_t *connection()
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,5 +23,5 @@ ecm_qt_declare_logging_category(SCENE_OPENGL_BACKEND_SRCS
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(SceneOpenGLBackend STATIC ${SCENE_OPENGL_BACKEND_SRCS})
|
add_library(SceneOpenGLBackend STATIC ${SCENE_OPENGL_BACKEND_SRCS})
|
||||||
target_link_libraries(SceneOpenGLBackend Qt::Core Qt::Widgets KF5::CoreAddons KF5::ConfigCore KF5::WindowSystem Plasma::KWaylandServer)
|
target_link_libraries(SceneOpenGLBackend Qt::Core KF5::CoreAddons KF5::ConfigCore KF5::WindowSystem Plasma::KWaylandServer)
|
||||||
target_include_directories(SceneOpenGLBackend PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src)
|
target_include_directories(SceneOpenGLBackend PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src)
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "egl_dmabuf.h"
|
#include "egl_dmabuf.h"
|
||||||
#include "drm_fourcc.h"
|
#include "drm_fourcc.h"
|
||||||
#include "kwineglext.h"
|
#include "kwineglext.h"
|
||||||
|
#include "logging.h"
|
||||||
|
|
||||||
#include "wayland_server.h"
|
#include "wayland_server.h"
|
||||||
|
|
||||||
|
@ -384,7 +385,7 @@ void filterFormatsWithMultiplePlanes(QVector<uint32_t> &formats)
|
||||||
while (it != formats.end()) {
|
while (it != formats.end()) {
|
||||||
for (auto linuxFormat : s_multiPlaneFormats) {
|
for (auto linuxFormat : s_multiPlaneFormats) {
|
||||||
if (*it == linuxFormat) {
|
if (*it == linuxFormat) {
|
||||||
qDebug() << "Filter multi-plane format" << *it;
|
qCDebug(KWIN_OPENGL) << "Filter multi-plane format" << *it;
|
||||||
it = formats.erase(it);
|
it = formats.erase(it);
|
||||||
it--;
|
it--;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -18,5 +18,5 @@ ecm_qt_declare_logging_category(SCENE_QPAINTER_BACKEND_SRCS
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(SceneQPainterBackend STATIC ${SCENE_QPAINTER_BACKEND_SRCS})
|
add_library(SceneQPainterBackend STATIC ${SCENE_QPAINTER_BACKEND_SRCS})
|
||||||
target_link_libraries(SceneQPainterBackend Qt::Core Qt::Widgets KF5::CoreAddons KF5::ConfigCore KF5::WindowSystem Plasma::KWaylandServer)
|
target_link_libraries(SceneQPainterBackend Qt::Core KF5::CoreAddons KF5::ConfigCore KF5::WindowSystem Plasma::KWaylandServer)
|
||||||
target_include_directories(SceneQPainterBackend PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src)
|
target_include_directories(SceneQPainterBackend PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src)
|
||||||
|
|
|
@ -763,14 +763,14 @@ void WaylandServer::simulateUserActivity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaylandServer::updateKeyState(KWin::Xkb::LEDs leds)
|
void WaylandServer::updateKeyState(KWin::LEDs leds)
|
||||||
{
|
{
|
||||||
if (!m_keyState)
|
if (!m_keyState)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_keyState->setState(KeyStateInterface::Key::CapsLock, leds & KWin::Xkb::LED::CapsLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
|
m_keyState->setState(KeyStateInterface::Key::CapsLock, leds & KWin::LED::CapsLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
|
||||||
m_keyState->setState(KeyStateInterface::Key::NumLock, leds & KWin::Xkb::LED::NumLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
|
m_keyState->setState(KeyStateInterface::Key::NumLock, leds & KWin::LED::NumLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
|
||||||
m_keyState->setState(KeyStateInterface::Key::ScrollLock, leds & KWin::Xkb::LED::ScrollLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
|
m_keyState->setState(KeyStateInterface::Key::ScrollLock, leds & KWin::LED::ScrollLock ? KeyStateInterface::State::Locked : KeyStateInterface::State::Unlocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WaylandServer::isKeyboardShortcutsInhibited() const
|
bool WaylandServer::isKeyboardShortcutsInhibited() const
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
#define KWIN_WAYLAND_SERVER_H
|
#define KWIN_WAYLAND_SERVER_H
|
||||||
|
|
||||||
#include <kwinglobals.h>
|
#include <kwinglobals.h>
|
||||||
#include "keyboard_input.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QPointer>
|
||||||
|
#include <QSet>
|
||||||
|
|
||||||
class QThread;
|
class QThread;
|
||||||
class QProcess;
|
class QProcess;
|
||||||
|
@ -206,7 +207,7 @@ public:
|
||||||
SocketPairConnection createConnection();
|
SocketPairConnection createConnection();
|
||||||
|
|
||||||
void simulateUserActivity();
|
void simulateUserActivity();
|
||||||
void updateKeyState(KWin::Xkb::LEDs leds);
|
void updateKeyState(KWin::LEDs leds);
|
||||||
|
|
||||||
QSet<KWaylandServer::LinuxDmaBufV1ClientBuffer*> linuxDmabufBuffers() const {
|
QSet<KWaylandServer::LinuxDmaBufV1ClientBuffer*> linuxDmabufBuffers() const {
|
||||||
return m_linuxDmabufBuffers;
|
return m_linuxDmabufBuffers;
|
||||||
|
|
|
@ -78,7 +78,7 @@ Xkb::Xkb(QObject *parent)
|
||||||
, m_keysym(XKB_KEY_NoSymbol)
|
, m_keysym(XKB_KEY_NoSymbol)
|
||||||
, m_leds()
|
, m_leds()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<KWin::Xkb::LEDs>();
|
qRegisterMetaType<KWin::LEDs>();
|
||||||
if (!m_context) {
|
if (!m_context) {
|
||||||
qCDebug(KWIN_XKB) << "Could not create xkb context";
|
qCDebug(KWIN_XKB) << "Could not create xkb context";
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -66,12 +66,6 @@ public:
|
||||||
void switchToPreviousLayout();
|
void switchToPreviousLayout();
|
||||||
bool switchToLayout(xkb_layout_index_t layout);
|
bool switchToLayout(xkb_layout_index_t layout);
|
||||||
|
|
||||||
enum class LED {
|
|
||||||
NumLock = 1 << 0,
|
|
||||||
CapsLock = 1 << 1,
|
|
||||||
ScrollLock = 1 << 2
|
|
||||||
};
|
|
||||||
Q_DECLARE_FLAGS(LEDs, LED)
|
|
||||||
LEDs leds() const {
|
LEDs leds() const {
|
||||||
return m_leds;
|
return m_leds;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +154,4 @@ Qt::KeyboardModifiers Xkb::modifiers() const
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(KWin::Xkb::LED)
|
|
||||||
Q_DECLARE_METATYPE(KWin::Xkb::LEDs)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue