SDL/src
Sam Lantinga 50203d58b3 Fixed bug 5329 - SDL_SetWindowGrab(SDL_FALSE) fails to unlock cursor if window is partially offscreen
Ivan Mogilko

With SDL 2.0.12 under MS Windows, if the window is partially offscreen calling SDL_SetWindowGrab(w, SDL_TRUE) works, but subsequent call to SDL_SetWindowGrab(w, SDL_FALSE) does not work.

I tested this in both real program, and a small test app, where unlocking cursor worked perfectly while window is fully in desktop bounds, but did not work if it was at least few pixels outside.

For the reference, following code is enough to reproduce the issue:

#include <windows.h>
#include <SDL.h>

int WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR     lpCmdLine,
    int       nShowCmd)
{
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Window* w = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 400, 0);

    bool grabbed = false;
    bool want_quit = false;
    while (!want_quit)
    {
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
            case SDL_QUIT: want_quit = true; break;
            case SDL_KEYDOWN:
                if (event.key.keysym.scancode == SDL_SCANCODE_SPACE)
                {
                    SDL_SetWindowGrab(w, static_cast<SDL_bool>(!grabbed));
                    grabbed = !grabbed;
                }
            }
        }
    }

    SDL_DestroyWindow(w);
    SDL_Quit();
    return 0;
}
2020-12-08 22:00:06 -08:00
..
atomic Add basic support for compiling on RISC OS 2020-02-13 20:50:47 +00:00
audio SIZE_MAX need not be defined in limits.h 2020-11-11 12:33:55 +03:00
core Generalized the raw input controller driver and moved XInput/WGI detection into it for XInput devices 2020-11-23 18:24:05 -08:00
cpuinfo Add Zhaoxin processor support 2020-11-09 20:36:35 -08:00
dynapi Added SDL_wcscasecmp() and SDL_wcsncasecmp() 2020-11-24 12:43:01 -08:00
events os2: integrate the port into main tree. 2020-10-14 23:01:06 +03:00
file Fixed compile warning 2020-02-10 13:59:05 -08:00
filesystem winrt: Add EffectiveLocation support for newer Win10 releases 2020-11-09 17:05:21 -05:00
haptic Fixed building on Mac OS X on the command line and with an older macOS SDK 2020-11-21 14:13:26 -08:00
hidapi Fixed bug 5222 - Crash when running with -DHIDAPI=ON 2020-12-08 19:03:50 -08:00
joystick Fixed potential hang in joystick close if the rumble thread is blocked for some reason 2020-12-07 09:38:21 -08:00
libm k_rem_pio2.c: fix typo in second memset(): iq, not q. fixes bug #5309. 2020-10-08 11:51:02 +03:00
loadso os2: a _lot_ of coding style cleanup, sot that they match the SDL style. 2020-10-15 21:37:30 +03:00
locale windows/SDL_syslocale.c: make it build against older SDKs. 2020-10-06 00:20:20 +03:00
main Updated SDL to 2.0.14 in preparation for release candidate 2020-12-08 18:56:06 -08:00
misc riscos: Implement SDL_OpenURL() 2020-10-11 17:32:32 +01:00
power Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
render SDL Renderer: specify the correct flag when recreating the window 2020-12-02 13:45:24 +01:00
sensor Added API for sensors on game controllers 2020-11-17 10:30:20 -08:00
stdlib Fixed crash when printing NULL wide character string 2020-12-03 18:16:56 -08:00
test fix watcom build of SDL_test_common.c 2020-06-14 12:05:56 +03:00
thread Fix SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL also applying to HIGH priorities 2020-11-12 07:53:05 -08:00
timer os2: a _lot_ of coding style cleanup, sot that they match the SDL style. 2020-10-15 21:37:30 +03:00
video Fixed bug 5329 - SDL_SetWindowGrab(SDL_FALSE) fails to unlock cursor if window is partially offscreen 2020-12-08 22:00:06 -08:00
SDL.c os2: integrate the port into main tree. 2020-10-14 23:01:06 +03:00
SDL_assert.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_assert_c.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_dataqueue.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_dataqueue.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_error.c SDL_error: simplified error string management. 2020-04-21 01:30:36 -04:00
SDL_error_c.h SDL_error: simplified error string management. 2020-04-21 01:30:36 -04:00
SDL_hints.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_hints_c.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_internal.h Added SDL_log.h to SDL_internal.h so logging is available everywhere 2020-04-07 09:38:57 -07:00
SDL_log.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00