From 76793045a9639c58119e84a3d25aa63b28137e54 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sun, 13 Mar 2016 10:33:25 -0400 Subject: [PATCH] Only block keyboard events in OS X SDL_PollEvent hook without focus Blocking all events causes issues with window manager controls when the window is not focused - for example, DF doesn't resize certain screen buffers, leading to flickering in OpenGL print modes. --- library/Hooks-darwin.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/Hooks-darwin.cpp b/library/Hooks-darwin.cpp index 3e020f9be..81ed828bc 100644 --- a/library/Hooks-darwin.cpp +++ b/library/Hooks-darwin.cpp @@ -47,6 +47,7 @@ typedef struct interpose_s #include "DFHack.h" #include "Core.h" #include "Hooks.h" +#include "SDL_events.h" #include /*static const interpose_t interposers[] __attribute__ ((section("__DATA, __interpose"))) = @@ -105,7 +106,8 @@ DFhackCExport int DFH_SDL_PollEvent(SDL::Event* event) pollevent_again: // if SDL returns 0 here, it means there are no more events. return 0 int orig_return = SDL_PollEvent(event); - if(!orig_return || !(SDL_GetAppState() & SDL_APPINPUTFOCUS)) + if(!orig_return || (!(SDL_GetAppState() & SDL_APPINPUTFOCUS) && + (event->type == SDL::ET_KEYDOWN || event->type == SDL::ET_KEYUP))) return 0; // otherwise we have an event to filter else if( event != 0 )