From 6ce3bd1e3051764066dbf83f9ac76c067893b985 Mon Sep 17 00:00:00 2001 From: lixianjing Date: Tue, 18 Apr 2023 17:20:29 +0800 Subject: [PATCH] improve window sdl focus --- docs/changes.md | 1 + src/native_window/native_window_sdl.c | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/changes.md b/docs/changes.md index ee404bad2..5ee9b9ce0 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -2,6 +2,7 @@ 2023/04/18 * 修改离线画布用户自定义函数的宏名字(感谢智明提供补丁) + * 支持SDL点击窗口后自动聚焦(感谢智明提供补丁) 2023/04/15 * 增加cmd_args用于解析命令行参数。 diff --git a/src/native_window/native_window_sdl.c b/src/native_window/native_window_sdl.c index ea394dd4f..d4e5e58f6 100644 --- a/src/native_window/native_window_sdl.c +++ b/src/native_window/native_window_sdl.c @@ -658,6 +658,7 @@ ret_t native_window_sdl_init(bool_t shared, uint32_t w, uint32_t h) { const char* title = system_info()->app_name; SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1"); + SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_AUDIO) != 0) { log_debug("Failed to initialize SDL: %s", SDL_GetError()); exit(0);