Skip to content

Commit

Permalink
Fixed bug 4265 - SDL window falls to the bottom of the screen when dr…
Browse files Browse the repository at this point in the history
…agged down and stuck there

Alexei

On WM_WINDOWPOSCHANGED event, WIN_UpdateClipCursor() is called. SDL_WINDOW_INPUT_FOCUS is set even when the mouse pointer is not inside the SDL window and therefore ClipCursor(&rect) is called. When dragging the window and rect.bottom=800 (i.e. the bottom edge of the screen) the SDL window is clipped to the bottom of the screen and it is not possible to move it back to the center of the screen.
  • Loading branch information
slouken committed Sep 26, 2018
1 parent ffc19ee commit 55b24b9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/video/windows/SDL_windowsevents.c
Expand Up @@ -414,6 +414,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
break;

case WM_NCACTIVATE:
{
/* Don't immediately clip the cursor in case we're clicking minimize/maximize buttons */
data->skip_update_clipcursor = SDL_TRUE;
}
break;

case WM_ACTIVATE:
{
POINT cursorPos;
Expand Down
6 changes: 5 additions & 1 deletion src/video/windows/SDL_windowswindow.c
Expand Up @@ -904,7 +904,11 @@ WIN_UpdateClipCursor(SDL_Window *window)
SDL_Mouse *mouse = SDL_GetMouse();
RECT rect;

if (data->focus_click_pending) {
if (data->in_title_click || data->focus_click_pending) {
return;
}
if (data->skip_update_clipcursor) {
data->skip_update_clipcursor = SDL_FALSE;
return;
}

Expand Down
1 change: 1 addition & 0 deletions src/video/windows/SDL_windowswindow.h
Expand Up @@ -44,6 +44,7 @@ typedef struct
SDL_bool in_border_change;
SDL_bool in_title_click;
Uint8 focus_click_pending;
SDL_bool skip_update_clipcursor;
SDL_bool windowed_mode_was_maximized;
SDL_bool in_window_deactivation;
RECT cursor_clipped_rect;
Expand Down

0 comments on commit 55b24b9

Please sign in to comment.