We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4265

Summary: SDL window falls to the bottom of the screen when dragged down and stuck there
Product: SDL Reporter: Alexei <al3x3i.k>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2    
Version: 2.0.8   
Hardware: x86   
OS: Windows 10   

Description Alexei 2018-09-20 17:57:45 UTC
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.

Possible solution : sending SDL_WINDOWEVENT_FOCUS_LOST event when mouse pointer leaves the SDL window.

Add this to beginning of SDL_PrivateSendMouseMotion():

/* disable SDL_WINDOW_INPUT_FOCUS when mouse leaves window borders */
int xx;
int yy;
mouse->GetGlobalMouseState(&xx, &yy);

if (xx < window->x | yy < window->y | yy >(window->y + window->h) | xx > (window->x + window->w))
{
	//SDL_Log("OUTSIDE");
	SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0);
}
/* **************************************************************** */
Comment 1 Sam Lantinga 2018-09-26 18:18:46 UTC
This should be fixed, can you check it?
https://hg.libsdl.org/SDL/rev/e653f009e6c0

Thanks!
Comment 2 Alexei 2018-09-30 12:42:05 UTC
Looks good :)

Thanks!
Comment 3 Sam Lantinga 2018-10-01 16:24:04 UTC
Great! :)