diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -455,6 +455,7 @@ popup_input_filter.cpp abstract_opengl_context_attribute_builder.cpp egl_context_attribute_builder.cpp + was_user_interaction_x11_filter.cpp ) if(KWIN_BUILD_TABBOX) diff --git a/events.cpp b/events.cpp --- a/events.cpp +++ b/events.cpp @@ -265,7 +265,6 @@ switch (eventType) { case XCB_BUTTON_PRESS: case XCB_BUTTON_RELEASE: { - was_user_interaction = true; auto *mouseEvent = reinterpret_cast(e); #ifdef KWIN_BUILD_TABBOX if (TabBox::TabBox::self()->isGrabbed()) { @@ -301,7 +300,6 @@ break; } case XCB_KEY_PRESS: { - was_user_interaction = true; int keyQt; xcb_key_press_event_t *event = reinterpret_cast(e); KKeyServer::xcbKeyPressEventToQt(event, &keyQt); @@ -319,7 +317,6 @@ break; } case XCB_KEY_RELEASE: - was_user_interaction = true; #ifdef KWIN_BUILD_TABBOX if (TabBox::TabBox::self()->isGrabbed()) { TabBox::TabBox::self()->keyRelease(reinterpret_cast(e)); @@ -644,12 +641,10 @@ break; case XCB_KEY_PRESS: updateUserTime(reinterpret_cast(e)->time); - workspace()->setWasUserInteraction(); break; case XCB_BUTTON_PRESS: { const auto *event = reinterpret_cast(e); updateUserTime(event->time); - workspace()->setWasUserInteraction(); buttonPressEvent(event->event, event->detail, event->state, event->event_x, event->event_y, event->root_x, event->root_y, event->time); break; @@ -1068,7 +1063,6 @@ if (w == wrapperId() || w == frameId() || w == inputId()) { // FRAME neco s tohohle by se melo zpracovat, nez to dostane dekorace updateUserTime(time); - workspace()->setWasUserInteraction(); const bool bModKeyHeld = modKeyDown(state); if (isSplash() diff --git a/was_user_interaction_x11_filter.h b/was_user_interaction_x11_filter.h new file mode 100644 --- /dev/null +++ b/was_user_interaction_x11_filter.h @@ -0,0 +1,37 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2017 Martin Flöser + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +#ifndef KWIN_WAS_USER_INTERACTION_X11_FILTER_H +#define KWIN_WAS_USER_INTERACTION_X11_FILTER_H +#include "x11eventfilter.h" + +namespace KWin +{ + +class WasUserInteractionX11Filter : public X11EventFilter +{ +public: + explicit WasUserInteractionX11Filter(); + + bool event(xcb_generic_event_t *event) override; +}; + +} + +#endif diff --git a/was_user_interaction_x11_filter.cpp b/was_user_interaction_x11_filter.cpp new file mode 100644 --- /dev/null +++ b/was_user_interaction_x11_filter.cpp @@ -0,0 +1,38 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + +Copyright (C) 2017 Martin Flöser + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +#include "was_user_interaction_x11_filter.h" +#include "workspace.h" +#include + +namespace KWin +{ +WasUserInteractionX11Filter::WasUserInteractionX11Filter() + : X11EventFilter(QVector{XCB_KEY_PRESS, XCB_KEY_RELEASE, XCB_BUTTON_PRESS, XCB_BUTTON_RELEASE}) +{ +} + +bool WasUserInteractionX11Filter::event(xcb_generic_event_t *event) +{ + Q_UNUSED(event); + workspace()->setWasUserInteraction(); + return false; +} + +} diff --git a/workspace.h b/workspace.h --- a/workspace.h +++ b/workspace.h @@ -571,6 +571,7 @@ GroupList groups; bool was_user_interaction; + QScopedPointer m_wasUserInteractionFilter; bool session_saving; int session_active_client; int session_desktop; @@ -691,11 +692,6 @@ return stacking_order; } -inline void Workspace::setWasUserInteraction() -{ - was_user_interaction = true; -} - inline bool Workspace::wasUserInteraction() const { return was_user_interaction; diff --git a/workspace.cpp b/workspace.cpp --- a/workspace.cpp +++ b/workspace.cpp @@ -54,6 +54,7 @@ #include "useractions.h" #include "virtualdesktops.h" #include "shell_client.h" +#include "was_user_interaction_x11_filter.h" #include "wayland_server.h" #include "xcbutils.h" #include "main.h" @@ -214,6 +215,9 @@ void Workspace::init() { + if (kwinApp()->operationMode() == Application::OperationModeX11) { + m_wasUserInteractionFilter.reset(new WasUserInteractionX11Filter); + } updateXTime(); // Needed for proper initialization of user_time in Client ctor KSharedConfigPtr config = kwinApp()->config(); kwinApp()->createScreens(); @@ -1786,5 +1790,19 @@ m_xStackingQueryTree.reset(new Xcb::Tree(rootWindow())); } +void Workspace::setWasUserInteraction() +{ + if (was_user_interaction) { + return; + } + was_user_interaction = true; + // might be called from within the filter, so delay till we now the filter returned + QTimer::singleShot(0, this, + [this] { + m_wasUserInteractionFilter.reset(); + } + ); +} + } // namespace