rvaiya / warpd

A modal keyboard-driven virtual pointer
MIT License
2.85k stars 126 forks source link

bug: activation in windows on non-primary screen fails assertion for scr #279

Open Aeyk opened 6 months ago

Aeyk commented 6 months ago

To reproduce: start warpd.exe, mouse over to non-primary screen, activate warpd

Microsoft Visual C++ Runtime Library
Assertion failed!
Program:
File: src\platform\windows\windows.c
Line: 345
Expression: scr
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts
(Press Retry to debug the application - JIT must be enabled)

https://github.com/rvaiya/warpd/issues/117#issuecomment-1541522280 https://github.com/rvaiya/warpd/issues/117#issuecomment-1868073101

Ill try to take a stab at it and update the issue with what I find in the likely case I am unsuccessful, maybe my notes will help another contributor.

Aeyk commented 6 months ago

Speculative: what it seems like is happening, is that GetCursorPos will return coordinates larger than the bounding box defined in wn_get_screen_at:

dprintf src/platform/windows/windows.c:343, "p.x: %ld, p.y: %ld\n",p.x,p.y

dprintf src/platform/windows/winscreen.c:174, "display %ld, top: %ld, left: %ld, bottom: %ld, right: %ld, x: %ld, y: %ld, w: %ld, h:%ld\n", nscreens, dim->top, dim->left, dim->bottom, dim->right, scr->x, scr->y, scr->w, scr->h

dprintf src/platform/windows/winscreen.c:229, "scr->x: %ld, scr->y: %ld, scr->w: %ld, scr->h: %ld\n", scr->x, scr->y, scr->w, scr->h
dprintf src/platform/windows/winscreen.c:278, "wn_get_screen_at reports in bounds: %s\n", (x >= screens[i].x && x <= screens[i].x + screens[i].w && y >= screens[i].y && y <= screens[i].y + screens[i].h) ? "true" : "false"

On primary monitor activate hints:

display 1, top: 0, left: 0, bottom: 1440, right: 2560, x: 0, y: 0, w: 2560, h:1440
display 1, top: 0, left: 0, bottom: 1440, right: 2560, x: 0, y: 0, w: 2560, h:1440
display 2, top: 0, left: 2560, bottom: 1440, right: 5120, x: 0, y: 2560, w: 2560, h:1440
display 2, top: 0, left: 2560, bottom: 1440, right: 5120, x: 0, y: 2560, w: 2560, h:1440
[New Thread 32224.0x5d10]
p.x: 285, p.y: 560
p.x: 285, p.y: 560
wn_get_screen_at reports in bounds: true
p.x: 285, p.y: 560
p.x: 285, p.y: 560
wn_get_screen_at reports in bounds: true
p.x: 285, p.y: 560
p.x: 285, p.y: 560
wn_get_screen_at reports in bounds: true
p.x: 285, p.y: 560
p.x: 285, p.y: 560
wn_get_screen_at reports in bounds: true
p.x: 101, p.y: 1350
p.x: 101, p.y: 1350
wn_get_screen_at reports in bounds: true

On secondary monitor activate hints:

p.x: 3564, p.y: 655
p.x: 3564, p.y: 655

then the failed assertion.