diff --git a/autotests/integration/kwin_wayland_test.h b/autotests/integration/kwin_wayland_test.h index 798c1cf357..9e7ebeadf4 100644 --- a/autotests/integration/kwin_wayland_test.h +++ b/autotests/integration/kwin_wayland_test.h @@ -10,6 +10,7 @@ #define KWIN_WAYLAND_TEST_H #include "abstract_client.h" +#include "inputdevice.h" #include "main.h" // Qt @@ -460,6 +461,45 @@ enum class AdditionalWaylandInterface { OutputDeviceV2 = 1 << 14, }; Q_DECLARE_FLAGS(AdditionalWaylandInterfaces, AdditionalWaylandInterface) + +class VirtualInputDevice : public InputDevice +{ + Q_OBJECT + +public: + explicit VirtualInputDevice(QObject *parent = nullptr); + + void setPointer(bool set); + void setKeyboard(bool set); + void setTouch(bool set); + void setName(const QString &name); + + QString sysName() const override; + QString name() const override; + + bool isEnabled() const override; + void setEnabled(bool enabled) override; + + LEDs leds() const override; + void setLeds(LEDs leds) override; + + bool isKeyboard() const override; + bool isAlphaNumericKeyboard() const override; + bool isPointer() const override; + bool isTouchpad() const override; + bool isTouch() const override; + bool isTabletTool() const override; + bool isTabletPad() const override; + bool isTabletModeSwitch() const override; + bool isLidSwitch() const override; + +private: + QString m_name; + bool m_pointer = false; + bool m_keyboard = false; + bool m_touch = false; +}; + /** * Creates a Wayland Connection in a dedicated thread and creates various * client side objects which can be used to create windows. diff --git a/autotests/integration/test_helpers.cpp b/autotests/integration/test_helpers.cpp index 9b6978a446..5ac4527bcb 100644 --- a/autotests/integration/test_helpers.cpp +++ b/autotests/integration/test_helpers.cpp @@ -1272,5 +1272,104 @@ uint32_t WaylandOutputDeviceV2::rgbRange() const return m_rgbRange; } +VirtualInputDevice::VirtualInputDevice(QObject *parent) + : InputDevice(parent) +{ +} + +void VirtualInputDevice::setPointer(bool set) +{ + m_pointer = set; +} + +void VirtualInputDevice::setKeyboard(bool set) +{ + m_keyboard = set; +} + +void VirtualInputDevice::setTouch(bool set) +{ + m_touch = set; +} + +void VirtualInputDevice::setName(const QString &name) +{ + m_name = name; +} + +QString VirtualInputDevice::sysName() const +{ + return QString(); +} + +QString VirtualInputDevice::name() const +{ + return m_name; +} + +bool VirtualInputDevice::isEnabled() const +{ + return true; +} + +void VirtualInputDevice::setEnabled(bool enabled) +{ + Q_UNUSED(enabled) +} + +LEDs VirtualInputDevice::leds() const +{ + return LEDs(); +} + +void VirtualInputDevice::setLeds(LEDs leds) +{ + Q_UNUSED(leds) +} + +bool VirtualInputDevice::isKeyboard() const +{ + return m_keyboard; +} + +bool VirtualInputDevice::isAlphaNumericKeyboard() const +{ + return m_keyboard; +} + +bool VirtualInputDevice::isPointer() const +{ + return m_pointer; +} + +bool VirtualInputDevice::isTouchpad() const +{ + return false; +} + +bool VirtualInputDevice::isTouch() const +{ + return m_touch; +} + +bool VirtualInputDevice::isTabletTool() const +{ + return false; +} + +bool VirtualInputDevice::isTabletPad() const +{ + return false; +} + +bool VirtualInputDevice::isTabletModeSwitch() const +{ + return false; +} + +bool VirtualInputDevice::isLidSwitch() const +{ + return false; +} } } diff --git a/src/backends/virtual/virtual_backend.cpp b/src/backends/virtual/virtual_backend.cpp index d6110247f5..8b76000c4e 100644 --- a/src/backends/virtual/virtual_backend.cpp +++ b/src/backends/virtual/virtual_backend.cpp @@ -22,135 +22,10 @@ namespace KWin { -VirtualInputDevice::VirtualInputDevice(QObject *parent) - : InputDevice(parent) -{ -} - -void VirtualInputDevice::setPointer(bool set) -{ - m_pointer = set; -} - -void VirtualInputDevice::setKeyboard(bool set) -{ - m_keyboard = set; -} - -void VirtualInputDevice::setTouch(bool set) -{ - m_touch = set; -} - -void VirtualInputDevice::setName(const QString &name) -{ - m_name = name; -} - -QString VirtualInputDevice::sysName() const -{ - return QString(); -} - -QString VirtualInputDevice::name() const -{ - return m_name; -} - -bool VirtualInputDevice::isEnabled() const -{ - return true; -} - -void VirtualInputDevice::setEnabled(bool enabled) -{ - Q_UNUSED(enabled) -} - -LEDs VirtualInputDevice::leds() const -{ - return LEDs(); -} - -void VirtualInputDevice::setLeds(LEDs leds) -{ - Q_UNUSED(leds) -} - -bool VirtualInputDevice::isKeyboard() const -{ - return m_keyboard; -} - -bool VirtualInputDevice::isAlphaNumericKeyboard() const -{ - return m_keyboard; -} - -bool VirtualInputDevice::isPointer() const -{ - return m_pointer; -} - -bool VirtualInputDevice::isTouchpad() const -{ - return false; -} - -bool VirtualInputDevice::isTouch() const -{ - return m_touch; -} - -bool VirtualInputDevice::isTabletTool() const -{ - return false; -} - -bool VirtualInputDevice::isTabletPad() const -{ - return false; -} - -bool VirtualInputDevice::isTabletModeSwitch() const -{ - return false; -} - -bool VirtualInputDevice::isLidSwitch() const -{ - return false; -} - -VirtualInputBackend::VirtualInputBackend(VirtualBackend *backend, QObject *parent) - : InputBackend(parent) - , m_backend(backend) -{ -} - -void VirtualInputBackend::initialize() -{ - Q_EMIT deviceAdded(m_backend->virtualPointer()); - Q_EMIT deviceAdded(m_backend->virtualKeyboard()); - Q_EMIT deviceAdded(m_backend->virtualTouch()); -} - VirtualBackend::VirtualBackend(QObject *parent) : Platform(parent) , m_session(Session::create(Session::Type::Noop, this)) { - m_virtualKeyboard.reset(new VirtualInputDevice()); - m_virtualKeyboard->setName(QStringLiteral("Virtual Keyboard 1")); - m_virtualKeyboard->setKeyboard(true); - - m_virtualPointer.reset(new VirtualInputDevice()); - m_virtualPointer->setName(QStringLiteral("Virtual Pointer 1")); - m_virtualPointer->setPointer(true); - - m_virtualTouch.reset(new VirtualInputDevice()); - m_virtualTouch->setName(QStringLiteral("Virtual Touch 1")); - m_virtualTouch->setTouch(true); - if (qEnvironmentVariableIsSet("KWIN_WAYLAND_VIRTUAL_SCREENSHOTS")) { m_screenshotDir.reset(new QTemporaryDir); if (!m_screenshotDir->isValid()) { @@ -200,21 +75,6 @@ bool VirtualBackend::initialize() return true; } -VirtualInputDevice *VirtualBackend::virtualPointer() const -{ - return m_virtualPointer.data(); -} - -VirtualInputDevice *VirtualBackend::virtualKeyboard() const -{ - return m_virtualKeyboard.data(); -} - -VirtualInputDevice *VirtualBackend::virtualTouch() const -{ - return m_virtualTouch.data(); -} - QString VirtualBackend::screenshotDirPath() const { if (m_screenshotDir.isNull()) { @@ -223,11 +83,6 @@ QString VirtualBackend::screenshotDirPath() const return m_screenshotDir->path(); } -InputBackend *VirtualBackend::createInputBackend() -{ - return new VirtualInputBackend(this); -} - QPainterBackend *VirtualBackend::createQPainterBackend() { return new VirtualQPainterBackend(this); diff --git a/src/backends/virtual/virtual_backend.h b/src/backends/virtual/virtual_backend.h index 1875f82b76..3445c4633a 100644 --- a/src/backends/virtual/virtual_backend.h +++ b/src/backends/virtual/virtual_backend.h @@ -9,8 +9,6 @@ #ifndef KWIN_VIRTUAL_BACKEND_H #define KWIN_VIRTUAL_BACKEND_H -#include "inputbackend.h" -#include "inputdevice.h" #include "platform.h" #include @@ -25,57 +23,6 @@ namespace KWin class VirtualBackend; class VirtualOutput; -class VirtualInputDevice : public InputDevice -{ - Q_OBJECT - -public: - explicit VirtualInputDevice(QObject *parent = nullptr); - - void setPointer(bool set); - void setKeyboard(bool set); - void setTouch(bool set); - void setName(const QString &name); - - QString sysName() const override; - QString name() const override; - - bool isEnabled() const override; - void setEnabled(bool enabled) override; - - LEDs leds() const override; - void setLeds(LEDs leds) override; - - bool isKeyboard() const override; - bool isAlphaNumericKeyboard() const override; - bool isPointer() const override; - bool isTouchpad() const override; - bool isTouch() const override; - bool isTabletTool() const override; - bool isTabletPad() const override; - bool isTabletModeSwitch() const override; - bool isLidSwitch() const override; - -private: - QString m_name; - bool m_pointer = false; - bool m_keyboard = false; - bool m_touch = false; -}; - -class VirtualInputBackend : public InputBackend -{ - Q_OBJECT - -public: - explicit VirtualInputBackend(VirtualBackend *backend, QObject *parent = nullptr); - - void initialize() override; - -private: - VirtualBackend *m_backend; -}; - class KWIN_EXPORT VirtualBackend : public Platform { Q_OBJECT @@ -94,11 +41,6 @@ public: } QString screenshotDirPath() const; - VirtualInputDevice *virtualPointer() const; - VirtualInputDevice *virtualKeyboard() const; - VirtualInputDevice *virtualTouch() const; - - InputBackend *createInputBackend() override; QPainterBackend* createQPainterBackend() override; OpenGLBackend *createOpenGLBackend() override; @@ -126,10 +68,6 @@ private: QVector m_outputsEnabled; QScopedPointer m_screenshotDir; Session *m_session; - - QScopedPointer m_virtualPointer; - QScopedPointer m_virtualKeyboard; - QScopedPointer m_virtualTouch; }; }