Fix !KWIN_BUILD_GLOBALSHORTCUTS builds
Makes it so the GlobalShortucts object gets built and its KGlobalAccelD parts get disabled. Addresses the TODO in GestureHandler. Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
This commit is contained in:
parent
a7470f4b4a
commit
2601d06f5b
5 changed files with 19 additions and 10 deletions
|
@ -99,6 +99,7 @@ target_sources(kwin PRIVATE
|
||||||
focuschain.cpp
|
focuschain.cpp
|
||||||
ftrace.cpp
|
ftrace.cpp
|
||||||
gestures.cpp
|
gestures.cpp
|
||||||
|
globalshortcuts.cpp
|
||||||
hide_cursor_spy.cpp
|
hide_cursor_spy.cpp
|
||||||
idle_inhibition.cpp
|
idle_inhibition.cpp
|
||||||
idledetector.cpp
|
idledetector.cpp
|
||||||
|
@ -258,7 +259,6 @@ target_link_libraries(kwin
|
||||||
)
|
)
|
||||||
|
|
||||||
if (TARGET K::KGlobalAccelD)
|
if (TARGET K::KGlobalAccelD)
|
||||||
target_sources(kwin PRIVATE globalshortcuts.cpp)
|
|
||||||
target_link_libraries(kwin PRIVATE K::KGlobalAccelD)
|
target_link_libraries(kwin PRIVATE K::KGlobalAccelD)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,10 @@
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "utils/common.h"
|
#include "utils/common.h"
|
||||||
// KDE
|
// KDE
|
||||||
|
#if KWIN_BUILD_GLOBALSHORTCUTS
|
||||||
#include <kglobalaccel_interface.h>
|
#include <kglobalaccel_interface.h>
|
||||||
#include <kglobalacceld.h>
|
#include <kglobalacceld.h>
|
||||||
|
#endif
|
||||||
// Qt
|
// Qt
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
// system
|
// system
|
||||||
|
@ -96,6 +98,7 @@ GlobalShortcutsManager::~GlobalShortcutsManager()
|
||||||
|
|
||||||
void GlobalShortcutsManager::init()
|
void GlobalShortcutsManager::init()
|
||||||
{
|
{
|
||||||
|
#if KWIN_BUILD_GLOBALSHORTCUTS
|
||||||
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
if (kwinApp()->shouldUseWaylandForCompositing()) {
|
||||||
qputenv("KGLOBALACCELD_PLATFORM", QByteArrayLiteral("org.kde.kwin"));
|
qputenv("KGLOBALACCELD_PLATFORM", QByteArrayLiteral("org.kde.kwin"));
|
||||||
m_kglobalAccel = std::make_unique<KGlobalAccelD>();
|
m_kglobalAccel = std::make_unique<KGlobalAccelD>();
|
||||||
|
@ -106,6 +109,7 @@ void GlobalShortcutsManager::init()
|
||||||
qCDebug(KWIN_CORE) << "KGlobalAcceld inited";
|
qCDebug(KWIN_CORE) << "KGlobalAcceld inited";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutsManager::objectDeleted(QObject *object)
|
void GlobalShortcutsManager::objectDeleted(QObject *object)
|
||||||
|
@ -189,6 +193,7 @@ void GlobalShortcutsManager::forceRegisterTouchscreenSwipe(SwipeDirection direct
|
||||||
|
|
||||||
bool GlobalShortcutsManager::processKey(Qt::KeyboardModifiers mods, int keyQt)
|
bool GlobalShortcutsManager::processKey(Qt::KeyboardModifiers mods, int keyQt)
|
||||||
{
|
{
|
||||||
|
#if KWIN_BUILD_GLOBALSHORTCUTS
|
||||||
if (m_kglobalAccelInterface) {
|
if (m_kglobalAccelInterface) {
|
||||||
auto check = [this](Qt::KeyboardModifiers mods, int keyQt) {
|
auto check = [this](Qt::KeyboardModifiers mods, int keyQt) {
|
||||||
bool retVal = false;
|
bool retVal = false;
|
||||||
|
@ -217,17 +222,20 @@ bool GlobalShortcutsManager::processKey(Qt::KeyboardModifiers mods, int keyQt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GlobalShortcutsManager::processKeyRelease(Qt::KeyboardModifiers mods, int keyQt)
|
bool GlobalShortcutsManager::processKeyRelease(Qt::KeyboardModifiers mods, int keyQt)
|
||||||
{
|
{
|
||||||
|
#if KWIN_BUILD_GLOBALSHORTCUTS
|
||||||
if (m_kglobalAccelInterface) {
|
if (m_kglobalAccelInterface) {
|
||||||
QMetaObject::invokeMethod(m_kglobalAccelInterface,
|
QMetaObject::invokeMethod(m_kglobalAccelInterface,
|
||||||
"checkKeyReleased",
|
"checkKeyReleased",
|
||||||
Qt::DirectConnection,
|
Qt::DirectConnection,
|
||||||
Q_ARG(int, int(mods) | keyQt));
|
Q_ARG(int, int(mods) | keyQt));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,6 +256,7 @@ bool match(QList<GlobalShortcut> &shortcuts, Args... args)
|
||||||
// TODO(C++20): use ranges for a nicer way of filtering by shortcut type
|
// TODO(C++20): use ranges for a nicer way of filtering by shortcut type
|
||||||
bool GlobalShortcutsManager::processPointerPressed(Qt::KeyboardModifiers mods, Qt::MouseButtons pointerButtons)
|
bool GlobalShortcutsManager::processPointerPressed(Qt::KeyboardModifiers mods, Qt::MouseButtons pointerButtons)
|
||||||
{
|
{
|
||||||
|
#if KWIN_BUILD_GLOBALSHORTCUTS
|
||||||
// currently only used to better support modifier only shortcuts
|
// currently only used to better support modifier only shortcuts
|
||||||
// modifier-only shortcuts are not triggered if a pointer button is pressed
|
// modifier-only shortcuts are not triggered if a pointer button is pressed
|
||||||
if (m_kglobalAccelInterface) {
|
if (m_kglobalAccelInterface) {
|
||||||
|
@ -256,11 +265,13 @@ bool GlobalShortcutsManager::processPointerPressed(Qt::KeyboardModifiers mods, Q
|
||||||
Qt::DirectConnection,
|
Qt::DirectConnection,
|
||||||
Q_ARG(Qt::MouseButtons, pointerButtons));
|
Q_ARG(Qt::MouseButtons, pointerButtons));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return match<PointerButtonShortcut>(m_shortcuts, mods, pointerButtons);
|
return match<PointerButtonShortcut>(m_shortcuts, mods, pointerButtons);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GlobalShortcutsManager::processAxis(Qt::KeyboardModifiers mods, PointerAxisDirection axis)
|
bool GlobalShortcutsManager::processAxis(Qt::KeyboardModifiers mods, PointerAxisDirection axis)
|
||||||
{
|
{
|
||||||
|
#if KWIN_BUILD_GLOBALSHORTCUTS
|
||||||
// currently only used to better support modifier only shortcuts
|
// currently only used to better support modifier only shortcuts
|
||||||
// modifier-only shortcuts are not triggered if a pointer axis is used
|
// modifier-only shortcuts are not triggered if a pointer axis is used
|
||||||
if (m_kglobalAccelInterface) {
|
if (m_kglobalAccelInterface) {
|
||||||
|
@ -269,6 +280,7 @@ bool GlobalShortcutsManager::processAxis(Qt::KeyboardModifiers mods, PointerAxis
|
||||||
Qt::DirectConnection,
|
Qt::DirectConnection,
|
||||||
Q_ARG(int, axis));
|
Q_ARG(int, axis));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return match<PointerAxisShortcut>(m_shortcuts, mods, axis);
|
return match<PointerAxisShortcut>(m_shortcuts, mods, axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,10 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
|
#if KWIN_BUILD_GLOBALSHORTCUTS
|
||||||
class KGlobalAccelD;
|
class KGlobalAccelD;
|
||||||
class KGlobalAccelInterface;
|
class KGlobalAccelInterface;
|
||||||
|
#endif
|
||||||
namespace KWin
|
namespace KWin
|
||||||
{
|
{
|
||||||
class GlobalShortcut;
|
class GlobalShortcut;
|
||||||
|
@ -109,10 +110,12 @@ public:
|
||||||
void processPinchCancel();
|
void processPinchCancel();
|
||||||
void processPinchEnd();
|
void processPinchEnd();
|
||||||
|
|
||||||
|
#if KWIN_BUILD_GLOBALSHORTCUTS
|
||||||
void setKGlobalAccelInterface(KGlobalAccelInterface *interface)
|
void setKGlobalAccelInterface(KGlobalAccelInterface *interface)
|
||||||
{
|
{
|
||||||
m_kglobalAccelInterface = interface;
|
m_kglobalAccelInterface = interface;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void objectDeleted(QObject *object);
|
void objectDeleted(QObject *object);
|
||||||
|
@ -120,8 +123,10 @@ private:
|
||||||
|
|
||||||
QList<GlobalShortcut> m_shortcuts;
|
QList<GlobalShortcut> m_shortcuts;
|
||||||
|
|
||||||
|
#if KWIN_BUILD_GLOBALSHORTCUTS
|
||||||
std::unique_ptr<KGlobalAccelD> m_kglobalAccel;
|
std::unique_ptr<KGlobalAccelD> m_kglobalAccel;
|
||||||
KGlobalAccelInterface *m_kglobalAccelInterface = nullptr;
|
KGlobalAccelInterface *m_kglobalAccelInterface = nullptr;
|
||||||
|
#endif
|
||||||
std::unique_ptr<GestureRecognizer> m_touchpadGestureRecognizer;
|
std::unique_ptr<GestureRecognizer> m_touchpadGestureRecognizer;
|
||||||
std::unique_ptr<GestureRecognizer> m_touchscreenGestureRecognizer;
|
std::unique_ptr<GestureRecognizer> m_touchscreenGestureRecognizer;
|
||||||
};
|
};
|
||||||
|
|
|
@ -166,12 +166,10 @@ public:
|
||||||
void removeIdleInhibitor(Window *inhibitor);
|
void removeIdleInhibitor(Window *inhibitor);
|
||||||
|
|
||||||
Window *findToplevel(const QPointF &pos);
|
Window *findToplevel(const QPointF &pos);
|
||||||
#if KWIN_BUILD_GLOBALSHORTCUTS
|
|
||||||
GlobalShortcutsManager *shortcuts() const
|
GlobalShortcutsManager *shortcuts() const
|
||||||
{
|
{
|
||||||
return m_shortcuts;
|
return m_shortcuts;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends an event through all InputFilters.
|
* Sends an event through all InputFilters.
|
||||||
|
@ -322,9 +320,7 @@ private:
|
||||||
TouchInputRedirection *m_touch;
|
TouchInputRedirection *m_touch;
|
||||||
QObject *m_lastInputDevice = nullptr;
|
QObject *m_lastInputDevice = nullptr;
|
||||||
|
|
||||||
#if KWIN_BUILD_GLOBALSHORTCUTS
|
|
||||||
GlobalShortcutsManager *m_shortcuts;
|
GlobalShortcutsManager *m_shortcuts;
|
||||||
#endif
|
|
||||||
|
|
||||||
std::vector<std::unique_ptr<InputBackend>> m_inputBackends;
|
std::vector<std::unique_ptr<InputBackend>> m_inputBackends;
|
||||||
QList<InputDevice *> m_inputDevices;
|
QList<InputDevice *> m_inputDevices;
|
||||||
|
|
|
@ -37,7 +37,6 @@ void SwipeGestureHandler::componentComplete()
|
||||||
connect(m_gesture.get(), &SwipeGesture::cancelled, this, &SwipeGestureHandler::cancelled);
|
connect(m_gesture.get(), &SwipeGesture::cancelled, this, &SwipeGestureHandler::cancelled);
|
||||||
connect(m_gesture.get(), &SwipeGesture::progress, this, &SwipeGestureHandler::setProgress);
|
connect(m_gesture.get(), &SwipeGesture::progress, this, &SwipeGestureHandler::setProgress);
|
||||||
|
|
||||||
#if KWIN_BUILD_GLOBALSHORTCUTS // TODO: input()->shortcuts() should be built even when building without KGlobalAccelD
|
|
||||||
switch (m_deviceType) {
|
switch (m_deviceType) {
|
||||||
case Device::Touchpad:
|
case Device::Touchpad:
|
||||||
input()->shortcuts()->registerTouchpadSwipe(m_gesture.get());
|
input()->shortcuts()->registerTouchpadSwipe(m_gesture.get());
|
||||||
|
@ -46,7 +45,6 @@ void SwipeGestureHandler::componentComplete()
|
||||||
input()->shortcuts()->registerTouchscreenSwipe(m_gesture.get());
|
input()->shortcuts()->registerTouchscreenSwipe(m_gesture.get());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SwipeGestureHandler::Direction SwipeGestureHandler::direction() const
|
SwipeGestureHandler::Direction SwipeGestureHandler::direction() const
|
||||||
|
@ -125,13 +123,11 @@ void PinchGestureHandler::componentComplete()
|
||||||
connect(m_gesture.get(), &PinchGesture::cancelled, this, &PinchGestureHandler::cancelled);
|
connect(m_gesture.get(), &PinchGesture::cancelled, this, &PinchGestureHandler::cancelled);
|
||||||
connect(m_gesture.get(), &PinchGesture::progress, this, &PinchGestureHandler::setProgress);
|
connect(m_gesture.get(), &PinchGesture::progress, this, &PinchGestureHandler::setProgress);
|
||||||
|
|
||||||
#if KWIN_BUILD_GLOBALSHORTCUTS // TODO: input()->shortcuts() should be built even when building without KGlobalAccelD
|
|
||||||
switch (m_deviceType) {
|
switch (m_deviceType) {
|
||||||
case Device::Touchpad:
|
case Device::Touchpad:
|
||||||
input()->shortcuts()->registerTouchpadPinch(m_gesture.get());
|
input()->shortcuts()->registerTouchpadPinch(m_gesture.get());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PinchGestureHandler::Direction PinchGestureHandler::direction() const
|
PinchGestureHandler::Direction PinchGestureHandler::direction() const
|
||||||
|
|
Loading…
Reference in a new issue