Lea-fish / Leafish

A minecraft-like multi version client implemented in Rust.
Apache License 2.0
824 stars 46 forks source link

Due to the changing of cursor grabbing code window crashes upon entering the game on x11 and possibly windows #265

Closed RecentRunner closed 8 months ago

RecentRunner commented 1 year ago

So I could successfully run Leafish on Wayland but it would crash immediately upon running in X11.

I deduced it was because of the line which is used a couple times in the code

window.set_cursor_grab(winit::window::CursorGrabMode::Locked).unwrap();

so the same as the stevenarella issue https://github.com/iceiix/stevenarella/issues/714 which we inadvertently recreated in our fork with the pull request https://github.com/Lea-fish/Leafish/pull/262

So to quickly summarize, whenever the line above runs on an x11 system the game crashes. This is because CursorGrabMode::Locked is not implemented for x11 and Windows but is for Wayland and MacOS. The X11 and Windows equivalent of the statement seems to be CursorGrabMode::Confined.

So the solution is relatively simple, we just need an if statement where if the user is running on either MacOS or Wayland we use CursorGrabMode::Locked otherwise we use CursorGrabMode::Confined. This is exactly how infernaa fixed the issue in https://github.com/iceiix/stevenarella/issues/714

further detail on both the enums are below

https://docs.rs/winit/latest/winit/window/enum.CursorGrabMode.html

skillman623 commented 1 year ago

I've got this. I should have the patch submitted today or tomorrow.

skillman623 commented 1 year ago

Winit needs to be updated to the latest version to support the required patch. See #266

terrarier2111 commented 8 months ago

Fixed by https://github.com/Lea-fish/Leafish/pull/268 and https://github.com/Lea-fish/Leafish/pull/318