2013-06-26 08:15:20 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org>
|
2018-09-15 00:00:24 +00:00
|
|
|
Copyright (C) 2018 Roman Gilg <subdiff@gmail.com>
|
2019-09-29 14:03:25 +00:00
|
|
|
Copyright (C) 2019 Vlad Zahorodnii <vladzzag@gmail.com>
|
2013-06-26 08:15:20 +00:00
|
|
|
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
#ifndef KWIN_INPUT_H
|
|
|
|
#define KWIN_INPUT_H
|
|
|
|
#include <kwinglobals.h>
|
2015-02-19 09:38:49 +00:00
|
|
|
#include <QAction>
|
2013-06-26 08:15:20 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QPoint>
|
2016-05-12 14:33:03 +00:00
|
|
|
#include <QPointer>
|
2013-07-02 09:44:18 +00:00
|
|
|
#include <config-kwin.h>
|
2013-06-26 08:15:20 +00:00
|
|
|
|
2016-05-06 07:53:36 +00:00
|
|
|
#include <KSharedConfig>
|
|
|
|
|
2016-11-15 13:23:51 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2015-06-26 11:47:08 +00:00
|
|
|
class KGlobalAccelInterface;
|
2013-07-10 09:41:16 +00:00
|
|
|
class QKeySequence;
|
2016-02-15 12:51:36 +00:00
|
|
|
class QMouseEvent;
|
|
|
|
class QKeyEvent;
|
|
|
|
class QWheelEvent;
|
2013-07-10 09:41:16 +00:00
|
|
|
|
2013-06-26 08:15:20 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
2013-07-10 09:41:16 +00:00
|
|
|
class GlobalShortcutsManager;
|
2013-07-01 06:37:59 +00:00
|
|
|
class Toplevel;
|
2016-02-03 14:17:49 +00:00
|
|
|
class InputEventFilter;
|
2016-12-27 19:16:50 +00:00
|
|
|
class InputEventSpy;
|
2016-02-15 12:42:48 +00:00
|
|
|
class KeyboardInputRedirection;
|
2016-02-12 12:30:00 +00:00
|
|
|
class PointerInputRedirection;
|
2016-02-15 08:36:59 +00:00
|
|
|
class TouchInputRedirection;
|
2016-11-15 13:23:51 +00:00
|
|
|
class WindowSelectorFilter;
|
2017-12-27 19:25:36 +00:00
|
|
|
class SwitchEvent;
|
2013-06-26 08:15:20 +00:00
|
|
|
|
2016-05-12 14:33:03 +00:00
|
|
|
namespace Decoration
|
|
|
|
{
|
|
|
|
class DecoratedClientImpl;
|
|
|
|
}
|
|
|
|
|
2015-03-30 06:55:41 +00:00
|
|
|
namespace LibInput
|
|
|
|
{
|
|
|
|
class Connection;
|
|
|
|
}
|
|
|
|
|
2013-06-26 08:15:20 +00:00
|
|
|
/**
|
|
|
|
* @brief This class is responsible for redirecting incoming input to the surface which currently
|
|
|
|
* has input or send enter/leave events.
|
|
|
|
*
|
|
|
|
* In addition input is intercepted before passed to the surfaces to have KWin internal areas
|
|
|
|
* getting input first (e.g. screen edges) and filter the input event out if we currently have
|
|
|
|
* a full input grab.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2015-06-26 11:47:08 +00:00
|
|
|
class KWIN_EXPORT InputRedirection : public QObject
|
2013-06-26 08:15:20 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum PointerButtonState {
|
|
|
|
PointerButtonReleased,
|
|
|
|
PointerButtonPressed
|
|
|
|
};
|
|
|
|
enum PointerAxis {
|
|
|
|
PointerAxisVertical,
|
|
|
|
PointerAxisHorizontal
|
|
|
|
};
|
Send axis_source, axis_discrete, and axis_stop
Summary:
So far KWin didn't send axis_source, axis_discrete, and axis_stop. Even
though most of those events are optional, clients need them to work as
expected. For example, one needs axis_source and axis_stop to implement
kinetic scrolling; Xwayland needs axis_discrete to prevent multiple
scroll events when the compositor sends axis deltas greater than 10, etc.
BUG: 404152
FIXED-IN: 5.17.0
Test Plan:
* Content of a webpage in Firefox is moved by one line per each mouse
wheel "click";
* Scrolled gedit using 2 fingers on GNOME Shell, sway, and KDE Plasma;
in all three cases wayland debug looked the same (except diagonal scroll
motions).
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19000
2019-02-12 09:14:51 +00:00
|
|
|
enum PointerAxisSource {
|
|
|
|
PointerAxisSourceUnknown,
|
|
|
|
PointerAxisSourceWheel,
|
|
|
|
PointerAxisSourceFinger,
|
|
|
|
PointerAxisSourceContinuous,
|
|
|
|
PointerAxisSourceWheelTilt
|
|
|
|
};
|
2013-07-02 09:44:18 +00:00
|
|
|
enum KeyboardKeyState {
|
|
|
|
KeyboardKeyReleased,
|
2016-02-19 06:53:20 +00:00
|
|
|
KeyboardKeyPressed,
|
|
|
|
KeyboardKeyAutoRepeat
|
2013-07-02 09:44:18 +00:00
|
|
|
};
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~InputRedirection() override;
|
2015-06-26 11:47:08 +00:00
|
|
|
void init();
|
2013-06-26 08:15:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return const QPointF& The current global pointer position
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-02-12 12:30:00 +00:00
|
|
|
QPointF globalPointer() const;
|
2013-06-26 12:32:03 +00:00
|
|
|
Qt::MouseButtons qtButtonStates() const;
|
2013-07-02 09:44:18 +00:00
|
|
|
Qt::KeyboardModifiers keyboardModifiers() const;
|
2016-12-26 13:19:56 +00:00
|
|
|
Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const;
|
2013-06-26 08:15:20 +00:00
|
|
|
|
2013-07-10 09:41:16 +00:00
|
|
|
void registerShortcut(const QKeySequence &shortcut, QAction *action);
|
2015-02-19 09:38:49 +00:00
|
|
|
/**
|
|
|
|
* @overload
|
|
|
|
*
|
|
|
|
* Like registerShortcut, but also connects QAction::triggered to the @p slot on @p receiver.
|
|
|
|
* It's recommended to use this method as it ensures that the X11 timestamp is updated prior
|
|
|
|
* to the @p slot being invoked. If not using this overload it's required to ensure that
|
|
|
|
* registerShortcut is called before connecting to QAction's triggered signal.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-07-18 19:12:37 +00:00
|
|
|
template <typename T, typename Slot>
|
|
|
|
void registerShortcut(const QKeySequence &shortcut, QAction *action, T *receiver, Slot slot);
|
2013-07-14 20:52:58 +00:00
|
|
|
void registerPointerShortcut(Qt::KeyboardModifiers modifiers, Qt::MouseButton pointerButtons, QAction *action);
|
2013-07-15 09:26:56 +00:00
|
|
|
void registerAxisShortcut(Qt::KeyboardModifiers modifiers, PointerAxisDirection axis, QAction *action);
|
2017-03-18 10:00:30 +00:00
|
|
|
void registerTouchpadSwipeShortcut(SwipeDirection direction, QAction *action);
|
2015-06-26 11:47:08 +00:00
|
|
|
void registerGlobalAccel(KGlobalAccelInterface *interface);
|
2013-07-10 09:41:16 +00:00
|
|
|
|
2013-06-26 08:15:20 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-06-26 08:15:20 +00:00
|
|
|
void processPointerMotion(const QPointF &pos, uint32_t time);
|
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-06-26 08:15:20 +00:00
|
|
|
void processPointerButton(uint32_t button, PointerButtonState state, uint32_t time);
|
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
Send axis_source, axis_discrete, and axis_stop
Summary:
So far KWin didn't send axis_source, axis_discrete, and axis_stop. Even
though most of those events are optional, clients need them to work as
expected. For example, one needs axis_source and axis_stop to implement
kinetic scrolling; Xwayland needs axis_discrete to prevent multiple
scroll events when the compositor sends axis deltas greater than 10, etc.
BUG: 404152
FIXED-IN: 5.17.0
Test Plan:
* Content of a webpage in Firefox is moved by one line per each mouse
wheel "click";
* Scrolled gedit using 2 fingers on GNOME Shell, sway, and KDE Plasma;
in all three cases wayland debug looked the same (except diagonal scroll
motions).
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19000
2019-02-12 09:14:51 +00:00
|
|
|
void processPointerAxis(PointerAxis axis, qreal delta, qint32 discreteDelta, PointerAxisSource source, uint32_t time);
|
2013-07-02 09:44:18 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-07-02 09:44:18 +00:00
|
|
|
void processKeyboardKey(uint32_t key, KeyboardKeyState state, uint32_t time);
|
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-07-02 09:44:18 +00:00
|
|
|
void processKeyboardModifiers(uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group);
|
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-07-02 09:44:18 +00:00
|
|
|
void processKeymapChange(int fd, uint32_t size);
|
2015-03-25 13:50:14 +00:00
|
|
|
void processTouchDown(qint32 id, const QPointF &pos, quint32 time);
|
|
|
|
void processTouchUp(qint32 id, quint32 time);
|
|
|
|
void processTouchMotion(qint32 id, const QPointF &pos, quint32 time);
|
|
|
|
void cancelTouch();
|
|
|
|
void touchFrame();
|
2013-06-26 08:15:20 +00:00
|
|
|
|
2015-06-05 04:43:12 +00:00
|
|
|
bool supportsPointerWarping() const;
|
|
|
|
void warpPointer(const QPointF &pos);
|
|
|
|
|
2016-02-15 14:40:25 +00:00
|
|
|
/**
|
|
|
|
* Adds the @p filter to the list of event filters and makes it the first
|
|
|
|
* event filter in processing.
|
|
|
|
*
|
|
|
|
* Note: the event filter will get events before the lock screen can get them, thus
|
|
|
|
* this is a security relevant method.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-01-02 19:13:30 +00:00
|
|
|
void prependInputEventFilter(InputEventFilter *filter);
|
2016-02-03 14:17:49 +00:00
|
|
|
void uninstallInputEventFilter(InputEventFilter *filter);
|
2016-12-27 19:16:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Installs the @p spy for spying on events.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-12-27 19:16:50 +00:00
|
|
|
void installInputEventSpy(InputEventSpy *spy);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Uninstalls the @p spy. This happens automatically when deleting an InputEventSpy.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-12-27 19:16:50 +00:00
|
|
|
void uninstallInputEventSpy(InputEventSpy *spy);
|
|
|
|
|
2016-02-03 14:17:49 +00:00
|
|
|
Toplevel *findToplevel(const QPoint &pos);
|
2018-08-22 12:56:48 +00:00
|
|
|
Toplevel *findManagedToplevel(const QPoint &pos);
|
2016-02-03 14:17:49 +00:00
|
|
|
GlobalShortcutsManager *shortcuts() const {
|
|
|
|
return m_shortcuts;
|
|
|
|
}
|
|
|
|
|
2016-12-24 10:00:08 +00:00
|
|
|
/**
|
|
|
|
* Sends an event through all InputFilters.
|
|
|
|
* The method @p function is invoked on each input filter. Processing is stopped if
|
|
|
|
* a filter returns @c true for @p function.
|
|
|
|
*
|
2017-01-02 19:08:01 +00:00
|
|
|
* The UnaryPredicate is defined like the UnaryPredicate of std::any_of.
|
|
|
|
* The signature of the function should be equivalent to the following:
|
|
|
|
* @code
|
|
|
|
* bool function(const InputEventFilter *spy);
|
|
|
|
* @endcode
|
|
|
|
*
|
2016-12-24 10:00:08 +00:00
|
|
|
* The intended usage is to std::bind the method to invoke on the filter with all arguments
|
|
|
|
* bind.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2017-01-02 19:08:01 +00:00
|
|
|
template <class UnaryPredicate>
|
|
|
|
void processFilters(UnaryPredicate function) {
|
|
|
|
std::any_of(m_filters.constBegin(), m_filters.constEnd(), function);
|
|
|
|
}
|
2016-12-24 10:00:08 +00:00
|
|
|
|
2016-12-27 19:16:50 +00:00
|
|
|
/**
|
|
|
|
* Sends an event through all input event spies.
|
|
|
|
* The @p function is invoked on each InputEventSpy.
|
|
|
|
*
|
|
|
|
* The UnaryFunction is defined like the UnaryFunction of std::for_each.
|
|
|
|
* The signature of the function should be equivalent to the following:
|
|
|
|
* @code
|
|
|
|
* void function(const InputEventSpy *spy);
|
|
|
|
* @endcode
|
|
|
|
*
|
|
|
|
* The intended usage is to std::bind the method to invoke on the spies with all arguments
|
|
|
|
* bind.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-12-27 19:16:50 +00:00
|
|
|
template <class UnaryFunction>
|
|
|
|
void processSpies(UnaryFunction function) {
|
|
|
|
std::for_each(m_spies.constBegin(), m_spies.constEnd(), function);
|
|
|
|
}
|
|
|
|
|
2016-02-15 12:42:48 +00:00
|
|
|
KeyboardInputRedirection *keyboard() const {
|
|
|
|
return m_keyboard;
|
|
|
|
}
|
2016-02-12 12:30:00 +00:00
|
|
|
PointerInputRedirection *pointer() const {
|
|
|
|
return m_pointer;
|
|
|
|
}
|
2016-02-15 08:36:59 +00:00
|
|
|
TouchInputRedirection *touch() const {
|
|
|
|
return m_touch;
|
|
|
|
}
|
2013-07-01 06:37:59 +00:00
|
|
|
|
2016-08-03 06:31:58 +00:00
|
|
|
bool hasAlphaNumericKeyboard();
|
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
2018-01-24 10:36:56 +00:00
|
|
|
bool hasTabletModeSwitch();
|
2016-08-03 06:31:58 +00:00
|
|
|
|
2016-11-15 13:23:51 +00:00
|
|
|
void startInteractiveWindowSelection(std::function<void(KWin::Toplevel*)> callback, const QByteArray &cursorName);
|
2016-11-23 14:53:17 +00:00
|
|
|
void startInteractivePositionSelection(std::function<void(const QPoint &)> callback);
|
2016-11-15 13:23:51 +00:00
|
|
|
bool isSelectingWindow() const;
|
|
|
|
|
2013-06-26 08:15:20 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* @brief Emitted when the global pointer position changed
|
|
|
|
*
|
|
|
|
* @param pos The new global pointer position.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-06-26 08:15:20 +00:00
|
|
|
void globalPointerChanged(const QPointF &pos);
|
|
|
|
/**
|
|
|
|
* @brief Emitted when the state of a pointer button changed.
|
|
|
|
*
|
|
|
|
* @param button The button which changed
|
|
|
|
* @param state The new button state
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-06-26 12:32:03 +00:00
|
|
|
void pointerButtonStateChanged(uint32_t button, InputRedirection::PointerButtonState state);
|
2013-06-26 08:15:20 +00:00
|
|
|
/**
|
|
|
|
* @brief Emitted when a pointer axis changed
|
|
|
|
*
|
|
|
|
* @param axis The axis on which the even occurred
|
|
|
|
* @param delta The delta of the event.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-06-26 12:32:03 +00:00
|
|
|
void pointerAxisChanged(InputRedirection::PointerAxis axis, qreal delta);
|
2013-07-02 10:16:03 +00:00
|
|
|
/**
|
|
|
|
* @brief Emitted when the modifiers changes.
|
|
|
|
*
|
|
|
|
* Only emitted for the mask which is provided by Qt::KeyboardModifiers, if other modifiers
|
|
|
|
* change signal is not emitted
|
|
|
|
*
|
|
|
|
* @param newMods The new modifiers state
|
|
|
|
* @param oldMods The previous modifiers state
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2013-07-02 10:16:03 +00:00
|
|
|
void keyboardModifiersChanged(Qt::KeyboardModifiers newMods, Qt::KeyboardModifiers oldMods);
|
2015-08-31 06:55:26 +00:00
|
|
|
/**
|
|
|
|
* @brief Emitted when the state of a key changed.
|
|
|
|
*
|
|
|
|
* @param keyCode The keycode of the key which changed
|
2019-01-11 13:36:17 +00:00
|
|
|
* @param state The new key state
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2015-08-31 06:55:26 +00:00
|
|
|
void keyStateChanged(quint32 keyCode, InputRedirection::KeyboardKeyState state);
|
2013-06-26 08:15:20 +00:00
|
|
|
|
2016-08-03 06:31:58 +00:00
|
|
|
void hasAlphaNumericKeyboardChanged(bool set);
|
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
2018-01-24 10:36:56 +00:00
|
|
|
void hasTabletModeSwitchChanged(bool set);
|
2016-08-03 06:31:58 +00:00
|
|
|
|
2013-06-26 08:15:20 +00:00
|
|
|
private:
|
2014-08-15 07:30:08 +00:00
|
|
|
void setupLibInput();
|
2017-05-06 23:40:48 +00:00
|
|
|
void setupTouchpadShortcuts();
|
2015-03-30 06:55:41 +00:00
|
|
|
void setupLibInputWithScreens();
|
2015-06-13 15:54:08 +00:00
|
|
|
void setupWorkspace();
|
2015-09-15 08:29:06 +00:00
|
|
|
void reconfigure();
|
2016-02-03 14:17:49 +00:00
|
|
|
void setupInputFilters();
|
|
|
|
void installInputEventFilter(InputEventFilter *filter);
|
2016-02-15 12:42:48 +00:00
|
|
|
KeyboardInputRedirection *m_keyboard;
|
2016-02-12 12:30:00 +00:00
|
|
|
PointerInputRedirection *m_pointer;
|
2016-02-15 08:36:59 +00:00
|
|
|
TouchInputRedirection *m_touch;
|
2013-06-26 08:15:20 +00:00
|
|
|
|
2013-07-10 09:41:16 +00:00
|
|
|
GlobalShortcutsManager *m_shortcuts;
|
|
|
|
|
2015-03-30 06:55:41 +00:00
|
|
|
LibInput::Connection *m_libInput = nullptr;
|
|
|
|
|
2016-11-15 13:23:51 +00:00
|
|
|
WindowSelectorFilter *m_windowSelector = nullptr;
|
|
|
|
|
2016-02-03 14:17:49 +00:00
|
|
|
QVector<InputEventFilter*> m_filters;
|
2016-12-27 19:16:50 +00:00
|
|
|
QVector<InputEventSpy*> m_spies;
|
2016-02-03 14:17:49 +00:00
|
|
|
|
2013-06-26 08:15:20 +00:00
|
|
|
KWIN_SINGLETON(InputRedirection)
|
|
|
|
friend InputRedirection *input();
|
2016-02-03 14:17:49 +00:00
|
|
|
friend class DecorationEventFilter;
|
|
|
|
friend class InternalWindowEventFilter;
|
|
|
|
friend class ForwardInputFilter;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base class for filtering input events inside InputRedirection.
|
|
|
|
*
|
|
|
|
* The idea behind the InputEventFilter is to have task oriented
|
|
|
|
* filters. E.g. there is one filter taking care of a locked screen,
|
|
|
|
* one to take care of interacting with window decorations, etc.
|
|
|
|
*
|
|
|
|
* A concrete subclass can reimplement the virtual methods and decide
|
|
|
|
* whether an event should be filtered out or not by returning either
|
|
|
|
* @c true or @c false. E.g. the lock screen filter can easily ensure
|
|
|
|
* that all events are filtered out.
|
|
|
|
*
|
|
|
|
* As soon as a filter returns @c true the processing is stopped. If
|
|
|
|
* a filter returns @c false the next one is invoked. This means a filter
|
|
|
|
* installed early gets to see more events than a filter installed later on.
|
|
|
|
*
|
|
|
|
* Deleting an instance of InputEventFilter automatically uninstalls it from
|
|
|
|
* InputRedirection.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-02-15 14:40:25 +00:00
|
|
|
class KWIN_EXPORT InputEventFilter
|
2016-02-03 14:17:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
InputEventFilter();
|
|
|
|
virtual ~InputEventFilter();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Event filter for pointer events which can be described by a QMouseEvent.
|
|
|
|
*
|
|
|
|
* Please note that the button translation in QMouseEvent cannot cover all
|
|
|
|
* possible buttons. Because of that also the @p nativeButton code is passed
|
|
|
|
* through the filter. For internal areas it's fine to use @p event, but for
|
|
|
|
* passing to client windows the @p nativeButton should be used.
|
|
|
|
*
|
|
|
|
* @param event The event information about the move or button press/release
|
|
|
|
* @param nativeButton The native key code of the button, for move events 0
|
|
|
|
* @return @c true to stop further event processing, @c false to pass to next filter
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-02-03 14:17:49 +00:00
|
|
|
virtual bool pointerEvent(QMouseEvent *event, quint32 nativeButton);
|
|
|
|
/**
|
|
|
|
* Event filter for pointer axis events.
|
|
|
|
*
|
|
|
|
* @param event The event information about the axis event
|
|
|
|
* @return @c true to stop further event processing, @c false to pass to next filter
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-02-03 14:17:49 +00:00
|
|
|
virtual bool wheelEvent(QWheelEvent *event);
|
|
|
|
/**
|
|
|
|
* Event filter for keyboard events.
|
|
|
|
*
|
|
|
|
* @param event The event information about the key event
|
|
|
|
* @return @c tru to stop further event processing, @c false to pass to next filter.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-02-03 14:17:49 +00:00
|
|
|
virtual bool keyEvent(QKeyEvent *event);
|
2019-08-11 19:57:45 +00:00
|
|
|
virtual bool touchDown(qint32 id, const QPointF &pos, quint32 time);
|
|
|
|
virtual bool touchMotion(qint32 id, const QPointF &pos, quint32 time);
|
|
|
|
virtual bool touchUp(qint32 id, quint32 time);
|
2016-08-05 12:35:33 +00:00
|
|
|
|
|
|
|
virtual bool pinchGestureBegin(int fingerCount, quint32 time);
|
|
|
|
virtual bool pinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time);
|
|
|
|
virtual bool pinchGestureEnd(quint32 time);
|
|
|
|
virtual bool pinchGestureCancelled(quint32 time);
|
|
|
|
|
|
|
|
virtual bool swipeGestureBegin(int fingerCount, quint32 time);
|
|
|
|
virtual bool swipeGestureUpdate(const QSizeF &delta, quint32 time);
|
|
|
|
virtual bool swipeGestureEnd(quint32 time);
|
|
|
|
virtual bool swipeGestureCancelled(quint32 time);
|
2016-09-15 06:47:01 +00:00
|
|
|
|
2017-12-27 19:25:36 +00:00
|
|
|
virtual bool switchEvent(SwitchEvent *event);
|
|
|
|
|
2016-09-15 06:47:01 +00:00
|
|
|
protected:
|
|
|
|
void passToWaylandServer(QKeyEvent *event);
|
2013-06-26 08:15:20 +00:00
|
|
|
};
|
|
|
|
|
2018-09-15 00:00:24 +00:00
|
|
|
class KWIN_EXPORT InputDeviceHandler : public QObject
|
2016-05-12 14:33:03 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.
The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.
Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.
A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!
The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.
The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, apol, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 16:52:26 +00:00
|
|
|
~InputDeviceHandler() override;
|
2018-09-15 00:00:24 +00:00
|
|
|
virtual void init();
|
2016-05-12 14:33:03 +00:00
|
|
|
|
2018-09-15 00:00:24 +00:00
|
|
|
void update();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief First Toplevel currently at the position of the input device
|
|
|
|
* according to the stacking order.
|
|
|
|
* @return Toplevel* at device position.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-09-15 00:00:24 +00:00
|
|
|
QPointer<Toplevel> at() const {
|
2019-06-06 21:17:01 +00:00
|
|
|
return m_at.at;
|
2018-09-15 00:00:24 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @brief Toplevel currently having pointer input focus (this might
|
|
|
|
* be different from the Toplevel at the position of the pointer).
|
|
|
|
* @return Toplevel* with pointer focus.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-09-15 00:00:24 +00:00
|
|
|
QPointer<Toplevel> focus() const {
|
|
|
|
return m_focus.focus;
|
2016-05-12 14:33:03 +00:00
|
|
|
}
|
2018-09-15 00:00:24 +00:00
|
|
|
/**
|
|
|
|
* @brief The Decoration currently receiving events.
|
|
|
|
* @return decoration with pointer focus.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-05-12 14:33:03 +00:00
|
|
|
QPointer<Decoration::DecoratedClientImpl> decoration() const {
|
2018-09-15 00:00:24 +00:00
|
|
|
return m_focus.decoration;
|
2016-05-12 14:33:03 +00:00
|
|
|
}
|
2018-09-15 00:00:24 +00:00
|
|
|
/**
|
|
|
|
* @brief The internal window currently receiving events.
|
|
|
|
* @return QWindow with pointer focus.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-05-23 15:07:08 +00:00
|
|
|
QPointer<QWindow> internalWindow() const {
|
2018-09-15 00:00:24 +00:00
|
|
|
return m_focus.internalWindow;
|
2016-05-23 15:07:08 +00:00
|
|
|
}
|
2016-05-12 14:33:03 +00:00
|
|
|
|
2018-09-15 00:00:24 +00:00
|
|
|
virtual QPointF position() const = 0;
|
|
|
|
|
|
|
|
void setFocus(Toplevel *toplevel);
|
|
|
|
void setDecoration(QPointer<Decoration::DecoratedClientImpl> decoration);
|
|
|
|
void setInternalWindow(QWindow *window);
|
|
|
|
|
2016-05-12 14:33:03 +00:00
|
|
|
Q_SIGNALS:
|
2018-09-15 00:00:24 +00:00
|
|
|
void atChanged(Toplevel *old, Toplevel *now);
|
2016-05-12 14:33:03 +00:00
|
|
|
void decorationChanged();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
explicit InputDeviceHandler(InputRedirection *parent);
|
2018-09-15 00:00:24 +00:00
|
|
|
|
|
|
|
virtual void cleanupInternalWindow(QWindow *old, QWindow *now) = 0;
|
|
|
|
virtual void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) = 0;
|
|
|
|
|
|
|
|
virtual void focusUpdate(Toplevel *old, Toplevel *now) = 0;
|
|
|
|
|
2019-02-02 18:17:44 +00:00
|
|
|
/**
|
|
|
|
* Certain input devices can be in a state of having no valid
|
2018-12-13 09:46:21 +00:00
|
|
|
* position. An example are touch screens when no finger/pen
|
|
|
|
* is resting on the surface (no touch point).
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-12-13 09:46:21 +00:00
|
|
|
virtual bool positionValid() const {
|
|
|
|
return false;
|
|
|
|
}
|
2018-09-15 00:00:24 +00:00
|
|
|
virtual bool focusUpdatesBlocked() {
|
|
|
|
return false;
|
2018-09-15 00:37:24 +00:00
|
|
|
}
|
2018-09-15 00:00:24 +00:00
|
|
|
|
|
|
|
inline bool inited() const {
|
|
|
|
return m_inited;
|
2018-09-15 00:37:24 +00:00
|
|
|
}
|
2018-09-15 00:00:24 +00:00
|
|
|
inline void setInited(bool set) {
|
|
|
|
m_inited = set;
|
2018-09-15 00:37:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-09-15 00:00:24 +00:00
|
|
|
bool setAt(Toplevel *toplevel);
|
|
|
|
void updateFocus();
|
|
|
|
bool updateDecoration();
|
|
|
|
void updateInternalWindow(QWindow *window);
|
|
|
|
|
|
|
|
QWindow* findInternalWindow(const QPoint &pos) const;
|
|
|
|
|
2019-06-06 21:17:01 +00:00
|
|
|
struct {
|
|
|
|
QPointer<Toplevel> at;
|
|
|
|
QMetaObject::Connection surfaceCreatedConnection;
|
|
|
|
} m_at;
|
|
|
|
|
2018-09-15 00:00:24 +00:00
|
|
|
struct {
|
|
|
|
QPointer<Toplevel> focus;
|
|
|
|
QPointer<Decoration::DecoratedClientImpl> decoration;
|
|
|
|
QPointer<QWindow> internalWindow;
|
|
|
|
} m_focus;
|
|
|
|
|
|
|
|
bool m_inited = false;
|
2016-05-12 14:33:03 +00:00
|
|
|
};
|
|
|
|
|
2013-06-26 08:15:20 +00:00
|
|
|
inline
|
|
|
|
InputRedirection *input()
|
|
|
|
{
|
|
|
|
return InputRedirection::s_self;
|
|
|
|
}
|
|
|
|
|
2017-07-18 19:12:37 +00:00
|
|
|
template <typename T, typename Slot>
|
2015-02-19 09:38:49 +00:00
|
|
|
inline
|
2017-07-18 19:12:37 +00:00
|
|
|
void InputRedirection::registerShortcut(const QKeySequence &shortcut, QAction *action, T *receiver, Slot slot) {
|
2015-02-19 09:38:49 +00:00
|
|
|
registerShortcut(shortcut, action);
|
|
|
|
connect(action, &QAction::triggered, receiver, slot);
|
|
|
|
}
|
|
|
|
|
2013-06-26 08:15:20 +00:00
|
|
|
} // namespace KWin
|
|
|
|
|
2015-09-02 08:10:49 +00:00
|
|
|
Q_DECLARE_METATYPE(KWin::InputRedirection::KeyboardKeyState)
|
|
|
|
Q_DECLARE_METATYPE(KWin::InputRedirection::PointerButtonState)
|
|
|
|
Q_DECLARE_METATYPE(KWin::InputRedirection::PointerAxis)
|
Send axis_source, axis_discrete, and axis_stop
Summary:
So far KWin didn't send axis_source, axis_discrete, and axis_stop. Even
though most of those events are optional, clients need them to work as
expected. For example, one needs axis_source and axis_stop to implement
kinetic scrolling; Xwayland needs axis_discrete to prevent multiple
scroll events when the compositor sends axis deltas greater than 10, etc.
BUG: 404152
FIXED-IN: 5.17.0
Test Plan:
* Content of a webpage in Firefox is moved by one line per each mouse
wheel "click";
* Scrolled gedit using 2 fingers on GNOME Shell, sway, and KDE Plasma;
in all three cases wayland debug looked the same (except diagonal scroll
motions).
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: davidedmundson, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D19000
2019-02-12 09:14:51 +00:00
|
|
|
Q_DECLARE_METATYPE(KWin::InputRedirection::PointerAxisSource)
|
2015-09-02 08:10:49 +00:00
|
|
|
|
2013-06-26 08:15:20 +00:00
|
|
|
#endif // KWIN_INPUT_H
|