diff --git a/src/backends/libinput/connection.cpp b/src/backends/libinput/connection.cpp index eb96cf4a69..acdefb528d 100644 --- a/src/backends/libinput/connection.cpp +++ b/src/backends/libinput/connection.cpp @@ -476,8 +476,10 @@ void Connection::processEvents() if (workspace()) { #ifndef KWIN_BUILD_TESTING - auto client = workspace()->activeClient(); - auto *output = static_cast(client ? client->output() : tte->device()->output()); + AbstractWaylandOutput *output = static_cast(tte->device()->output()); + if (!output && workspace()->activeClient()) { + output = static_cast(workspace()->activeClient()->output()); + } if (!output) { output = static_cast(workspace()->activeOutput()); } diff --git a/src/backends/libinput/device.cpp b/src/backends/libinput/device.cpp index fa5bd82249..12647429b6 100644 --- a/src/backends/libinput/device.cpp +++ b/src/backends/libinput/device.cpp @@ -109,7 +109,7 @@ enum class ConfigKey { ScrollFactor, Orientation, Calibration, - Screen + OutputName }; struct ConfigData { @@ -188,8 +188,7 @@ static const QMap s_configData { {ConfigKey::ScrollFactor, ConfigData(QByteArrayLiteral("ScrollFactor"), &Device::setScrollFactor, &Device::scrollFactorDefault)}, {ConfigKey::Orientation, ConfigData(QByteArrayLiteral("Orientation"), &Device::setOrientation, &Device::defaultOrientation)}, {ConfigKey::Calibration, ConfigData(QByteArrayLiteral("CalibrationMatrix"), &Device::setCalibrationMatrix, &Device::defaultCalibrationMatrix)}, - {ConfigKey::Screen, ConfigData(QByteArrayLiteral("Screen"), &Device::setScreen, &Device::defaultScreen)} -}; + {ConfigKey::OutputName, ConfigData(QByteArrayLiteral("OutputName"), &Device::setOutputName, &Device::defaultOutputName)}}; namespace { QMatrix4x4 getMatrix(libinput_device *device, std::function getter) @@ -661,15 +660,17 @@ void Device::setOrientation(Qt::ScreenOrientation orientation) } } -void Device::setScreen(QString name) +void Device::setOutputName(QString name) { #ifndef KWIN_BUILD_TESTING - auto outputs = kwinApp()->platform()->enabledOutputs(); - for(int i = 0; i < outputs.count(); ++i) { + if (name.isEmpty()) { + setOutput(nullptr); + return; + } + auto outputs = kwinApp()->platform()->enabledOutputs(); + for (int i = 0; i < outputs.count(); ++i) { if (outputs[i]->name() == name) { setOutput(outputs[i]); - writeEntry(ConfigKey::Screen, outputs[i]->uuid().toString()); - Q_EMIT screenChanged(); break; } } @@ -686,6 +687,12 @@ AbstractOutput *Device::output() const void Device::setOutput(AbstractOutput *output) { m_output = output; + if (m_output) { + writeEntry(ConfigKey::OutputName, output->name()); + } else { + writeEntry(ConfigKey::OutputName, QString()); + } + Q_EMIT outputNameChanged(); } static libinput_led toLibinputLEDS(LEDs leds) diff --git a/src/backends/libinput/device.h b/src/backends/libinput/device.h index c5543cdde9..251733086b 100644 --- a/src/backends/libinput/device.h +++ b/src/backends/libinput/device.h @@ -47,7 +47,7 @@ class KWIN_EXPORT Device : public InputDevice Q_PROPERTY(bool gestureSupport READ supportsGesture CONSTANT) Q_PROPERTY(QString name READ name CONSTANT) Q_PROPERTY(QString sysName READ sysName CONSTANT) - Q_PROPERTY(QString outputName READ outputName CONSTANT) + Q_PROPERTY(QString outputName READ outputName WRITE setOutputName NOTIFY outputNameChanged) Q_PROPERTY(QSizeF size READ size CONSTANT) Q_PROPERTY(quint32 product READ product CONSTANT) Q_PROPERTY(quint32 vendor READ vendor CONSTANT) @@ -60,6 +60,7 @@ class KWIN_EXPORT Device : public InputDevice Q_PROPERTY(QMatrix4x4 defaultCalibrationMatrix READ defaultCalibrationMatrix CONSTANT) Q_PROPERTY(QMatrix4x4 calibrationMatrix READ calibrationMatrix WRITE setCalibrationMatrix NOTIFY calibrationMatrixChanged) Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) + Q_PROPERTY(int orientationDBus READ orientation WRITE setOrientationDBus NOTIFY orientationChanged) Q_PROPERTY(bool supportsLeftHanded READ supportsLeftHanded CONSTANT) Q_PROPERTY(bool leftHandedEnabledByDefault READ leftHandedEnabledByDefault CONSTANT) @@ -368,6 +369,10 @@ public: return m_orientation; } void setOrientation(Qt::ScreenOrientation orientation); + void setOrientationDBus(int orientation) + { + setOrientation(Qt::ScreenOrientation(orientation)); + } qreal defaultPointerAcceleration() const { return m_defaultPointerAcceleration; @@ -468,8 +473,11 @@ public: /** * Used to deserialize monitor data from KConfig when initializing a device */ - void setScreen(QString uuid); - QString defaultScreen() const { return {}; } + void setOutputName(QString uuid); + QString defaultOutputName() const + { + return {}; + } /** * Loads the configuration and applies it to the Device @@ -514,7 +522,7 @@ Q_SIGNALS: void tapButtonMapChanged(); void calibrationMatrixChanged(); void orientationChanged(); - void screenChanged(); + void outputNameChanged(); void leftHandedChanged(); void disableWhileTypingChanged(); void pointerAccelerationChanged();