| Summary: | Captured mouse and WM_MOVE messages | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Alex Denisov <ad> |
| Component: | events | Assignee: | (disabled) Jørgen Tjernø <jorgen> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | x86 | ||
| OS: | Windows (All) | ||
Hey Jorgen, can you take a quick look at this for SDL 2.0 release? Thanks! Alex, if you look at SDL_GetMouse()->last_x + event.motion.xrel and SDL_GetMouse()->last_y + event.motion.yrel, you should be able to get the coordinate outside the window even with SetCapture. I'm updating the code so that it will properly cast the lParam, but I'm not adding any functionality (right now) to support mouse motion events with absolute values outside of the window. Fixed in http://hg.libsdl.org/SDL/rev/37814e7eeff3 Let me know if this works for you. :) |
In Windows OS, the file SDL_windowsevents.c converts WM_MOUSEMOVE event incorrectly: case WM_MOUSEMOVE: ... SDL_SendMouseMotion(data->window, 0, LOWORD(lParam), HIWORD(lParam)); The issue is manifested in windowed mode, when the main window has captured the mouse using SetCapture() call from windows API. In this case, when the mouse is on the left or above the main window, WM_MOUSEMOVE is sending negative 16bit coordinates and LOWORD incorrectly typecasts it to an unsigned word. Typecasting LOWORD(lParam) to (Sint16)LOWORD(lParam) resolves the problem. Of course, for this to work properly, further modifications are required in SDL_mouse.c. I had to remove the constraints on mouse cursor assignment: if (mouse->x > x_max) { mouse->x = x_max; }, etc... If would be nice if you could add a flag into the SDL_mouse structure to disable this check. I know that in general, cursor capturing is not supported, but it would be beneficial for building GUIs based on SDL. At its present stage, it is possible to work around by using direct windows API calls, but some built-in support would be good.