Win32: Add GLFW_WIN32_KEYBOARD_MENU

This platform specific window hint enables access to the Windows window
menu via the keyboard shortcuts.
This commit is contained in:
Camilla Löwy 2019-08-20 19:00:59 +02:00
parent de23429455
commit 8e288dc94c
12 changed files with 45 additions and 1 deletions

View File

@ -123,6 +123,8 @@ information on what to include when reporting a bug.
relocatable (#1470) relocatable (#1470)
- Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556) - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556)
- Bugfix: Compiling with -Wextra-semi caused warnings (#1440) - 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 - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
symbol redefinition (#1524) symbol redefinition (#1524)
- [Win32] Bugfix: The cursor position event was emitted before its cursor enter - [Win32] Bugfix: The cursor position event was emitted before its cursor enter

View File

@ -9,6 +9,15 @@
@subsection features_34 New features in version 3.4 @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 @subsection caveats_34 Caveats for version 3.4
@subsubsection standalone_34 Tests and examples are disabled when built as a sub-project @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 types_34 New types in version 3.4
@subsubsection constants_34 New constants 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 @section news_archive Release notes for earlier versions

View File

@ -455,6 +455,14 @@ The no error mode for OpenGL and OpenGL ES is described in detail by the
extension. 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 @subsubsection window_hints_osx macOS specific window hints
@anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint @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_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
GLFW_OPENGL_DEBUG_CONTEXT | `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_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_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
GLFW_COCOA_FRAME_NAME | `""` | A UTF-8 encoded frame autosave name GLFW_COCOA_FRAME_NAME | `""` | A UTF-8 encoded frame autosave name
GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`

View File

@ -1003,6 +1003,7 @@ extern "C" {
* [window hint](@ref GLFW_X11_CLASS_NAME_hint). * [window hint](@ref GLFW_X11_CLASS_NAME_hint).
*/ */
#define GLFW_X11_INSTANCE_NAME 0x00024002 #define GLFW_X11_INSTANCE_NAME 0x00024002
#define GLFW_WIN32_KEYBOARD_MENU 0x00025001
/*! @} */ /*! @} */
#define GLFW_NO_API 0 #define GLFW_NO_API 0

View File

@ -274,6 +274,9 @@ struct _GLFWwndconfig
char className[256]; char className[256];
char instanceName[256]; char instanceName[256];
} x11; } x11;
struct {
GLFWbool keymenu;
} win32;
}; };
// Context configuration // Context configuration

View File

@ -315,6 +315,7 @@ typedef struct _GLFWwindowWin32
// Whether to enable framebuffer transparency on DWM // Whether to enable framebuffer transparency on DWM
GLFWbool transparent; GLFWbool transparent;
GLFWbool scaleToMonitor; GLFWbool scaleToMonitor;
GLFWbool keymenu;
// The last received cursor position, regardless of source // The last received cursor position, regardless of source
int lastCursorPosX, lastCursorPosY; int lastCursorPosX, lastCursorPosY;

View File

@ -699,7 +699,12 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
// User trying to access application menu using ALT? // User trying to access application menu using ALT?
case SC_KEYMENU: case SC_KEYMENU:
return 0; {
if (!window->win32.keymenu)
return 0;
break;
}
} }
break; break;
} }
@ -731,6 +736,10 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
} }
_glfwInputChar(window, (unsigned int) wParam, getKeyMods(), plain); _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), plain);
if (uMsg == WM_SYSCHAR && window->win32.keymenu)
break;
return 0; return 0;
} }
@ -1275,6 +1284,7 @@ static int createNativeWindow(_GLFWwindow* window,
} }
window->win32.scaleToMonitor = wndconfig->scaleToMonitor; window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
window->win32.keymenu = wndconfig->win32.keymenu;
// Adjust window rect to account for DPI scaling of the window frame and // Adjust window rect to account for DPI scaling of the window frame and
// (if enabled) DPI scaling of the content area // (if enabled) DPI scaling of the content area

View File

@ -363,6 +363,9 @@ GLFWAPI void glfwWindowHint(int hint, int value)
case GLFW_COCOA_RETINA_FRAMEBUFFER: case GLFW_COCOA_RETINA_FRAMEBUFFER:
_glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE;
return; return;
case GLFW_WIN32_KEYBOARD_MENU:
_glfw.hints.window.win32.keymenu = value ? GLFW_TRUE : GLFW_FALSE;
return;
case GLFW_COCOA_GRAPHICS_SWITCHING: case GLFW_COCOA_GRAPHICS_SWITCHING:
_glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE; _glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
return; return;

View File

@ -101,6 +101,7 @@ int main(int argc, char** argv)
monitor = glfwGetPrimaryMonitor(); monitor = glfwGetPrimaryMonitor();
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE);
window = glfwCreateWindow(800, 400, "Gamma Test", NULL, NULL); window = glfwCreateWindow(800, 400, "Gamma Test", NULL, NULL);
if (!window) if (!window)

View File

@ -202,6 +202,7 @@ int main(int argc, char** argv)
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE);
window = glfwCreateWindow(width, height, "Input lag test", monitor, NULL); window = glfwCreateWindow(width, height, "Input lag test", monitor, NULL);
if (!window) if (!window)

View File

@ -182,6 +182,7 @@ int main(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE);
window = glfwCreateWindow(800, 600, "Joystick Test", NULL, NULL); window = glfwCreateWindow(800, 600, "Joystick Test", NULL, NULL);
if (!window) if (!window)

View File

@ -59,6 +59,7 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE);
window = glfwCreateWindow(400, 400, "Opacity", NULL, NULL); window = glfwCreateWindow(400, 400, "Opacity", NULL, NULL);
if (!window) if (!window)