commit 34ba8008e57bbdc58349c087f8cea249cf8ade36
Author: Jonathan Dowland <jon+github@alcopop.org>
AuthorDate: Fri Apr 8 23:59:52 2016 +0100
Commit: Jonathan Dowland <jon+github@alcopop.org>
CommitDate: Sun Apr 10 09:46:18 2016 +0100
vary fullscreen keyboard shortcut by platform
On Windows, the common idiom for fullscreen mode in applications is
alt+enter. On Mac, there is less consensus but it seems to be often
command+enter (see e.g. iTerm). I'm not sure there's any consensus
on other platforms.
Use alt+enter by default for all platforms but additionally support
command+enter on Mac OS X.
---
src/i_video.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/i_video.c b/src/i_video.c
index cc7c8331..d64a078f 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -318,6 +318,15 @@ static void HandleWindowEvent(SDL_WindowEvent *event)
}
}
+static boolean ToggleFullScreenKeyShortcut(SDL_Keysym *sym)
+{
+ Uint16 flags = (KMOD_LALT | KMOD_RALT);
+#if defined(__MACOSX__)
+ flags |= (KMOD_LGUI | KMOD_RGUI);
+#endif
+ return (sym->scancode == SDL_SCANCODE_RETURN && sym->mod & flags);
+}
+
static void I_ToggleFullScreen(void)
{
Uint32 flags = SDL_GetWindowFlags(screen) & SDL_WINDOW_FULLSCREEN_DESKTOP;
@@ -337,8 +346,7 @@ void I_GetEvent(void)
switch (sdlevent.type)
{
case SDL_KEYDOWN:
- if (sdlevent.key.keysym.scancode == SDL_SCANCODE_RETURN &&
- sdlevent.key.keysym.mod & (KMOD_LGUI | KMOD_RGUI))
+ if (ToggleFullScreenKeyShortcut(&sdlevent.key.keysym))
{
I_ToggleFullScreen();
break;