diff --git a/3rd/SDL/SConscript b/3rd/SDL/SConscript index aa34a55b5..d5bfcafa2 100644 --- a/3rd/SDL/SConscript +++ b/3rd/SDL/SConscript @@ -5,6 +5,9 @@ sources=[] env=DefaultEnvironment().Clone() OS_NAME=platform.system() LIB_DIR=os.environ['LIB_DIR']; + +SDL_FLAGS = ' -DSDL_REAL_API -DSDL_HAPTIC_DISABLED -DSDL_SENSOR_DISABLED -DSDL_JOYSTICK_DISABLED ' + if OS_NAME == 'Windows': CPPPATH=['include','src', 'src/video/khronos'] sources=Glob('src/atomic/*.c')+\ @@ -87,7 +90,6 @@ elif OS_NAME == 'Linux': Glob('src/loadso/dlopen//*.c')+\ Glob('src/audio/dummy/*.c')+\ Glob('src/audio/sndio/*.c')+\ - Glob('src/video/x11/*.c')+\ Glob('src/video/dummy/*.c')+\ Glob('src/audio/alsa/*.c')+\ Glob('src/core/linux/*.c')+\ @@ -98,7 +100,26 @@ elif OS_NAME == 'Linux': Glob('src/core/unix/*.c')+\ Glob('src/main/dummy/*.c') -CCFLAGS=os.environ['CCFLAGS']; + SDL_FLAGS += ' -DSDL_TIMER_UNIX -DSDL_AUDIO_DRIVER_SNDIO -DSDL_LOADSO_DLOPEN ' + SDL_FLAGS += ' -DSDL_VIDEO_OPENGL_EGL -DSDL_VIDEO_OPENGL_ES2 ' + + SDL_VIDEODRIVER=os.getenv('SDL_VIDEODRIVER'); + if SDL_VIDEODRIVER is None: + SDL_VIDEODRIVER = 'x11' + + if SDL_VIDEODRIVER == 'x11' or SDL_VIDEODRIVER == 'wayland': + sources += Glob('src/video/'+SDL_VIDEODRIVER+'/*.c') + else: + SDL_VIDEODRIVER = 'x11' + sources += Glob('src/video/'+SDL_VIDEODRIVER+'/*.c') + + if SDL_VIDEODRIVER == 'x11': + SDL_FLAGS += ' -DSDL_VIDEO_DRIVER_X11 -DSDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS ' + SDL_FLAGS += ' -DSDL_VIDEO_OPENGL_GLX -DSDL_VIDEO_RENDER_OGL ' + elif SDL_VIDEODRIVER == 'wayland': + SDL_FLAGS = SDL_FLAGS + ' -DSDL_VIDEO_DRIVER_WAYLAND -DWITHOUT_NATIVE_FILE_DIALOG ' + +CCFLAGS=os.environ['CCFLAGS'] + SDL_FLAGS; CCFLAGS = CCFLAGS + ' -DSDL_STATIC_LIB -D__FLTUSED__ ' if OS_NAME == 'Linux': diff --git a/3rd/nativefiledialog/SConscript b/3rd/nativefiledialog/SConscript index 170a255a2..92ee04a5d 100644 --- a/3rd/nativefiledialog/SConscript +++ b/3rd/nativefiledialog/SConscript @@ -39,5 +39,6 @@ elif OS_NAME == 'Darwin': CCFLAGS=os.environ['CCFLAGS']; CCFLAGS = CCFLAGS + ' -DSDL_STATIC_LIB -D__FLTUSED__ ' -env.Library(os.path.join(LIB_DIR, 'nfd'), sources, CPPPATH = CPPPATH, CCFLAGS = CCFLAGS) +if os.getenv('SDL_VIDEODRIVER') is None: + env.Library(os.path.join(LIB_DIR, 'nfd'), sources, CPPPATH = CPPPATH, CCFLAGS = CCFLAGS) diff --git a/awtk_config.py b/awtk_config.py index b26f3e2a1..55db49a20 100644 --- a/awtk_config.py +++ b/awtk_config.py @@ -26,8 +26,12 @@ WIN32_AWTK_RES = complie_helper.get_value('WIN32_RES', WIN32_AWTK_RES) if not os.path.isabs(WIN32_AWTK_RES) : WIN32_AWTK_RES = os.path.join(compile_config.get_curr_app_root(), WIN32_AWTK_RES) -AWTK_STATIC_LIBS = ['awtk_global', 'fscript_ext_widgets', 'extwidgets', 'nfd', +AWTK_STATIC_LIBS = ['awtk_global', 'fscript_ext_widgets', 'extwidgets', 'widgets', 'base', 'gpinyin', 'fribidi', 'linebreak', 'svgtiny'] + +if os.getenv('SDL_VIDEODRIVER') is None: + AWTK_STATIC_LIBS += ['nfd'] + AWTK_STATIC_LIBS = AWTK_STATIC_LIBS+TKC_STATIC_LIBS # INPUT_ENGINE='null' diff --git a/awtk_config_common.py b/awtk_config_common.py index 32c79c9e7..c01789218 100644 --- a/awtk_config_common.py +++ b/awtk_config_common.py @@ -120,16 +120,10 @@ if OS_NAME == 'Darwin': elif OS_NAME == 'Linux': TOOLS_NAME = '' OS_FLAGS = ' -Wall -Wno-unused-function -fPIC ' - OS_LIBS = ['GL', 'gtk-3', 'gdk-3', 'glib-2.0', 'gobject-2.0', 'Xext', 'X11', - 'sndio', 'stdc++', 'asound', 'pthread', 'm', 'dl'] + OS_LIBS = ['sndio', 'stdc++', 'asound', 'pthread', 'm', 'dl'] COMMON_CFLAGS = COMMON_CFLAGS+' -std=gnu99 ' OS_FLAGS = OS_FLAGS + ' -DLINUX -DHAS_PTHREAD' - OS_FLAGS = OS_FLAGS + ' -DSDL_TIMER_UNIX -DSDL_VIDEO_DRIVER_X11 -DSDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS ' - OS_FLAGS = OS_FLAGS + \ - ' -DSDL_AUDIO_DRIVER_SNDIO -DSDL_VIDEO_OPENGL_GLX -DSDL_VIDEO_RENDER_OGL ' - OS_FLAGS = OS_FLAGS + ' -DSDL_LOADSO_DLOPEN -DSDL_VIDEO_OPENGL_EGL -DSDL_VIDEO_OPENGL_ES2 ' - OS_FLAGS = OS_FLAGS + \ - ' -DSDL_REAL_API -DSDL_HAPTIC_DISABLED -DSDL_SENSOR_DISABLED -DSDL_JOYSTICK_DISABLED ' + OS_PROJECTS = ['3rd/SDL/SConscript'] if TARGET_ARCH == 'x86': OS_FLAGS = OS_FLAGS + ' -U__FLT_EVAL_METHOD__ -D__FLT_EVAL_METHOD__=0 ' @@ -140,6 +134,16 @@ elif OS_NAME == 'Linux': if is_raspberrypi(): OS_FLAGS = OS_FLAGS + ' -DRASPBERRYPI ' os.environ['RASPBERRYPI'] = 'true' + + SDL_VIDEODRIVER=os.getenv('SDL_VIDEODRIVER'); + if SDL_VIDEODRIVER is None: + SDL_VIDEODRIVER = 'x11' + + if SDL_VIDEODRIVER == 'wayland': + OS_LIBS = ['GL', 'xkbcommon', 'wayland-cursor', 'wayland-egl', 'wayland-client'] + OS_LIBS; + OS_FLAGS += '-DWITHOUT_NATIVE_FILE_DIALOG ' + else: + OS_LIBS = ['GL', 'gtk-3', 'gdk-3', 'glib-2.0', 'gobject-2.0', 'Xext', 'X11'] + OS_LIBS; elif OS_NAME == 'Windows': @@ -175,8 +179,6 @@ elif OS_NAME == 'Windows': OS_FLAGS = OS_FLAGS+' -U__FLT_EVAL_METHOD__ -D__FLT_EVAL_METHOD__=0 -DDECLSPEC= ' #OS_FLAGS='-DWIN32 -D_WIN32 -DWINDOWS /EHsc -D_CONSOLE /DEBUG /Od /FS /Z7 -D_DEBUG /MDd ' - OS_FLAGS = OS_FLAGS + \ - ' -DSDL_REAL_API -DSDL_HAPTIC_DISABLED -DSDL_SENSOR_DISABLED -DSDL_JOYSTICK_DISABLED ' OS_FLAGS = OS_FLAGS + '-D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -D_HAS_EXCEPTIONS=0 -D_HAS_ITERATOR_DEBUGGING=0 -D_ITERATOR_DEBUG_LEVEL=0 -D_SCL_SECURE=0' OS_FLAGS = OS_FLAGS + \ '-D_SECURE_SCL=0 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE ' diff --git a/docs/changes.md b/docs/changes.md index 8fe092bf0..f8974ce16 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,5 +1,8 @@ # 最新动态 +2024/10/20 + * [如何使用 wayland 作为 SDL 的 Video Driver](how_to_use_wayland_as_sdl_video_driver.md) + 2024/10/18 * 程序结束时自动释放事件注册名称(感谢兆坤提供补丁) diff --git a/docs/how_to_use_wayland_as_sdl_video_driver.md b/docs/how_to_use_wayland_as_sdl_video_driver.md new file mode 100644 index 000000000..12adce58b --- /dev/null +++ b/docs/how_to_use_wayland_as_sdl_video_driver.md @@ -0,0 +1,45 @@ +# 如何使用 wayland 作为 SDL 的 Video Driver + +在 Linux 平台,默认使用 x11 作为 SDL 的 Video Driver。如果想使用 wayland,可以按下列步骤: + + +## 编译 + +``` +SDL_VIDEODRIVER=wayland scons +``` + +## 运行 + +``` +./bin/demoui +``` + +> 以下可选 + +## 使用 weston + +* 安装 weston + +``` +sudo apt install weson +sudo apt install libwayland-dev libegl1-mesa libgles2-mesa +``` + +* 运行 weston + +``` +weston --socket=wayland-1 +``` + +* 运行程序 + +``` +export WAYLAND_DISPLAY=wayland-1 +``` + +``` +./bin/demoui +``` + + diff --git a/src/ext_widgets/file_browser/file_dialog.c b/src/ext_widgets/file_browser/file_dialog.c index bac274a70..72bcd5d61 100644 --- a/src/ext_widgets/file_browser/file_dialog.c +++ b/src/ext_widgets/file_browser/file_dialog.c @@ -22,9 +22,11 @@ #include "awtk.h" #include "ext_widgets/file_browser/file_chooser.h" +#ifndef WITHOUT_NATIVE_FILE_DIALOG #if defined(WITH_SDL) && (!defined(LINUX_FB) && !defined(ANDROID) && !defined(IOS)) #define WITH_NATIVE_FILE_DIALOG 1 #endif /*WITH_SDL*/ +#endif/*WITHOUT_NATIVE_FILE_DIALOG*/ #ifdef WITH_NATIVE_FILE_DIALOG #include "../3rd/nativefiledialog/src/include/nfd.h"