Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-06-23 08:38:43 +0300
committerCampbell Barton <campbell@blender.org>2022-06-23 08:38:43 +0300
commitd20bad914e310f93f53dba4decf6e1e534a08345 (patch)
treed89a6bf1879a6afd550461d3b96f6967e39719aa /intern
parente4f51b3a6eb69bf71e997b11e33a2baabbf0fdfe (diff)
Fix key repeat continuing after a window loses focus for GHOST/Wayland
Also remove NULL checks in keyboard enter/leave handlers, as they didn't serve any purpose.
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index a5359b8dd28..2adbca7ee40 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -47,6 +47,8 @@
static GHOST_WindowWayland *window_from_surface(struct wl_surface *surface);
+static void keyboard_handle_key_repeat_cancel(struct input_t *input);
+
/**
* GNOME (mutter 42.2 had a bug with confine not respecting scale - Hi-DPI), See: T98793.
* Even though this has been fixed, at time of writing it's not yet in a release.
@@ -365,9 +367,7 @@ static void display_destroy(display_t *d)
}
if (input->wl_keyboard) {
if (input->key_repeat.timer) {
- delete static_cast<key_repeat_payload_t *>(input->key_repeat.timer->getUserData());
- input->system->removeTimer(input->key_repeat.timer);
- input->key_repeat.timer = nullptr;
+ keyboard_handle_key_repeat_cancel(input);
}
wl_keyboard_destroy(input->wl_keyboard);
}
@@ -1699,9 +1699,8 @@ static void keyboard_handle_enter(void *data,
struct wl_surface *surface,
struct wl_array * /*keys*/)
{
- if (surface != nullptr) {
- static_cast<input_t *>(data)->focus_keyboard = surface;
- }
+ input_t *input = static_cast<input_t *>(data);
+ input->focus_keyboard = surface;
}
/**
@@ -1713,10 +1712,14 @@ static void keyboard_handle_enter(void *data,
static void keyboard_handle_leave(void *data,
struct wl_keyboard * /*wl_keyboard*/,
uint32_t /*serial*/,
- struct wl_surface *surface)
+ struct wl_surface * /*surface*/)
{
- if (surface != nullptr) {
- static_cast<input_t *>(data)->focus_keyboard = nullptr;
+ input_t *input = static_cast<input_t *>(data);
+ input->focus_keyboard = nullptr;
+
+ /* Losing focus must stop repeating text. */
+ if (input->key_repeat.timer) {
+ keyboard_handle_key_repeat_cancel(input);
}
}
@@ -1746,6 +1749,14 @@ static xkb_keysym_t xkb_state_key_get_one_sym_without_modifiers(struct xkb_state
return sym;
}
+static void keyboard_handle_key_repeat_cancel(input_t *input)
+{
+ GHOST_ASSERT(input->key_repeat.timer != nullptr, "Caller much check for timer");
+ delete static_cast<key_repeat_payload_t *>(input->key_repeat.timer->getUserData());
+ input->system->removeTimer(input->key_repeat.timer);
+ input->key_repeat.timer = nullptr;
+}
+
/**
* Restart the key-repeat timer.
* \param use_delay: When false, use the interval