zwp_text_input_v3 implementation in Gtk3/4 does not emit set_cursor_rectangle when upon initial focus in
Both gtk3 and gtk4 implementations have similar issues, tested with gtk{3,4}-demo-application, or gedit.
Run WAYLAND_DEBUG=1 gtk4-demo-application 2>&1 | grep text_input
, and click in the text box, obviously there's no set_cursor_rectangle.
Tested under GNOME shell and kwin and same behavior is observed.
[ 153345.052] wl_registry@2.global(23, "zwp_text_input_manager_v3", 1)
[ 153393.191] wl_registry@31.global(23, "zwp_text_input_manager_v3", 1)
[ 154972.454] wl_registry@32.global(23, "zwp_text_input_manager_v3", 1)
[ 155034.258] wl_registry@39.global(23, "zwp_text_input_manager_v3", 1)
[ 155034.261] -> wl_registry@39.bind(23, "zwp_text_input_manager_v3", 1, new id [unknown]@34)
[ 155034.265] -> zwp_text_input_manager_v3@34.get_text_input(new id zwp_text_input_v3@41, wl_seat@21)
[ 155057.630] zwp_text_input_v3@41.enter(wl_surface@30)
[ 156381.636] zwp_text_input_v3@41.leave(wl_surface@30)
[ 156734.556] zwp_text_input_v3@41.enter(wl_surface@30)
[ 158050.306] -> zwp_text_input_v3@41.enable()
[ 158050.373] -> zwp_text_input_v3@41.set_surrounding_text("", 0, 0)
[ 158050.389] -> zwp_text_input_v3@41.set_text_change_cause(0)
[ 158050.398] -> zwp_text_input_v3@41.commit()
[ 158050.410] -> zwp_text_input_v3@41.commit()
[ 158055.937] zwp_text_input_v3@41.done(2)
Cursor rectangle is expected to be sent upon the initial focus-in event, otherwise the initial position of input method popup could be wrong.
The cause of this is:
- gtk's text-input has strict check on done serial, if done is not acked from client, it refuse to send a new state. IMHO, this is wrong and not required by the protocol.
- Even consider that, the current implementation looks like
g_signal_emit_by_name (global->current, "retrieve-surrounding", &result);
notify_content_type (context_wayland);
notify_cursor_location (context_wayland);
The retrieve-surrounding signal would initiate the request looks like:
[ 936772.981] -> zwp_text_input_v3@36.set_surrounding_text("", 0, 0)
[ 936772.990] -> zwp_text_input_v3@36.set_text_change_cause(0)
[ 936772.993] -> zwp_text_input_v3@36.commit()
which basically always increases the done serial. It makes the following code never send any state because there's no way that done() is received at this point.
Ideally, there should be only one commit state at the end of enable() callback.