Get any/all text input boxes on screen, and present a floating box for AI grammer checking

I am currently working on a plugin that works as an extension for some applications, like Thunderbird, but only works within the application itself.

In Windows, Grammarly has an application that sits in the sys-tray, and anytime you click on a window that has text input, which could be Word or Teams, it can show the Grammarly options overlayed the window within the area of the text input. I can figure out how to do that in Windows, but I am trying to achieve something similar in Gnome with Wayland, which will add a layer of problems. Can anyone point me in the right direction?

I don’t see how Wayland has much to do with this, but I doubt it’s possible in the way you’re thinking.

Even if an application were GTK, I don’t know of a way for the compositor process to “introspect” what’s happening inside the application process. Entries aren’t necessary GtkEntry (or implementations of GtkEditable), and the application itself could be GTK, Qt/KDE, or even a foreign executable being run through e.g. Wine.

You could probably do this for widgets that are a part of GNOME Shell, although that would be considerably less useful I expect. In principle, you could “snoop” all text input and try to infer where it was going based on the focused window, but that sounds fragile.

There are extensions like Screen word translate and Light Dict which look they operate on the secondary clipboard selection, but that requires the text to be selected and the user to have that feature enabled (usually true).

EDIT: sorry, I saw the extensions tag and assumed you were referring to a shell extension; my advice might not apply.

I know Wayland is isolating applications and making it harder to perform screen capturing and keyboard logging, so I assumed it would add a layer to the mix. I had an idea of creating a “transparent” virtual keyboard that would engage when the user started inputting text, maybe via i-dbus or something, but the overlay would still be challenging without the right approach.

1 Like

Sure, I mean part of what Wayland is intended to do is isolated applications from each other, I’m just not sure X11 had features for snooping arbitrary widget events either.

But I think I did misread your question, and assumed you were speaking from the compositor’s perspective. From a GNOME Shell extension, you could operate on the secondary selection (i.e. middle-click copy/paste), but I’m not sure that’s as a good an experience as you might want. Reading all text input, associating it with a window, and operating on it some cache is probably possible too, but obviously a little awkward.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.