From e89591f3c0c9d792c6c138eb6d858acb041a841b Mon Sep 17 00:00:00 2001 From: Alberto Mardegan Date: Fri, 19 Jan 2024 22:55:28 +0300 Subject: [PATCH] ogc: always give focus to the window We support only one window and that should receive the focus. Failing to do this breaks the delivering of Joystick and GameController events, unless the SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS hints is set (which is not, by default). Some backends do this in CreateWindow(), some in ShowWindow(). In our case it doesn't really make a difference, but ShowWindow() sounds more correct. --- src/video/ogc/SDL_ogcvideo.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/video/ogc/SDL_ogcvideo.c b/src/video/ogc/SDL_ogcvideo.c index 0aaa6fdd42cae..85de13439b0ef 100644 --- a/src/video/ogc/SDL_ogcvideo.c +++ b/src/video/ogc/SDL_ogcvideo.c @@ -47,6 +47,12 @@ static int OGC_VideoInit(_THIS); static void OGC_VideoQuit(_THIS); +static void OGC_ShowWindow(_THIS, SDL_Window *window) +{ + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); +} + /* OGC driver bootstrap functions */ static void OGC_DeleteDevice(SDL_VideoDevice *device) @@ -80,6 +86,7 @@ static SDL_VideoDevice *OGC_CreateDevice(void) device->VideoInit = OGC_VideoInit; device->VideoQuit = OGC_VideoQuit; device->PumpEvents = OGC_PumpEvents; + device->ShowWindow = OGC_ShowWindow; device->CreateWindowFramebuffer = SDL_OGC_CreateWindowFramebuffer; device->UpdateWindowFramebuffer = SDL_OGC_UpdateWindowFramebuffer; device->DestroyWindowFramebuffer = SDL_OGC_DestroyWindowFramebuffer;