sdl2_frt/src/video
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
..
android Fixed bug 5239 - Play audio on Android while backgrounded (Thanks Superfury) 2020-09-25 10:14:42 +02:00
arm ARM: NEON assembly optimization for SDL_FillRect 2019-10-24 21:17:52 -04:00
cocoa cocoa: Cut and paste from HTML strikes again! 2020-10-08 21:11:09 -04:00
directfb Fixed bug 5354 - DirectFB: Add Vulkan support 2020-11-23 21:25:07 -08:00
dummy Merge VideoBootStrap::available into VideoBootStrap::create 2020-07-12 19:11:15 -04:00
emscripten Merge VideoBootStrap::available into VideoBootStrap::create 2020-07-12 19:11:15 -04:00
haiku Added events for dynamically connecting and disconnecting displays, with an iOS implementation 2020-10-08 16:42:20 -07:00
khronos Updated Vulkan headers to version 1.2.158 2020-10-24 10:46:18 -07:00
kmsdrm kmsdrm: Make this build with significantly older system libraries. 2020-10-26 09:49:09 -04:00
nacl Merge VideoBootStrap::available into VideoBootStrap::create 2020-07-12 19:11:15 -04:00
offscreen Merge VideoBootStrap::available into VideoBootStrap::create 2020-07-12 19:11:15 -04:00
os2 SDL_os2messagebox.c (_makeDlg): fix crash if title and/or message is NULL. 2020-11-20 12:20:02 +03:00
pandora Added events for dynamically connecting and disconnecting displays, with an iOS implementation 2020-10-08 16:42:20 -07:00
psp Added events for dynamically connecting and disconnecting displays, with an iOS implementation 2020-10-08 16:42:20 -07:00
qnx Added events for dynamically connecting and disconnecting displays, with an iOS implementation 2020-10-08 16:42:20 -07:00
raspberry Added events for dynamically connecting and disconnecting displays, with an iOS implementation 2020-10-08 16:42:20 -07:00
uikit uikit: Don't implement main() twice for iOS static libs. 2020-11-10 13:12:10 -05:00
vivante Added events for dynamically connecting and disconnecting displays, with an iOS implementation 2020-10-08 16:42:20 -07:00
wayland Removed debug log message 2020-10-19 17:29:16 -07:00
windows Fixed bug 5329 - SDL_SetWindowGrab(SDL_FALSE) fails to unlock cursor if window is partially offscreen 2020-12-08 22:00:06 -08:00
winrt Added events for dynamically connecting and disconnecting displays, with an iOS implementation 2020-10-08 16:42:20 -07:00
x11 x11: Don't try to grab the pointer on an unmapped window (thanks, Lee!) 2020-11-23 21:07:28 -05:00
yuv2rgb Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds 2020-01-23 01:00:52 -08:00
SDL_blit_0.c Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds 2020-01-23 01:00:52 -08:00
SDL_blit_1.c Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds 2020-01-23 01:00:52 -08:00
SDL_blit_A.c Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds 2020-01-23 01:00:52 -08:00
SDL_blit_auto.c Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds 2020-01-23 01:00:52 -08:00
SDL_blit_auto.h Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds 2020-01-23 01:00:52 -08:00
SDL_blit_copy.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_blit_copy.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_blit_N.c SDL_blit: Fix undefined bitshift operations 2020-05-29 13:05:37 +01:00
SDL_blit_slow.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_blit_slow.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_blit.c Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds 2020-01-23 01:00:52 -08:00
SDL_blit.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_bmp.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_clipboard.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_egl_c.h egl: Make SDL_EGL_HasExtension() available outside of SDL_egl.c. 2020-09-10 15:02:00 -04:00
SDL_egl.c egl: Make SDL_EGL_HasExtension() available outside of SDL_egl.c. 2020-09-10 15:02:00 -04:00
SDL_fillrect.c SDL_FillRects: prevent empty SDL_surface from raising an error message 2020-11-27 09:42:14 +01:00
SDL_pixels_c.h SDL_Surface refcount: destination surface keep track of surfaces 2020-09-07 18:50:30 +02:00
SDL_pixels.c SDL_Surface refcount: destination surface keep track of surfaces 2020-09-07 18:50:30 +02:00
SDL_rect_c.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_rect.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_RLEaccel_c.h A few #defines to reduce SDL2 footprint. 2020-01-21 21:33:40 +01:00
SDL_RLEaccel.c Fixed bug 5333 - Replace character of legacy code page with utf-8 one. 2020-11-08 23:34:59 -08:00
SDL_shape_internals.h SDL_shape_internals.h: forward-declare struct SDL_ShapeTree. 2020-10-25 10:10:10 +03:00
SDL_shape.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_stretch.c Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_surface.c Fixed bug 5304 - add SDL_HasSurfaceRLE() (Thanks Rene Dudfield and Dan Lawrence) 2020-10-18 09:52:56 +02:00
SDL_sysvideo.h os2: integrate the port into main tree. 2020-10-14 23:01:06 +03:00
SDL_video.c SDL_RecreateWindow: allow clearing VULKAN when recreating the window 2020-12-02 13:37:59 +01:00
SDL_vulkan_internal.h Fixed bug 5354 - DirectFB: Add Vulkan support 2020-11-23 21:25:07 -08:00
SDL_vulkan_utils.c Updated Vulkan headers to version 1.2.158 2020-10-24 10:46:18 -07:00
SDL_yuv_c.h Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
SDL_yuv.c Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds 2020-01-23 01:00:52 -08:00
sdlgenblit.pl Added a single SDL_LEAN_AND_MEAN define to turn on minimal SDL builds 2020-01-23 01:00:52 -08:00