fix(linux): the cursor over the game's window hides while a controller or the keys are used, as on Windows #2440
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2440
Loading…
Reference in a new issue
No description provided.
Delete branch "jabbaxipil/Longshot:fix/linux-cursor-hide"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On Linux the mouse cursor stayed over the game while you played with a controller, in the middle of the picture, until the mouse moved (#892: Bazzite, KDE Wayland). On Windows it hides once the pads or the keys are used and comes back when the mouse is (
host/display.c,gm_cursor_shown). The Linux window (host/posix/display_sdl.c) hid it only while the mouse was captured for the camera.The SDL window now keeps the Windows rule: hidden once
hos_player_input_ns(nn_hid.c: a pad button, a stick past a third, a bound key) is newer than the mouse's last use; shown again by a move of more than 4 units from the last point one counted at, or by a button. The first move after the window changes size only sets that point (SDL can report a cursor at rest at a new point after F11). The Insert menu shows it, for its clicks, and so does losing the focus.host/hos_sdl.cgainshos_sdl_cursor: SDL3'sSDL_ShowCursor/SDL_HideCursor, SDL2'sSDL_ShowCursor(1 or 0), both looked up as optional.To see it on main: on Linux, start the game in a window, put the mouse over it and play with a controller: the cursor stays.
Read first: the block above
keys_update()inhost/posix/display_sdl.c, thenhos_sdl_cursorinhost/hos_sdl.c.See #892 (its Linux report; the idle timer proposed there is not part of this, and Windows has none either).
Testing
Tested: Ubuntu 26.04.1 (Linux 7.0.0-44), GNOME Wayland, RTX 4070 (NVIDIA 615.71.09), Ryzen 7 5800X3D; a build of
9411a6c4(on main @8aa5ab87), in a 1600x900 window, SDL3 (the log'ssdl: SDL3), a GameSir G7 Pro controller (Xbox layout), adult Link in Hyrule Field.python3 -I -B tests/test_cursor_hidden_linux.py(new): passed before the latest changes. It runs the rule cut fromdisplay_sdl.c(shown at start, hidden by a pad, 4 units of slack from the last counted point, the point after a resize, the Insert menu, the focus, SDL asked only on a change) and reads the event loop's lines and the SDL3/SDL2 calls. With main's sources it stops withsrccut: ... is not in host/posix/display_sdl.c; it also fails on seven broken versions of the change (no slack, no focus or menu condition, no reset on resize, SDL asked every loop, the point not moved, the SDL2 call changed).tests/test_display_pointer.pycompiles the SDL window's click handler: its stand-ins gaingm_mouse_used(); passes with clang++ and g++. This and the new test also passed at5437658d.python3 -I -B tests/run_all.py --strict --jobs 8(whatmise run testruns),5437658dand main @8aa5ab87in the same sitting: 841 passed / 121 failed / 18 skipped here, 840 / 121 / 18 on main, the same 121 failing. 104 of them are--strictrefusing for test tools this PC lacks; the others fail on main too (among themtest_menu_text_field,test_crt_options,test_vibration_menu,test_dev_packs,test_pipeline_share).Still to test:
libSDL2-2.0.so.0without a system SDL3) on X11 or Wayland: the same three steps, expecting the same (by hand).host/hos_sdl.cis compiled there too and gains plain C only (hos_sdl_cursor, two optional lookups); nothing on Windows calls it. There is no Windows compiler on this PC (CI, or by hand).Measurements
Nothing to measure: one comparison and, on a change, one SDL call per pass of the window loop; no rendering change.
Risks
A player who uses the mouse only by clicking, without moving it, sees the cursor come back at the click (as on Windows). Where SDL has no cursor calls (none known), nothing changes. A revert is enough; nothing changes in saves, options or caches.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Ubuntu 26.04.1 GNOME Wayland, RTX 4070 (NVIDIA 615.71.09), SDL3, a build of 9411a6c4 in a 1600x900 window, adult Link in Hyrule Field, a GameSir G7 Pro controller: with the mouse over the window and no click, a controller button hid the cursor, a small nudge left it hidden, a real move brought it back. The run ended cleanly (no crash or device lost).
@review
Recommendation: Request changes. The first mouse movement can be discarded after controller input, leaving the cursor hidden when the player tries to use it. The new test also hard-codes GCC instead of using the configured compiler.
The change hides the Linux cursor after controller or bound-key input and restores it for mouse use, the Insert menu, or loss of focus. It keeps the visibility logic small, but its initial mouse position is not established until a motion event arrives.
Blocking (1): must change before merging.
host/posix/display_sdl.c:110: The first real mouse movement is discarded if no motion event has established the initial point. (more on the line) Do: Establish the initial point from the current SDL mouse position when the window is created, and add a test that hides the cursor before the first motion event.Should fix (1): not blocking, but worth doing before merging.
tests/test_cursor_hidden_linux.py:22: The test runner is forced to use gcc instead of its configured C compiler. (more on the line) Do: Declare the runner's {cc} placeholder and use the configured compiler for direct invocation as well.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1 and L2.Checks: Still running: 9 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes, for the reported controller case on the tested SDL3 setup: the author observed the cursor hide on controller input and return on a real mouse move. SDL2 and the reporter's KDE Wayland setup remain untested.
Other systems: The new SDL adapter is compiled on Windows but called by the Linux window only. SDL2, KDE Wayland, and Steam Deck game mode can follow different cursor and input paths and have no reported game run; the SDL3 GNOME Wayland run is positive. The input timestamp is read through the existing interlocked accessor.
Switches: None.
Reviewed:
5437658d73against8aa5ab876d: Read the diff, commit, repository rules and PR template, changed cursor code and test, and the surrounding SDL event loop, input timestamp, capture, and test-runner paths. Skimmed the remainder of the large SDL adapter, pointer fixture, and standards; docs/review-checklist.md and the adjacent Tooling checkout were absent. No generated files or recorded runs were changed.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run, as requested. The author reports an SDL3 game run and game-free test results; CI is still running.
Overlaps and merge order: Not determined from the supplied checkout and PR data.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -92,0 +107,4 @@}/* a move to (x, y): from the last point a move counted at, any other point while shown, more than 4 units away while hidden */static void gm_mouse_moved(float x, float y) {if (gm_rebase) {L1 (blocking): The first real mouse movement is discarded if no motion event has established the initial point.
When: Start with the pointer already over the window, use a controller before moving the mouse, then move the mouse: the controller hides the cursor, but gm_rebase causes that first movement to return without showing it. The player must move it again.
Do: Establish the initial point from the current SDL mouse position when the window is created, and add a test that hides the cursor before the first motion event.
@ -0,0 +19,4 @@sys.path.insert(0, str(Path(__file__).resolve().parent)) # (tests/srccut.py: python -I leaves this folder off the path)from srccut import between, block # noqa: E402RUN_ALL_ARGS = ["--cc", "gcc"]L2 (should fix): The test runner is forced to use gcc instead of its configured C compiler.
When: On a supported machine with Clang configured through CC but no gcc on PATH, run_all skips this test, or fails it in strict mode, even though a usable compiler is available.
Do: Declare the runner's {cc} placeholder and use the configured compiler for direct invocation as well.
@fix
5437658d7391462d1a28Recommendation: Approve. The code is ready: only testing is left. The reported SDL3 game run shows the cursor behavior working on GNOME Wayland. The SDL2, KDE Wayland and Steam Deck game-mode runs remain outstanding. Recommend approval; not approved on the forge.
What
@fixchangedI changed this pull request: the new head is
91462d1a28. I rebased it ontomain(c7cb5eab38). I edited its description to match the change.Changed
Nothing was built or run: the checks run again on the new head.
The change hides the Linux game-window cursor during controller or keyboard play and restores it on mouse use. The follow-up initializes the mouse position before the event loop and lets the test use the configured C compiler.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
Checks: they run again on this head; a failure shows on the pull request.
Also noticed (3; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes: the reported SDL3 game run hid the cursor on controller input and restored it on a real mouse move. The latest initialization change has not been reported tested in game.
Other systems: SDL2 and SDL3 use different cursor calls; only SDL3 has a reported game run. KDE Wayland and Steam Deck game mode remain untested. Windows compiles the SDL wrapper but does not call the new cursor function; its build is awaiting CI or a manual run.
Switches: None.
Reviewed:
91462d1a28againstc7cb5eab38: Read AGENTS.md, CONTRIBUTING.md, the fix diff, the cursor change diff, and tests/test_cursor_hidden_linux.py. Read the relevant display loop, SDL mouse-position wrapper and test-runner references. The supplied base-to-HEAD diff contains 1,492 files and was not read in full; it includes many commits beyond the described five-file pull request. The pull request template and remaining changed files were not read in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build or run project code were executed. The description reports an SDL3 game run and earlier game-free test results; CI has not yet run on the latest head.
Overlaps and merge order: Not checked.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, after its fix. Nothing was run; a maintainer decides.