mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Fixed iconify and activation for fullscreen windows.
This commit is contained in:
parent
a7a5e1091b
commit
2631d0e8e0
12
src/win32/platform.h
Normal file → Executable file
12
src/win32/platform.h
Normal file → Executable file
@ -317,9 +317,6 @@ typedef struct _GLFWwindowWin32
|
|||||||
DWORD dwExStyle; // --"--
|
DWORD dwExStyle; // --"--
|
||||||
|
|
||||||
// Various platform specific internal variables
|
// Various platform specific internal variables
|
||||||
int oldMouseLock; // Old mouse-lock flag (used for remembering
|
|
||||||
// mouse-lock state when iconifying)
|
|
||||||
int oldMouseLockValid;
|
|
||||||
int desiredRefreshRate; // Desired vertical monitor refresh rate
|
int desiredRefreshRate; // Desired vertical monitor refresh rate
|
||||||
int mouseMoved;
|
int mouseMoved;
|
||||||
int oldMouseX, oldMouseY;
|
int oldMouseX, oldMouseY;
|
||||||
@ -336,6 +333,15 @@ typedef struct _GLFWlibraryWin32
|
|||||||
HHOOK keyboardHook; // Keyboard hook handle
|
HHOOK keyboardHook; // Keyboard hook handle
|
||||||
DWORD foregroundLockTimeout;
|
DWORD foregroundLockTimeout;
|
||||||
|
|
||||||
|
// Default monitor
|
||||||
|
struct {
|
||||||
|
int modeChanged;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int bitsPerPixel;
|
||||||
|
int refreshRate;
|
||||||
|
} monitor;
|
||||||
|
|
||||||
// Timer data
|
// Timer data
|
||||||
struct {
|
struct {
|
||||||
int hasPerformanceCounter;
|
int hasPerformanceCounter;
|
||||||
|
0
src/win32/win32_fullscreen.c
Normal file → Executable file
0
src/win32/win32_fullscreen.c
Normal file → Executable file
@ -622,7 +622,7 @@ static void translateChar(_GLFWwindow* window, DWORD wParam, DWORD lParam)
|
|||||||
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||||
WPARAM wParam, LPARAM lParam)
|
WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
int wheelDelta, iconified;
|
int wheelDelta;
|
||||||
|
|
||||||
_GLFWwindow* window = (_GLFWwindow*) GetWindowLongPtr(hWnd, 0);
|
_GLFWwindow* window = (_GLFWwindow*) GetWindowLongPtr(hWnd, 0);
|
||||||
|
|
||||||
@ -635,69 +635,65 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Window activate message? (iconification?)
|
|
||||||
case WM_ACTIVATE:
|
case WM_ACTIVATE:
|
||||||
{
|
{
|
||||||
if (LOWORD(wParam) != WA_INACTIVE)
|
// Window was (de)activated and/or (de)iconified
|
||||||
_glfwLibrary.activeWindow = window;
|
|
||||||
|
|
||||||
iconified = HIWORD(wParam) ? GL_TRUE : GL_FALSE;
|
BOOL active = LOWORD(wParam) != WA_INACTIVE;
|
||||||
|
BOOL iconified = HIWORD(wParam) ? TRUE : FALSE;
|
||||||
|
|
||||||
// Were we deactivated/iconified?
|
if ((!active && _glfwLibrary.activeWindow == window) ||
|
||||||
if ((window != _glfwLibrary.activeWindow || iconified) && !window->iconified)
|
(iconified && !window->iconified))
|
||||||
{
|
{
|
||||||
|
// The window was either deactivated, iconified or both
|
||||||
|
|
||||||
_glfwInputDeactivation(window);
|
_glfwInputDeactivation(window);
|
||||||
|
|
||||||
// If we are in fullscreen mode we need to iconify
|
if (window == _glfwLibrary.cursorLockWindow)
|
||||||
|
_glfwPlatformShowMouseCursor(window);
|
||||||
|
|
||||||
if (window->mode == GLFW_FULLSCREEN)
|
if (window->mode == GLFW_FULLSCREEN)
|
||||||
{
|
{
|
||||||
// Do we need to manually iconify?
|
|
||||||
if (!iconified)
|
if (!iconified)
|
||||||
{
|
{
|
||||||
// Minimize window
|
// Iconify the (on top, borderless, oddly positioned)
|
||||||
CloseWindow(window->Win32.handle);
|
// window or the user will be annoyed
|
||||||
iconified = GL_TRUE;
|
ShowWindow(window->Win32.handle, SW_MINIMIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the original desktop resolution
|
if (_glfwLibrary.Win32.monitor.modeChanged)
|
||||||
ChangeDisplaySettings(NULL, CDS_FULLSCREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unlock mouse if locked
|
|
||||||
//if (!window->Win32.oldMouseLockValid)
|
|
||||||
//{
|
|
||||||
//window->Win32.oldMouseLock = window->mouseLock;
|
|
||||||
//window->Win32.oldMouseLockValid = GL_TRUE;
|
|
||||||
//glfwEnable(GLFW_MOUSE_CURSOR);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
else if (window == _glfwLibrary.activeWindow || !iconified)
|
|
||||||
{
|
{
|
||||||
// If we are in fullscreen mode we need to maximize
|
_glfwRestoreVideoMode();
|
||||||
if (window->mode == GLFW_FULLSCREEN && window->iconified)
|
_glfwLibrary.Win32.monitor.modeChanged = GL_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (active && !iconified)
|
||||||
{
|
{
|
||||||
// Change display settings to the user selected mode
|
if (window == _glfwLibrary.cursorLockWindow)
|
||||||
//_glfwSetVideoModeMODE(window->Win32.modeID);
|
_glfwPlatformHideMouseCursor(window);
|
||||||
|
|
||||||
// Do we need to manually restore window?
|
if (window->mode == GLFW_FULLSCREEN)
|
||||||
if (iconified)
|
|
||||||
{
|
{
|
||||||
// Restore window
|
if (!_glfwLibrary.Win32.monitor.modeChanged)
|
||||||
OpenIcon(window->Win32.handle);
|
{
|
||||||
iconified = GL_FALSE;
|
_glfwSetVideoMode(&_glfwLibrary.Win32.monitor.width,
|
||||||
|
&_glfwLibrary.Win32.monitor.height,
|
||||||
|
&_glfwLibrary.Win32.monitor.bitsPerPixel,
|
||||||
|
&_glfwLibrary.Win32.monitor.refreshRate,
|
||||||
|
GL_TRUE);
|
||||||
|
|
||||||
// Activate window
|
_glfwLibrary.Win32.monitor.modeChanged = GL_TRUE;
|
||||||
ShowWindow(hWnd, SW_SHOW);
|
}
|
||||||
setForegroundWindow(window->Win32.handle);
|
|
||||||
SetFocus(window->Win32.handle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock mouse, if necessary
|
if (active)
|
||||||
//if (window->Win32.oldMouseLockValid && window->Win32.oldMouseLock)
|
_glfwLibrary.activeWindow = window;
|
||||||
//glfwDisable(GLFW_MOUSE_CURSOR);
|
else
|
||||||
|
{
|
||||||
//window->Win32.oldMouseLockValid = GL_FALSE;
|
if (window == _glfwLibrary.activeWindow)
|
||||||
|
_glfwLibrary.activeWindow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
window->iconified = iconified;
|
window->iconified = iconified;
|
||||||
@ -1276,14 +1272,22 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (window->mode == GLFW_FULLSCREEN)
|
if (window->mode == GLFW_FULLSCREEN)
|
||||||
{
|
{
|
||||||
int refreshRate = wndconfig->refreshRate;
|
|
||||||
|
|
||||||
int bpp = fbconfig->redBits + fbconfig->greenBits + fbconfig->blueBits;
|
int bpp = fbconfig->redBits + fbconfig->greenBits + fbconfig->blueBits;
|
||||||
if (bpp < 15 || bpp >= 24)
|
if (bpp < 15 || bpp >= 24)
|
||||||
bpp = 32;
|
bpp = 32;
|
||||||
|
|
||||||
_glfwSetVideoMode(&window->width, &window->height,
|
_glfwLibrary.Win32.monitor.width = window->width;
|
||||||
&bpp, &refreshRate, GL_FALSE);
|
_glfwLibrary.Win32.monitor.height = window->height;
|
||||||
|
_glfwLibrary.Win32.monitor.refreshRate = wndconfig->refreshRate;
|
||||||
|
_glfwLibrary.Win32.monitor.bitsPerPixel = bpp;
|
||||||
|
|
||||||
|
_glfwSetVideoMode(&_glfwLibrary.Win32.monitor.width,
|
||||||
|
&_glfwLibrary.Win32.monitor.height,
|
||||||
|
&_glfwLibrary.Win32.monitor.bitsPerPixel,
|
||||||
|
&_glfwLibrary.Win32.monitor.refreshRate,
|
||||||
|
GL_FALSE);
|
||||||
|
|
||||||
|
_glfwLibrary.Win32.monitor.modeChanged = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This call only clears the WGL extension member variables
|
// This call only clears the WGL extension member variables
|
||||||
@ -1374,7 +1378,13 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
|||||||
destroyWindow(window);
|
destroyWindow(window);
|
||||||
|
|
||||||
if (window->mode == GLFW_FULLSCREEN)
|
if (window->mode == GLFW_FULLSCREEN)
|
||||||
|
{
|
||||||
|
if (_glfwLibrary.Win32.monitor.modeChanged)
|
||||||
|
{
|
||||||
_glfwRestoreVideoMode();
|
_glfwRestoreVideoMode();
|
||||||
|
_glfwLibrary.Win32.monitor.modeChanged = GL_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1463,24 +1473,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y)
|
|||||||
|
|
||||||
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
// Despite the name, this iconifies the window without closing it
|
ShowWindow(window->Win32.handle, SW_MINIMIZE);
|
||||||
CloseWindow(window->Win32.handle);
|
|
||||||
window->iconified = GL_TRUE;
|
|
||||||
|
|
||||||
// If we are in fullscreen mode we need to change video modes
|
|
||||||
if (window->mode == GLFW_FULLSCREEN)
|
|
||||||
{
|
|
||||||
// Change display settings to the desktop resolution
|
|
||||||
ChangeDisplaySettings(NULL, CDS_FULLSCREEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unlock mouse
|
|
||||||
//if (!window->Win32.oldMouseLockValid)
|
|
||||||
//{
|
|
||||||
//window->Win32.oldMouseLock = _glfwWin.mouseLock;
|
|
||||||
//window->Win32.oldMouseLockValid = GL_TRUE;
|
|
||||||
//glfwEnable(window, GLFW_MOUSE_CURSOR);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1490,28 +1483,7 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
|
|||||||
|
|
||||||
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->mode == GLFW_FULLSCREEN)
|
ShowWindow(window->Win32.handle, SW_RESTORE);
|
||||||
{
|
|
||||||
// Change display settings to the user selected mode
|
|
||||||
//_glfwSetVideoModeMODE(window->Win32.modeID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Un-iconify window
|
|
||||||
OpenIcon(window->Win32.handle);
|
|
||||||
|
|
||||||
// Make sure that our window ends up on top of things
|
|
||||||
ShowWindow(window->Win32.handle, SW_SHOW);
|
|
||||||
setForegroundWindow(window->Win32.handle);
|
|
||||||
SetFocus(window->Win32.handle);
|
|
||||||
|
|
||||||
// Window is no longer iconified
|
|
||||||
window->iconified = GL_FALSE;
|
|
||||||
|
|
||||||
// Lock mouse, if necessary
|
|
||||||
//if (window->Win32.oldMouseLockValid && window->Win32.oldMouseLock)
|
|
||||||
//glfwDisable(GLFW_MOUSE_CURSOR);
|
|
||||||
|
|
||||||
window->Win32.oldMouseLockValid = GL_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user