Skip to content

Commit

Permalink
add WIN_UnclipCursorForWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
expikr committed Nov 23, 2024
1 parent 00145c3 commit 0fbe530
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/video/windows/SDL_windowsevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,6 @@ static void WIN_UpdateFocus(SDL_Window *window, bool expect_focus)

WIN_UpdateWindowICCProfile(data->window, true);
} else {
RECT rect;

data->in_window_deactivation = true;

SDL_SetKeyboardFocus(NULL);
Expand All @@ -361,10 +359,7 @@ static void WIN_UpdateFocus(SDL_Window *window, bool expect_focus)
}
WIN_ResetDeadKeys();

if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect)) == 0) {
ClipCursor(NULL);
SDL_zero(data->cursor_clipped_rect);
}
WIN_UnclipCursorForWindow(window);

data->in_window_deactivation = false;
}
Expand Down
12 changes: 10 additions & 2 deletions src/video/windows/SDL_windowswindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,15 @@ static BOOL GetClientScreenRect(HWND hwnd, RECT *rect)
ClientToScreen(hwnd, (LPPOINT)rect + 1); // POINT( right , bottom )
}

void WIN_UnclipCursorForWindow(SDL_Window *window) {
SDL_WindowData *data = window->internal;
RECT rect;
if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect)) == 0) {
ClipCursor(NULL);
SDL_zero(data->cursor_clipped_rect);
}
}

void WIN_UpdateClipCursor(SDL_Window *window)
{
SDL_WindowData *data = window->internal;
Expand Down Expand Up @@ -1634,8 +1643,7 @@ void WIN_UpdateClipCursor(SDL_Window *window)
if (IntersectRect(&overlap, &client, &custom)) {
target = overlap;
} else if (!win_is_grabbed) {
ClipCursor(NULL);
SDL_zero(data->cursor_clipped_rect);
WIN_UnclipCursorForWindow(window);
return;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/video/windows/SDL_windowswindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ extern bool WIN_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window
extern void WIN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window);
extern void WIN_OnWindowEnter(SDL_VideoDevice *_this, SDL_Window *window);
extern void WIN_UpdateClipCursor(SDL_Window *window);
extern void WIN_UnclipCursorForWindow(SDL_Window *window);
extern bool WIN_SetWindowHitTest(SDL_Window *window, bool enabled);
extern void WIN_AcceptDragAndDrop(SDL_Window *window, bool accept);
extern bool WIN_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation);
Expand Down

0 comments on commit 0fbe530

Please sign in to comment.