From 2c874fc3e0f4c004e0bf75f39a75cf448e2017c6 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 27 Sep 2022 01:17:20 +0200 Subject: [PATCH] tablet: Ensure persistency of the outputName property With this change, when the specified output is disconnected, it will just behave as if none were selected but when it's connected again it will pick it back up. BUG: 456857 --- src/backends/libinput/connection.cpp | 4 ++-- src/backends/libinput/device.cpp | 22 +++++++++------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/backends/libinput/connection.cpp b/src/backends/libinput/connection.cpp index 2ba725e6a1..5ee27b492e 100644 --- a/src/backends/libinput/connection.cpp +++ b/src/backends/libinput/connection.cpp @@ -529,7 +529,7 @@ void Connection::applyScreenToDevice(Device *device) { #ifndef KWIN_BUILD_TESTING QMutexLocker locker(&m_mutex); - if (!device->isTouch()) { + if (!device->isTouch() && !device->isTabletTool()) { return; } @@ -549,7 +549,7 @@ void Connection::applyScreenToDevice(Device *device) } } } - if (!deviceOutput) { + if (!deviceOutput && device->isTouch()) { // do we have an internal screen? Output *internalOutput = nullptr; for (Output *output : outputs) { diff --git a/src/backends/libinput/device.cpp b/src/backends/libinput/device.cpp index c1093db42b..a5ae78f0c5 100644 --- a/src/backends/libinput/device.cpp +++ b/src/backends/libinput/device.cpp @@ -628,8 +628,12 @@ void Device::setOrientation(Qt::ScreenOrientation orientation) void Device::setOutputName(const QString &name) { #ifndef KWIN_BUILD_TESTING + if (name == m_outputName) { + return; + } + + setOutput(nullptr); if (name.isEmpty()) { - setOutput(nullptr); return; } auto outputs = kwinApp()->platform()->outputs(); @@ -642,6 +646,10 @@ void Device::setOutputName(const QString &name) break; } } + + m_outputName = name; + writeEntry(ConfigKey::OutputName, name); + Q_EMIT outputNameChanged(); #else Q_UNUSED(name) #endif @@ -654,19 +662,7 @@ Output *Device::output() const void Device::setOutput(Output *output) { -#ifndef KWIN_BUILD_TESTING m_output = output; - if (m_output) { - m_outputName = output->name(); - writeEntry(ConfigKey::OutputName, output->name()); - } else { - m_outputName = QString(); - writeEntry(ConfigKey::OutputName, QString()); - } - Q_EMIT outputNameChanged(); -#else - Q_UNUSED(output) -#endif } static libinput_led toLibinputLEDS(LEDs leds)