A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2018 Marco Martin <mart@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
|
|
|
|
|
|
*/
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
|
|
|
|
#include "tabletmodemanager.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "input_event.h"
|
|
|
|
#include "input_event_spy.h"
|
|
|
|
|
|
|
|
#include "libinput/device.h"
|
|
|
|
#include "libinput/connection.h"
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
|
|
|
|
#include <QTimer>
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
#include <QDBusConnection>
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
|
|
|
|
KWIN_SINGLETON_FACTORY_VARIABLE(TabletModeManager, s_manager)
|
|
|
|
|
|
|
|
class TabletModeSwitchEventSpy : public QObject, public InputEventSpy
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit TabletModeSwitchEventSpy(TabletModeManager *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, m_parent(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void switchEvent(SwitchEvent *event) override
|
|
|
|
{
|
|
|
|
if (!event->device()->isTabletModeSwitch()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (event->state()) {
|
|
|
|
case SwitchEvent::State::Off:
|
|
|
|
m_parent->setIsTablet(false);
|
|
|
|
break;
|
|
|
|
case SwitchEvent::State::On:
|
|
|
|
m_parent->setIsTablet(true);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
}
|
|
|
|
}
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
|
|
|
|
private:
|
|
|
|
TabletModeManager * const m_parent;
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class TabletModeTouchpadRemovedSpy : public QObject
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit TabletModeTouchpadRemovedSpy(TabletModeManager *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, m_parent(parent)
|
|
|
|
{
|
|
|
|
auto c = LibInput::Connection::self();
|
|
|
|
connect(c, &LibInput::Connection::deviceAdded, this, &TabletModeTouchpadRemovedSpy::refresh);
|
|
|
|
connect(c, &LibInput::Connection::deviceRemoved, this, &TabletModeTouchpadRemovedSpy::refresh);
|
|
|
|
|
|
|
|
check();
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
}
|
|
|
|
|
|
|
|
void refresh(LibInput::Device* d) {
|
|
|
|
if (!d->isTouch() && !d->isPointer())
|
|
|
|
return;
|
|
|
|
check();
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
}
|
|
|
|
|
|
|
|
void check() {
|
|
|
|
if (!LibInput::Connection::self()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto devices = LibInput::Connection::self()->devices();
|
|
|
|
const bool hasTouch = std::any_of(devices.constBegin(), devices.constEnd(), [](LibInput::Device* device){ return device->isTouch(); });
|
|
|
|
m_parent->setTabletModeAvailable(hasTouch);
|
|
|
|
|
|
|
|
const bool hasPointer = std::any_of(devices.constBegin(), devices.constEnd(), [](LibInput::Device* device){ return device->isPointer(); });
|
|
|
|
m_parent->setIsTablet(hasTouch && !hasPointer);
|
|
|
|
}
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
|
|
|
|
private:
|
|
|
|
TabletModeManager * const m_parent;
|
|
|
|
};
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
|
|
|
|
TabletModeManager::TabletModeManager(QObject *parent)
|
|
|
|
: QObject(parent)
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
{
|
|
|
|
if (input()->hasTabletModeSwitch()) {
|
|
|
|
input()->installInputEventSpy(new TabletModeSwitchEventSpy(this));
|
|
|
|
} else {
|
|
|
|
hasTabletModeInputChanged(false);
|
|
|
|
}
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
|
|
|
|
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KWin"),
|
|
|
|
QStringLiteral("org.kde.KWin.TabletModeManager"),
|
|
|
|
this,
|
|
|
|
QDBusConnection::ExportAllProperties | QDBusConnection::ExportAllSignals
|
|
|
|
);
|
Expose if the tablet mode switch is available
Summary:
expose in the libinput wrapper a property that tells whether
a tablet mode switch input device is present on the machine,
expose it trough dbus
Test Plan:
still not complete, I need a way to either access the connection
from TabletModeManager or setting to TabletModeManager from input.cpp
Reviewers: #kwin, #plasma, graesslin
Reviewed By: #kwin, #plasma, graesslin
Subscribers: graesslin, ngraham, davidedmundson, plasma-devel, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9944
7 years ago
|
|
|
|
|
|
|
connect(input(), &InputRedirection::hasTabletModeSwitchChanged, this, &TabletModeManager::hasTabletModeInputChanged);
|
Expose if the tablet mode switch is available
Summary:
expose in the libinput wrapper a property that tells whether
a tablet mode switch input device is present on the machine,
expose it trough dbus
Test Plan:
still not complete, I need a way to either access the connection
from TabletModeManager or setting to TabletModeManager from input.cpp
Reviewers: #kwin, #plasma, graesslin
Reviewed By: #kwin, #plasma, graesslin
Subscribers: graesslin, ngraham, davidedmundson, plasma-devel, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9944
7 years ago
|
|
|
}
|
|
|
|
|
|
|
|
void KWin::TabletModeManager::hasTabletModeInputChanged(bool set)
|
|
|
|
{
|
|
|
|
if (set) {
|
|
|
|
input()->installInputEventSpy(new TabletModeSwitchEventSpy(this));
|
|
|
|
setTabletModeAvailable(true);
|
|
|
|
} else {
|
|
|
|
auto setupDetector = [this] {
|
|
|
|
auto spy = new TabletModeTouchpadRemovedSpy(this);
|
|
|
|
connect(input(), &InputRedirection::hasTabletModeSwitchChanged, spy, [spy](bool set){
|
|
|
|
if (set)
|
|
|
|
spy->deleteLater();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
if (LibInput::Connection::self())
|
|
|
|
setupDetector();
|
|
|
|
else
|
|
|
|
QTimer::singleShot(2000, this, setupDetector);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Expose if the tablet mode switch is available
Summary:
expose in the libinput wrapper a property that tells whether
a tablet mode switch input device is present on the machine,
expose it trough dbus
Test Plan:
still not complete, I need a way to either access the connection
from TabletModeManager or setting to TabletModeManager from input.cpp
Reviewers: #kwin, #plasma, graesslin
Reviewed By: #kwin, #plasma, graesslin
Subscribers: graesslin, ngraham, davidedmundson, plasma-devel, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D9944
7 years ago
|
|
|
bool TabletModeManager::isTabletModeAvailable() const
|
|
|
|
{
|
|
|
|
return m_detecting;
|
A basic TabletModeManager
Summary:
depends from D9521
listens to switch events and updates the tablet mode status
which is exposed to dbus in the org.kde.KWin.TabletModeManager
interface
Test Plan:
as hardware support is limited, testing of clients
so far is done by the setter in the dbus property,
which should be removed from the final version.
It has been tested to successfully work on a Thinkpad.
Reviewers: #plasma, #kwin, graesslin
Reviewed By: #plasma, #kwin, graesslin
Subscribers: graesslin, davidedmundson, plasma-devel, kwin, #kwin
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D9764
7 years ago
|
|
|
}
|
|
|
|
|
|
|
|
bool TabletModeManager::isTablet() const
|
|
|
|
{
|
|
|
|
return m_isTabletMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabletModeManager::setIsTablet(bool tablet)
|
|
|
|
{
|
|
|
|
if (m_isTabletMode == tablet) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_isTabletMode = tablet;
|
|
|
|
emit tabletModeChanged(tablet);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWin::TabletModeManager::setTabletModeAvailable(bool detecting)
|
|
|
|
{
|
|
|
|
if (m_detecting != detecting) {
|
|
|
|
m_detecting = detecting;
|
|
|
|
emit tabletModeAvailableChanged(detecting);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace KWin
|