From cdeacdbdadedb1ac6ea64a51e016737e485b4067 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Sat, 19 Nov 2022 15:10:15 +0100 Subject: [PATCH] backends/libinput: update screens on Workspace::outputsChanged Using OutputBackend::outputsQueried can cause problems because it's emitted before output settings like enablement get adjusted to the new output configuration. It also doesn't react to output changes initiated by KScreen and is in the way of plans to use multiple output backends at the same time. BUG: 461901 --- src/backends/libinput/connection.cpp | 1 - src/backends/libinput/libinputbackend.cpp | 5 +++++ src/backends/libinput/libinputbackend.h | 1 + src/core/inputbackend.h | 4 ++++ src/input.cpp | 8 ++++++++ src/input.h | 1 + 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/backends/libinput/connection.cpp b/src/backends/libinput/connection.cpp index b3917f7203..78139499a8 100644 --- a/src/backends/libinput/connection.cpp +++ b/src/backends/libinput/connection.cpp @@ -136,7 +136,6 @@ void Connection::doSetup() deactivate(); } }); - connect(kwinApp()->outputBackend(), &OutputBackend::outputsQueried, this, &Connection::updateScreens); handleEvent(); } diff --git a/src/backends/libinput/libinputbackend.cpp b/src/backends/libinput/libinputbackend.cpp index 541b91b520..f8d36d5bb0 100644 --- a/src/backends/libinput/libinputbackend.cpp +++ b/src/backends/libinput/libinputbackend.cpp @@ -46,4 +46,9 @@ void LibinputBackend::initialize() m_connection->setup(); } +void LibinputBackend::updateScreens() +{ + m_connection->updateScreens(); +} + } // namespace KWin diff --git a/src/backends/libinput/libinputbackend.h b/src/backends/libinput/libinputbackend.h index 03e23a65fb..3e406fc3de 100644 --- a/src/backends/libinput/libinputbackend.h +++ b/src/backends/libinput/libinputbackend.h @@ -29,6 +29,7 @@ public: ~LibinputBackend() override; void initialize() override; + void updateScreens() override; private: QThread m_thread; diff --git a/src/core/inputbackend.h b/src/core/inputbackend.h index 6b33cf6656..0dd0169a8b 100644 --- a/src/core/inputbackend.h +++ b/src/core/inputbackend.h @@ -31,6 +31,10 @@ public: { } + virtual void updateScreens() + { + } + Q_SIGNALS: void deviceAdded(InputDevice *device); void deviceRemoved(InputDevice *device); diff --git a/src/input.cpp b/src/input.cpp index 74a701789e..b8e4ea9ffd 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -2588,6 +2588,7 @@ void InputRedirection::init() void InputRedirection::setupWorkspace() { + connect(workspace(), &Workspace::outputsChanged, this, &InputRedirection::updateScreens); if (waylandServer()) { m_keyboard->init(); m_pointer->init(); @@ -2602,6 +2603,13 @@ void InputRedirection::setupWorkspace() } } +void InputRedirection::updateScreens() +{ + for (const auto &backend : m_inputBackends) { + backend->updateScreens(); + } +} + QObject *InputRedirection::lastInputHandler() const { return m_lastInputDevice; diff --git a/src/input.h b/src/input.h index 4aa68d6352..4a4dd81bb3 100644 --- a/src/input.h +++ b/src/input.h @@ -302,6 +302,7 @@ public Q_SLOTS: private Q_SLOTS: void handleInputConfigChanged(const KConfigGroup &group); + void updateScreens(); private: void setupInputBackends();