From 1f6680b4924354da6ba83bc2ba60fb17a2cc4825 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Wed, 21 Apr 2021 09:51:40 +0200 Subject: [PATCH] Add macos flush specific fix Taken from @mathewmariani lite-macos --- src/api/system.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/api/system.c b/src/api/system.c index 224c6ac3..99180ad8 100644 --- a/src/api/system.c +++ b/src/api/system.c @@ -155,6 +155,16 @@ top: return 2; case SDL_KEYUP: +#ifdef __APPLE__ + /* on macos command+w will close the current window + ** we want to flush this event and let the keymapper + ** handle this key combination. + ** Thanks to mathewmariani, taken from his lite-macos github repository. */ + if ((e.key.keysym.sym == SDLK_w) && (e.key.keysym.mod & KMOD_GUI)) + { + SDL_FlushEvent(SDL_QUIT); + } +#endif lua_pushstring(L, "keyreleased"); lua_pushstring(L, key_name(buf, e.key.keysym.sym)); return 2;