gtkimcontextwayland: Refactor handling of client updates
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 17 Aug 2022 22:58:38 +0000 (00:58 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 18 Aug 2022 17:19:53 +0000 (19:19 +0200)
commitf66ffde68d7bd22b77b588671776020296392a6b
tree5eb990c16ee48bc4be5b7507ae1659f425d64ce0
parent52ac71b9727b9a63773865309a970c4d97c0a75d
gtkimcontextwayland: Refactor handling of client updates

Currently, the wayland IM context sends zwp_text_input_v3.commit from
a number of places, and some of them with partial data. In order to
make client state updates "atomic" and complete, make the communication
happen over an unified notify_im_change() function that happens on
a narrower set of circumstances:

  - The GtkIMContext is reset
  - The GtkIMContext is just focused
  - The gesture to invoke the OSK is triggered
  - The IM context is reacting to changes coming from the compositor

Notably, setting the cursor location or the surrounding text do not try
to commit state on their own, and now will be flushed with the corresponding
IM update or reset. But also, these requests won't be prevented from
happening individually on serial mismatch, instead it will be the whole
state commit which is held off.

With these changes in place, all client-side updates are notified
atomically to the compositor under a single .commit request.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5106
Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5105
gtk/gtkimcontextwayland.c