10#if QT_CONFIG(wayland_datadevice)
14#if QT_CONFIG(wayland_client_primary_selection)
17#if QT_CONFIG(tabletevent)
28#if QT_WAYLAND_TEXT_INPUT_V4_WIP
29#include "qwaylandtextinputv4_p.h"
35#include <QtGui/private/qpixmap_raster_p.h>
36#include <QtGui/private/qguiapplication_p.h>
37#include <qpa/qplatformwindow.h>
38#include <qpa/qplatforminputcontext.h>
39#include <qpa/qplatformtheme.h>
47#include <wayland-cursor.h>
50#include <QtGui/QGuiApplication>
51#include <QtGui/QPointingDevice>
66 init(
p->get_keyboard());
67 mRepeatTimer.callOnTimeout([&]() {
73 mRepeatTimer.setInterval(1000 / mRepeatRate);
75 mRepeatKey.code, mRepeatKey.nativeVirtualKey, mRepeatKey.nativeModifiers,
76 mRepeatKey.text,
true);
77 handleKey(mRepeatKey.time,
QEvent::KeyPress, mRepeatKey.key, mRepeatKey.modifiers,
78 mRepeatKey.code, mRepeatKey.nativeVirtualKey, mRepeatKey.nativeModifiers,
79 mRepeatKey.text,
true);
83#if QT_CONFIG(xkbcommon)
84bool QWaylandInputDevice::Keyboard::createDefaultKeymap()
86 struct xkb_context *
ctx = mParent->mQDisplay->xkbContext();
90 struct xkb_rule_names
names;
91 names.rules =
"evdev";
92 names.model =
"pc105";
97 mXkbKeymap.reset(xkb_keymap_new_from_names(
ctx, &
names, XKB_KEYMAP_COMPILE_NO_FLAGS));
99 mXkbState.reset(xkb_state_new(mXkbKeymap.get()));
101 if (!mXkbKeymap || !mXkbState) {
102 qCWarning(lcQpaWayland,
"failed to create default keymap");
110QWaylandInputDevice::Keyboard::~Keyboard()
115 wl_keyboard_release(
object());
117 wl_keyboard_destroy(
object());
120QWaylandWindow *QWaylandInputDevice::Keyboard::focusWindow()
const
122 return mFocus ? QWaylandWindow::fromWlSurface(mFocus) :
nullptr;
125QWaylandInputDevice::Pointer::Pointer(QWaylandInputDevice *seat)
128 init(seat->get_pointer());
130 if (
auto cursorShapeManager = seat->mQDisplay->cursorShapeManager()) {
131 mCursor.shape.reset(
new QWaylandCursorShape(cursorShapeManager->get_pointer(
object())));
134 mCursor.frameTimer.setSingleShot(
true);
135 mCursor.frameTimer.callOnTimeout([&]() {
136 cursorTimerCallback();
141QWaylandInputDevice::Pointer::~Pointer()
144 wl_pointer_release(
object());
146 wl_pointer_destroy(
object());
149QWaylandWindow *QWaylandInputDevice::Pointer::focusWindow()
const
151 return mFocus ? mFocus->waylandWindow() :
nullptr;
156class WlCallback :
public QtWayland::wl_callback {
158 explicit WlCallback(::wl_callback *callback, std::function<
void(uint32_t)> fn,
bool autoDelete =
false)
161 , m_autoDelete(autoDelete)
163 ~WlCallback()
override { wl_callback_destroy(
object()); }
164 bool done()
const {
return m_done; }
165 void callback_done(uint32_t callback_data)
override {
173 std::function<
void(uint32_t)> m_fn;
174 bool m_autoDelete =
false;
180 explicit CursorSurface(QWaylandInputDevice::Pointer *
pointer, QWaylandDisplay *
display)
184 connect(
this, &QWaylandSurface::screensChanged,
185 m_pointer, &QWaylandInputDevice::Pointer::updateCursor);
190 uint serial = m_pointer->mEnterSerial;
192 m_pointer->set_cursor(serial,
nullptr, 0, 0);
197 void update(wl_buffer *
buffer,
const QPoint &hotspot,
const QSize &
size,
int bufferScale,
bool animated =
false)
200 Q_ASSERT(bufferScale == 1 || version() >= 3);
202 auto enterSerial = m_pointer->mEnterSerial;
203 if (m_setSerial < enterSerial || m_hotspot != hotspot) {
204 m_pointer->set_cursor(m_pointer->mEnterSerial,
object(), hotspot.
x(), hotspot.
y());
205 m_setSerial = enterSerial;
210 set_buffer_scale(bufferScale);
213 damage(0, 0,
size.width(),
size.height());
214 m_frameCallback.reset();
216 m_frameCallback.reset(
new WlCallback(
frame(), [
this](uint32_t
time){
218 m_pointer->cursorFrameCallback();
224 int outputScale()
const
227 for (
auto *
screen : m_screens)
234 QWaylandInputDevice::Pointer *m_pointer =
nullptr;
235 uint m_setSerial = 0;
239int QWaylandInputDevice::Pointer::idealCursorScale()
const
241 if (seat()->mQDisplay->compositor()->version() < 3) {
245 if (
auto *
s = mCursor.surface.data()) {
246 if (
s->outputScale() > 0)
247 return s->outputScale();
250 return seat()->mCursor.fallbackOutputScale;
253void QWaylandInputDevice::Pointer::updateCursorTheme()
266 cursorSize =
QSize(24, 24);
268 int scale = idealCursorScale();
270 auto *
display = seat()->mQDisplay;
271 mCursor.theme =
display->loadCursorTheme(cursorThemeName, pixelSize);
277 int arrowPixelSize =
qMax(arrow->images[0]->width, arrow->images[0]->height);
281 qCWarning(lcQpaWayland) <<
"Cursor theme does not support the arrow cursor";
283 mCursor.themeBufferScale =
scale;
286void QWaylandInputDevice::Pointer::updateCursor()
288 if (mEnterSerial == 0)
291 auto shape = seat()->mCursor.shape;
294 getOrCreateCursorSurface()->hide();
299 auto buffer = seat()->mCursor.bitmapBuffer;
301 qCWarning(lcQpaWayland) <<
"No buffer for bitmap cursor, can't set cursor";
304 auto hotspot = seat()->mCursor.hotspot;
305 int bufferScale = seat()->mCursor.bitmapScale;
306 getOrCreateCursorSurface()->update(
buffer->buffer(), hotspot,
buffer->size(), bufferScale);
311 mCursor.shape->setShape(mEnterSerial, shape);
315 if (!mCursor.theme || idealCursorScale() != mCursor.themeBufferScale)
322 uint time = seat()->mCursor.animationTimer.elapsed();
324 if (struct ::wl_cursor *waylandCursor = mCursor.theme->cursor(shape)) {
326 int frame = wl_cursor_frame_and_duration(waylandCursor,
time, &duration);
327 ::wl_cursor_image *
image = waylandCursor->images[
frame];
329 struct wl_buffer *
buffer = wl_cursor_image_get_buffer(
image);
331 qCWarning(lcQpaWayland) <<
"Could not find buffer for cursor" << shape;
334 int bufferScale = mCursor.themeBufferScale;
337 bool animated = duration > 0;
339 mCursor.gotFrameCallback =
false;
340 mCursor.gotTimerCallback =
false;
341 mCursor.frameTimer.start(duration);
343 getOrCreateCursorSurface()->update(
buffer, hotspot,
size, bufferScale, animated);
347 qCWarning(lcQpaWayland) <<
"Unable to change to cursor" << shape;
350CursorSurface *QWaylandInputDevice::Pointer::getOrCreateCursorSurface()
352 if (!mCursor.surface)
353 mCursor.surface.reset(
new CursorSurface(
this, seat()->mQDisplay));
354 return mCursor.surface.get();
357void QWaylandInputDevice::Pointer::cursorTimerCallback()
359 mCursor.gotTimerCallback =
true;
360 if (mCursor.gotFrameCallback) {
365void QWaylandInputDevice::Pointer::cursorFrameCallback()
367 mCursor.gotFrameCallback =
true;
368 if (mCursor.gotTimerCallback) {
375QWaylandInputDevice::Touch::Touch(QWaylandInputDevice *
p)
378 init(
p->get_touch());
381QWaylandInputDevice::Touch::~Touch()
384 wl_touch_release(
object());
386 wl_touch_destroy(
object());
392 , mDisplay(
display->wl_display())
395#if QT_CONFIG(wayland_datadevice)
397 mDataDevice =
mQDisplay->dndSelectionHandler()->getDataDevice(
this);
401#if QT_CONFIG(wayland_client_primary_selection)
403 if (
auto *psm =
mQDisplay->primarySelectionManager())
404 setPrimarySelectionDevice(psm->createDevice(
this));
416#if QT_WAYLAND_TEXT_INPUT_V4_WIP
424#if QT_CONFIG(tabletevent)
425 if (
auto *tm =
mQDisplay->tabletManager())
437 if (caps & WL_SEAT_CAPABILITY_KEYBOARD && !
mKeyboard) {
439 }
else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) &&
mKeyboard) {
443 if (caps & WL_SEAT_CAPABILITY_POINTER && !
mPointer) {
447 if (pointerGestures) {
459 }
else if (!(caps & WL_SEAT_CAPABILITY_POINTER) &&
mPointer) {
465 if (caps & WL_SEAT_CAPABILITY_TOUCH && !
mTouch) {
476 }
else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) &&
mTouch) {
529#if QT_CONFIG(wayland_datadevice)
535QWaylandDataDevice *QWaylandInputDevice::dataDevice()
const
541#if QT_CONFIG(wayland_client_primary_selection)
542void QWaylandInputDevice::setPrimarySelectionDevice(QWaylandPrimarySelectionDeviceV1 *primarySelectionDevice)
544 mPrimarySelectionDevice.reset(primarySelectionDevice);
547QWaylandPrimarySelectionDeviceV1 *QWaylandInputDevice::primarySelectionDevice()
const
549 return mPrimarySelectionDevice.data();
601#if QT_CONFIG(xkbcommon)
618Qt::KeyboardModifiers QWaylandInputDevice::Keyboard::modifiers()
const
622#if QT_CONFIG(xkbcommon)
635 CursorState oldCursor = mCursor;
636 mCursor = CursorState();
639 mCursor.fallbackOutputScale = fallbackOutputScale;
640 mCursor.animationTimer.start();
643 mCursor.bitmapBuffer = cachedBuffer ? cachedBuffer : QWaylandCursor::cursorBitmapBuffer(
mQDisplay,
cursor);
645 mCursor.bitmapScale = int(
dpr);
647 if (mCursor.bitmapScale <
dpr)
648 mCursor.hotspot *=
dpr / mCursor.bitmapScale;
653 && mCursor.shape == oldCursor.shape
654 && mCursor.hotspot == oldCursor.hotspot
655 && mCursor.fallbackOutputScale == oldCursor.fallbackOutputScale) {
673void QWaylandInputDevice::Pointer::pointer_enter(uint32_t serial,
struct wl_surface *surface,
674 wl_fixed_t sx, wl_fixed_t sy)
685 qCWarning(lcQpaWayland) <<
"The compositor sent a wl_pointer.enter event before sending a"
686 <<
"leave event first, this is not allowed by the wayland protocol"
687 <<
"attempting to work around it by invalidating the current focus";
690 mFocus =
window->waylandSurface();
693 mSurfacePos =
QPointF(wl_fixed_to_double(sx), wl_fixed_to_double(sy));
694 mGlobalPos =
window->mapToGlobal(mSurfacePos.toPoint());
696 mParent->mSerial = serial;
697 mEnterSerial = serial;
706 setFrameEvent(
new EnterEvent(
window, mSurfacePos, mGlobalPos));
714 localPos, globalPos,
Qt::NoButton,
Qt::NoButton,
Qt::NoModifier)
718void QWaylandInputDevice::Pointer::pointer_leave(uint32_t
time,
struct wl_surface *surface)
723 mParent->mTime =
time;
735 setFrameEvent(
new LeaveEvent(
window, mSurfacePos, mGlobalPos));
749void QWaylandInputDevice::Pointer::pointer_motion(uint32_t
time, wl_fixed_t surface_x, wl_fixed_t surface_y)
751 QWaylandWindow *
window = focusWindow();
758 QPointF pos(wl_fixed_to_double(surface_x), wl_fixed_to_double(surface_y));
765 mParent->mTime =
time;
768 if (grab && grab !=
window) {
772 global = grab->mapToGlobal(
pos.toPoint());
802void QWaylandInputDevice::Pointer::pointer_button(uint32_t serial, uint32_t
time,
805 QWaylandWindow *
window = focusWindow();
836 mLastButton = qt_button;
839 mButtons |= qt_button;
841 mButtons &= ~qt_button;
843 mParent->mTime =
time;
844 mParent->mSerial = serial;
846 mParent->mQDisplay->setLastInputDevice(mParent, serial,
window);
852 if (grab && grab != focusWindow()) {
854 global = grab->mapToGlobal(
pos.toPoint());
860 setFrameEvent(
new PressEvent(
window,
time,
pos,
global, mButtons, qt_button, mParent->modifiers()));
862 setFrameEvent(
new ReleaseEvent(
window,
time,
pos,
global, mButtons, qt_button, mParent->modifiers()));
865void QWaylandInputDevice::Pointer::invalidateFocus()
874void QWaylandInputDevice::Pointer::releaseButtons()
881 if (
auto *
window = focusWindow()) {
882 ReleaseEvent
e(focusWindow(), mParent->mTime, mSurfacePos, mGlobalPos, mButtons, mLastButton, mParent->modifiers());
883 window->handleMouse(mParent,
e);
899void QWaylandInputDevice::Pointer::pointer_axis(uint32_t
time, uint32_t axis, int32_t
value)
901 if (!focusWindow()) {
909 case WL_POINTER_AXIS_VERTICAL_SCROLL:
910 mFrameData.delta.ry() += wl_fixed_to_double(
value);
911 qCDebug(lcQpaWaylandInput) <<
"wl_pointer.axis vertical:" << mFrameData.delta.y();
913 case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
914 mFrameData.delta.rx() += wl_fixed_to_double(
value);
915 qCDebug(lcQpaWaylandInput) <<
"wl_pointer.axis horizontal:" << mFrameData.delta.x();
919 qCWarning(lcQpaWaylandInput) <<
"wl_pointer.axis: Unknown axis:" << axis;
923 mParent->mTime =
time;
925 if (version() < WL_POINTER_FRAME_SINCE_VERSION) {
926 qCDebug(lcQpaWaylandInput) <<
"Flushing new event; no frame event in this version";
931void QWaylandInputDevice::Pointer::pointer_frame()
936void QWaylandInputDevice::Pointer::pointer_axis_source(uint32_t
source)
939 case axis_source_wheel:
940 qCDebug(lcQpaWaylandInput) <<
"Axis source wheel";
942 case axis_source_finger:
943 qCDebug(lcQpaWaylandInput) <<
"Axis source finger";
945 case axis_source_continuous:
946 qCDebug(lcQpaWaylandInput) <<
"Axis source continuous";
948 case axis_source_wheel_tilt:
949 qCDebug(lcQpaWaylandInput) <<
"Axis source wheel tilt";
951 mFrameData.axisSource = axis_source(
source);
954void QWaylandInputDevice::Pointer::pointer_axis_stop(uint32_t
time, uint32_t axis)
959 mParent->mTime =
time;
961 case axis_vertical_scroll:
962 qCDebug(lcQpaWaylandInput) <<
"Received vertical wl_pointer.axis_stop";
963 mFrameData.delta.setY(0);
965 case axis_horizontal_scroll:
966 qCDebug(lcQpaWaylandInput) <<
"Received horizontal wl_pointer.axis_stop";
967 mFrameData.delta.setX(0);
970 qCWarning(lcQpaWaylandInput) <<
"wl_pointer.axis_stop: Unknown axis: " << axis
971 <<
"This is most likely a compositor bug";
977 if (!mScrollBeginSent) {
987 Qt::KeyboardModifiers mods = mParent->modifiers();
990 target->handleMouse(mParent, wheelEvent);
991 mScrollBeginSent =
false;
992 mScrollDeltaRemainder =
QPointF();
995void QWaylandInputDevice::Pointer::pointer_axis_discrete(uint32_t axis, int32_t
value)
1000 const int32_t delta120 =
value * 15 * 8;
1003 case axis_vertical_scroll:
1004 qCDebug(lcQpaWaylandInput) <<
"wl_pointer.axis_discrete vertical:" <<
value;
1005 mFrameData.delta120.ry() += delta120;
1007 case axis_horizontal_scroll:
1008 qCDebug(lcQpaWaylandInput) <<
"wl_pointer.axis_discrete horizontal:" <<
value;
1009 mFrameData.delta120.rx() += delta120;
1013 qCWarning(lcQpaWaylandInput) <<
"wl_pointer.axis_discrete: Unknown axis:" << axis;
1018void QWaylandInputDevice::Pointer::pointer_axis_value120(uint32_t axis, int32_t
value)
1024 case axis_vertical_scroll:
1025 qCDebug(lcQpaWaylandInput) <<
"wl_pointer.axis_value120 vertical:" <<
value;
1026 mFrameData.delta120.ry() +=
value;
1028 case axis_horizontal_scroll:
1029 qCDebug(lcQpaWaylandInput) <<
"wl_pointer.axis_value120 horizontal:" <<
value;
1030 mFrameData.delta120.rx() +=
value;
1033 qCWarning(lcQpaWaylandInput) <<
"wl_pointer.axis_value120: Unknown axis:" << axis;
1038void QWaylandInputDevice::Pointer::setFrameEvent(QWaylandPointerEvent *
event)
1040 qCDebug(lcQpaWaylandInput) <<
"Setting frame event " <<
event->type;
1041 if (mFrameData.event && mFrameData.event->type !=
event->type) {
1042 qCDebug(lcQpaWaylandInput) <<
"Flushing; previous was " << mFrameData.event->type;
1046 mFrameData.event =
event;
1048 if (version() < WL_POINTER_FRAME_SINCE_VERSION) {
1049 qCDebug(lcQpaWaylandInput) <<
"Flushing new event; no frame event in this version";
1054void QWaylandInputDevice::Pointer::FrameData::resetScrollData()
1058 axisSource = axis_source_wheel;
1061bool QWaylandInputDevice::Pointer::FrameData::hasPixelDelta()
const
1063 switch (axisSource) {
1064 case axis_source_wheel_tilt:
1065 case axis_source_wheel:
1070 case axis_source_finger:
1071 case axis_source_continuous:
1078QPoint QWaylandInputDevice::Pointer::FrameData::pixelDeltaAndError(
QPointF *accumulatedError)
const
1080 if (!hasPixelDelta())
1085 QPoint pixelDelta = (delta + *accumulatedError).toPoint();
1086 *accumulatedError += delta - pixelDelta;
1098QPoint QWaylandInputDevice::Pointer::FrameData::angleDelta()
const
1100 if (delta120.isNull()) {
1103 return (delta * -12).toPoint();
1114 switch (axisSource) {
1115 case axis_source_wheel_tilt:
1116 case axis_source_wheel:
1118 case axis_source_finger:
1119 case axis_source_continuous:
1125void QWaylandInputDevice::Pointer::flushScrollEvent()
1127 QPoint angleDelta = mFrameData.angleDelta();
1130 if (!angleDelta.
isNull()) {
1135 if (isDefinitelyTerminated(mFrameData.axisSource) && !mScrollBeginSent) {
1136 qCDebug(lcQpaWaylandInput) <<
"Flushing scroll event sending ScrollBegin";
1140 mParent->modifiers()));
1141 mScrollBeginSent =
true;
1142 mScrollDeltaRemainder =
QPointF();
1146 QPoint pixelDelta = mFrameData.pixelDeltaAndError(&mScrollDeltaRemainder);
1149 qCDebug(lcQpaWaylandInput) <<
"Flushing scroll event" << phase << pixelDelta << angleDelta;
1150 target->handleMouse(mParent,
WheelEvent(focusWindow(), phase, mParent->mTime, mSurfacePos, mGlobalPos,
1151 pixelDelta, angleDelta,
source, mParent->modifiers()));
1154 mFrameData.resetScrollData();
1157void QWaylandInputDevice::Pointer::flushFrameEvent()
1159 if (
auto *
event = mFrameData.event) {
1170 delete mFrameData.event;
1171 mFrameData.event =
nullptr;
1178bool QWaylandInputDevice::Pointer::isDefinitelyTerminated(QtWayland::wl_pointer::axis_source
source)
const
1180 return source == axis_source_finger;
1183void QWaylandInputDevice::Keyboard::keyboard_keymap(uint32_t
format, int32_t
fd, uint32_t
size)
1186#if QT_CONFIG(xkbcommon)
1187 if (
format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
1193 char *map_str =
static_cast<char *
>(mmap(
nullptr,
size, PROT_READ, MAP_PRIVATE,
fd, 0));
1199 mXkbKeymap.reset(xkb_keymap_new_from_string(mParent->mQDisplay->xkbContext(), map_str,
1200 XKB_KEYMAP_FORMAT_TEXT_V1,
1201 XKB_KEYMAP_COMPILE_NO_FLAGS));
1204 munmap(map_str,
size);
1208 mXkbState.reset(xkb_state_new(mXkbKeymap.get()));
1210 mXkbState.reset(
nullptr);
1217void QWaylandInputDevice::Keyboard::keyboard_enter(uint32_t
time,
struct wl_surface *surface,
struct wl_array *
keys)
1229 qCWarning(lcQpaWayland()) <<
"Unexpected wl_keyboard.enter event. Keyboard already has focus";
1236 mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
1239void QWaylandInputDevice::Keyboard::keyboard_leave(uint32_t
time,
struct wl_surface *surface)
1248 if (surface != mFocus) {
1249 qCWarning(lcQpaWayland) <<
"Ignoring unexpected wl_keyboard.leave event."
1250 <<
"wl_surface argument does not match the current focus"
1251 <<
"This is most likely a compositor bug";
1268 nativeModifiers,
text, autorepeat,
count);
1269 event.setTimestamp(timestamp);
1274 auto window = focusWindow()->window();
1286 nativeScanCode, nativeVirtualKey, nativeModifiers,
text, autorepeat,
count);
1290void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t
time, uint32_t
key, uint32_t
state)
1292 if (mKeymapFormat != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1 && mKeymapFormat != WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP) {
1297 auto *
window = focusWindow();
1304 mParent->mSerial = serial;
1306 const bool isDown =
state != WL_KEYBOARD_KEY_STATE_RELEASED;
1308 mParent->mQDisplay->setLastInputDevice(mParent, serial,
window);
1310 if (mKeymapFormat == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
1311#if QT_CONFIG(xkbcommon)
1312 if ((!mXkbKeymap || !mXkbState) && !createDefaultKeymap())
1317 xkb_keysym_t sym = xkb_state_key_get_one_sym(mXkbState.get(), code);
1319 Qt::KeyboardModifiers
modifiers = mParent->modifiers();
1321 int qtkey = keysymToQtKey(sym,
modifiers, mXkbState.get(), code);
1327 if (
state == WL_KEYBOARD_KEY_STATE_PRESSED && xkb_keymap_key_repeats(mXkbKeymap.get(), code) && mRepeatRate > 0) {
1328 mRepeatKey.key = qtkey;
1329 mRepeatKey.code =
code;
1330 mRepeatKey.time =
time;
1331 mRepeatKey.text =
text;
1333 mRepeatKey.nativeModifiers = mNativeModifiers;
1334 mRepeatKey.nativeVirtualKey = sym;
1335 mRepeatTimer.setInterval(mRepeatDelay);
1336 mRepeatTimer.start();
1337 }
else if (mRepeatKey.code == code) {
1338 mRepeatTimer.stop();
1343 qCWarning(lcQpaWayland,
"xkbcommon not available on this build, not performing key mapping");
1346 }
else if (mKeymapFormat == WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP) {
1352void QWaylandInputDevice::Keyboard::handleFocusDestroyed()
1356 auto *
window = qobject_cast<QWaylandWindow *>(sender());
1362void QWaylandInputDevice::Keyboard::handleFocusLost()
1365 mParent->mQDisplay->handleKeyboardFocusChanged(mParent);
1366 mRepeatTimer.stop();
1369void QWaylandInputDevice::Keyboard::keyboard_modifiers(uint32_t serial,
1370 uint32_t mods_depressed,
1371 uint32_t mods_latched,
1372 uint32_t mods_locked,
1376#if QT_CONFIG(xkbcommon)
1378 xkb_state_update_mask(mXkbState.get(),
1379 mods_depressed, mods_latched, mods_locked,
1381 mNativeModifiers = mods_depressed | mods_latched | mods_locked;
1390void QWaylandInputDevice::Keyboard::keyboard_repeat_info(int32_t
rate, int32_t delay)
1393 mRepeatDelay = delay;
1396void QWaylandInputDevice::Touch::touch_down(uint32_t serial,
1398 struct wl_surface *surface,
1410 mParent->mTime =
time;
1411 mParent->mSerial = serial;
1413 mParent->mQDisplay->setLastInputDevice(mParent, serial, mFocus);
1418void QWaylandInputDevice::Touch::touch_up(uint32_t serial, uint32_t
time, int32_t
id)
1421 mParent->mTime =
time;
1424 if (allTouchPointsReleased()) {
1433 qCDebug(lcQpaWayland,
"Generating fake frame event to work around Weston bug");
1438void QWaylandInputDevice::Touch::touch_motion(uint32_t
time, int32_t
id, wl_fixed_t
x, wl_fixed_t
y)
1441 mParent->mTime =
time;
1445void QWaylandInputDevice::Touch::touch_cancel()
1447 mPendingTouchPoints.clear();
1449 QWaylandTouchExtension *touchExt = mParent->mQDisplay->touchExtension();
1451 touchExt->touchCanceled();
1459 auto end =
mTouch->mPendingTouchPoints.end();
1489 QPointF localPosition =
win->mapFromWlSurface(surfacePosition);
1504bool QWaylandInputDevice::Touch::allTouchPointsReleased()
1506 for (
const auto &tp :
std::as_const(mPendingTouchPoints)) {
1513void QWaylandInputDevice::Touch::releasePoints()
1515 if (mPendingTouchPoints.empty())
1524void QWaylandInputDevice::Touch::touch_frame()
1537 if (mFocus->touchDragDecoration(mParent, localPos, tp.
area.
center(), tp.
state, mParent->modifiers()))
1544 const auto prevTouchPoints = mPendingTouchPoints;
1545 mPendingTouchPoints.clear();
1546 for (
const auto &prevPoint: prevTouchPoints) {
1551 mPendingTouchPoints.append(tp);
1561#include "moc_qwaylandinputdevice_p.cpp"
IOBluetoothDevice * device
The QCursor class provides a mouse cursor with an arbitrary shape.
QPixmap pixmap() const
Returns the cursor pixmap.
Qt::CursorShape shape() const
Returns the cursor shape identifier.
static QPoint pos()
Returns the position of the cursor (hot spot) of the primary screen in global screen coordinates.
QPoint hotSpot() const
Returns the cursor hot spot, or (0, 0) if it is one of the standard cursors.
The QEventPoint class provides information about a point in a QPointerEvent.
State
Specifies the state of this event point.
Type
This enum type defines the valid event types in Qt.
static QPlatformIntegration * platformIntegration()
static QPlatformTheme * platformTheme()
The QKeyEvent class describes a key event.
constexpr int left() const noexcept
Returns the left margin.
constexpr int top() const noexcept
Returns the top margin.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
qreal devicePixelRatio() const
Returns the device pixel ratio for the pixmap.
The QPlatformInputContext class abstracts the input method dependent data and composing state.
virtual bool filterEvent(const QEvent *event)
This function can be reimplemented to filter input events.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0.0 (ignoring the sign); otherwise returns fa...
\inmodule QtCore\reentrant
constexpr bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0, otherwise returns false.
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
QPointingDeviceUniqueId identifies a unique object, such as a tagged token or stylus,...
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\inmodule QtCore\reentrant
constexpr void moveCenter(const QPointF &p) noexcept
Moves the rectangle, leaving the center point at the given position.
constexpr QPointF center() const noexcept
Returns the center point of the rectangle.
T * data() const noexcept
Returns the value of the pointer referenced by this object.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
constexpr int width() const noexcept
Returns the width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
\qmltype WaylandSurface \instantiates QWaylandSurface \inqmlmodule QtWayland.Compositor
static bool handleTouchEvent(QWindow *window, const QPointingDevice *device, const QList< struct TouchPoint > &points, Qt::KeyboardModifiers mods=Qt::NoModifier)
static bool handleTouchCancelEvent(QWindow *window, const QPointingDevice *device, Qt::KeyboardModifiers mods=Qt::NoModifier)
static void handleContextMenuEvent(QWindow *window, bool mouseTriggered, const QPoint &pos, const QPoint &globalPos, Qt::KeyboardModifiers modifiers)
static bool handleMouseEvent(QWindow *window, const QPointF &local, const QPointF &global, Qt::MouseButtons state, Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods=Qt::NoModifier, Qt::MouseEventSource source=Qt::MouseEventNotSynthesized)
static void registerInputDevice(const QInputDevice *device)
static bool handleExtendedKeyEvent(QWindow *window, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString &text=QString(), bool autorep=false, ushort count=1)
static void handleWindowActivated(QWindow *window, Qt::FocusReason r=Qt::OtherFocusReason)
static QString lookupString(struct xkb_state *state, xkb_keycode_t code)
static void verifyHasLatinLayout(xkb_keymap *keymap)
static Qt::KeyboardModifiers modifiers(struct xkb_state *state, xkb_keysym_t keysym=XKB_KEY_VoidSymbol)
static QList< int > possibleKeys(xkb_state *state, const QKeyEvent *event, bool superAsMeta=false, bool hyperAsMeta=false)
EnterEvent(QWaylandWindow *surface, const QPointF &local, const QPointF &global)
LeaveEvent(QWaylandWindow *surface, const QPointF &localPos, const QPointF &globalPos)
MotionEvent(QWaylandWindow *surface, ulong timestamp, const QPointF &localPos, const QPointF &globalPos, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
PressEvent(QWaylandWindow *surface, ulong timestamp, const QPointF &localPos, const QPointF &globalPos, Qt::MouseButtons buttons, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
QtWayland::zwp_text_input_manager_v4 * textInputManagerv4() const
QtWayland::zwp_text_input_manager_v1 * textInputManagerv1() const
QWaylandPointerGestures * pointerGestures() const
QtWayland::zwp_text_input_manager_v2 * textInputManagerv2() const
QtWayland::qt_text_input_method_manager_v1 * textInputMethodManager() const
QPointer< QWaylandWindow > surface
void wlSurfaceDestroyed()
static QWaylandWindow * fromWlSurface(::wl_surface *surface)
static QWaylandWindow * mouseGrab()
ReleaseEvent(QWaylandWindow *surface, ulong timestamp, const QPointF &localPos, const QPointF &globalPos, Qt::MouseButtons buttons, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
WheelEvent(QWaylandWindow *surface, Qt::ScrollPhase phase, ulong timestamp, const QPointF &local, const QPointF &global, const QPoint &pixelDelta, const QPoint &angleDelta, Qt::MouseEventSource source, Qt::KeyboardModifiers modifiers)
EGLImageKHR int int EGLuint64KHR * modifiers
QSet< QString >::iterator it
struct wl_display * display
Combined button and popup list for selecting options.
QFuture< typename std::decay_t< Sequence >::value_type > filtered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&keep)
Calls filterFunction once for each item in sequence and returns a new Sequence of kept items.
static const int MaxTouchPoints
@ MouseEventSynthesizedBySystem
@ MouseEventNotSynthesized
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_LOGGING_CATEGORY(name,...)
#define qCWarning(category,...)
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
GLint GLint GLint GLint GLsizei GLsizei GLsizei GLboolean commit
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
GLsizei const void * pointer
GLenum GLenum GLenum GLenum GLenum scale
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
myObject disconnect()
[26]