diff --git a/src/input.cpp b/src/input.cpp index 7ef54e2452..b6f328f07a 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -2669,8 +2669,6 @@ InputRedirection::~InputRedirection() m_inputDevices.clear(); s_self = nullptr; - qDeleteAll(m_filters); - qDeleteAll(m_spies); } void InputRedirection::installInputEventFilter(InputEventFilter *filter) @@ -2911,36 +2909,72 @@ void InputRedirection::setupInputFilters() { const bool hasGlobalShortcutSupport = waylandServer()->hasGlobalShortcutSupport(); if (kwinApp()->session()->capabilities() & Session::Capability::SwitchTerminal) { - installInputEventFilter(new VirtualTerminalFilter); + m_virtualTerminalFilter = std::make_unique(); + installInputEventFilter(m_virtualTerminalFilter.get()); } - installInputEventSpy(new HideCursorSpy); - installInputEventSpy(new UserActivitySpy); - installInputEventSpy(new WindowInteractedSpy); + + m_hideCursorSpy = std::make_unique(); + installInputEventSpy(m_hideCursorSpy.get()); + + m_userActivitySpy = std::make_unique(); + installInputEventSpy(m_userActivitySpy.get()); + + m_windowInteractedSpy = std::make_unique(); + installInputEventSpy(m_windowInteractedSpy.get()); + if (hasGlobalShortcutSupport) { - installInputEventFilter(new TerminateServerFilter); + m_terminateServerFilter = std::make_unique(); + installInputEventFilter(m_terminateServerFilter.get()); } - installInputEventFilter(new DragAndDropInputFilter); - installInputEventFilter(new LockScreenFilter); - m_windowSelector = new WindowSelectorFilter; - installInputEventFilter(m_windowSelector); + + m_dragAndDropFilter = std::make_unique(); + installInputEventFilter(m_dragAndDropFilter.get()); + + m_lockscreenFilter = std::make_unique(); + installInputEventFilter(m_lockscreenFilter.get()); + + m_windowSelector = std::make_unique(); + installInputEventFilter(m_windowSelector.get()); + if (hasGlobalShortcutSupport) { - installInputEventFilter(new ScreenEdgeInputFilter); + m_screenEdgeFilter = std::make_unique(); + installInputEventFilter(m_screenEdgeFilter.get()); } #if KWIN_BUILD_TABBOX - installInputEventFilter(new TabBoxInputFilter); + m_tabboxFilter = std::make_unique(); + installInputEventFilter(m_tabboxFilter.get()); #endif if (hasGlobalShortcutSupport) { - installInputEventFilter(new GlobalShortcutFilter); + m_globalShortcutFilter = std::make_unique(); + installInputEventFilter(m_globalShortcutFilter.get()); } - installInputEventFilter(new EffectsFilter); - installInputEventFilter(new MoveResizeFilter); - installInputEventFilter(new PopupInputFilter); - installInputEventFilter(new DecorationEventFilter); - installInputEventFilter(new WindowActionInputFilter); - installInputEventFilter(new InternalWindowEventFilter); - installInputEventFilter(new InputKeyboardFilter); - installInputEventFilter(new ForwardInputFilter); - installInputEventFilter(new TabletInputFilter); + + m_effectsFilter = std::make_unique(); + installInputEventFilter(m_effectsFilter.get()); + + m_interactiveMoveResizeFilter = std::make_unique(); + installInputEventFilter(m_interactiveMoveResizeFilter.get()); + + m_popupFilter = std::make_unique(); + installInputEventFilter(m_popupFilter.get()); + + m_decorationFilter = std::make_unique(); + installInputEventFilter(m_decorationFilter.get()); + + m_windowActionFilter = std::make_unique(); + installInputEventFilter(m_windowActionFilter.get()); + + m_internalWindowFilter = std::make_unique(); + installInputEventFilter(m_internalWindowFilter.get()); + + m_inputKeyboardFilter = std::make_unique(); + installInputEventFilter(m_inputKeyboardFilter.get()); + + m_forwardFilter = std::make_unique(); + installInputEventFilter(m_forwardFilter.get()); + + m_tabletFilter = std::make_unique(); + installInputEventFilter(m_tabletFilter.get()); } void InputRedirection::handleInputConfigChanged(const KConfigGroup &group) diff --git a/src/input.h b/src/input.h index dd0e5534d9..b4fa56014f 100644 --- a/src/input.h +++ b/src/input.h @@ -325,12 +325,33 @@ private: QList m_idleDetectors; QList m_idleInhibitors; - WindowSelectorFilter *m_windowSelector = nullptr; + std::unique_ptr m_windowSelector; QList m_filters; QList m_spies; KConfigWatcher::Ptr m_inputConfigWatcher; + std::unique_ptr m_virtualTerminalFilter; + std::unique_ptr m_terminateServerFilter; + std::unique_ptr m_dragAndDropFilter; + std::unique_ptr m_lockscreenFilter; + std::unique_ptr m_screenEdgeFilter; + std::unique_ptr m_tabboxFilter; + std::unique_ptr m_globalShortcutFilter; + std::unique_ptr m_effectsFilter; + std::unique_ptr m_interactiveMoveResizeFilter; + std::unique_ptr m_popupFilter; + std::unique_ptr m_decorationFilter; + std::unique_ptr m_windowActionFilter; + std::unique_ptr m_internalWindowFilter; + std::unique_ptr m_inputKeyboardFilter; + std::unique_ptr m_forwardFilter; + std::unique_ptr m_tabletFilter; + + std::unique_ptr m_hideCursorSpy; + std::unique_ptr m_userActivitySpy; + std::unique_ptr m_windowInteractedSpy; + LEDs m_leds; bool m_hasKeyboard = false; bool m_hasAlphaNumericKeyboard = false;