GaijinEntertainment / DagorEngine

Dagor Engine and Tools source code from Gaijin Games KFT
Other
2.14k stars 267 forks source link

Mouse pointer is not grabbed properly in Linux, causes mouse issues in Wayland #64

Open flasheeprom opened 1 month ago

flasheeprom commented 1 month ago

https://github.com/GaijinEntertainment/DagorEngine/blob/6221a23ace14a8d1af7ba6896fb15d8f52580cd2/prog/engine/drv/hid_mouse/linux_ms_api.cpp#L95

This seems to work for X11, but under Wayland this doesn't properly capture the mouse pointer. In multi-display use, the mouse can leave the game window and causes all sorts of issues.

I'm not too familiar with X11 and Wayland, but I suspect that using XGrabPointer and XUngrabPointer instead should fix the issue in Wayland, as Wayland has a compatibility layer to X11's API.

XGrabPointer has a confine_to parameter where the window the cursor should be confined to can be specified.

https://github.com/GaijinEntertainment/DagorEngine/blob/6221a23ace14a8d1af7ba6896fb15d8f52580cd2/prog/engine/drv/hid_mouse/linux_ms_api.cpp#L98

I suspect this should be implemented and call XUngrabPointer.