Spawning window at mouse pointer using gtk4?

, ,

Since support for moving windows was removed in gtk4, I guess there is no way to spawn a window at the mouse pointer anymore, right?

Background:
I wrote an application that scans the currently selected text and displays a window at the current mouse position showing a dictionary definition of that word. It is important that the shown text is selectable to allow for recursive lookups.
The lack of support for moving windows and a slow startup time were the reasons why I had to choose gtk3.

You can position popovers: Gtk.Popover.set_pointing_to

You cannot position top levels: those are under the control of the display server (or window manager, on X11), and of the user.

GTK3 vs GTK4 does not matter at all: positioning toplevels with GTK3 only works on X11, even if the API looks generic. That’s why the API was removed in GTK4.

Hmm, okay that’s unfortunate, but thank you.
I suppose it isn’t possible for an application to consist entirely of a popover which contains a scrollable text view and reacts to keyboard shortcuts.

Not without the help of the compositor, no, as it would be incredibly easy otherwise to make an overlay that covered the password entry in another application and stole your credentials. What you’re writing looks like a system or a privileged component.

Okay, makes sense. Then I’m stuck with X11 I suppose. Thanks for replying.

I’ll leave a link in case anyone is interested, but it’s Japanese only GitHub - GenjiFujimoto/dictpopup: Looks up selected (Japanese) text in your Yomichan dictionaries and displays the result as a popup.

That looks like an input method, and you should probably look into that particular stack, since it’s handled by the compositor for you.

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