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 - SDL window falls to the bottom of the screen when dragged down and stuck there
Summary: SDL window falls to the bottom of the screen when dragged down and stuck there
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.8
Hardware: x86 Windows 10
: P2 minor
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-20 17:57 UTC by Alexei
Modified: 2018-10-01 16:24 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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! :)