1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the plugins of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #ifndef QWAYLANDINPUTDEVICE_H
43 #define QWAYLANDINPUTDEVICE_H
45 #include "qwaylandwindow.h"
47 #include <QSocketNotifier>
49 #include <qpa/qplatformintegration.h>
50 #include <qpa/qplatformscreen.h>
51 #include <qpa/qwindowsysteminterface.h>
53 #include <wayland-client.h>
55 #ifndef QT_NO_WAYLAND_XKB
64 class QWaylandDisplay;
66 class QWaylandInputDevice {
68 QWaylandInputDevice(QWaylandDisplay *display, uint32_t id);
69 ~QWaylandInputDevice();
71 uint32_t capabilities() const { return mCaps; }
73 struct wl_seat *wl_seat() const { return mSeat; }
75 void setCursor(wl_surface *surface, int x, int y);
76 void handleWindowDestroyed(QWaylandWindow *window);
78 void setTransferDevice(struct wl_data_device *device);
79 struct wl_data_device *transferDevice() const;
81 void removeMouseButtonFromState(Qt::MouseButton button);
84 QWaylandDisplay *mQDisplay;
85 struct wl_display *mDisplay;
87 struct wl_seat *mSeat;
91 struct wl_pointer *pointer;
92 struct wl_keyboard *keyboard;
93 struct wl_touch *touch;
96 struct wl_data_device *mTransferDevice;
97 QWaylandWindow *mPointerFocus;
98 QWaylandWindow *mKeyboardFocus;
99 QWaylandWindow *mTouchFocus;
101 Qt::MouseButtons mButtons;
106 static const struct wl_seat_listener seatListener;
108 static void seat_capabilities(void *data,
109 struct wl_seat *seat,
112 static const struct wl_pointer_listener pointerListener;
114 static void pointer_enter(void *data,
115 struct wl_pointer *pointer,
116 uint32_t time, struct wl_surface *surface,
117 wl_fixed_t sx, wl_fixed_t sy);
118 static void pointer_leave(void *data,
119 struct wl_pointer *pointer,
120 uint32_t time, struct wl_surface *surface);
121 static void pointer_motion(void *data,
122 struct wl_pointer *pointer,
124 wl_fixed_t sx, wl_fixed_t sy);
125 static void pointer_button(void *data,
126 struct wl_pointer *pointer,
127 uint32_t serial, uint32_t time,
128 uint32_t button, uint32_t state);
129 static void pointer_axis(void *data,
130 struct wl_pointer *pointer,
135 static const struct wl_keyboard_listener keyboardListener;
137 static void keyboard_keymap(void *data,
138 struct wl_keyboard *keyboard,
142 static void keyboard_enter(void *data,
143 struct wl_keyboard *keyboard,
145 struct wl_surface *surface,
146 struct wl_array *keys);
147 static void keyboard_leave(void *data,
148 struct wl_keyboard *keyboard,
150 struct wl_surface *surface);
151 static void keyboard_key(void *data,
152 struct wl_keyboard *keyboard,
153 uint32_t serial, uint32_t time,
154 uint32_t key, uint32_t state);
155 static void keyboard_modifiers(void *data,
156 struct wl_keyboard *keyboard,
158 uint32_t mods_depressed,
159 uint32_t mods_latched,
160 uint32_t mods_locked,
163 static const struct wl_touch_listener touchListener;
165 static void touch_down(void *data,
166 struct wl_touch *touch,
169 struct wl_surface *surface,
173 static void touch_up(void *data,
174 struct wl_touch *touch,
178 static void touch_motion(void *data,
179 struct wl_touch *touch,
184 static void touch_frame(void *data,
185 struct wl_touch *touch);
186 static void touch_cancel(void *data,
187 struct wl_touch *touch);
189 void handleTouchPoint(int id, double x, double y, Qt::TouchPointState state);
190 void handleTouchFrame();
191 QList<QWindowSystemInterface::TouchPoint> mTouchPoints;
192 QList<QWindowSystemInterface::TouchPoint> mPrevTouchPoints;
193 QTouchDevice *mTouchDevice;
195 #ifndef QT_NO_WAYLAND_XKB
196 xkb_context *mXkbContext;
198 xkb_state *mXkbState;
201 friend class QWaylandTouchExtension;
202 friend class QWaylandQtKeyExtension;