mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Win32: Fix extra resize event during mode switch
The switch to full screen is now done with a single call to SetWindowPos.
This commit is contained in:
parent
cfb5cb8805
commit
d10463ac91
@ -471,27 +471,28 @@ static int translateKey(WPARAM wParam, LPARAM lParam)
|
|||||||
return _glfw.win32.keycodes[HIWORD(lParam) & 0x1FF];
|
return _glfw.win32.keycodes[HIWORD(lParam) & 0x1FF];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fitToMonitor(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
MONITORINFO mi = { sizeof(mi) };
|
||||||
|
GetMonitorInfo(window->monitor->win32.handle, &mi);
|
||||||
|
SetWindowPos(window->win32.handle, HWND_TOPMOST,
|
||||||
|
mi.rcMonitor.left,
|
||||||
|
mi.rcMonitor.top,
|
||||||
|
mi.rcMonitor.right - mi.rcMonitor.left,
|
||||||
|
mi.rcMonitor.bottom - mi.rcMonitor.top,
|
||||||
|
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS);
|
||||||
|
}
|
||||||
|
|
||||||
// Make the specified window and its video mode active on its monitor
|
// Make the specified window and its video mode active on its monitor
|
||||||
//
|
//
|
||||||
static void acquireMonitor(_GLFWwindow* window)
|
static void acquireMonitor(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
GLFWvidmode mode;
|
|
||||||
int xpos, ypos;
|
|
||||||
|
|
||||||
if (!_glfw.win32.acquiredMonitorCount)
|
if (!_glfw.win32.acquiredMonitorCount)
|
||||||
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
|
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
|
||||||
if (!window->monitor->window)
|
if (!window->monitor->window)
|
||||||
_glfw.win32.acquiredMonitorCount++;
|
_glfw.win32.acquiredMonitorCount++;
|
||||||
|
|
||||||
_glfwSetVideoModeWin32(window->monitor, &window->videoMode);
|
_glfwSetVideoModeWin32(window->monitor, &window->videoMode);
|
||||||
|
|
||||||
_glfwPlatformGetVideoMode(window->monitor, &mode);
|
|
||||||
_glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
|
|
||||||
|
|
||||||
SetWindowPos(window->win32.handle, HWND_TOPMOST,
|
|
||||||
xpos, ypos, mode.width, mode.height,
|
|
||||||
SWP_NOACTIVATE | SWP_NOCOPYBITS);
|
|
||||||
|
|
||||||
_glfwInputMonitorWindow(window->monitor, window);
|
_glfwInputMonitorWindow(window->monitor, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -899,7 +900,10 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
if (iconified)
|
if (iconified)
|
||||||
releaseMonitor(window);
|
releaseMonitor(window);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
|
fitToMonitor(window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window->win32.iconified = iconified;
|
window->win32.iconified = iconified;
|
||||||
@ -1239,6 +1243,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
_glfwPlatformShowWindow(window);
|
_glfwPlatformShowWindow(window);
|
||||||
_glfwPlatformFocusWindow(window);
|
_glfwPlatformFocusWindow(window);
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
|
fitToMonitor(window);
|
||||||
|
|
||||||
if (wndconfig->centerCursor)
|
if (wndconfig->centerCursor)
|
||||||
centerCursor(window);
|
centerCursor(window);
|
||||||
@ -1357,7 +1362,10 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||||||
if (window->monitor)
|
if (window->monitor)
|
||||||
{
|
{
|
||||||
if (window->monitor->window == window)
|
if (window->monitor->window == window)
|
||||||
|
{
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
|
fitToMonitor(window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1487,7 +1495,10 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
|||||||
if (monitor)
|
if (monitor)
|
||||||
{
|
{
|
||||||
if (monitor->window == window)
|
if (monitor->window == window)
|
||||||
|
{
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
|
fitToMonitor(window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1510,20 +1521,27 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (monitor)
|
if (monitor)
|
||||||
{
|
{
|
||||||
|
MONITORINFO mi = { sizeof(mi) };
|
||||||
|
UINT flags = SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS;
|
||||||
|
|
||||||
if (window->decorated)
|
if (window->decorated)
|
||||||
{
|
{
|
||||||
DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
|
DWORD style = GetWindowLongW(window->win32.handle, GWL_STYLE);
|
||||||
UINT flags = SWP_FRAMECHANGED | SWP_SHOWWINDOW |
|
|
||||||
SWP_NOACTIVATE | SWP_NOCOPYBITS |
|
|
||||||
SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE;
|
|
||||||
|
|
||||||
style &= ~WS_OVERLAPPEDWINDOW;
|
style &= ~WS_OVERLAPPEDWINDOW;
|
||||||
style |= getWindowStyle(window);
|
style |= getWindowStyle(window);
|
||||||
SetWindowLongW(window->win32.handle, GWL_STYLE, style);
|
SetWindowLongW(window->win32.handle, GWL_STYLE, style);
|
||||||
SetWindowPos(window->win32.handle, HWND_TOPMOST, 0, 0, 0, 0, flags);
|
flags |= SWP_FRAMECHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
acquireMonitor(window);
|
acquireMonitor(window);
|
||||||
|
|
||||||
|
GetMonitorInfo(window->monitor->win32.handle, &mi);
|
||||||
|
SetWindowPos(window->win32.handle, HWND_TOPMOST,
|
||||||
|
mi.rcMonitor.left,
|
||||||
|
mi.rcMonitor.top,
|
||||||
|
mi.rcMonitor.right - mi.rcMonitor.left,
|
||||||
|
mi.rcMonitor.bottom - mi.rcMonitor.top,
|
||||||
|
flags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user