4

How does one go about finding the absolute mouse cursor position in wayland (Not X11). For example in windows we use the GetCursorPos() function from windows.h and that will give absolute X,Y positions starting from 0,0.

I'm aware of /dev/input/mice however that is relative and not absolute. The closest thing I came across was setting them, but not getting them.

DatGuy
  • 41
  • 2

2 Answers2

1

In Wayland, you need to implement this for each compositor separately (if the compositor implements it at all). The Wayland protocol itself does not provide such feature.

There are also external tools/libraries that should be able to expose such functionality: Wayland Global Pointer Location

Raf
  • 131
  • 3
1

In KDE you can just run a kwin script:

print("Mouse position x=" + workspace.cursorPos.x + " y=" + workspace.cursorPos.y)

You can run a kwin scripts from the command line. And then use the output of the kwin script in your application.

Ashark
  • 643
  • 7
  • 16