libinput: Successfully set the output of a device from the dbus interface
This commit is contained in:
parent
449da861f3
commit
5ff22d7765
3 changed files with 31 additions and 14 deletions
|
@ -476,8 +476,10 @@ void Connection::processEvents()
|
|||
|
||||
if (workspace()) {
|
||||
#ifndef KWIN_BUILD_TESTING
|
||||
auto client = workspace()->activeClient();
|
||||
auto *output = static_cast<AbstractWaylandOutput *>(client ? client->output() : tte->device()->output());
|
||||
AbstractWaylandOutput *output = static_cast<AbstractWaylandOutput *>(tte->device()->output());
|
||||
if (!output && workspace()->activeClient()) {
|
||||
output = static_cast<AbstractWaylandOutput *>(workspace()->activeClient()->output());
|
||||
}
|
||||
if (!output) {
|
||||
output = static_cast<AbstractWaylandOutput *>(workspace()->activeOutput());
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ enum class ConfigKey {
|
|||
ScrollFactor,
|
||||
Orientation,
|
||||
Calibration,
|
||||
Screen
|
||||
OutputName
|
||||
};
|
||||
|
||||
struct ConfigData {
|
||||
|
@ -188,8 +188,7 @@ static const QMap<ConfigKey, ConfigData> 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<int(libinput_device *, float[6])> 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)
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue