From b70bf618688c51ec5c532b8fa9240bed9fe84344 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sun, 8 Sep 2024 18:00:34 +0000 Subject: [PATCH] wayland: Implement server-side key repeat This implements wl_keyboard key repeat events. [ChangeLog][Third-Party Code] Update wayland.xml to 1.24.0. Change-Id: I21fc247bd95485e3c7189c47cb0cc999c431587f Reviewed-by: David Edmundson --- .../protocols/wayland/qt_attribution.json | 4 +- .../wayland/protocols/wayland/wayland.xml | 77 +++++++++++++++---- .../platforms/wayland/qwaylandinputdevice.cpp | 16 +++- .../wayland/qwaylandvulkaninstance.cpp | 2 +- 4 files changed, 81 insertions(+), 18 deletions(-) diff --git a/src/3rdparty/wayland/protocols/wayland/qt_attribution.json b/src/3rdparty/wayland/protocols/wayland/qt_attribution.json index 413d1503767..000ee0d4b2e 100644 --- a/src/3rdparty/wayland/protocols/wayland/qt_attribution.json +++ b/src/3rdparty/wayland/protocols/wayland/qt_attribution.json @@ -8,8 +8,8 @@ "Description": "Wayland is a protocol for a compositor to talk to its clients.", "Homepage": "https://wayland.freedesktop.org", - "Version": "1.23.0", - "DownloadLocation": "https://gitlab.freedesktop.org/wayland/wayland/raw/1.23.0/protocol/wayland.xml", + "Version": "1.24.0", + "DownloadLocation": "https://gitlab.freedesktop.org/wayland/wayland/raw/1.24.0/protocol/wayland.xml", "LicenseId": "MIT", "License": "MIT License", "LicenseFile": "../MIT_LICENSE.txt", diff --git a/src/3rdparty/wayland/protocols/wayland/wayland.xml b/src/3rdparty/wayland/protocols/wayland/wayland.xml index 9418c62f3f6..bee74a10084 100644 --- a/src/3rdparty/wayland/protocols/wayland/wayland.xml +++ b/src/3rdparty/wayland/protocols/wayland/wayland.xml @@ -501,8 +501,10 @@ Sent when this wl_buffer is no longer used by the compositor. - The client is now free to reuse or destroy this buffer and its - backing storage. + + For more information on when release events may or may not be sent, + and what consequences it has, please see the description of + wl_surface.attach. If a client receives a release event before the frame callback requested in the same wl_surface.commit that attaches this @@ -1504,7 +1506,8 @@ the delivery of wl_buffer.release events becomes undefined. A well behaved client should not rely on wl_buffer.release events in this case. Alternatively, a client could create multiple wl_buffer objects - from the same backing storage or use wp_linux_buffer_release. + from the same backing storage or use a protocol extension providing + per-commit release notifications. Destroying the wl_buffer after wl_buffer.release does not change the surface contents. Destroying the wl_buffer before wl_buffer.release @@ -1832,6 +1835,9 @@ x and y, combined with the new surface size define in which directions the surface's size changes. + The exact semantics of wl_surface.offset are role-specific. Refer to + the documentation of specific roles for more information. + Surface location offset is double-buffered state, see wl_surface.commit. @@ -1880,7 +1886,7 @@ - + A seat is a group of keyboards, pointer and touch devices. This object is published as a global during start up, or when such a @@ -1908,9 +1914,10 @@ - This is emitted whenever a seat gains or loses the pointer, - keyboard or touch capabilities. The argument is a capability - enum containing the complete set of capabilities this seat has. + This is sent on binding to the seat global or whenever a seat gains + or loses the pointer, keyboard or touch capabilities. + The argument is a capability enum containing the complete set of + capabilities this seat has. When the pointer capability is added, a client may create a wl_pointer object using the wl_seat.get_pointer request. This object @@ -1992,9 +1999,9 @@ The same seat names are used for all clients. Thus, the name can be shared across processes to refer to a specific wl_seat global. - The name event is sent after binding to the seat global. This event is - only sent once per seat object, and the name does not change over the - lifetime of the wl_seat global. + The name event is sent after binding to the seat global, and should be sent + before announcing capabilities. This event only sent once per seat object, + and the name does not change over the lifetime of the wl_seat global. Compositors may re-use the same seat name if the wl_seat global is destroyed and re-created later. @@ -2013,7 +2020,7 @@ - + The wl_pointer interface represents one or more input devices, such as mice, which control the pointer location and pointer_focus @@ -2426,7 +2433,7 @@ - + The wl_keyboard interface represents one or more keyboards associated with a seat. @@ -2479,6 +2486,9 @@ the surface argument and the keys currently logically down to the keys in the keys argument. The compositor must not send this event if the wl_keyboard already had an active surface immediately before this event. + + Clients should not use the list of pressed keys to emulate key-press + events. The order of keys in the list is unspecified. @@ -2505,9 +2515,18 @@ Describes the physical state of a key that produced the key event. + + Since version 10, the key can be in a "repeated" pseudo-state which + means the same as "pressed", but is used to signal repetition in the + key event. + + The key may only enter the repeated state after entering the pressed + state and before entering the released state. This event may be + generated multiple times while the key is down. + @@ -2530,6 +2549,11 @@ compositor must not send this event if state is pressed (resp. released) and the key was already logically down (resp. was not logically down) immediately before this event. + + Since version 10, compositors may send key events with the "repeated" + key state when a wl_keyboard.repeat_info event with a rate argument of + 0 has been received. This allows the compositor to take over the + responsibility of key repetition. @@ -2590,7 +2614,7 @@ - + The wl_touch interface represents a touchscreen associated with a seat. @@ -3245,4 +3269,31 @@ + + + This global fixes problems with other core-protocol interfaces that + cannot be fixed in these interfaces themselves. + + + + + + + + + This request destroys a wl_registry object. + + The client should no longer use the wl_registry after making this + request. + + The compositor will emit a wl_display.delete_id event with the object ID + of the registry and will no longer emit any events on the registry. The + client should re-use the object ID once it receives the + wl_display.delete_id event. + + + + + diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index f9397c859ca..7fcda34c57c 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -345,7 +345,7 @@ QWaylandInputDevice::Touch::~Touch() } QWaylandInputDevice::QWaylandInputDevice(QWaylandDisplay *display, int version, uint32_t id) - : QtWayland::wl_seat(display->wl_registry(), id, qMin(version, 9)) + : QtWayland::wl_seat(display->wl_registry(), id, qMin(version, 10)) , mQDisplay(display) , mDisplay(display->wl_display()) , mId(id) @@ -1377,7 +1377,19 @@ void QWaylandInputDevice::Keyboard::keyboard_key(uint32_t serial, uint32_t time, QString text = QXkbCommon::lookupString(mXkbState.get(), code); QEvent::Type type = isDown ? QEvent::KeyPress : QEvent::KeyRelease; - handleKey(time, type, qtkey, modifiers, code, sym, mNativeModifiers, text); + bool isAutoRepeat = state == WL_KEYBOARD_KEY_STATE_REPEATED; + if (isAutoRepeat && mRepeatRate > 0) { + qCWarning(lcQpaWayland, "received key repeat event while repeat rate is non-zero"); + return; + } + if (isAutoRepeat && !xkb_keymap_key_repeats(mXkbKeymap.get(), code)) { + qCWarning(lcQpaWayland, "received key repeat event for a key that should not be repeated"); + return; + } + if (isAutoRepeat) + handleKey(time, QEvent::KeyRelease, qtkey, modifiers, code, sym, mNativeModifiers, text, isAutoRepeat); + + handleKey(time, type, qtkey, modifiers, code, sym, mNativeModifiers, text, isAutoRepeat); if (state == WL_KEYBOARD_KEY_STATE_PRESSED && xkb_keymap_key_repeats(mXkbKeymap.get(), code) && mRepeatRate > 0) { mRepeatKey.key = qtkey; diff --git a/src/plugins/platforms/wayland/qwaylandvulkaninstance.cpp b/src/plugins/platforms/wayland/qwaylandvulkaninstance.cpp index 89f97f28f2c..619a5aa4839 100644 --- a/src/plugins/platforms/wayland/qwaylandvulkaninstance.cpp +++ b/src/plugins/platforms/wayland/qwaylandvulkaninstance.cpp @@ -1,8 +1,8 @@ // Copyright (C) 2019 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 -#include "qwaylandvulkaninstance_p.h" #include "qwaylandwindow_p.h" +#include "qwaylandvulkaninstance_p.h" #include "qwaylandscreen_p.h" #include "qwaylanddisplay_p.h"