How does Squeekboard pop up when needed?

Hi everyone,
I am trying to understand Squeekboard because I want to implement gesture typing the next couple of months. I’d like to write my own little simplified keyboard application to experiment with it but I can’t get it to pop up only when needed and forward input to other applications.
If I understand correctly the wayland protocols input-method-unstable-v2, text-input-unstable-v3 and virtual-keyboard-unstable-v1 are used for this functionality. I don’t understand how/where the keyboard communicates with wayland though. I assume the keyboard is talking with phoc/phosh when it is running on a Librem 5 but I don’t know how to use a wayland protocol with gtk

If you are interested in working to add a feature to squeekboard. I would recommend you to open a ticket about this new feature here: https://source.puri.sm/Librem5/squeekboard/issues

But before check if there is already a similar ticket about the same or a similar feature, to avoid duplication.

And ask for extra information and feedback there.

I would suggest starting by looking at the virtboard code: https://source.puri.sm/Librem5/virtboard

The communication happens basically via libwayland, using not much more than bare C calls. For GTK, it loos like this: https://source.puri.sm/Librem5/squeekboard/-/blob/master/src/server-main.c#L175

You can always join the #wayland channel on Freenode IRC, people are friendly and helpful there.