Only reset the clip rect if it's currently the rect we previously clipped.
This prevents us from clearing the clip rect globally when another application has set it. There's also an experimental change to regularly update the clip rect for a window defensively, in case someone else has reset it. It works well, but I don't know if it's cheap enough to call as frequently as it would be called now, and might have other undesirable side effects. Also fixed whitespace and SDL coding style
parent
09ab752aa3
commit
15b3794f11
|
@ -1543,8 +1543,9 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
|||
// Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation,
|
||||
// but it's important or window focus will get broken on windows!
|
||||
#if !defined(__WIN32__)
|
||||
if ( window->flags & SDL_WINDOW_MINIMIZED )
|
||||
if (window->flags & SDL_WINDOW_MINIMIZED) {
|
||||
window->flags &= ~SDL_WINDOW_MINIMIZED;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10)
|
||||
|
|
|
@ -228,10 +228,8 @@ WIN_CheckWParamMouseButton(SDL_bool bwParamMousePressed, SDL_bool bSDLMousePress
|
|||
/* Ignore the button click for activation */
|
||||
if (!bwParamMousePressed) {
|
||||
data->focus_click_pending &= ~SDL_BUTTON(button);
|
||||
if (!data->focus_click_pending) {
|
||||
WIN_UpdateClipCursor(data->window);
|
||||
}
|
||||
}
|
||||
if (WIN_ShouldIgnoreFocusClick()) {
|
||||
return;
|
||||
}
|
||||
|
@ -401,6 +399,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
#endif /* WMMSG_DEBUG */
|
||||
|
||||
/* Update the clipping rect in case someone else has stolen it */
|
||||
/* FIXME: Is this function cheap enough to call this frequently?
|
||||
WIN_UpdateClipCursor(data->window);
|
||||
*/
|
||||
|
||||
if (IME_HandleMessage(hwnd, msg, wParam, &lParam, data->videodata))
|
||||
return 0;
|
||||
|
||||
|
@ -465,6 +468,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
SDL_ToggleModState(KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) != 0);
|
||||
SDL_ToggleModState(KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) != 0);
|
||||
} else {
|
||||
RECT rect;
|
||||
|
||||
data->in_window_deactivation = SDL_TRUE;
|
||||
|
||||
if (SDL_GetKeyboardFocus() == data->window) {
|
||||
|
@ -472,7 +477,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
WIN_ResetDeadKeys();
|
||||
}
|
||||
|
||||
if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect) == 0)) {
|
||||
SDL_Log("Windows deactivate, ClipCursor(NULL)\n");
|
||||
ClipCursor(NULL);
|
||||
SDL_zero(data->cursor_clipped_rect);
|
||||
}
|
||||
|
||||
data->in_window_deactivation = SDL_FALSE;
|
||||
}
|
||||
|
@ -1099,9 +1108,9 @@ IsWin10FCUorNewer(void)
|
|||
SDL_zero(info);
|
||||
info.dwOSVersionInfoSize = sizeof(info);
|
||||
if (getVersionPtr(&info) == 0) { /* STATUS_SUCCESS == 0 */
|
||||
if ( (info.dwMajorVersion == 10 && info.dwMinorVersion == 0 && info.dwBuildNumber >= 16299)
|
||||
|| (info.dwMajorVersion == 10 && info.dwMinorVersion > 0)
|
||||
|| (info.dwMajorVersion > 10) )
|
||||
if ((info.dwMajorVersion == 10 && info.dwMinorVersion == 0 && info.dwBuildNumber >= 16299) ||
|
||||
(info.dwMajorVersion == 10 && info.dwMinorVersion > 0) ||
|
||||
(info.dwMajorVersion > 10))
|
||||
{
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
|
|
@ -99,9 +99,10 @@ GetWindowStyle(SDL_Window * window)
|
|||
}
|
||||
|
||||
/* Need to set initialize minimize style, or when we call ShowWindow with WS_MINIMIZE it will activate a random window */
|
||||
if ( window->flags & SDL_WINDOW_MINIMIZED )
|
||||
if (window->flags & SDL_WINDOW_MINIMIZED) {
|
||||
style |= WS_MINIMIZE;
|
||||
}
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
|
@ -334,8 +335,9 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
|
|||
/* Inform Windows of the frame change so we can respond to WM_NCCALCSIZE */
|
||||
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||
|
||||
if ( window->flags & SDL_WINDOW_MINIMIZED )
|
||||
if (window->flags & SDL_WINDOW_MINIMIZED) {
|
||||
ShowWindow(hwnd, SW_SHOWMINNOACTIVE);
|
||||
}
|
||||
|
||||
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
||||
return 0;
|
||||
|
@ -409,11 +411,9 @@ WIN_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
|
|||
SDL_sscanf(hint, "%p", (void**)&otherWindow);
|
||||
|
||||
/* Do some error checking on the pointer */
|
||||
if (otherWindow != NULL && otherWindow->magic == &_this->window_magic)
|
||||
{
|
||||
if (otherWindow != NULL && otherWindow->magic == &_this->window_magic) {
|
||||
/* If the otherWindow has SDL_WINDOW_OPENGL set, set it for the new window as well */
|
||||
if (otherWindow->flags & SDL_WINDOW_OPENGL)
|
||||
{
|
||||
if (otherWindow->flags & SDL_WINDOW_OPENGL) {
|
||||
window->flags |= SDL_WINDOW_OPENGL;
|
||||
if (!WIN_GL_SetPixelFormatFrom(_this, otherWindow, window)) {
|
||||
return -1;
|
||||
|
@ -555,9 +555,9 @@ WIN_ShowWindow(_THIS, SDL_Window * window)
|
|||
hwnd = ((SDL_WindowData *)window->driverdata)->hwnd;
|
||||
nCmdShow = SW_SHOW;
|
||||
style = GetWindowLong(hwnd, GWL_EXSTYLE);
|
||||
if ( style & WS_EX_NOACTIVATE )
|
||||
if (style & WS_EX_NOACTIVATE) {
|
||||
nCmdShow = SW_SHOWNOACTIVATE;
|
||||
|
||||
}
|
||||
ShowWindow(hwnd, nCmdShow);
|
||||
}
|
||||
|
||||
|
@ -902,6 +902,7 @@ WIN_UpdateClipCursor(SDL_Window *window)
|
|||
{
|
||||
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
|
||||
SDL_Mouse *mouse = SDL_GetMouse();
|
||||
RECT rect;
|
||||
|
||||
if (data->focus_click_pending) {
|
||||
return;
|
||||
|
@ -911,7 +912,6 @@ WIN_UpdateClipCursor(SDL_Window *window)
|
|||
(window->flags & SDL_WINDOW_INPUT_FOCUS)) {
|
||||
if (mouse->relative_mode && !mouse->relative_mode_warp) {
|
||||
LONG cx, cy;
|
||||
RECT rect;
|
||||
GetWindowRect(data->hwnd, &rect);
|
||||
|
||||
cx = (rect.left + rect.right) / 2;
|
||||
|
@ -923,17 +923,21 @@ WIN_UpdateClipCursor(SDL_Window *window)
|
|||
rect.top = cy - 1;
|
||||
rect.bottom = cy + 1;
|
||||
|
||||
ClipCursor(&rect);
|
||||
if (ClipCursor(&rect)) {
|
||||
data->cursor_clipped_rect = rect;
|
||||
}
|
||||
} else {
|
||||
RECT rect;
|
||||
if (GetClientRect(data->hwnd, &rect) && !IsRectEmpty(&rect)) {
|
||||
ClientToScreen(data->hwnd, (LPPOINT) & rect);
|
||||
ClientToScreen(data->hwnd, (LPPOINT) & rect + 1);
|
||||
ClipCursor(&rect);
|
||||
if (ClipCursor(&rect)) {
|
||||
data->cursor_clipped_rect = rect;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect)) == 0) {
|
||||
ClipCursor(NULL);
|
||||
SDL_zero(data->cursor_clipped_rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ typedef struct
|
|||
Uint8 focus_click_pending;
|
||||
SDL_bool windowed_mode_was_maximized;
|
||||
SDL_bool in_window_deactivation;
|
||||
RECT cursor_clipped_rect;
|
||||
struct SDL_VideoData *videodata;
|
||||
#if SDL_VIDEO_OPENGL_EGL
|
||||
EGLSurface egl_surface;
|
||||
|
|
Loading…
Reference in New Issue