1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Sun, 31 May 2026 11:23:06 +0200
Subject: [PATCH] wayland: Only schedule a single cursor location update
If the cursor is updated multiple times before the state is applied
on the surface, the newer signal handled would overwrite the ID of
the previous.
We can coalesce these calls and keep just the last value with the
already existing signal handler, add a check to make sure we don't
add a second signal handler if there's one pending already.
Fixes (harmless) warnings like:
clutter_input_focus_set_cursor_location: assertion 'CLUTTER_IS_INPUT_FOCUS (focus)' failed
When a second handler would stumble upon already cleared data.
Easily reproducible when a VTE widget has the IM focus, but there
may be other cases.
Closes: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/5096
---
src/wayland/meta-wayland-text-input.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c
index ae8abf45e040..22c6c42ede62 100644
--- a/src/wayland/meta-wayland-text-input.c
+++ b/src/wayland/meta-wayland-text-input.c
@@ -833,8 +833,11 @@ update_cursor_location (MetaWaylandSurface *surface,
{
MetaWaylandTextInput *text_input = user_data;
- clutter_input_focus_set_cursor_location (text_input->cursor_update.focus,
- &text_input->cursor_update.rect);
+ if (clutter_input_focus_is_focused (text_input->cursor_update.focus))
+ {
+ clutter_input_focus_set_cursor_location (text_input->cursor_update.focus,
+ &text_input->cursor_update.rect);
+ }
g_clear_object (&text_input->cursor_update.focus);
graphene_rect_init (&text_input->cursor_update.rect, 0, 0, 0, 0);
@@ -938,10 +941,13 @@ text_input_commit_state (struct wl_client *client,
graphene_rect_init (&text_input->cursor_update.rect,
x1, y1, x2 - x1, y2 - y1);
- text_input->cursor_update.signal_id =
- g_signal_connect (text_input->surface, "pre-state-applied",
- G_CALLBACK (update_cursor_location),
- text_input);
+ if (text_input->cursor_update.signal_id == 0)
+ {
+ text_input->cursor_update.signal_id =
+ g_signal_connect (text_input->surface, "pre-state-applied",
+ G_CALLBACK (update_cursor_location),
+ text_input);
+ }
}
if (text_input->pending_state & META_WAYLAND_PENDING_STATE_ACTIONS)
|