You are not logged in.

#1 2026-02-06 20:48:03

PGComai
Member
Registered: 2026-02-06
Posts: 1

How to check if any application is currently grabbing the cursor? X11

X11 and KDE Plasma

I'll start by stating my end goal. I stream using an overlay build in Godot, which handles screen capture but does not capture (record) the cursor. To remedy this, I track the cursor position and place my own cursor there in-engine. This works until the cursor is grabbed, as in the way an fps game will grab and hide your cursor. Godot detects the location of the cursor as being in the center (roughly) of whichever window has grabbed it, but it cannot detect whether or not the cursor is in the grabbed state. I want to do this so I can hide my fake cursor in accordance with the real one.

Things I have tried so far:

  • Using Godot's OS.execute() and OS.execute_with_pipe() functions to run stuff like

    xdotool key "XF86LogGrabInfo"

    and then

    cat /var/log/Xorg.0.log

    to no avail. Godot does not seem to be able to read certain directories in /var, including /var/log. I am able to read hardware temps in /sys through the same method.

  • Running a script through cron that copies the Xorg.0.log file somewhere Godot can read it, but I need to be checking for grabs more often than that allows, and I haven't even confirmed that I can get the info I need from that log file.

  • Using xprop to examine window properties. There doesn't seem to be a property that changes according to whether or not my cursor is grabbed.

I have asked the Godot forum here but it seems like the solution is more likely to exist outside Godot.

I would appreciate any advice.

Offline

#2 2026-02-06 21:39:01

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,821

Re: How to check if any application is currently grabbing the cursor? X11

You seems to be more interested in the cursor shape than the grabbing state?
https://stackoverflow.com/questions/179 … rsor-image

Offline

#3 2026-09-15 12:53:46

Ruhanilinks
Member
Registered: 2026-09-11
Posts: 6

Re: How to check if any application is currently grabbing the cursor? X11

Since you're on X11, I wonder if querying the X server directly would be more reliable than trying to inspect Xorg.0.log. A cursor grab is an X11 server state, so the log isn't really the best place to detect it in real time.

You could look into using Xlib/XCB calls such as `XQueryPointer` and the active pointer/keyboard grab functions rather than going through `xdotool` and shell commands. If you're comfortable with a small helper program, that might also avoid the permission and process-spawning issues you're seeing from Godot.

It would be interesting to know whether the FPS game is using an actual X11 pointer grab or simply hiding/re-centering the cursor, since that could affect which approach works.

Offline

#4 Yesterday 08:22:38

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,407

Re: How to check if any application is currently grabbing the cursor? X11

Unfortunately OP hasn't visited the forum since starting this thread.
Please check the rules on necro-bumping

Moderator Note
Closing this thread.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

Board footer

Powered by FluxBB