Keep the wheel's focus until the pointer leaves a dead zone, and draw a pointer of our own

After the scroll wheel, the keys or the pad move the focus in a menu, the pointer takes it back only once it has
moved 6 layout units from where it was then (menu_cursor_poll), so a hand resting on the mouse no longer undoes a
scroll. While the cursor is not captured, the game window shows a gold arrowhead drawn at the window's DPI
(cursor_art.c) instead of the Windows arrow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
itaskaev2andClaude Opus 5.5 committed 2026-11-11 09:44:01 +01:00
1 parent a10c546a06
commit c0ca89fdda
5 files changed
+168 -4

No files matched your search

+18
View File
@@ -200,8 +200,26 @@ void ikb_menu_closed(void) {
if (o & CUR_ESC) plat_cas32(&cur_rel, 0, o);
}
// The pointer over the window while the cursor is not captured (cursor_art.c), sized by the window's display scale.
// The default arrow stays when SDL refuses it.
static void art_cursor(SDL_Window *w) {
float scale = SDL_GetWindowDisplayScale(w);
int size = (int)lrintf(32 * (scale > 0 ? scale : 1)), hot;
size = size < 32 ? 32 : size > 128 ? 128 : size;
SDL_Surface *s = SDL_CreateSurface(size, size, SDL_PIXELFORMAT_ARGB8888);
if (!s) return;
if (s->pitch == size * 4) {
cursor_art(s->pixels, size, &hot);
SDL_Cursor *c = SDL_CreateColorCursor(s, hot, hot);
if (c) SDL_SetCursor(c);
else rt_log("input: the pointer's image failed (%s); the arrow stays", SDL_GetError());
}
SDL_DestroySurface(s);
}
void input_sdl_window(SDL_Window *w) {
win = w;
art_cursor(w);
wake_event = SDL_RegisterEvents(1);
plat_xchg32(&focused, (SDL_GetWindowFlags(w) & SDL_WINDOW_INPUT_FOCUS) != 0);
__atomic_store_n(&ptr_have, 0, __ATOMIC_RELEASE); // the pointer's place is unknown until it enters or moves