wayland/text-input: Reset surrounding text values by focus change
For zwp_text_input_v3_set_surrounding_text(), the protocol specifies:
"If the client is unaware of the text around the cursor, it should
not issue this request, to signify lack of support to the compositor."
Mutter currently doesn't clear its stored surrounding text when the
input focus changes, re-using the existing text for the newly focused
client. This already seems problematic, but since clients aren't
supposed to set surrounding text to NULL or an empty string if they
don't have one (and instead should simply avoid calling
`set_surrounding_text()`), this is clearly a bug in Mutter.
Fix it by unsetting the stored surrounding text when removing input
focus from a client.
Fixes: 33088d59db
("wayland/text-input: Pass char based offset to ClutterInputFocus")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3604>
This commit is contained in:

committed by
Marge Bot

parent
a516090014
commit
fb86d5d5b0
@ -418,6 +418,13 @@ meta_wayland_text_input_set_focus (MetaWaylandTextInput *text_input,
|
||||
|
||||
wl_list_remove (&text_input->surface_listener.link);
|
||||
text_input->surface = NULL;
|
||||
/* Wayland set_surrounding_text() does not support to set null string
|
||||
* for applications with the non-supported surrounding text feature
|
||||
* and reset the values here with focus changes.
|
||||
*/
|
||||
g_clear_pointer (&text_input->surrounding.text, g_free);
|
||||
text_input->surrounding.cursor = 0;
|
||||
text_input->surrounding.anchor = 0;
|
||||
}
|
||||
|
||||
if (surface && surface->resource)
|
||||
|
Reference in New Issue
Block a user