From fde7d44941d70686b835a2b7791463d9c55e65ea Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Wed, 3 Aug 2022 11:27:35 +0200 Subject: [PATCH] tabletmodemanager: move global to Application --- src/main.cpp | 6 ++++++ src/main.h | 3 +++ src/main_wayland.cpp | 2 +- src/main_x11.cpp | 2 +- src/tabletmodemanager.cpp | 5 +---- src/tabletmodemanager.h | 2 +- 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cfa32fec4b..ac3acf4438 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,7 @@ #endif #include "session.h" #include "sm.h" +#include "tabletmodemanager.h" #include "utils/xcbutils.h" #include "wayland/surface_interface.h" #include "workspace.h" @@ -278,6 +279,11 @@ void Application::createInputMethod() m_inputMethod = std::make_unique(); } +void Application::createTabletModeManager() +{ + m_tabletModeManager = std::make_unique(); +} + void Application::installNativeX11EventFilter() { installNativeEventFilter(m_eventFilter.get()); diff --git a/src/main.h b/src/main.h index 1d951aee13..0742cdf95a 100644 --- a/src/main.h +++ b/src/main.h @@ -34,6 +34,7 @@ class PluginManager; class InputMethod; class ColorManager; class ScreenLockerWatcher; +class TabletModeManager; class XcbEventFilter : public QAbstractNativeEventFilter { @@ -261,6 +262,7 @@ protected: void createPlugins(); void createColorManager(); void createInputMethod(); + void createTabletModeManager(); void destroyInput(); void destroyWorkspace(); void destroyCompositor(); @@ -299,6 +301,7 @@ private: std::unique_ptr m_pluginManager; std::unique_ptr m_inputMethod; std::unique_ptr m_colorManager; + std::unique_ptr m_tabletModeManager; #if KWIN_BUILD_SCREENLOCKER std::unique_ptr m_screenLockerWatcher; #endif diff --git a/src/main_wayland.cpp b/src/main_wayland.cpp index 67a091ccd3..3f22f84cb8 100644 --- a/src/main_wayland.cpp +++ b/src/main_wayland.cpp @@ -151,7 +151,7 @@ void ApplicationWayland::performStartup() createInput(); createInputMethod(); - TabletModeManager::create(this); + createTabletModeManager(); WaylandCompositor::create(); diff --git a/src/main_x11.cpp b/src/main_x11.cpp index 676236bd9f..e3b199d23c 100644 --- a/src/main_x11.cpp +++ b/src/main_x11.cpp @@ -259,7 +259,7 @@ void ApplicationX11::performStartup() createAtoms(); - TabletModeManager::create(this); + createTabletModeManager(); } bool ApplicationX11::notify(QObject *o, QEvent *e) diff --git a/src/tabletmodemanager.cpp b/src/tabletmodemanager.cpp index 09fb073855..4e2f224239 100644 --- a/src/tabletmodemanager.cpp +++ b/src/tabletmodemanager.cpp @@ -21,8 +21,6 @@ namespace KWin { -KWIN_SINGLETON_FACTORY_VARIABLE(TabletModeManager, s_manager) - static bool shouldIgnoreDevice(InputDevice *device) { if (qobject_cast(device)) { @@ -111,8 +109,7 @@ private: TabletModeManager *const m_parent; }; -TabletModeManager::TabletModeManager(QObject *parent) - : QObject(parent) +TabletModeManager::TabletModeManager() { if (waylandServer()) { if (input()->hasTabletModeSwitch()) { diff --git a/src/tabletmodemanager.h b/src/tabletmodemanager.h index 06a9657196..679e6dc70e 100644 --- a/src/tabletmodemanager.h +++ b/src/tabletmodemanager.h @@ -32,6 +32,7 @@ public: On }; + explicit TabletModeManager(); ~TabletModeManager() override = default; void setTabletModeAvailable(bool detecting); @@ -56,7 +57,6 @@ private: bool m_isTabletMode = false; bool m_detecting = false; ConfiguredMode m_configuredMode = ConfiguredMode::Auto; - KWIN_SINGLETON_VARIABLE(TabletModeManager, s_manager) }; }