diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index d7dbd96ec..dc330c925 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -31,6 +31,7 @@ #if !SDL_EVENTS_DISABLED #include "../events/SDL_events_c.h" #endif +#include "../video/SDL_sysvideo.h" static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE; @@ -582,16 +583,10 @@ SDL_PrivateJoystickShouldIgnoreEvent() return SDL_FALSE; } - if (SDL_WasInit(SDL_INIT_VIDEO)) { - if (SDL_GetKeyboardFocus() == NULL) { - /* Video is initialized and we don't have focus, ignore the event. */ - return SDL_TRUE; - } else { - return SDL_FALSE; - } + if (SDL_HasWindows() && SDL_GetKeyboardFocus() == NULL) { + /* We have windows but we don't have focus, ignore the event. */ + return SDL_TRUE; } - - /* Video subsystem wasn't initialized, always allow the event */ return SDL_FALSE; } diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index d2b8bf9ff..936837897 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -403,6 +403,7 @@ extern void *SDL_GetDisplayDriverData( int displayIndex ); extern void SDL_GL_DeduceMaxSupportedESProfile(int* major, int* minor); extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); +extern SDL_bool SDL_HasWindows(); extern void SDL_OnWindowShown(SDL_Window * window); extern void SDL_OnWindowHidden(SDL_Window * window); diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 564d108c7..2f15ec528 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1606,6 +1606,12 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags) return 0; } +SDL_bool +SDL_HasWindows() +{ + return (_this && _this->windows != NULL); +} + Uint32 SDL_GetWindowID(SDL_Window * window) {