Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
flasheeprom opened this issue May 25, 2024 · 1 comment

Comments

@flasheeprom
Copy link

flasheeprom commented May 25, 2024

XSetInputFocus(display, *window, RevertToParent, CurrentTime);

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.

  • Camera control is lost
  • Clicking while cursor is off-window minimizes WT and sets focus to whatever was under the mouse pointer

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.

void mouse_api_UnclipCursor() {}

I suspect this should be implemented and call XUngrabPointer.

@apemax
Copy link

apemax commented Jul 23, 2024

Unfortunately I don't think this would solve the issue. On both X11 and Wayland WT does not grab the cursor, The difference between X11 and Wayland is the cursor is not being warped back to the center of the window on Wayland, Where as it is on X11.

Also I don't think XGrabPointer works with XWayland anyway.

It does seem like there might be a way to fix this however, SDL and Blender had the same issue:

libsdl-org/SDL#9539

Looking into the fix Blender implemented to fix it:

https://archive.blender.org/developer/D2898

It looks like they use the XFixesHideCursor function from the XFixes X11 Extension, More information on this here:

https://metacpan.org/pod/X11::Protocol::Ext::XFIXES

Hopefully this can be looked into at some point. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants