feat(sdl/egl): detected driver at runtime

This commit is contained in:
André Costa
2026-04-13 11:19:53 +02:00
parent a76707c8bb
commit 17eee2e4e2
2 changed files with 28 additions and 12 deletions
+28 -8
View File
@@ -164,16 +164,36 @@ static void * create_window_cb(void * driver_data, const lv_egl_native_window_pr
SDL_GetWindowWMInfo(lv_sdl_window_get_window(display), &wmInfo);
EGLNativeWindowType native_window;
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
native_window = wmInfo.info.win.window;
#elif defined(SDL_VIDEO_DRIVER_X11)
native_window = wmInfo.info.x11.window;
#elif defined(SDL_VIDEO_DRIVER_WAYLAND)
native_window = wmInfo.info.wl.surface;
const char * driver = SDL_GetCurrentVideoDriver();
if(driver && strcmp(driver, "wayland") == 0) {
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
native_window = (EGLNativeWindowType)wmInfo.info.wl.egl_window;
#else
LV_LOG_ERROR("Unsupported platform for EGL");
return NULL;
LV_LOG_ERROR("SDL built without Wayland support");
return NULL;
#endif
}
else if(driver && strcmp(driver, "x11") == 0) {
#if defined(SDL_VIDEO_DRIVER_X11)
native_window = (EGLNativeWindowType)wmInfo.info.x11.window;
#else
LV_LOG_ERROR("SDL built without X11 support");
return NULL;
#endif
}
else if(driver && strcmp(driver, "windows") == 0) {
#if defined(SDL_VIDEO_DRIVER_WINDOWS)
native_window = (EGLNativeWindowType)wmInfo.info.win.window;
#else
LV_LOG_ERROR("SDL built without Windows support");
return NULL;
#endif
}
else {
LV_LOG_ERROR("Unsupported SDL video driver: (%s)", driver);
return NULL;
}
return (void *)native_window;
}
-4
View File
@@ -60,10 +60,6 @@ static lv_timer_t * event_handler_timer;
lv_display_t * lv_sdl_window_create(int32_t hor_res, int32_t ver_res)
{
if(!inited) {
#if LV_SDL_USE_EGL && defined(SDL_VIDEO_DRIVER_X11)
SDL_SetHintWithPriority("SDL_VIDEODRIVER", "x11", SDL_HINT_OVERRIDE);
SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1");
#endif
SDL_Init(SDL_INIT_VIDEO);
SDL_StartTextInput();
event_handler_timer = lv_timer_create(sdl_event_handler, 5, NULL);