2014-08-14 12:43:57 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2014 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
|
|
|
|
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_LIBINPUT_CONNECTION_H
|
|
|
|
#define KWIN_LIBINPUT_CONNECTION_H
|
|
|
|
|
|
|
|
#include "../input.h"
|
2016-10-05 09:50:20 +00:00
|
|
|
#include "../keyboard_input.h"
|
2014-08-14 12:43:57 +00:00
|
|
|
#include <kwinglobals.h>
|
|
|
|
|
|
|
|
#include <QObject>
|
2017-09-30 07:36:30 +00:00
|
|
|
#include <QPointer>
|
2014-08-14 12:43:57 +00:00
|
|
|
#include <QSize>
|
2015-09-02 09:32:26 +00:00
|
|
|
#include <QMutex>
|
|
|
|
#include <QVector>
|
2016-12-02 13:58:56 +00:00
|
|
|
#include <QStringList>
|
2014-08-14 12:43:57 +00:00
|
|
|
|
|
|
|
class QSocketNotifier;
|
2015-09-02 08:12:18 +00:00
|
|
|
class QThread;
|
2014-08-14 12:43:57 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
namespace LibInput
|
|
|
|
{
|
|
|
|
|
2015-09-02 09:32:26 +00:00
|
|
|
class Event;
|
[libinput] Add a wrapper class Device for a libinput_device
Summary:
The Device class wraps all the information we can get from libinput
about the device, like whether it's a keyboard, pointer, touch, etc.
In addition some more information is queried to figure out how "useful"
a device is. For a keyboard all alphanumeric keys are checked whether
they exist, for a pointer all (normal) buttons are queried.
All the information is exposed as Q_PROPERTY and used by the
DebugConsole. The DebugConsole gained a new tab "Input Devices" which
renders all devices and their properties in a tree view. When plugging
in/out a device, the model gets reset, so it's always up to date.
The new Device class can be used in future to configure the device,
e.g. disable touch pad, set mouse acceleration, etc.
Reviewers: #plasma
Subscribers: plasma-devel
Projects: #plasma
Differential Revision: https://phabricator.kde.org/D1538
2016-05-04 11:42:26 +00:00
|
|
|
class Device;
|
2014-08-14 12:43:57 +00:00
|
|
|
class Context;
|
|
|
|
|
2019-03-22 17:29:15 +00:00
|
|
|
class KWIN_EXPORT Connection : public QObject
|
2014-08-14 12:43:57 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2017-01-12 07:16:04 +00:00
|
|
|
|
2014-08-14 12:43:57 +00:00
|
|
|
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
|
|
|
~Connection() override;
|
2014-08-14 12:43:57 +00:00
|
|
|
|
2016-05-06 07:53:36 +00:00
|
|
|
void setInputConfig(const KSharedConfigPtr &config) {
|
|
|
|
m_config = config;
|
|
|
|
}
|
|
|
|
|
2014-08-14 12:43:57 +00:00
|
|
|
void setup();
|
|
|
|
/**
|
|
|
|
* Sets the screen @p size. This is needed for mapping absolute pointer events to
|
|
|
|
* the screen data.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2014-08-14 12:43:57 +00:00
|
|
|
void setScreenSize(const QSize &size);
|
|
|
|
|
2017-11-10 17:07:15 +00:00
|
|
|
void updateScreens();
|
|
|
|
|
2015-03-26 15:19:26 +00:00
|
|
|
bool hasKeyboard() const {
|
|
|
|
return m_keyboard > 0;
|
|
|
|
}
|
2016-05-24 10:59:57 +00:00
|
|
|
bool hasAlphaNumericKeyboard() const {
|
|
|
|
return m_alphaNumericKeyboard > 0;
|
|
|
|
}
|
2015-03-26 15:19:26 +00:00
|
|
|
bool hasTouch() const {
|
|
|
|
return m_touch > 0;
|
|
|
|
}
|
|
|
|
bool hasPointer() const {
|
|
|
|
return m_pointer > 0;
|
|
|
|
}
|
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() const {
|
|
|
|
return m_tabletModeSwitch > 0;
|
|
|
|
}
|
2015-03-26 15:19:26 +00:00
|
|
|
|
2015-03-31 07:16:16 +00:00
|
|
|
bool isSuspended() const;
|
|
|
|
|
2015-04-15 15:47:56 +00:00
|
|
|
void deactivate();
|
|
|
|
|
2015-09-02 09:32:26 +00:00
|
|
|
void processEvents();
|
|
|
|
|
2016-05-06 10:28:07 +00:00
|
|
|
void toggleTouchpads();
|
2017-05-06 23:40:48 +00:00
|
|
|
void enableTouchpads();
|
|
|
|
void disableTouchpads();
|
2016-05-06 10:28:07 +00:00
|
|
|
|
[libinput] Add a wrapper class Device for a libinput_device
Summary:
The Device class wraps all the information we can get from libinput
about the device, like whether it's a keyboard, pointer, touch, etc.
In addition some more information is queried to figure out how "useful"
a device is. For a keyboard all alphanumeric keys are checked whether
they exist, for a pointer all (normal) buttons are queried.
All the information is exposed as Q_PROPERTY and used by the
DebugConsole. The DebugConsole gained a new tab "Input Devices" which
renders all devices and their properties in a tree view. When plugging
in/out a device, the model gets reset, so it's always up to date.
The new Device class can be used in future to configure the device,
e.g. disable touch pad, set mouse acceleration, etc.
Reviewers: #plasma
Subscribers: plasma-devel
Projects: #plasma
Differential Revision: https://phabricator.kde.org/D1538
2016-05-04 11:42:26 +00:00
|
|
|
QVector<Device*> devices() const {
|
|
|
|
return m_devices;
|
|
|
|
}
|
|
|
|
|
2016-12-02 13:58:56 +00:00
|
|
|
QStringList devicesSysNames() const;
|
|
|
|
|
2016-10-05 09:50:20 +00:00
|
|
|
void updateLEDs(KWin::Xkb::LEDs leds);
|
|
|
|
|
2017-09-30 07:36:30 +00:00
|
|
|
static void createThread();
|
|
|
|
|
2014-08-14 12:43:57 +00:00
|
|
|
Q_SIGNALS:
|
2016-05-24 08:57:57 +00:00
|
|
|
void keyChanged(quint32 key, KWin::InputRedirection::KeyboardKeyState, quint32 time, KWin::LibInput::Device *device);
|
|
|
|
void pointerButtonChanged(quint32 button, KWin::InputRedirection::PointerButtonState state, quint32 time, KWin::LibInput::Device *device);
|
|
|
|
void pointerMotionAbsolute(QPointF orig, QPointF screen, quint32 time, KWin::LibInput::Device *device);
|
2016-10-07 12:47:25 +00:00
|
|
|
void pointerMotion(const QSizeF &delta, const QSizeF &deltaNonAccelerated, quint32 time, quint64 timeMicroseconds, KWin::LibInput::Device *device);
|
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 pointerAxisChanged(KWin::InputRedirection::PointerAxis axis, qreal delta, qint32 discreteDelta,
|
|
|
|
KWin::InputRedirection::PointerAxisSource source, quint32 time, KWin::LibInput::Device *device);
|
2016-05-24 08:57:57 +00:00
|
|
|
void touchFrame(KWin::LibInput::Device *device);
|
|
|
|
void touchCanceled(KWin::LibInput::Device *device);
|
|
|
|
void touchDown(qint32 id, const QPointF &absolutePos, quint32 time, KWin::LibInput::Device *device);
|
|
|
|
void touchUp(qint32 id, quint32 time, KWin::LibInput::Device *device);
|
|
|
|
void touchMotion(qint32 id, const QPointF &absolutePos, quint32 time, KWin::LibInput::Device *device);
|
2015-03-26 15:19:26 +00:00
|
|
|
void hasKeyboardChanged(bool);
|
2016-05-24 10:59:57 +00:00
|
|
|
void hasAlphaNumericKeyboardChanged(bool);
|
2015-03-26 15:19:26 +00:00
|
|
|
void hasPointerChanged(bool);
|
|
|
|
void hasTouchChanged(bool);
|
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);
|
[libinput] Add a wrapper class Device for a libinput_device
Summary:
The Device class wraps all the information we can get from libinput
about the device, like whether it's a keyboard, pointer, touch, etc.
In addition some more information is queried to figure out how "useful"
a device is. For a keyboard all alphanumeric keys are checked whether
they exist, for a pointer all (normal) buttons are queried.
All the information is exposed as Q_PROPERTY and used by the
DebugConsole. The DebugConsole gained a new tab "Input Devices" which
renders all devices and their properties in a tree view. When plugging
in/out a device, the model gets reset, so it's always up to date.
The new Device class can be used in future to configure the device,
e.g. disable touch pad, set mouse acceleration, etc.
Reviewers: #plasma
Subscribers: plasma-devel
Projects: #plasma
Differential Revision: https://phabricator.kde.org/D1538
2016-05-04 11:42:26 +00:00
|
|
|
void deviceAdded(KWin::LibInput::Device *);
|
|
|
|
void deviceRemoved(KWin::LibInput::Device *);
|
2017-01-12 07:16:04 +00:00
|
|
|
void deviceAddedSysName(QString);
|
|
|
|
void deviceRemovedSysName(QString);
|
2016-08-05 12:35:33 +00:00
|
|
|
void swipeGestureBegin(int fingerCount, quint32 time, KWin::LibInput::Device *device);
|
|
|
|
void swipeGestureUpdate(const QSizeF &delta, quint32 time, KWin::LibInput::Device *device);
|
|
|
|
void swipeGestureEnd(quint32 time, KWin::LibInput::Device *device);
|
|
|
|
void swipeGestureCancelled(quint32 time, KWin::LibInput::Device *device);
|
|
|
|
void pinchGestureBegin(int fingerCount, quint32 time, KWin::LibInput::Device *device);
|
|
|
|
void pinchGestureUpdate(qreal scale, qreal angleDelta, const QSizeF &delta, quint32 time, KWin::LibInput::Device *device);
|
|
|
|
void pinchGestureEnd(quint32 time, KWin::LibInput::Device *device);
|
|
|
|
void pinchGestureCancelled(quint32 time, KWin::LibInput::Device *device);
|
2017-12-27 16:57:00 +00:00
|
|
|
void switchToggledOn(quint32 time, quint64 timeMicroseconds, KWin::LibInput::Device *device);
|
|
|
|
void switchToggledOff(quint32 time, quint64 timeMicroseconds, KWin::LibInput::Device *device);
|
2014-08-14 12:43:57 +00:00
|
|
|
|
2019-12-01 17:51:15 +00:00
|
|
|
void tabletToolEvent(KWin::InputRedirection::TabletEventType type, const QPointF &pos,
|
|
|
|
qreal pressure, int xTilt, int yTilt, qreal rotation, bool tipDown,
|
|
|
|
bool tipNear, quint64 serialId, quint64 toolId, LibInput::Device *device);
|
|
|
|
void tabletToolButtonEvent(uint button, bool isPressed);
|
|
|
|
|
|
|
|
void tabletPadButtonEvent(uint button, bool isPressed);
|
|
|
|
void tabletPadStripEvent(int number, int position, bool isFinger);
|
|
|
|
void tabletPadRingEvent(int number, int position, bool isFinger);
|
|
|
|
|
2015-09-02 09:32:26 +00:00
|
|
|
void eventsRead();
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void doSetup();
|
2016-05-06 07:53:36 +00:00
|
|
|
void slotKGlobalSettingsNotifyChange(int type, int arg);
|
2015-09-02 09:32:26 +00:00
|
|
|
|
2014-08-14 12:43:57 +00:00
|
|
|
private:
|
|
|
|
Connection(Context *input, QObject *parent = nullptr);
|
|
|
|
void handleEvent();
|
2016-05-06 07:53:36 +00:00
|
|
|
void applyDeviceConfig(Device *device);
|
2017-11-10 17:07:15 +00:00
|
|
|
void applyScreenToDevice(Device *device);
|
2014-08-14 12:43:57 +00:00
|
|
|
Context *m_input;
|
|
|
|
QSocketNotifier *m_notifier;
|
|
|
|
QSize m_size;
|
2015-03-26 15:19:26 +00:00
|
|
|
int m_keyboard = 0;
|
2016-05-24 10:59:57 +00:00
|
|
|
int m_alphaNumericKeyboard = 0;
|
2015-03-26 15:19:26 +00:00
|
|
|
int m_pointer = 0;
|
|
|
|
int m_touch = 0;
|
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
|
|
|
int m_tabletModeSwitch = 0;
|
2015-03-31 07:16:16 +00:00
|
|
|
bool m_keyboardBeforeSuspend = false;
|
2016-05-24 10:59:57 +00:00
|
|
|
bool m_alphaNumericKeyboardBeforeSuspend = false;
|
2015-03-31 07:16:16 +00:00
|
|
|
bool m_pointerBeforeSuspend = false;
|
|
|
|
bool m_touchBeforeSuspend = false;
|
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 m_tabletModeSwitchBeforeSuspend = false;
|
2015-09-02 09:32:26 +00:00
|
|
|
QMutex m_mutex;
|
|
|
|
QVector<Event*> m_eventQueue;
|
|
|
|
bool wasSuspended = false;
|
[libinput] Add a wrapper class Device for a libinput_device
Summary:
The Device class wraps all the information we can get from libinput
about the device, like whether it's a keyboard, pointer, touch, etc.
In addition some more information is queried to figure out how "useful"
a device is. For a keyboard all alphanumeric keys are checked whether
they exist, for a pointer all (normal) buttons are queried.
All the information is exposed as Q_PROPERTY and used by the
DebugConsole. The DebugConsole gained a new tab "Input Devices" which
renders all devices and their properties in a tree view. When plugging
in/out a device, the model gets reset, so it's always up to date.
The new Device class can be used in future to configure the device,
e.g. disable touch pad, set mouse acceleration, etc.
Reviewers: #plasma
Subscribers: plasma-devel
Projects: #plasma
Differential Revision: https://phabricator.kde.org/D1538
2016-05-04 11:42:26 +00:00
|
|
|
QVector<Device*> m_devices;
|
2016-05-06 07:53:36 +00:00
|
|
|
KSharedConfigPtr m_config;
|
2016-05-06 10:28:07 +00:00
|
|
|
bool m_touchpadsEnabled = true;
|
2016-10-05 09:50:20 +00:00
|
|
|
Xkb::LEDs m_leds;
|
2014-08-14 12:43:57 +00:00
|
|
|
|
|
|
|
KWIN_SINGLETON(Connection)
|
2017-09-30 07:36:30 +00:00
|
|
|
static QPointer<QThread> s_thread;
|
2014-08-14 12:43:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|