From 25e7ff11962f4509588e582560929d4e6300544f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 8 Apr 2014 15:32:34 +0200 Subject: [PATCH] Added GLFW_AUTO_ICONIFY. By default, full screen windows that lose focus will be iconified and the video mode will be restored. This makes it impossible to create applications spanning multiple monitors. The GLFW_AUTO_ICONIFY window hint will allow users to disable this behavior. Fixes #143. --- README.md | 2 ++ docs/news.dox | 8 ++++++++ docs/window.dox | 23 ++++++++++++++--------- include/GLFW/glfw3.h | 1 + src/internal.h | 3 +++ src/win32_window.c | 4 ++-- src/window.c | 20 +++++++++++++------- 7 files changed, 43 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 5c6e3bd6..a7ecbfc1 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,8 @@ GLFW bundles a number of dependencies in the `deps/` directory. - Added `empty` test program for verifying posting of empty events - Added `glfwGetWindowFrameSize` for retrieving the size of the frame around the client area of a window + - Added `GLFW_AUTO_ICONIFY` for controlling whether full screen windows + automatically iconify (and restore the previous video mode) on focus loss - Added `GLFW_INCLUDE_ES31` for including the OpenGL ES 3.1 header - Added *partial and experimental* support for Wayland - Bugfix: The debug context attribute was set from `GL_ARB_debug_output` even diff --git a/docs/news.dox b/docs/news.dox index c0530fb0..c45021bd 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -33,6 +33,14 @@ GLFW now supports querying the size, on each side, of the frame around the client area of a window, with @ref glfwGetWindowFrameSize. +@subsection news_31_autoiconify Multi-monitor installation support + +GLFW now supports disabling auto-iconification of full screen windows with +[GLFW_AUTO_ICONIFY](@ref window_hints_wnd). This is intended for people +building multi-monitor installations, where you need windows to stay in full +screen despite losing focus. + + @section news_30 New features in version 3.0 @subsection news_30_cmake CMake build system diff --git a/docs/window.dox b/docs/window.dox index 1fc899c1..d6dfdf37 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -105,17 +105,21 @@ Hints that do not apply to a given type of window or context are ignored. @subsection window_hints_wnd Window related hints -The `GLFW_RESIZABLE` hint specifies whether the window will be resizable *by the -user*. The window will still be resizable using the @ref glfwSetWindowSize -function. This hint is ignored for full screen windows. +The `GLFW_RESIZABLE` hint specifies whether the (windowed mode) window will be +resizable *by the user*. The window will still be resizable using the @ref +glfwSetWindowSize function. This hint is ignored for full screen windows. -The `GLFW_VISIBLE` hint specifies whether the window will be initially -visible. This hint is ignored for full screen windows. +The `GLFW_VISIBLE` hint specifies whether the (windowed mode) window will be +initially visible. This hint is ignored for full screen windows. -The `GLFW_DECORATED` hint specifies whether the window will have window -decorations such as a border, a close widget, etc. This hint is ignored for -full screen windows. Note that even though a window may lack a close widget, it -is usually still possible for the user to generate close events. +The `GLFW_DECORATED` hint specifies whether the (windowed mode) window will have +window decorations such as a border, a close widget, etc. This hint is ignored +for full screen windows. Note that even though a window may lack a close +widget, it is usually still possible for the user to generate close events. + +The `GLFW_AUTO_ICONIFY` hint specifies whether the (full screen) window +will automatically iconify and restore the previous video mode on focus loss. +This hint is ignored for windowed mode windows. @subsection window_hints_fb Framebuffer related hints @@ -196,6 +200,7 @@ a robustness strategy. | `GLFW_RESIZABLE` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE` | | `GLFW_VISIBLE` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE` | | `GLFW_DECORATED` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE` | +| `GLFW_AUTO_ICONIFY` | `GL_TRUE` | `GL_TRUE` or `GL_FALSE` | | `GLFW_RED_BITS` | 8 | 0 to `INT_MAX` | | `GLFW_GREEN_BITS` | 8 | 0 to `INT_MAX` | | `GLFW_BLUE_BITS` | 8 | 0 to `INT_MAX` | diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 620897fa..8ac11c15 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -497,6 +497,7 @@ extern "C" { #define GLFW_RESIZABLE 0x00020003 #define GLFW_VISIBLE 0x00020004 #define GLFW_DECORATED 0x00020005 +#define GLFW_AUTO_ICONIFY 0x00020006 #define GLFW_RED_BITS 0x00021001 #define GLFW_GREEN_BITS 0x00021002 diff --git a/src/internal.h b/src/internal.h index 319f7064..fef8dc48 100644 --- a/src/internal.h +++ b/src/internal.h @@ -152,6 +152,7 @@ struct _GLFWwndconfig GLboolean resizable; GLboolean visible; GLboolean decorated; + GLboolean autoIconify; _GLFWmonitor* monitor; }; @@ -215,6 +216,7 @@ struct _GLFWwindow GLboolean iconified; GLboolean resizable; GLboolean decorated; + GLboolean autoIconify; GLboolean visible; GLboolean closed; void* userPointer; @@ -319,6 +321,7 @@ struct _GLFWlibrary GLboolean resizable; GLboolean visible; GLboolean decorated; + GLboolean autoIconify; int samples; GLboolean sRGB; int refreshRate; diff --git a/src/win32_window.c b/src/win32_window.c index 760d796d..3ff59ff9 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -436,7 +436,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (window->cursorMode != GLFW_CURSOR_NORMAL) restoreCursor(window); - if (window->monitor) + if (window->monitor && window->autoIconify) { if (!iconified) { @@ -455,7 +455,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (window->cursorMode != GLFW_CURSOR_NORMAL) _glfwPlatformApplyCursorMode(window); - if (window->monitor) + if (window->monitor && window->autoIconify) _glfwSetVideoMode(window->monitor, &window->videoMode); } diff --git a/src/window.c b/src/window.c index a3912501..bf26e806 100644 --- a/src/window.c +++ b/src/window.c @@ -173,6 +173,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, wndconfig.resizable = _glfw.hints.resizable ? GL_TRUE : GL_FALSE; wndconfig.visible = _glfw.hints.visible ? GL_TRUE : GL_FALSE; wndconfig.decorated = _glfw.hints.decorated ? GL_TRUE : GL_FALSE; + wndconfig.autoIconify = _glfw.hints.autoIconify ? GL_TRUE : GL_FALSE; wndconfig.monitor = (_GLFWmonitor*) monitor; // Set up desired context config @@ -207,10 +208,11 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, window->videoMode.refreshRate = Max(_glfw.hints.refreshRate, 0); } - window->monitor = wndconfig.monitor; - window->resizable = wndconfig.resizable; - window->decorated = wndconfig.decorated; - window->cursorMode = GLFW_CURSOR_NORMAL; + window->monitor = wndconfig.monitor; + window->resizable = wndconfig.resizable; + window->decorated = wndconfig.decorated; + window->autoIconify = wndconfig.autoIconify; + window->cursorMode = GLFW_CURSOR_NORMAL; // Save the currently current context so it can be restored later previous = _glfwPlatformGetCurrentContext(); @@ -267,9 +269,10 @@ void glfwDefaultWindowHints(void) _glfw.hints.minor = 0; // The default is a visible, resizable window with decorations - _glfw.hints.resizable = GL_TRUE; - _glfw.hints.visible = GL_TRUE; - _glfw.hints.decorated = GL_TRUE; + _glfw.hints.resizable = GL_TRUE; + _glfw.hints.visible = GL_TRUE; + _glfw.hints.decorated = GL_TRUE; + _glfw.hints.autoIconify = GL_TRUE; // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil _glfw.hints.redBits = 8; @@ -331,6 +334,9 @@ GLFWAPI void glfwWindowHint(int target, int hint) case GLFW_DECORATED: _glfw.hints.decorated = hint; break; + case GLFW_AUTO_ICONIFY: + _glfw.hints.autoIconify = hint; + break; case GLFW_VISIBLE: _glfw.hints.visible = hint; break;