Locking mouse cursor to specific window

Say I have a specific GtkWindow, is there an API to lock the cursor so that it will never leave that window? Or perhaps to query the cursor position and fix it if it passes the window boundaries?

GTK has no API for this.

On X11, you want to look at the pointer warping API.

On Wayland, you want to read this topic.

Ok, I use X11, so I guess you mean calling XQueryPointer followed by XWarpPointer.
About that-

  1. Can I detect whenever the mouse left the window using gtk’s signal system?
  2. Should I call XSync after XWarpPointer, or should I let the gtk’s render phase do that?

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