diff --git a/README.md b/README.md index 9b9ef7db..744cc751 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,8 @@ information on what to include when reporting a bug. relocatable (#1470) - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556) - Bugfix: Compiling with -Wextra-semi caused warnings (#1440) + - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access + to the window menu - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused symbol redefinition (#1524) - [Win32] Bugfix: The cursor position event was emitted before its cursor enter diff --git a/docs/news.dox b/docs/news.dox index e3063c63..39f19031 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -9,6 +9,15 @@ @subsection features_34 New features in version 3.4 +@subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu + +GLFW now provides the +[GLFW_WIN32_KEYBOARD_MENU](@ref GLFW_WIN32_KEYBOARD_MENU_hint) window hint for +enabling keyboard access to the window menu via the Alt+Space and +Alt-and-then-Space shortcuts. This may be useful for more GUI-oriented +applications. + + @subsection caveats_34 Caveats for version 3.4 @subsubsection standalone_34 Tests and examples are disabled when built as a sub-project @@ -35,6 +44,8 @@ add_subdirectory(path/to/glfw) @subsubsection types_34 New types in version 3.4 @subsubsection constants_34 New constants in version 3.4 + - @ref GLFW_WIN32_KEYBOARD_MENU + @section news_archive Release notes for earlier versions diff --git a/docs/window.dox b/docs/window.dox index 4c4ab026..868c6c21 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -455,6 +455,14 @@ The no error mode for OpenGL and OpenGL ES is described in detail by the extension. +@subsubsection window_hints_win32 Windows specific window hints + +@anchor GLFW_WIN32_KEYBOARD_MENU_hint +__GLFW_WIN32_KEYBOARD_MENU__ specifies whether to allow access to the window +menu via the Alt+Space and Alt-and-then-Space keyboard shortcuts. This is +ignored on other platforms. + + @subsubsection window_hints_osx macOS specific window hints @anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint @@ -535,6 +543,7 @@ GLFW_CONTEXT_RELEASE_BEHAVIOR | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_ GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_OPENGL_DEBUG_CONTEXT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE` +GLFW_WIN32_KEYBOARD_MENU | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_COCOA_FRAME_NAME | `""` | A UTF-8 encoded frame autosave name GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 2aade0f0..0b603160 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1003,6 +1003,7 @@ extern "C" { * [window hint](@ref GLFW_X11_CLASS_NAME_hint). */ #define GLFW_X11_INSTANCE_NAME 0x00024002 +#define GLFW_WIN32_KEYBOARD_MENU 0x00025001 /*! @} */ #define GLFW_NO_API 0 diff --git a/src/internal.h b/src/internal.h index acdae22d..4c75c9b1 100644 --- a/src/internal.h +++ b/src/internal.h @@ -274,6 +274,9 @@ struct _GLFWwndconfig char className[256]; char instanceName[256]; } x11; + struct { + GLFWbool keymenu; + } win32; }; // Context configuration diff --git a/src/win32_platform.h b/src/win32_platform.h index 6507c872..2b00b001 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -315,6 +315,7 @@ typedef struct _GLFWwindowWin32 // Whether to enable framebuffer transparency on DWM GLFWbool transparent; GLFWbool scaleToMonitor; + GLFWbool keymenu; // The last received cursor position, regardless of source int lastCursorPosX, lastCursorPosY; diff --git a/src/win32_window.c b/src/win32_window.c index 455c4e2e..81cdf62a 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -699,7 +699,12 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, // User trying to access application menu using ALT? case SC_KEYMENU: - return 0; + { + if (!window->win32.keymenu) + return 0; + + break; + } } break; } @@ -731,6 +736,10 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, } _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), plain); + + if (uMsg == WM_SYSCHAR && window->win32.keymenu) + break; + return 0; } @@ -1275,6 +1284,7 @@ static int createNativeWindow(_GLFWwindow* window, } window->win32.scaleToMonitor = wndconfig->scaleToMonitor; + window->win32.keymenu = wndconfig->win32.keymenu; // Adjust window rect to account for DPI scaling of the window frame and // (if enabled) DPI scaling of the content area diff --git a/src/window.c b/src/window.c index fa604d01..bb5ba956 100644 --- a/src/window.c +++ b/src/window.c @@ -363,6 +363,9 @@ GLFWAPI void glfwWindowHint(int hint, int value) case GLFW_COCOA_RETINA_FRAMEBUFFER: _glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE; return; + case GLFW_WIN32_KEYBOARD_MENU: + _glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE; + return; case GLFW_COCOA_GRAPHICS_SWITCHING: _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE; return; diff --git a/tests/gamma.c b/tests/gamma.c index aa4c8b78..d1961609 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -101,6 +101,7 @@ int main(int argc, char** argv) monitor = glfwGetPrimaryMonitor(); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); window = glfwCreateWindow(800, 400, "Gamma Test", NULL, NULL); if (!window) diff --git a/tests/inputlag.c b/tests/inputlag.c index 269a0c8f..2ed4c49f 100644 --- a/tests/inputlag.c +++ b/tests/inputlag.c @@ -202,6 +202,7 @@ int main(int argc, char** argv) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); window = glfwCreateWindow(width, height, "Input lag test", monitor, NULL); if (!window) diff --git a/tests/joysticks.c b/tests/joysticks.c index 8eae021e..d4aef36f 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -182,6 +182,7 @@ int main(void) exit(EXIT_FAILURE); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); window = glfwCreateWindow(800, 600, "Joystick Test", NULL, NULL); if (!window) diff --git a/tests/opacity.c b/tests/opacity.c index 47f28b16..e1da9ef1 100644 --- a/tests/opacity.c +++ b/tests/opacity.c @@ -59,6 +59,7 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); + glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE); window = glfwCreateWindow(400, 400, "Opacity", NULL, NULL); if (!window)