Insert menu: free the mouse while it's open, and make the menu clickable #946
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
No milestone
No assignees
1 participant
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!946
Loading…
Reference in a new issue
No description provided.
Delete branch "menu-mouse"
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?
What and why
While the in-game menu (Insert / F1) is open, the mouse stayed in the game's capture: hidden, relative, and still turning the camera. The menu could only be used with the keyboard or a gamepad.
With this change the mouse is released while the menu is open, and the menu can be used with it. When the menu closes, the capture goes back to what it was before (captured for mouse camera, or free if it was free).
The change
Mouse release (host/display.c on Windows, host/posix/display_sdl.c on Linux)
WM_APP + 8, the same channel the Fullscreen row already uses withWM_APP + 7).hos_mouse_takereports the mouse as not captured, andnn_hid.calready ignores keys and mouse buttons while the menu is open.Clicks (gpu/vk/vk_menu.cpp, new gpu/vk/vk_menu_hit.h)
MkwVkHost.pointer, gives the renderer the free mouse: the cursor position in window pixels and the window's pixel size, the buttons held, the presses since the last read and the wheel notches.MKWVK_API_VERSIONis bumped to 5.vk_menu_hit.hholds the layout constantspaint_menunow draws with and a pure hit-test, so the picture and the hit areas can't drift apart.[Q / LB]/[E / RB]hints get a lighter highlight. A cursor resting over the menu when it opens does not move the keyboard selection.[Q / LB]or[E / RB]goes to the previous or next tab.<side) steps it down. The right half (the>side) steps it up.set_rowfunction that both use.SDL wrapper (host/hos_sdl.c/.h): mouse button up, wheel and enter events, the button and position on button events, the absolute position on motion events (SDL3 and SDL2 layouts), and
SDL_GetWindowSize.Tests
New
tests/test_menu_hit.py(registered intests/run_all.pywith--cxx g++). It compilestests/test_menu_hit.cppand checks the hit-test:It also checks the sources: the menu hit-tests with the shared layout, posts open/close to the window, and both window procedures release the mouse, give it back and don't capture on a click while the menu is open.
python -I -B tests/run_all.py: 106 passed, 0 failed, 6 skipped (Linux).Linux build (SDL3, Wayland): the game and
hookshot_vk.sobuild with this change, and the ABI check passes (no undefinedmkwvksymbols). The game started and presented normally at 60 fps.A live mouse run (a headless compositor output, with clicks injected through the compositor's seat cursor) did not reach the menu. The injected keypress never opened the menu, and a later run was cut short. Since then it has been tried by hand on Linux (SDL3, Wayland) with a real mouse, in the merged build with the Cheats pages: the cursor appears when the menu opens, and hover, clicks, the sliders, the wheel and the capture coming back on close all work.
Not tested
Notes
MkwVkHost(#926 also bumpsMKWVK_API_VERSIONto 5). Whichever lands second needs a trivial rebase there and anotherMKWVK_API_VERSIONbump.Thanks! This is a draft that hasn't been tried with a real mouse yet. Closing to keep the queue clear; please reopen once it has had that test.
Reopened: this has now had the live test with a real mouse on Linux (hover, clicks, sliders, wheel, and the capture returning on close all work), and it's up to date with main. Windows still needs a try; the Win32 side is described under Not tested.