summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylandinputdevice_p.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/qwaylandinputdevice_p.h')
-rw-r--r--src/client/qwaylandinputdevice_p.h229
1 files changed, 144 insertions, 85 deletions
diff --git a/src/client/qwaylandinputdevice_p.h b/src/client/qwaylandinputdevice_p.h
index 60d6f2c17..becd5f9be 100644
--- a/src/client/qwaylandinputdevice_p.h
+++ b/src/client/qwaylandinputdevice_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QWAYLANDINPUTDEVICE_H
#define QWAYLANDINPUTDEVICE_H
@@ -63,9 +27,10 @@
#include <qpa/qwindowsysteminterface.h>
#include <QtWaylandClient/private/qwayland-wayland.h>
+#include <QtWaylandClient/private/qwayland-pointer-gestures-unstable-v1.h>
#if QT_CONFIG(xkbcommon)
-#include <QtXkbCommonSupport/private/qxkbcommon_p.h>
+#include <QtGui/private/qxkbcommon_p.h>
#endif
#include <QtCore/QDebug>
@@ -89,13 +54,23 @@ class QWaylandDisplay;
#if QT_CONFIG(wayland_client_primary_selection)
class QWaylandPrimarySelectionDeviceV1;
#endif
-class QWaylandTextInput;
+#if QT_CONFIG(tabletevent)
+class QWaylandTabletSeatV2;
+#endif
+class QWaylandPointerGestures;
+class QWaylandPointerGestureSwipe;
+class QWaylandPointerGesturePinch;
+class QWaylandTextInputInterface;
+class QWaylandTextInputMethod;
#if QT_CONFIG(cursor)
class QWaylandCursorTheme;
+class QWaylandCursorShape;
class CursorSurface;
#endif
-class Q_WAYLAND_CLIENT_EXPORT QWaylandInputDevice
+Q_DECLARE_LOGGING_CATEGORY(lcQpaWaylandInput);
+
+class Q_WAYLANDCLIENT_EXPORT QWaylandInputDevice
: public QObject
, public QtWayland::wl_seat
{
@@ -109,7 +84,9 @@ public:
~QWaylandInputDevice() override;
uint32_t capabilities() const { return mCaps; }
+ QString seatname() const { return mSeatName; }
+ QWaylandDisplay *display() const { return mQDisplay; }
struct ::wl_seat *wl_seat() { return QtWayland::wl_seat::object(); }
#if QT_CONFIG(cursor)
@@ -127,8 +104,16 @@ public:
QWaylandPrimarySelectionDeviceV1 *primarySelectionDevice() const;
#endif
- void setTextInput(QWaylandTextInput *textInput);
- QWaylandTextInput *textInput() const;
+#if QT_CONFIG(tabletevent)
+ void setTabletSeat(QWaylandTabletSeatV2 *tabletSeat);
+ QWaylandTabletSeatV2* tabletSeat() const;
+#endif
+
+ void setTextInput(QWaylandTextInputInterface *textInput);
+ QWaylandTextInputInterface *textInput() const;
+
+ void setTextInputMethod(QWaylandTextInputMethod *textInputMethod);
+ QWaylandTextInputMethod *textInputMethod() const;
void removeMouseButtonFromState(Qt::MouseButton button);
@@ -150,14 +135,16 @@ public:
Keyboard *keyboard() const;
Pointer *pointer() const;
+ QWaylandPointerGestureSwipe *pointerGestureSwipe() const;
+ QWaylandPointerGesturePinch *pointerGesturePinch() const;
Touch *touch() const;
-private:
+protected:
QWaylandDisplay *mQDisplay = nullptr;
struct wl_display *mDisplay = nullptr;
- int mVersion;
uint32_t mCaps = 0;
+ QString mSeatName;
#if QT_CONFIG(cursor)
struct CursorState {
@@ -178,22 +165,33 @@ private:
QScopedPointer<QWaylandPrimarySelectionDeviceV1> mPrimarySelectionDevice;
#endif
- Keyboard *mKeyboard = nullptr;
- Pointer *mPointer = nullptr;
- Touch *mTouch = nullptr;
+ QScopedPointer<Keyboard> mKeyboard;
+ QScopedPointer<Pointer> mPointer;
+ QScopedPointer<QWaylandPointerGestureSwipe> mPointerGestureSwipe;
+ QScopedPointer<QWaylandPointerGesturePinch> mPointerGesturePinch;
+ QScopedPointer<Touch> mTouch;
- QScopedPointer<QWaylandTextInput> mTextInput;
+ QScopedPointer<QWaylandTextInputInterface> mTextInput;
+ QScopedPointer<QWaylandTextInputMethod> mTextInputMethod;
+#if QT_CONFIG(tabletevent)
+ QScopedPointer<QWaylandTabletSeatV2> mTabletSeat;
+#endif
uint32_t mTime = 0;
uint32_t mSerial = 0;
void seat_capabilities(uint32_t caps) override;
- void handleTouchPoint(int id, Qt::TouchPointState state, const QPointF &surfacePosition = QPoint());
+ void seat_name(const QString &name) override;
+ void handleTouchPoint(int id, QEventPoint::State state, const QPointF &surfacePosition = QPoint());
- QTouchDevice *mTouchDevice = nullptr;
+ QPointingDevice *mTouchDevice = nullptr;
+ QPointingDevice *mTouchPadDevice = nullptr;
friend class QWaylandTouchExtension;
friend class QWaylandQtKeyExtension;
+ friend class QWaylandPointerGestureSwipe;
+ friend class QWaylandPointerGesturePinch;
+ friend class QWaylandWindow;
};
inline uint32_t QWaylandInputDevice::serial() const
@@ -202,7 +200,7 @@ inline uint32_t QWaylandInputDevice::serial() const
}
-class Q_WAYLAND_CLIENT_EXPORT QWaylandInputDevice::Keyboard : public QObject, public QtWayland::wl_keyboard
+class Q_WAYLANDCLIENT_EXPORT QWaylandInputDevice::Keyboard : public QObject, public QtWayland::wl_keyboard
{
Q_OBJECT
@@ -230,18 +228,16 @@ public:
void keyboard_repeat_info(int32_t rate, int32_t delay) override;
QWaylandInputDevice *mParent = nullptr;
- ::wl_surface *mFocus = nullptr;
+ QPointer<QWaylandSurface> mFocus;
uint32_t mNativeModifiers = 0;
struct repeatKey {
- int key;
- uint32_t code;
- uint32_t time;
+ int key = 0;
+ uint32_t code = 0;
+ uint32_t time = 0 ;
QString text;
- Qt::KeyboardModifiers modifiers;
- uint32_t nativeVirtualKey;
- uint32_t nativeModifiers;
+ uint32_t nativeVirtualKey = 0;
} mRepeatKey;
QTimer mRepeatTimer;
@@ -254,7 +250,13 @@ public:
struct ::wl_keyboard *wl_keyboard() { return QtWayland::wl_keyboard::object(); }
-private slots:
+#if QT_CONFIG(xkbcommon)
+ virtual int keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifiers, xkb_state *state, xkb_keycode_t code) {
+ return QXkbCommon::keysymToQtKey(keysym, modifiers, state, code);
+ }
+#endif
+
+private Q_SLOTS:
void handleFocusDestroyed();
void handleFocusLost();
@@ -273,7 +275,7 @@ private:
friend class QWaylandInputDevice;
};
-class Q_WAYLAND_CLIENT_EXPORT QWaylandInputDevice::Pointer : public QObject, public QtWayland::wl_pointer
+class Q_WAYLANDCLIENT_EXPORT QWaylandInputDevice::Pointer : public QObject, public QtWayland::wl_pointer
{
Q_OBJECT
public:
@@ -281,11 +283,11 @@ public:
~Pointer() override;
QWaylandWindow *focusWindow() const;
#if QT_CONFIG(cursor)
- QString cursorThemeName() const;
- int cursorSize() const; // in surface coordinates
int idealCursorScale() const;
void updateCursorTheme();
void updateCursor();
+ void cursorTimerCallback();
+ void cursorFrameCallback();
CursorSurface *getOrCreateCursorSurface();
#endif
QWaylandInputDevice *seat() const { return mParent; }
@@ -307,8 +309,10 @@ protected:
void pointer_axis_stop(uint32_t time, uint32_t axis) override;
void pointer_axis_discrete(uint32_t axis, int32_t value) override;
void pointer_frame() override;
+ void pointer_axis_value120(uint32_t axis, int32_t value120) override;
+ void pointer_axis_relative_direction(uint32_t axis, uint32_t direction) override;
-private slots:
+private Q_SLOTS:
void handleFocusDestroyed() { invalidateFocus(); }
private:
@@ -322,25 +326,28 @@ public:
uint32_t mEnterSerial = 0;
#if QT_CONFIG(cursor)
struct {
+ QScopedPointer<QWaylandCursorShape> shape;
QWaylandCursorTheme *theme = nullptr;
int themeBufferScale = 0;
QScopedPointer<CursorSurface> surface;
+ QTimer frameTimer;
+ bool gotFrameCallback = false;
+ bool gotTimerCallback = false;
} mCursor;
#endif
QPointF mSurfacePos;
QPointF mGlobalPos;
Qt::MouseButtons mButtons = Qt::NoButton;
-#if QT_CONFIG(cursor)
- wl_buffer *mCursorBuffer = nullptr;
- Qt::CursorShape mCursorShape = Qt::BitmapCursor;
-#endif
+ Qt::MouseButton mLastButton = Qt::NoButton;
struct FrameData {
QWaylandPointerEvent *event = nullptr;
QPointF delta;
- QPoint discreteDelta;
+ QPoint delta120;
axis_source axisSource = axis_source_wheel;
+ bool verticalAxisInverted = false;
+ bool horizontalAxisInverted = false;
void resetScrollData();
bool hasPixelDelta() const;
@@ -360,7 +367,7 @@ private: //TODO: should other methods be private as well?
bool isDefinitelyTerminated(axis_source source) const;
};
-class Q_WAYLAND_CLIENT_EXPORT QWaylandInputDevice::Touch : public QtWayland::wl_touch
+class Q_WAYLANDCLIENT_EXPORT QWaylandInputDevice::Touch : public QtWayland::wl_touch
{
public:
Touch(QWaylandInputDevice *p);
@@ -396,33 +403,25 @@ class QWaylandPointerEvent
{
Q_GADGET
public:
- enum Type {
- Enter,
- Leave,
- Motion,
- Press,
- Release,
- Wheel
- };
- Q_ENUM(Type)
-
- inline QWaylandPointerEvent(Type type, Qt::ScrollPhase phase, QWaylandWindow *surface,
+ inline QWaylandPointerEvent(QEvent::Type type, Qt::ScrollPhase phase, QWaylandWindow *surface,
ulong timestamp, const QPointF &localPos, const QPointF &globalPos,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
+ Qt::MouseButtons buttons, Qt::MouseButton button,
+ Qt::KeyboardModifiers modifiers)
: type(type)
, phase(phase)
, timestamp(timestamp)
, local(localPos)
, global(globalPos)
, buttons(buttons)
+ , button(button)
, modifiers(modifiers)
, surface(surface)
{}
- inline QWaylandPointerEvent(Type type, Qt::ScrollPhase phase, QWaylandWindow *surface,
+ inline QWaylandPointerEvent(QEvent::Type type, Qt::ScrollPhase phase, QWaylandWindow *surface,
ulong timestamp, const QPointF &local, const QPointF &global,
const QPoint &pixelDelta, const QPoint &angleDelta,
Qt::MouseEventSource source,
- Qt::KeyboardModifiers modifiers)
+ Qt::KeyboardModifiers modifiers, bool inverted)
: type(type)
, phase(phase)
, timestamp(timestamp)
@@ -433,20 +432,80 @@ public:
, angleDelta(angleDelta)
, source(source)
, surface(surface)
+ , inverted(inverted)
{}
- Type type;
+ QEvent::Type type = QEvent::None;
Qt::ScrollPhase phase = Qt::NoScrollPhase;
ulong timestamp = 0;
QPointF local;
QPointF global;
Qt::MouseButtons buttons;
+ Qt::MouseButton button = Qt::NoButton; // Button that caused the event (QMouseEvent::button)
Qt::KeyboardModifiers modifiers;
QPoint pixelDelta;
QPoint angleDelta;
Qt::MouseEventSource source = Qt::MouseEventNotSynthesized;
QPointer<QWaylandWindow> surface;
+ bool inverted = false;
+};
+
+#ifndef QT_NO_GESTURES
+class QWaylandPointerGestureSwipeEvent
+{
+ Q_GADGET
+public:
+ inline QWaylandPointerGestureSwipeEvent(QWaylandWindow *surface, Qt::GestureState state,
+ ulong timestamp, const QPointF &local,
+ const QPointF &global, uint fingers, const QPointF& delta)
+ : surface(surface)
+ , state(state)
+ , timestamp(timestamp)
+ , local(local)
+ , global(global)
+ , fingers(fingers)
+ , delta(delta)
+ {}
+
+ QPointer<QWaylandWindow> surface;
+ Qt::GestureState state = Qt::GestureState::NoGesture;
+ ulong timestamp = 0;
+ QPointF local;
+ QPointF global;
+ uint fingers = 0;
+ QPointF delta;
+};
+
+class QWaylandPointerGesturePinchEvent
+{
+ Q_GADGET
+public:
+ inline QWaylandPointerGesturePinchEvent(QWaylandWindow *surface, Qt::GestureState state,
+ ulong timestamp, const QPointF &local,
+ const QPointF &global, uint fingers, const QPointF& delta,
+ qreal scale_delta, qreal rotation_delta)
+ : surface(surface)
+ , state(state)
+ , timestamp(timestamp)
+ , local(local)
+ , global(global)
+ , fingers(fingers)
+ , delta(delta)
+ , scale_delta(scale_delta)
+ , rotation_delta(rotation_delta)
+ {}
+
+ QPointer<QWaylandWindow> surface;
+ Qt::GestureState state = Qt::GestureState::NoGesture;
+ ulong timestamp = 0;
+ QPointF local;
+ QPointF global;
+ uint fingers = 0;
+ QPointF delta;
+ qreal scale_delta = 0;
+ qreal rotation_delta = 0;
};
+#endif // #ifndef QT_NO_GESTURES
}