20#include <QDBusConnection>
27 if (qobject_cast<FakeInputDevice*>(device)) {
37 if (
auto udev = libinput_device_get_udev_device(
libinput_device->device()); udev) {
38 ignore = udev_device_has_tag(udev,
"kwin-ignore-tablet-mode");
39 udev_device_unref(udev);
59 switch (event->
state()) {
98 const bool hasTouch = std::any_of(devices.constBegin(), devices.constEnd(), [](
InputDevice *device) {
99 return device->isTouch() && !shouldIgnoreDevice(device);
103 const bool hasPointer = std::any_of(devices.constBegin(), devices.constEnd(), [](
InputDevice *device) {
104 return device->isPointer() && !shouldIgnoreDevice(device);
116 if (
input()->hasTabletModeSwitch()) {
119 hasTabletModeInputChanged(
false);
123 KSharedConfig::Ptr kwinSettings = kwinApp()->config();
124 m_settingsWatcher = KConfigWatcher::create(kwinSettings);
125 connect(m_settingsWatcher.data(), &KConfigWatcher::configChanged,
this, &KWin::TabletModeManager::refreshSettings);
128 QDBusConnection::sessionBus().registerObject(QStringLiteral(
"/org/kde/KWin"),
129 QStringLiteral(
"org.kde.KWin.TabletModeManager"),
132 QDBusConnection::ExportAllProperties | QDBusConnection::ExportAllSignals | QDBusConnection::ExportAllSlots);
139void KWin::TabletModeManager::refreshSettings()
141 KSharedConfig::Ptr kwinSettings = kwinApp()->config();
142 KConfigGroup cg = kwinSettings->group(QStringLiteral(
"Input"));
143 const QString tabletModeConfig = cg.readPathEntry(
"TabletMode", QStringLiteral(
"auto"));
144 const bool oldEffectiveTabletMode = effectiveTabletMode();
145 if (tabletModeConfig == QStringLiteral(
"on")) {
146 m_configuredMode = ConfiguredMode::On;
148 Q_EMIT tabletModeAvailableChanged(
true);
150 }
else if (tabletModeConfig == QStringLiteral(
"off")) {
151 m_configuredMode = ConfiguredMode::Off;
153 m_configuredMode = ConfiguredMode::Auto;
155 if (effectiveTabletMode() != oldEffectiveTabletMode) {
156 Q_EMIT tabletModeChanged(effectiveTabletMode());
160void KWin::TabletModeManager::hasTabletModeInputChanged(
bool set)
164 setTabletModeAvailable(
true);
166 auto spy =
new TabletModeTouchpadRemovedSpy(
this);
182 switch (m_configuredMode) {
192 return m_isTabletMode;
199 return m_isTabletMode;
204 if (m_isTabletMode == tablet) {
209 m_isTabletMode = tablet;
217 if (m_detecting == detecting) {
221 m_detecting = detecting;
222 Q_EMIT tabletModeAvailableChanged(isTabletModeAvailable());
227 return m_configuredMode;
232#include "moc_tabletmodemanager.cpp"
InputDevice * device() const
void setIsTablet(bool tablet)
void setTabletModeAvailable(bool detecting)
bool isTabletModeAvailable() const
ConfiguredMode configuredMode() const
bool effectiveTabletMode() const
void tabletModeChanged(bool tabletMode)
TabletModeSwitchEventSpy(TabletModeManager *parent)
void switchEvent(SwitchEvent *event) override
TabletModeTouchpadRemovedSpy(TabletModeManager *parent)
void refresh(InputDevice *inputDevice)
WaylandServer * waylandServer()
InputRedirection * input()