2016-02-12 12:30:00 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2013, 2016 Martin Gräßlin <mgraesslin@kde.org>
|
2018-09-15 00:00:24 +00:00
|
|
|
Copyright (C) 2018 Roman Gilg <subdiff@gmail.com>
|
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
|
|
|
Copyright (C) 2019 Vlad Zagorodniy <vladzzag@gmail.com>
|
2016-02-12 12:30:00 +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_POINTER_INPUT_H
|
|
|
|
#define KWIN_POINTER_INPUT_H
|
|
|
|
|
|
|
|
#include "input.h"
|
|
|
|
|
2016-02-23 11:29:05 +00:00
|
|
|
#include <QElapsedTimer>
|
2016-02-12 12:30:00 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QPointF>
|
|
|
|
|
|
|
|
class QWindow;
|
|
|
|
|
2016-08-22 17:20:57 +00:00
|
|
|
namespace KWayland
|
|
|
|
{
|
|
|
|
namespace Server
|
|
|
|
{
|
|
|
|
class SurfaceInterface;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-12 12:30:00 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
2016-02-23 11:29:05 +00:00
|
|
|
class CursorImage;
|
2016-02-12 12:30:00 +00:00
|
|
|
class InputRedirection;
|
|
|
|
class Toplevel;
|
2016-02-23 11:29:05 +00:00
|
|
|
class WaylandCursorTheme;
|
2018-06-07 00:33:54 +00:00
|
|
|
class CursorShape;
|
2016-02-12 12:30:00 +00:00
|
|
|
|
|
|
|
namespace Decoration
|
|
|
|
{
|
|
|
|
class DecoratedClientImpl;
|
|
|
|
}
|
|
|
|
|
2016-05-24 08:57:57 +00:00
|
|
|
namespace LibInput
|
|
|
|
{
|
|
|
|
class Device;
|
|
|
|
}
|
|
|
|
|
2016-05-12 14:33:03 +00:00
|
|
|
class KWIN_EXPORT PointerInputRedirection : public InputDeviceHandler
|
2016-02-12 12:30:00 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit PointerInputRedirection(InputRedirection *parent);
|
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
|
|
|
~PointerInputRedirection() override;
|
2016-02-12 12:30:00 +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
|
|
|
void init() override;
|
2016-02-12 12:30:00 +00:00
|
|
|
|
|
|
|
void updateAfterScreenChange();
|
|
|
|
bool supportsWarping() const;
|
|
|
|
void warp(const QPointF &pos);
|
|
|
|
|
|
|
|
QPointF pos() const {
|
|
|
|
return m_pos;
|
|
|
|
}
|
|
|
|
Qt::MouseButtons buttons() const {
|
|
|
|
return m_qtButtons;
|
|
|
|
}
|
2018-09-15 00:00:24 +00:00
|
|
|
bool areButtonsPressed() const;
|
2016-02-12 12:30:00 +00:00
|
|
|
|
2016-02-23 11:29:05 +00:00
|
|
|
QImage cursorImage() const;
|
|
|
|
QPoint cursorHotSpot() const;
|
|
|
|
void markCursorAsRendered();
|
|
|
|
void setEffectsOverrideCursor(Qt::CursorShape shape);
|
|
|
|
void removeEffectsOverrideCursor();
|
2016-11-15 13:23:51 +00:00
|
|
|
void setWindowSelectionCursor(const QByteArray &shape);
|
|
|
|
void removeWindowSelectionCursor();
|
2016-02-12 12:30:00 +00:00
|
|
|
|
2018-06-11 20:45:09 +00:00
|
|
|
void updatePointerConstraints();
|
2016-11-25 06:17:43 +00:00
|
|
|
|
2018-07-15 18:44:21 +00:00
|
|
|
void setEnableConstraints(bool set);
|
|
|
|
|
2016-11-25 06:17:43 +00:00
|
|
|
bool isConstrained() const {
|
|
|
|
return m_confined || m_locked;
|
|
|
|
}
|
|
|
|
|
2018-09-15 00:00:24 +00:00
|
|
|
bool focusUpdatesBlocked() override;
|
|
|
|
|
2016-02-12 12:30:00 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-05-24 08:57:57 +00:00
|
|
|
void processMotion(const QPointF &pos, uint32_t time, LibInput::Device *device = nullptr);
|
2016-10-07 12:47:25 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-10-07 12:47:25 +00:00
|
|
|
void processMotion(const QPointF &pos, const QSizeF &delta, const QSizeF &deltaNonAccelerated, uint32_t time, quint64 timeUsec, LibInput::Device *device);
|
2016-02-12 12:30:00 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-05-24 08:57:57 +00:00
|
|
|
void processButton(uint32_t button, InputRedirection::PointerButtonState state, uint32_t time, LibInput::Device *device = nullptr);
|
2016-02-12 12:30:00 +00:00
|
|
|
/**
|
|
|
|
* @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 processAxis(InputRedirection::PointerAxis axis, qreal delta, qint32 discreteDelta, InputRedirection::PointerAxisSource source, uint32_t time, LibInput::Device *device = nullptr);
|
2016-08-05 12:35:33 +00:00
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-05 12:35:33 +00:00
|
|
|
void processSwipeGestureBegin(int fingerCount, quint32 time, KWin::LibInput::Device *device = nullptr);
|
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-05 12:35:33 +00:00
|
|
|
void processSwipeGestureUpdate(const QSizeF &delta, quint32 time, KWin::LibInput::Device *device = nullptr);
|
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-05 12:35:33 +00:00
|
|
|
void processSwipeGestureEnd(quint32 time, KWin::LibInput::Device *device = nullptr);
|
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-05 12:35:33 +00:00
|
|
|
void processSwipeGestureCancelled(quint32 time, KWin::LibInput::Device *device = nullptr);
|
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-05 12:35:33 +00:00
|
|
|
void processPinchGestureBegin(int fingerCount, quint32 time, KWin::LibInput::Device *device = nullptr);
|
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-05 12:35:33 +00:00
|
|
|
void processPinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time, KWin::LibInput::Device *device = nullptr);
|
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-05 12:35:33 +00:00
|
|
|
void processPinchGestureEnd(quint32 time, KWin::LibInput::Device *device = nullptr);
|
|
|
|
/**
|
|
|
|
* @internal
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2016-08-05 12:35:33 +00:00
|
|
|
void processPinchGestureCancelled(quint32 time, KWin::LibInput::Device *device = nullptr);
|
2016-02-12 12:30:00 +00:00
|
|
|
|
|
|
|
private:
|
2018-09-15 00:00:24 +00:00
|
|
|
void cleanupInternalWindow(QWindow *old, QWindow *now) override;
|
|
|
|
void cleanupDecoration(Decoration::DecoratedClientImpl *old, Decoration::DecoratedClientImpl *now) override;
|
|
|
|
|
|
|
|
void focusUpdate(Toplevel *focusOld, Toplevel *focusNow) override;
|
|
|
|
|
|
|
|
QPointF position() const override;
|
|
|
|
|
2016-10-24 15:09:40 +00:00
|
|
|
void updateOnStartMoveResize();
|
2016-11-15 13:23:51 +00:00
|
|
|
void updateToReset();
|
2016-02-12 12:30:00 +00:00
|
|
|
void updatePosition(const QPointF &pos);
|
|
|
|
void updateButton(uint32_t button, InputRedirection::PointerButtonState state);
|
2016-08-22 17:20:57 +00:00
|
|
|
void warpXcbOnSurfaceLeft(KWayland::Server::SurfaceInterface *surface);
|
2016-11-25 06:17:43 +00:00
|
|
|
QPointF applyPointerConfinement(const QPointF &pos) const;
|
|
|
|
void disconnectConfinedPointerRegionConnection();
|
2018-07-18 07:06:56 +00:00
|
|
|
void disconnectLockedPointerAboutToBeUnboundConnection();
|
2016-11-25 06:17:43 +00:00
|
|
|
void disconnectPointerConstraintsConnection();
|
|
|
|
void breakPointerConstraints(KWayland::Server::SurfaceInterface *surface);
|
2016-02-23 11:29:05 +00:00
|
|
|
CursorImage *m_cursor;
|
2016-02-12 12:30:00 +00:00
|
|
|
bool m_supportsWarping;
|
|
|
|
QPointF m_pos;
|
|
|
|
QHash<uint32_t, InputRedirection::PointerButtonState> m_buttons;
|
|
|
|
Qt::MouseButtons m_qtButtons;
|
2018-09-15 00:00:24 +00:00
|
|
|
QMetaObject::Connection m_focusGeometryConnection;
|
2016-02-12 12:30:00 +00:00
|
|
|
QMetaObject::Connection m_internalWindowConnection;
|
2016-11-25 06:17:43 +00:00
|
|
|
QMetaObject::Connection m_constraintsConnection;
|
2018-06-18 18:14:04 +00:00
|
|
|
QMetaObject::Connection m_constraintsActivatedConnection;
|
2016-11-25 06:17:43 +00:00
|
|
|
QMetaObject::Connection m_confinedPointerRegionConnection;
|
2018-07-18 07:06:56 +00:00
|
|
|
QMetaObject::Connection m_lockedPointerAboutToBeUnboundConnection;
|
2017-09-27 16:17:33 +00:00
|
|
|
QMetaObject::Connection m_decorationGeometryConnection;
|
2016-11-25 06:17:43 +00:00
|
|
|
bool m_confined = false;
|
|
|
|
bool m_locked = false;
|
2018-07-15 18:44:21 +00:00
|
|
|
bool m_enableConstraints = true;
|
2016-02-12 12:30:00 +00:00
|
|
|
};
|
|
|
|
|
2016-02-23 11:29:05 +00:00
|
|
|
class CursorImage : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit CursorImage(PointerInputRedirection *parent = nullptr);
|
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
|
|
|
~CursorImage() override;
|
2016-02-23 11:29:05 +00:00
|
|
|
|
|
|
|
void setEffectsOverrideCursor(Qt::CursorShape shape);
|
|
|
|
void removeEffectsOverrideCursor();
|
2016-11-15 13:23:51 +00:00
|
|
|
void setWindowSelectionCursor(const QByteArray &shape);
|
|
|
|
void removeWindowSelectionCursor();
|
2016-02-23 11:29:05 +00:00
|
|
|
|
|
|
|
QImage image() const;
|
|
|
|
QPoint hotSpot() const;
|
|
|
|
void markAsRendered();
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void changed();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void reevaluteSource();
|
|
|
|
void update();
|
|
|
|
void updateServerCursor();
|
|
|
|
void updateDecoration();
|
|
|
|
void updateDecorationCursor();
|
2016-02-23 13:08:28 +00:00
|
|
|
void updateMoveResize();
|
2016-03-01 07:42:07 +00:00
|
|
|
void updateDrag();
|
|
|
|
void updateDragCursor();
|
2016-02-23 11:29:05 +00:00
|
|
|
void loadTheme();
|
|
|
|
struct Image {
|
|
|
|
QImage image;
|
|
|
|
QPoint hotSpot;
|
|
|
|
};
|
2018-06-07 00:33:54 +00:00
|
|
|
void loadThemeCursor(CursorShape shape, Image *image);
|
2016-11-15 13:23:51 +00:00
|
|
|
void loadThemeCursor(const QByteArray &shape, Image *image);
|
|
|
|
template <typename T>
|
|
|
|
void loadThemeCursor(const T &shape, QHash<T, Image> &cursors, Image *image);
|
2016-02-23 11:29:05 +00:00
|
|
|
|
|
|
|
enum class CursorSource {
|
|
|
|
LockScreen,
|
|
|
|
EffectsOverride,
|
2016-02-23 13:08:28 +00:00
|
|
|
MoveResize,
|
2016-02-23 11:29:05 +00:00
|
|
|
PointerSurface,
|
|
|
|
Decoration,
|
2016-03-01 07:42:07 +00:00
|
|
|
DragAndDrop,
|
2016-11-15 13:23:51 +00:00
|
|
|
Fallback,
|
|
|
|
WindowSelector
|
2016-02-23 11:29:05 +00:00
|
|
|
};
|
|
|
|
void setSource(CursorSource source);
|
|
|
|
|
|
|
|
PointerInputRedirection *m_pointer;
|
|
|
|
CursorSource m_currentSource = CursorSource::Fallback;
|
|
|
|
WaylandCursorTheme *m_cursorTheme = nullptr;
|
|
|
|
struct {
|
|
|
|
QMetaObject::Connection connection;
|
|
|
|
QImage image;
|
|
|
|
QPoint hotSpot;
|
|
|
|
} m_serverCursor;
|
|
|
|
|
|
|
|
Image m_effectsCursor;
|
|
|
|
Image m_decorationCursor;
|
|
|
|
QMetaObject::Connection m_decorationConnection;
|
|
|
|
Image m_fallbackCursor;
|
2016-02-23 13:08:28 +00:00
|
|
|
Image m_moveResizeCursor;
|
2016-11-15 13:23:51 +00:00
|
|
|
Image m_windowSelectionCursor;
|
2018-06-07 00:33:54 +00:00
|
|
|
QHash<CursorShape, Image> m_cursors;
|
2016-11-15 13:23:51 +00:00
|
|
|
QHash<QByteArray, Image> m_cursorsByName;
|
2016-02-23 11:29:05 +00:00
|
|
|
QElapsedTimer m_surfaceRenderedTimer;
|
2016-03-01 07:42:07 +00:00
|
|
|
struct {
|
|
|
|
Image cursor;
|
|
|
|
QMetaObject::Connection connection;
|
|
|
|
} m_drag;
|
2016-02-23 11:29:05 +00:00
|
|
|
};
|
|
|
|
|
2016-02-12 12:30:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|