diff --git a/Makefile b/Makefile index 90a9c87bd..914868d28 100644 --- a/Makefile +++ b/Makefile @@ -1633,59 +1633,6 @@ android-text-input-zi-test: $(ZI2C_BIN) test: android-text-input-zi-test -.PHONY: window-close-host-test -window-close-host-test: $(ZI2C_BIN) - @mkdir -p $(BUILD_DIR)/window-close-host-test/c - @$(ZI2C_BIN) --define PLATFORM_DESKTOP \ - --define NATIVE_WINDOW_HAVE_SDL \ - --entry window_close_behavior:main --root tests \ - --module-path src -o $(BUILD_DIR)/window-close-host-test/c \ - tests/window_close_behavior.zi - @$(CC) -std=c11 -O2 -I$(ZIRAN_DIR)/include \ - -iquote $(BUILD_DIR)/window-close-host-test/c \ - $(BUILD_DIR)/window-close-host-test/c/*.c \ - $(RAY_SDL_LDLIBS) -o $(BUILD_DIR)/window-close-host-test/test - @env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u GDK_DISPLAY \ - $(BUILD_DIR)/window-close-host-test/test - -test: window-close-host-test - -.PHONY: activity-host-test -activity-host-test: $(ZI2C_BIN) - @env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u GDK_DISPLAY \ - DBUS_SESSION_BUS_ADDRESS=invalid: \ - sh tests/activity_host_zi_test.sh $(ZIRAN_BUILD_DIR)/bin - -test: activity-host-test - -.PHONY: audio-picker-host-test -audio-picker-host-test: $(ZI2C_BIN) - @mkdir -p $(BUILD_DIR)/audio-picker-host-test/c - @cp tests/support/audio_picker_zenity.sh \ - $(BUILD_DIR)/audio-picker-host-test/zenity - @chmod +x $(BUILD_DIR)/audio-picker-host-test/zenity - @$(ZI2C_BIN) --no-main --define PLATFORM_DESKTOP --root src \ - --module-path $(ZIRAN_DIR)/std \ - -o $(BUILD_DIR)/audio-picker-host-test/c \ - src/platform/audio_picker_host.zi - @$(CC) -std=c11 -D_DEFAULT_SOURCE -Wall -Wextra -Werror \ - -Wno-unused-function -I$(ZIRAN_DIR)/include \ - -iquote $(BUILD_DIR)/audio-picker-host-test/c \ - tests/audio_picker_host_test.c \ - $(BUILD_DIR)/audio-picker-host-test/c/*.c \ - $(BUILD_DIR)/audio-picker-host-test/c/platform/audio_picker_host.c \ - $(BUILD_DIR)/audio-picker-host-test/c/platform/file_picker.c \ - -o $(BUILD_DIR)/audio-picker-host-test/test - @env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u GDK_DISPLAY \ - PATH="$(abspath $(BUILD_DIR)/audio-picker-host-test)" \ - $(abspath $(BUILD_DIR)/audio-picker-host-test/test) - -.PHONY: file-picker-zi-test -file-picker-zi-test: $(ZI2C_BIN) - @sh tests/file_picker_zi_test.sh $(abspath $(dir $(ZI2C_BIN))) - -test: audio-picker-host-test file-picker-zi-test - .PHONY: main-platform-zi-test main-platform-zi-test: $(ZI2C_BIN) $(RAYLIB_A) @RAY_LDLIBS='$(RAY_LDLIBS)' sh tests/main_platform_zi_test.sh \ @@ -1724,7 +1671,7 @@ raylib-log-host-test: $(ZI2C_BIN) $(RAYLIB_A) @mkdir -p $(BUILD_DIR)/raylib-log-host-test/c @$(ZI2C_BIN) --define PLATFORM_DESKTOP \ --entry raylib_log_behavior:main --root tests \ - --module-path src --module-path $(ZIRAN_DIR)/std \ + --module-path src --module-path $(KRYON_DIR)/src/backend --module-path $(ZIRAN_DIR)/std \ -o $(BUILD_DIR)/raylib-log-host-test/c tests/raylib_log_behavior.zi @$(CC) -std=c11 -O2 -I$(ZIRAN_DIR)/include \ -iquote $(BUILD_DIR)/raylib-log-host-test/c \ diff --git a/src/app/app_sync.zi b/src/app/app_sync.zi index 83cc078f2..c868ddd49 100644 --- a/src/app/app_sync.zi +++ b/src/app/app_sync.zi @@ -6,7 +6,7 @@ c :: #system_library "c"; LOG_INFO :: 3 LOG_WARNING :: 4 LOG_ERROR :: 5 -#import, file "../platform/trace_log.zi"; +#import "raylib_trace" SyncLog :: (level: s32, message: string) { TraceLog(level, message) } diff --git a/src/app/application.zi b/src/app/application.zi index d7f7ee439..28dc84e5d 100644 --- a/src/app/application.zi +++ b/src/app/application.zi @@ -7,6 +7,7 @@ LOG_INFO :: 3 LOG_WARNING :: 4 LOG_ERROR :: 5 #import, file "../platform/trace_log.zi"; +#import "raylib_trace" GetTime :: () -> float64 #foreign c; PackageNow :: () -> s64 #foreign c "now_seconds"; #import, file "modal_rules.zi"; diff --git a/src/app/device_link_session.zi b/src/app/device_link_session.zi index 2cbbd3364..8e09bfe8e 100644 --- a/src/app/device_link_session.zi +++ b/src/app/device_link_session.zi @@ -16,7 +16,7 @@ #import, file "../storage/sync_account.zi"; #import, file "../storage/sync_nodes.zi"; #import, file "../cells/package_files.zi"; -#import, file "../platform/trace_log.zi"; +#import "raylib_trace" c :: #system_library "c"; DeviceLinkClock :: () -> float64 #foreign c "GetTime"; diff --git a/src/breaks/app_breaks.zi b/src/breaks/app_breaks.zi index 573097c8b..f000e145c 100644 --- a/src/breaks/app_breaks.zi +++ b/src/breaks/app_breaks.zi @@ -48,7 +48,7 @@ using NativeWindowFlags; #import, file "../app/app_route_state.zi"; #import, file "../app/app_modal_state.zi"; #import, file "../platform/secondary_window.zi"; -#import, file "../platform/activity.zi"; +#import "idle_time" #import "text_widget" #import "box_widget" #import "box_props" @@ -177,7 +177,7 @@ break_fallback_input_seen :: () -> s32 { } break_sample_activity :: (app: *InnerBreeze, idle_ms_out: *s32) -> s32 { - idle_ms := ActivityGetIdleMilliseconds() + idle_ms := IdleMilliseconds() if idle_ms_out != null { idle_ms_out.* = cast(s32)idle_ms } @@ -227,7 +227,7 @@ break_engine_open_window :: (app: *InnerBreeze, t: s32) { // Wayland intentionally does not permit a global keyboard grab, but // The app-owned secondary window remains available on Wayland, where // a global keyboard grab is not available. - if ActivityIsWayland() { + if IsWaylandSession() { ClearWindowState(cast(u32)128) RestoreWindow() SetWindowFocused() @@ -318,7 +318,7 @@ app_breaks_window_update :: (app: *InnerBreeze) { } unused SetSecondaryWindowKeyboardGrab(break_window, - app.break_block_mode >= 1 && !ActivityIsWayland()) + app.break_block_mode >= 1 && !IsWaylandSession()) if BeginSecondaryWindow(break_window) { main_session := app.ui.session diff --git a/src/main.zi b/src/main.zi index df2696619..c5d6ab86c 100644 --- a/src/main.zi +++ b/src/main.zi @@ -29,7 +29,9 @@ CanvasTexture :: #import "canvas_texture"; using CanvasHost :: #import "canvas_host"; } -#import, file "platform/trace_log.zi"; +#import "raylib_trace" +// The desktop notification host; Android and the browser have their own. +#import "notification_desktop" raylib :: #system_library "raylib"; BeginDrawing :: () #foreign raylib; EndDrawing :: () #foreign raylib; diff --git a/src/platform/activity.zi b/src/platform/activity.zi deleted file mode 100644 index 479f22777..000000000 --- a/src/platform/activity.zi +++ /dev/null @@ -1,12 +0,0 @@ -c :: #system_library "c"; - -activity_idle_host :: () -> s64 #foreign c "app_idle_milliseconds"; -activity_wayland_host :: () -> bool #foreign c "app_is_wayland"; - -// The desktop host asks its session idle service. No display window is -// inspected or controlled by this adapter. -#program_export -ActivityGetIdleMilliseconds :: () -> s64 { return activity_idle_host() } - -#program_export -ActivityIsWayland :: () -> bool { return activity_wayland_host() } diff --git a/src/platform/activity_host.zi b/src/platform/activity_host.zi deleted file mode 100644 index 0f90a9daa..000000000 --- a/src/platform/activity_host.zi +++ /dev/null @@ -1,152 +0,0 @@ -// Desktop session information. This module does not open or manage a display. -#import "c_string" - -c :: #system_library "c"; -ActivityGetEnv :: (name: *u8) -> *u8 #foreign c "getenv"; -ActivityCompare :: (left: *u8, right: *u8) -> s32 #foreign c "strcmp"; - -ACTIVITY_GIO :: #defined(APP_HAVE_GIO) && !#defined(PLATFORM_WEB) && !#defined(ANDROID_BUILD) - -#if ACTIVITY_GIO { - gio :: #system_library "gio-2.0"; - glib :: #system_library "glib-2.0"; - ActivityBusGet :: (bus_type: s32, cancellable: *void, - error: **void) -> *void #foreign gio "g_bus_get_sync"; - ActivityBusCall :: (connection: *void, bus_name: *u8, - object_path: *u8, interface_name: *u8, method_name: *u8, - parameters: *void, reply_type: *void, flags: s32, - timeout_msec: s32, cancellable: *void, - error: **void) -> *void #foreign gio "g_dbus_connection_call_sync"; - ActivityErrorFree :: (error: *void) #foreign glib "g_error_free"; - ActivityVariantUnref :: (value: *void) #foreign glib "g_variant_unref"; - ActivityVariantChildren :: (value: *void) -> usize #foreign glib "g_variant_n_children"; - ActivityVariantChild :: (value: *void, index: usize) -> *void #foreign glib "g_variant_get_child_value"; - ActivityVariantType :: (value: *void) -> *u8 #foreign glib "g_variant_get_type_string"; - ActivityVariantUint64 :: (value: *void) -> u64 #foreign glib "g_variant_get_uint64"; - ActivityVariantUint32 :: (value: *void) -> u32 #foreign glib "g_variant_get_uint32"; - ActivityMonotonicTime :: () -> s64 #foreign glib "g_get_monotonic_time"; - - activity_bus: *void; - activity_backend: s32; - activity_initialized: bool; - activity_last_query: s64; - activity_cached: s64 = -1; -} - -#program_export -app_is_wayland :: () -> bool { - session_name: [24]u8 - display_name: [24]u8 - wayland_name: [16]u8 - if !CopyCString("XDG_SESSION_TYPE", session_name[:]) || - !CopyCString("WAYLAND_DISPLAY", display_name[:]) || - !CopyCString("wayland", wayland_name[:]) { - return false - } - session := ActivityGetEnv(*session_name[0]) - display := ActivityGetEnv(*display_name[0]) - return (session != null && - ActivityCompare(session, *wayland_name[0]) == 0) || - (display != null && display[0] != 0) -} - -#if ACTIVITY_GIO { - ActivityIdleCall :: (name: string, path: string, - interface_name: string, method: string) -> s64 { - if activity_bus == null { - return -1 - } - bus_name: [96]u8 - object_path: [96]u8 - interface_bytes: [96]u8 - method_name: [40]u8 - if !CopyCString(name, bus_name[:]) || - !CopyCString(path, object_path[:]) || - !CopyCString(interface_name, interface_bytes[:]) || - !CopyCString(method, method_name[:]) { - return -1 - } - error: *void - reply := ActivityBusCall(activity_bus, *bus_name[0], - *object_path[0], *interface_bytes[0], *method_name[0], - null, null, 0, 500, null, *error) - if reply == null { - if error != null { - ActivityErrorFree(error) - } - return -1 - } - if ActivityVariantChildren(reply) != 1 { - ActivityVariantUnref(reply) - return -1 - } - value := ActivityVariantChild(reply, 0) - idle: u64 = cast(u64)9223372036854775808 - value_type := ActivityVariantType(value) - if value_type != null { - if value_type[0] == #char "t" && value_type[1] == 0 { - idle = ActivityVariantUint64(value) - } else if value_type[0] == #char "u" && value_type[1] == 0 { - idle = cast(u64)ActivityVariantUint32(value) - } else { - idle = cast(u64)9223372036854775808 - } - } - ActivityVariantUnref(value) - ActivityVariantUnref(reply) - if idle > cast(u64)9223372036854775807 { - return -1 - } - return cast(s64)idle - } - - ActivityIdleInit :: () { - if activity_initialized { - return - } - activity_initialized = true - error: *void - activity_bus = ActivityBusGet(2, null, *error) - if activity_bus == null { - if error != null { - ActivityErrorFree(error) - } - return - } - if ActivityIdleCall("org.gnome.Mutter.IdleMonitor", - "/org/gnome/Mutter/IdleMonitor/Core", - "org.gnome.Mutter.IdleMonitor", "GetIdletime") >= 0 { - activity_backend = 1 - return - } - if ActivityIdleCall("org.freedesktop.ScreenSaver", "/ScreenSaver", - "org.freedesktop.ScreenSaver", "GetSessionIdleTime") >= 0 { - activity_backend = 2 - } - } -} - -#program_export -app_idle_milliseconds :: () -> s64 { - #if ACTIVITY_GIO { - now := ActivityMonotonicTime() - if activity_last_query != 0 && now - activity_last_query < 500000 { - return activity_cached - } - activity_last_query = now - ActivityIdleInit() - if activity_backend == 1 { - activity_cached = ActivityIdleCall("org.gnome.Mutter.IdleMonitor", - "/org/gnome/Mutter/IdleMonitor/Core", - "org.gnome.Mutter.IdleMonitor", "GetIdletime") - } else if activity_backend == 2 { - activity_cached = ActivityIdleCall("org.freedesktop.ScreenSaver", - "/ScreenSaver", "org.freedesktop.ScreenSaver", - "GetSessionIdleTime") - } else { - activity_cached = -1 - } - return activity_cached - } - return -1 -} diff --git a/src/platform/app_host.zi b/src/platform/app_host.zi index 8ebdfbf86..b07673f3e 100644 --- a/src/platform/app_host.zi +++ b/src/platform/app_host.zi @@ -3,7 +3,8 @@ raylib_log :: #system_library "raylib"; LOG_INFO :: 3 LOG_WARNING :: 4 LOG_ERROR :: 5 -#import, file "trace_log.zi"; +#import "raylib_trace" +#import "window_close" SetTraceLogLevel :: (level: s32) #foreign raylib_log; app_getenv_bytes :: (name: *u8) -> *u8 #foreign c; #import, file "../app/app_types.zi"; @@ -109,9 +110,7 @@ HostEnv :: (name: string) -> *u8 { native_limit_allocators :: () #foreign c; native_screenshot_data_root :: () #foreign c; -native_install_trace_log_filter :: () #foreign c; native_apply_desktop_identity :: (app_id: *u8, display_name: *u8) #foreign c; -native_take_window_close :: () -> s32 #foreign c; native_window_environment :: () #foreign c; native_before_window :: () #foreign c; native_after_window :: (icon_path: *u8) -> s32 #foreign c; @@ -172,7 +171,8 @@ Prepare :: (argc: s32, argv: **u8) { config.width = MINI_WINDOW_WIDTH config.height = MINI_WINDOW_HEIGHT } - native_install_trace_log_filter() + RaylibTraceToConsole(RaylibTraceProps.{.android_tag = "InnerBreeze", + .android_note_prefix = "APP PROBE:", .android_note_tag = "InbeStartup"}) if screenshot.active == 0 { // A separate data root identifies a debug desktop profile. #if !#defined(ANDROID_BUILD) && !#defined(PLATFORM_WEB) { @@ -203,7 +203,7 @@ WindowTitle :: () -> string { } TakeWindowCloseRequest :: () -> s32 { - return native_take_window_close() + return ifx WindowCloseTake() then 1 else 0 } InitialWindowSize :: () -> WindowSize { diff --git a/src/platform/audio_picker_host.zi b/src/platform/audio_picker_host.zi deleted file mode 100644 index 22c6b1ed3..000000000 --- a/src/platform/audio_picker_host.zi +++ /dev/null @@ -1,19 +0,0 @@ -// Audio selections use the same owned child-process picker as data files. -#import "file_picker" -#import "c_string" - -#program_export -app_audio_pick_file :: (title: *u8, music: bool, - output: *u8, capacity: s32) -> s32 { - filter: [80]u8 - if music { - if !CopyCString("Audio files | *.ogg *.wav *.qoa *.xm *.mod *.mp3 *.flac *.m4a *.opus", filter[:]) { - return -1 - } - } else { - if !CopyCString("Sound files | *.ogg *.wav *.qoa", filter[:]) { - return -1 - } - } - return PickPosixFile(title, *filter[0], null, false, output, capacity) -} diff --git a/src/platform/file_picker.zi b/src/platform/file_picker.zi deleted file mode 100644 index de1286613..000000000 --- a/src/platform/file_picker.zi +++ /dev/null @@ -1,281 +0,0 @@ -// Run the file picker as a child process, with no shell or display lookup. -#import "c_string" - -#if #defined(_WIN32) { - dialog_library :: #system_library "comdlg32"; - user32 :: #system_library "user32"; - FileDialog :: struct { - size: u32 - owner: *void - instance: *void - filter: *u8 - custom_filter: *u8 - custom_filter_capacity: u32 - filter_index: u32 - file: *u8 - file_capacity: u32 - file_title: *u8 - file_title_capacity: u32 - initial_directory: *u8 - title: *u8 - flags: u32 - file_offset: u16 - extension_offset: u16 - default_extension: *u8 - custom_data: isize - hook: *void - template_name: *u8 - reserved: *void - reserved_word: u32 - flags_extended: u32 - } - OpenFileDialog :: (dialog: *FileDialog) -> s32 #foreign dialog_library "GetOpenFileNameA"; - SaveFileDialog :: (dialog: *FileDialog) -> s32 #foreign dialog_library "GetSaveFileNameA"; - FileDialogError :: () -> u32 #foreign dialog_library "CommDlgExtendedError"; - ActiveWindow :: () -> *void #foreign user32 "GetActiveWindow"; - - PickWindowsFile :: (title: *u8, filter: *u8, - suggested_name: *u8, save: bool, output: *u8, - capacity: s32) -> s32 { - options: [256]u8 - separator: s32 = 0 - while filter[separator] != 0 && filter[separator] != #char "|" { - if separator >= 253 { - return -1 - } - separator += 1 - } - label_length := separator - while label_length > 0 && filter[label_length - 1] == #char " " { - label_length -= 1 - } - if label_length == 0 { - return -1 - } - index: s32 = 0 - while index < label_length { - options[index] = filter[index] - index += 1 - } - index = label_length + 1 - if filter[separator] == 0 { - if index + 5 > 256 { - return -1 - } - options[index] = #char "*" - options[index + 1] = #char "." - options[index + 2] = #char "*" - } - if filter[separator] != 0 { - separator += 1 - while filter[separator] == #char " " { - separator += 1 - } - while filter[separator] != 0 { - if index >= 254 { - return -1 - } - byte := filter[separator] - options[index] = ifx byte == #char " " then #char ";" else byte - index += 1 - separator += 1 - } - } - if save && suggested_name != null { - index = 0 - while index + 1 < capacity && suggested_name[index] != 0 { - output[index] = suggested_name[index] - index += 1 - } - output[index] = 0 - } - dialog: FileDialog - dialog.size = cast(u32)size_of(FileDialog) - dialog.owner = ActiveWindow() - dialog.title = title - dialog.filter = *options[0] - dialog.file = output - dialog.file_capacity = cast(u32)capacity - dialog.flags = 0x800 | 8 | (ifx save then 2 else 0x1000) - accepted := ifx save then SaveFileDialog(*dialog) else OpenFileDialog(*dialog) - if accepted != 0 { - return 1 - } - output[0] = 0 - return ifx FileDialogError() == 0 then 0 else -1 - } -} - -#if #defined(PLATFORM_WEB) { - browser :: #system_library "browser"; - PickBrowserFile :: (title: *u8, filter: *u8, - suggested_name: *u8, save: s32, output: *u8, - capacity: s32) -> s32 #foreign browser "app_pick_file_web"; -} - -#program_export -app_pick_file :: (title: *u8, filter: *u8, suggested_name: *u8, - save: bool, output: *u8, capacity: s32) -> s32 { - if output != null && capacity > 0 { - output[0] = 0 - } - if title == null || filter == null || output == null || capacity < 2 { - return -1 - } - #if #defined(_WIN32) { - return PickWindowsFile(title, filter, suggested_name, save, output, capacity) - } - #if #defined(PLATFORM_WEB) { - return PickBrowserFile(title, filter, suggested_name, - ifx save then 1 else 0, output, capacity) - } - return PickPosixFile(title, filter, suggested_name, save, output, capacity) -} - -PICKER_POSIX :: #defined(PLATFORM_DESKTOP) && !#defined(PLATFORM_WEB) && !#defined(ANDROID_BUILD) && !#defined(_WIN32) && !#defined(KRYON_PLATFORM_PLAN9) - -PickerArgument :: struct { - value: *u8 -} - -#if PICKER_POSIX { - c :: #system_library "c"; - PickerPipe :: (descriptors: *s32) -> s32 #foreign c "pipe"; - PickerFork :: () -> s32 #foreign c "fork"; - PickerClose :: (descriptor: s32) -> s32 #foreign c "close"; - PickerDup :: (old_descriptor: s32, new_descriptor: s32) -> s32 #foreign c "dup2"; - PickerExec :: (file: *u8, arguments: **u8) -> s32 #foreign c "execvp"; - PickerExit :: (status: s32) #foreign c "_exit"; - PickerRead :: (descriptor: s32, buffer: *u8, - capacity: usize) -> s64 #foreign c "read"; - PickerWait :: (pid: s32, status: *s32, - options: s32) -> s32 #foreign c "waitpid"; - #if #defined(__FreeBSD__) || #defined(__APPLE__) { - PickerErrno :: () -> *s32 #foreign c "__error"; - } else { - PickerErrno :: () -> *s32 #foreign c "__errno_location"; - } -} - -PickPosixFile :: (title: *u8, filter: *u8, suggested_name: *u8, - save: bool, output: *u8, capacity: s32) -> s32 { - if output != null && capacity > 0 { - output[0] = 0 - } - #if !PICKER_POSIX { - unused title - unused filter - unused suggested_name - unused save - return -1 - } - #if PICKER_POSIX { - if title == null || filter == null || output == null || capacity < 2 { - return -1 - } - descriptors: [2]s32 - if PickerPipe(*descriptors[0]) != 0 { - return -1 - } - child := PickerFork() - if child < 0 { - PickerClose(descriptors[0]) - PickerClose(descriptors[1]) - return -1 - } - if child == 0 { - PickerClose(descriptors[0]) - if PickerDup(descriptors[1], 1) < 0 { - PickerExit(127) - } - PickerClose(descriptors[1]) - program: [16]u8 - selection: [24]u8 - title_option: [16]u8 - filter_option: [24]u8 - save_option: [16]u8 - overwrite_option: [24]u8 - filename_option: [16]u8 - empty: [1]u8 - if !CopyCString("zenity", program[:]) || - !CopyCString("--file-selection", selection[:]) || - !CopyCString("--title", title_option[:]) || - !CopyCString("--file-filter", filter_option[:]) || - !CopyCString("--save", save_option[:]) || - !CopyCString("--confirm-overwrite", overwrite_option[:]) || - !CopyCString("--filename", filename_option[:]) { - PickerExit(127) - } - arguments: [11]PickerArgument - arguments[0].value = *program[0] - arguments[1].value = *selection[0] - arguments[2].value = *title_option[0] - arguments[3].value = title - arguments[4].value = *filter_option[0] - arguments[5].value = filter - if save { - arguments[6].value = *save_option[0] - arguments[7].value = *overwrite_option[0] - arguments[8].value = *filename_option[0] - arguments[9].value = ifx suggested_name != null then suggested_name else *empty[0] - } - PickerExec(*program[0], cast(**u8)(*arguments[0])) - PickerExit(127) - } - - PickerClose(descriptors[1]) - overflow := false - length: s32 = 0 - chunk: [256]u8 - while true { - count := PickerRead(descriptors[0], *chunk[0], 256) - if count == 0 { - break - } - if count < 0 { - if PickerErrno().* == 4 { - continue - } - overflow = true - break - } - index: s64 = 0 - while index < count { - if length + 1 < capacity { - output[length] = chunk[index] - length += 1 - } else { - overflow = true - } - index += 1 - } - } - PickerClose(descriptors[0]) - status: s32 - while PickerWait(child, *status, 0) < 0 { - if PickerErrno().* != 4 { - output[0] = 0 - return -1 - } - } - if (status & 127) != 0 || ((status >> 8) & 255) == 127 || overflow { - output[0] = 0 - return -1 - } - if ((status >> 8) & 255) != 0 { - output[0] = 0 - return 0 - } - while length > 0 && - (output[length - 1] == #char "\n" || - output[length - 1] == #char "\r") { - length -= 1 - } - output[length] = 0 - if length == 0 { - return -1 - } - return 1 - } - return -1 -} diff --git a/src/platform/main_platform.zi b/src/platform/main_platform.zi index 7e10b0e71..6864bcc33 100644 --- a/src/platform/main_platform.zi +++ b/src/platform/main_platform.zi @@ -1,10 +1,9 @@ // Process setup and effects on the application's own window. #import "c_string" #import "byte_text_linux" -#import "trace_log" -#import "trace_sink" +#import "raylib_trace" #import "device_host" -#import "window_close_host" +#import "window_close" #import "asset_files" #import, file "../app/assets.zi"; @@ -293,7 +292,7 @@ native_window_environment :: () { // Preserve the desktop idle counter used by break reminders. SetProcessEnvironment("SDL_VIDEO_ALLOW_SCREENSAVER", "1") #if #defined(_WIN32) { - InstallWindowsLogger() + unused RaylibTraceToFile("inbe.log") TraceLog(3, "APP: Windows startup") } } @@ -322,11 +321,11 @@ native_after_window :: (icon_path: *u8) -> s32 { #if #defined(_WIN32) && !#defined(ANDROID_BUILD) { dialog: [3072]u8 title: [32]u8 - if StartupErrorMessage(TraceRecentErrors(), dialog[:]) && + if StartupErrorMessage(RaylibTraceRecentErrors(), dialog[:]) && CopyCString("Inner Breeze", title[:]) { ErrorMessage(null, *dialog[0], *title[0], 0x10) } - CloseTraceStreams() + RaylibTraceClose() } return 0 } @@ -335,11 +334,11 @@ native_after_window :: (icon_path: *u8) -> s32 { if window != null { GrabWindow(window, 0) app_device_attach_window(window) - app_window_close_watch(window) + WindowCloseWatch(window) } } #if #defined(_WIN32) && !#defined(ANDROID_BUILD) { - app_window_close_watch(WindowHandle()) + WindowCloseWatch(WindowHandle()) } SetDesktopWindowIcon(icon_path) return 1 @@ -379,8 +378,8 @@ native_after_window :: (icon_path: *u8) -> s32 { #program_export native_platform_shutdown :: () { - app_window_close_shutdown() - CloseTraceStreams() + WindowCloseStop() + RaylibTraceClose() } #program_export diff --git a/src/platform/notification_host.zi b/src/platform/notification_host.zi deleted file mode 100644 index 719ad27ed..000000000 --- a/src/platform/notification_host.zi +++ /dev/null @@ -1,100 +0,0 @@ -// Desktop notification transport for Kryon's platform notification surface. -// The app owns scheduling and message content in app_notifications.zi. -#import "notification" -#import "c_string" - -DESKTOP_NOTIFICATIONS :: #defined(PLATFORM_DESKTOP) -WINDOWS_NOTIFICATIONS :: #defined(_WIN32) - -#if DESKTOP_NOTIFICATIONS && !WINDOWS_NOTIFICATIONS { - c :: #system_library "c"; - raylib :: #system_library "raylib"; - HostNotificationAccess :: (path: *u8, mode: s32) -> s32 #foreign c "access"; - HostNotificationFork :: () -> s32 #foreign c "fork"; - HostNotificationWait :: (pid: s32, status: *s32, - options: s32) -> s32 #foreign c "waitpid"; - HostNotificationExec :: (path: *u8, first: *u8, - args: ..any) -> s32 #foreign c "execl"; - HostNotificationExit :: (status: s32) #foreign c "_exit"; - HostNotificationWindowFocused :: () -> bool #foreign raylib "IsWindowFocused"; -} - -notification_app_name: [128]u8; - -#program_export -NotificationSetAppNameHost :: (name: string) { - if !CopyCString(name, notification_app_name[:]) { - notification_app_name[0] = cast(u8)0 - } -} - -#program_export -NotificationSupportedHost :: () -> bool { - #if DESKTOP_NOTIFICATIONS && !WINDOWS_NOTIFICATIONS { - executable: [32]u8 - if !CopyCString("/usr/bin/notify-send", executable[:]) { - return false - } - return HostNotificationAccess(*executable[0], 1) == 0 - } - return false -} - -#program_export -NotificationAllowedHost :: () -> bool { - return NotificationSupportedHost() -} - -#program_export -NotificationRequestHost :: () -> bool { - return NotificationSupportedHost() -} - -#program_export -NotificationWindowFocusedHost :: () -> bool { - #if DESKTOP_NOTIFICATIONS && !WINDOWS_NOTIFICATIONS { - return HostNotificationWindowFocused() - } - return false -} - -#program_export -NotificationSendHost :: (props: NotificationProps) -> bool { - #if DESKTOP_NOTIFICATIONS && !WINDOWS_NOTIFICATIONS { - if !NotificationSupportedHost() { - return false - } - executable: [32]u8 - app_flag: [4]u8 - title: [256]u8 - body: [2048]u8 - if !CopyCString("/usr/bin/notify-send", executable[:]) || - !CopyCString("-a", app_flag[:]) || - !CopyCString(props.title, title[:]) || - !CopyCString(props.body, body[:]) { - return false - } - parent_pid: s32 = HostNotificationFork() - if parent_pid < 0 { - return false - } - if parent_pid == 0 { - child_pid: s32 = HostNotificationFork() - if child_pid == 0 { - terminator: *u8 = null - HostNotificationExec(*executable[0], *executable[0], - *app_flag[0], *notification_app_name[0], - *title[0], *body[0], terminator) - HostNotificationExit(127) - } - if child_pid < 0 { - HostNotificationExit(1) - } - HostNotificationExit(0) - } - status: s32 = 0 - return HostNotificationWait(parent_pid, *status, 0) == parent_pid && - status == 0 - } - return false -} diff --git a/src/platform/trace_log.zi b/src/platform/trace_log.zi index d98f7b4ff..4d1da165c 100644 --- a/src/platform/trace_log.zi +++ b/src/platform/trace_log.zi @@ -1,27 +1,10 @@ -// Pass borrowed Ziran text to raylib without a C variadic adapter. -#import "byte_text_linux" +// Inner Breeze's formatted log lines, passed to raylib without a C variadic +// adapter. Plain text goes through Kryon's raylib_trace TraceLog. #import "c_string" -raylib_trace :: #system_library "raylib"; +trace_log_raylib :: #system_library "raylib"; HostTraceLog :: (level: s32, format: *u8, - args: ..any) #foreign raylib_trace "TraceLog"; - -TraceLog :: (level: s32, message: string) { - if message.count > 2147483647 { - return - } - format: [8]u8 - empty: [1]u8 = .[0] - if !CopyCString("%.*s", format[:]) { - return - } - data: *u8 = *empty[0] - if message.count > 0 { - descriptor := cast(*TextDescriptor)(*message) - data = descriptor.data - } - HostTraceLog(level, *format[0], cast(s32)message.count, data) -} + args: ..any) #foreign trace_log_raylib "TraceLog"; TraceLogInit :: (level: s32, format_text: string, width: s32, height: s32, embedded: s32) { diff --git a/src/platform/trace_sink.zi b/src/platform/trace_sink.zi deleted file mode 100644 index c3d861ffb..000000000 --- a/src/platform/trace_sink.zi +++ /dev/null @@ -1,271 +0,0 @@ -// Consume raylib's native va_list once, preserving its target ABI. -#import "c_string" -#import "byte_text_linux" - -c :: #system_library "c"; -raylib :: #system_library "raylib"; -TRACE_STRUCT_ARGUMENTS :: #defined(__aarch64__) && !#defined(_WIN32) && !#defined(__APPLE__) -#if TRACE_STRUCT_ARGUMENTS { - TraceArguments :: struct { - stack: *void - general_top: *void - vector_top: *void - general_offset: s32 - vector_offset: s32 - } -} else { - TraceArguments :: struct { - cursor: *void - } -} -#if TRACE_STRUCT_ARGUMENTS { - TraceCallback :: #type (s32, *u8, TraceArguments) -> void #c_call; -} else { - TraceCallback :: #type (s32, *u8, *void) -> void #c_call; -} -SetCallback :: (callback: TraceCallback) #foreign raylib "SetTraceLogCallback"; -SetLogLevel :: (level: s32) #foreign raylib "SetTraceLogLevel"; -GetEnvironment :: (name: *u8) -> *u8 #foreign c "getenv"; -CloseStream :: (stream: *void) -> s32 #foreign c "fclose"; -FlushStream :: (stream: *void) -> s32 #foreign c "fflush"; -#if TRACE_STRUCT_ARGUMENTS { - NativePrintArguments :: (stream: *void, format: *u8, - arguments: TraceArguments) -> s32 #foreign c "vfprintf"; - NativeFormatArguments :: (output: *u8, capacity: usize, format: *u8, - arguments: TraceArguments) -> s32 #foreign c "vsnprintf"; -} else { - NativePrintArguments :: (stream: *void, format: *u8, - arguments: *void) -> s32 #foreign c "vfprintf"; - NativeFormatArguments :: (output: *u8, capacity: usize, format: *u8, - arguments: *void) -> s32 #foreign c "vsnprintf"; -} -PrintArguments :: (stream: *void, format: *u8, arguments: TraceArguments) { - #if TRACE_STRUCT_ARGUMENTS { - NativePrintArguments(stream, format, arguments) - } else { - NativePrintArguments(stream, format, arguments.cursor) - } -} -FormatArguments :: (output: *u8, capacity: usize, format: *u8, - arguments: TraceArguments) { - #if TRACE_STRUCT_ARGUMENTS { - NativeFormatArguments(output, capacity, format, arguments) - } else { - NativeFormatArguments(output, capacity, format, arguments.cursor) - } -} -PrintBytes :: (bytes: *u8, size: usize, count: usize, - stream: *void) -> usize #foreign c "fwrite"; -PrintCharacter :: (character: s32, stream: *void) -> s32 #foreign c "fputc"; -OpenStream :: (path: *u8, mode: *u8) -> *void #foreign c "fopen"; -#if #defined(_WIN32) { - DuplicateDescriptor :: (descriptor: s32) -> s32 #foreign c "_dup"; - DescriptorStream :: (descriptor: s32, mode: *u8) -> *void #foreign c "_fdopen"; - CloseDescriptor :: (descriptor: s32) -> s32 #foreign c "_close"; -} else { - DuplicateDescriptor :: (descriptor: s32) -> s32 #foreign c "dup"; - DescriptorStream :: (descriptor: s32, mode: *u8) -> *void #foreign c "fdopen"; - CloseDescriptor :: (descriptor: s32) -> s32 #foreign c "close"; -} -#if #defined(ANDROID_BUILD) { - android_log :: #system_library "log"; - AndroidWrite :: (priority: s32, tag: *u8, text: *u8) -> s32 #foreign android_log "__android_log_write"; - #if TRACE_STRUCT_ARGUMENTS { - AndroidPrint :: (priority: s32, tag: *u8, format: *u8, - arguments: TraceArguments) -> s32 #foreign android_log "__android_log_vprint"; - } else { - AndroidPrint :: (priority: s32, tag: *u8, format: *u8, - arguments: *void) -> s32 #foreign android_log "__android_log_vprint"; - } -} - -trace_stream: *void; -trace_file: *void; -trace_errors: [2048]u8; -trace_errors_length: s32; - -TraceLevelName :: (level: s32) -> string { - if level == 1 { - return "TRACE" - } - if level == 2 { - return "DEBUG" - } - if level == 4 { - return "WARNING" - } - if level == 5 { - return "ERROR" - } - if level == 6 { - return "FATAL" - } - return "INFO" -} - -TraceStartsWith :: (text: *u8, prefix: string) -> bool { - if text == null { - return false - } - index: s64 = 0 - while index < prefix.count { - if text[index] != prefix[index] { - return false - } - index += 1 - } - return true -} - -TraceWriteText :: (stream: *void, value: string) { - if stream == null || value.count == 0 { - return - } - bytes := cast(*TextDescriptor)(*value) - PrintBytes(bytes.data, 1, cast(usize)value.count, stream) -} - -FilteredTrace :: (level: s32, format: *u8, arguments: TraceArguments) { - if level < 4 && (TraceStartsWith(format, "IMAGE:") || - TraceStartsWith(format, "TEXTURE:") || - TraceStartsWith(format, "TIMER: Target time per frame")) { - return - } - #if #defined(ANDROID_BUILD) { - if level == 3 { - message: [1024]u8 - FormatArguments(*message[0], 1024, format, arguments) - message[1023] = 0 - if TraceStartsWith(*message[0], "APP PROBE:") { - tag: [16]u8 - unused CopyCString("InbeStartup", tag[:]) - unused AndroidWrite(4, *tag[0], *message[0]) - } - return - } - if level >= 4 { - tag: [16]u8 - if CopyCString("InnerBreeze", tag[:]) { - #if TRACE_STRUCT_ARGUMENTS { - AndroidPrint(5, *tag[0], format, arguments) - } else { - AndroidPrint(5, *tag[0], format, arguments.cursor) - } - } - } - return - } - if trace_stream == null { - return - } - TraceWriteText(trace_stream, TraceLevelName(level)) - TraceWriteText(trace_stream, ": ") - PrintArguments(trace_stream, format, arguments) - PrintCharacter(10, trace_stream) - FlushStream(trace_stream) -} - -AppendTraceError :: (text: string) { - index: s64 = 0 - while index < text.count && trace_errors_length < 2047 { - trace_errors[trace_errors_length] = text[index] - trace_errors_length += 1 - index += 1 - } - trace_errors[trace_errors_length] = 0 -} - -WindowsTrace :: (level: s32, format: *u8, arguments: TraceArguments) { - bytes: [1024]u8 - FormatArguments(*bytes[0], 1024, format, arguments) - bytes[1023] = 0 - text := TextFromCString(*bytes[0]) - name := TraceLevelName(level) - if level >= 4 && text.count > 0 { - AppendTraceError("[") - AppendTraceError(name) - AppendTraceError("] ") - AppendTraceError(text) - AppendTraceError("\n") - } - if trace_file != null { - TraceWriteText(trace_file, "[") - TraceWriteText(trace_file, name) - TraceWriteText(trace_file, "] ") - TraceWriteText(trace_file, text) - TraceWriteText(trace_file, "\n") - FlushStream(trace_file) - } -} - -TraceRecentErrors :: () -> string { - return TextFromCString(*trace_errors[0]) -} - -InstallWindowsLogger :: () { - path: [16]u8 - mode: [4]u8 - if !CopyCString("inbe.log", path[:]) || !CopyCString("ab", mode[:]) { - return - } - trace_file = OpenStream(*path[0], *mode[0]) - if trace_file != null { - callback: TraceCallback = WindowsTraceCallback - SetCallback(callback) - } -} - -#program_export -native_install_trace_log_filter :: () { - #if #defined(KRYON_BACKEND_TERMI) { - name: [32]u8 - if CopyCString("APP_TERMI_LOG", name[:]) && - GetEnvironment(*name[0]) == null { - SetLogLevel(7) - return - } - } - #if !#defined(ANDROID_BUILD) { - if trace_stream == null { - mode: [4]u8 - if CopyCString("w", mode[:]) { - descriptor := DuplicateDescriptor(2) - if descriptor >= 0 { - trace_stream = DescriptorStream(descriptor, *mode[0]) - if trace_stream == null { - CloseDescriptor(descriptor) - } - } - } - } - } - callback: TraceCallback = FilteredTraceCallback - SetCallback(callback) -} - -CloseTraceStreams :: () { - if trace_file != null { - CloseStream(trace_file) - trace_file = null - } - if trace_stream != null { - CloseStream(trace_stream) - trace_stream = null - } -} - -#if TRACE_STRUCT_ARGUMENTS { - FilteredTraceCallback :: (level: s32, format: *u8, arguments: TraceArguments) { - FilteredTrace(level, format, arguments) - } - WindowsTraceCallback :: (level: s32, format: *u8, arguments: TraceArguments) { - WindowsTrace(level, format, arguments) - } -} else { - FilteredTraceCallback :: (level: s32, format: *u8, arguments: *void) { - FilteredTrace(level, format, TraceArguments.{arguments}) - } - WindowsTraceCallback :: (level: s32, format: *u8, arguments: *void) { - WindowsTrace(level, format, TraceArguments.{arguments}) - } -} diff --git a/src/platform/window_close_host.h b/src/platform/window_close_host.h deleted file mode 100644 index 3c3186e73..000000000 --- a/src/platform/window_close_host.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef INBE_WINDOW_CLOSE_HOST_H -#define INBE_WINDOW_CLOSE_HOST_H - -/* The caller passes only the window it created through raylib. */ -void app_window_close_watch(void *window); -int native_take_window_close(void); -void app_window_close_shutdown(void); - -#endif diff --git a/src/platform/window_close_host.zi b/src/platform/window_close_host.zi deleted file mode 100644 index 13a778ab6..000000000 --- a/src/platform/window_close_host.zi +++ /dev/null @@ -1,122 +0,0 @@ -// Observe close requests for the app's own window only. -WINDOW_CLOSE_WINDOWS :: #defined(_WIN32) && !#defined(ANDROID_BUILD) -WINDOW_CLOSE_SDL :: #defined(NATIVE_WINDOW_HAVE_SDL) && !#defined(_WIN32) && !#defined(PLATFORM_WEB) && !#defined(ANDROID_BUILD) - -#if WINDOW_CLOSE_WINDOWS { - user32 :: #system_library "user32"; - kernel32 :: #system_library "kernel32"; - atomic :: #system_library "atomic"; - WindowProcedure :: #type (*void, u32, usize, isize) -> isize #c_call; - SetWindowProcedure :: (window: *void, index: s32, - procedure: WindowProcedure) -> isize #foreign user32 "SetWindowLongPtrW"; - CallPreviousProcedure :: (procedure: isize, - window: *void, message: u32, wparam: usize, - lparam: isize) -> isize #foreign user32 "CallWindowProcW"; - WindowSetLastError :: (error: u32) #foreign kernel32 "SetLastError"; - WindowGetLastError :: () -> u32 #foreign kernel32 "GetLastError"; - WindowAtomicExchange :: (value: *s32, replacement: s32, - order: s32) -> s32 #foreign atomic "__atomic_exchange_4"; - - app_close_window: *void; - app_previous_window_proc: isize; - app_close_pending: s32; - - AppWindowCloseProcedure :: (window: *void, message: u32, - wparam: usize, lparam: isize) -> isize { - previous := app_previous_window_proc - if window == app_close_window && message == 0x0010 { - WindowAtomicExchange(*app_close_pending, 1, 4) - return cast(isize)0 - } - if window == app_close_window && message == 0x0082 { - app_close_window = null - app_previous_window_proc = cast(isize)0 - } - return CallPreviousProcedure(previous, window, message, - wparam, lparam) - } -} - -#if WINDOW_CLOSE_SDL { - sdl :: #system_library "SDL2"; - WindowCloseEventFilter :: #type (*void, *void) -> s32 #c_call; - SDLWindowId :: (window: *void) -> u32 #foreign sdl "SDL_GetWindowID"; - SDLAddWatch :: (callback: WindowCloseEventFilter, - userdata: *void) #foreign sdl "SDL_AddEventWatch"; - SDLRemoveWatch :: (callback: WindowCloseEventFilter, - userdata: *void) #foreign sdl "SDL_DelEventWatch"; - SDLAtomicSet :: (value: *s32, replacement: s32) -> s32 #foreign sdl "SDL_AtomicSet"; - - WindowEventHeader :: struct { - event_type: u32 - timestamp: u32 - window_id: u32 - event: u8 - } - app_close_window_id: u32; - app_close_pending: s32; - - AppWindowCloseEvent :: (userdata: *void, event_data: *void) -> s32 { - unused userdata - if event_data != null { - event := cast(*WindowEventHeader)event_data - if event.event_type == 0x200 && event.event == 14 && - event.window_id == app_close_window_id { - SDLAtomicSet(*app_close_pending, 1) - } - } - return 1 - } -} - -#program_export -app_window_close_watch :: (window: *void) { - #if WINDOW_CLOSE_WINDOWS { - if window == null || window == app_close_window { - return - } - WindowSetLastError(0) - procedure: WindowProcedure = AppWindowCloseProcedure - previous := SetWindowProcedure(window, -4, procedure) - if previous == cast(isize)0 && WindowGetLastError() != 0 { - return - } - app_close_window = window - app_previous_window_proc = previous - return - } - #if WINDOW_CLOSE_SDL { - if window == null || app_close_window_id != 0 { - return - } - app_close_window_id = SDLWindowId(window) - if app_close_window_id != 0 { - callback: WindowCloseEventFilter = AppWindowCloseEvent - SDLAddWatch(callback, null) - } - return - } - unused window -} - -#program_export -native_take_window_close :: () -> s32 { - #if WINDOW_CLOSE_WINDOWS { - return WindowAtomicExchange(*app_close_pending, 0, 4) - } - #if WINDOW_CLOSE_SDL { - return SDLAtomicSet(*app_close_pending, 0) - } - return 0 -} - -#program_export -app_window_close_shutdown :: () { - #if WINDOW_CLOSE_SDL { - if app_close_window_id != 0 { - callback: WindowCloseEventFilter = AppWindowCloseEvent - SDLRemoveWatch(callback, null) - app_close_window_id = 0 - } - } -} diff --git a/src/screens/diary_screen.zi b/src/screens/diary_screen.zi index 9a7608d78..185329796 100644 --- a/src/screens/diary_screen.zi +++ b/src/screens/diary_screen.zi @@ -12,7 +12,7 @@ #import, file "../cells/diary_store.zi"; #import, file "../cells/diary_history.zi"; #import, file "../cells/diary_spelling.zi"; -#import, file "../platform/file_picker.zi"; +#import "file_picker" #import, file "../platform/environment.zi"; #import, file "../platform/android/android_import.zi"; #import "layout" @@ -221,12 +221,9 @@ DiaryPhotoPicker :: (app: *InnerBreeze) { if !diary_photo_waiting { app.file_dialog_active = 0; diary_photo_error = true } return } - title: [128]u8 - filter: [128]u8 path: [4096]u8 - unused AppCopyText(LocaleText("diary_attach_photo"), title[:]) - unused AppCopyText("Images | *.png *.jpg *.jpeg *.webp *.gif", filter[:]) - selected := app_pick_file(*title[0], *filter[0], null, false, *path[0], cast(s32)path.count) + selected := PickFile(FilePickerProps.{.title = LocaleText("diary_attach_photo"), + .filter = "Images | *.png *.jpg *.jpeg *.webp *.gif"}, path[:]) app.file_dialog_active = 0 if selected == 1 { DiaryAcceptPhoto(AppTextFromCString(*path[0], cast(s32)path.count)) } if selected < 0 { diary_photo_error = true } diff --git a/src/screens/practice_screen.zi b/src/screens/practice_screen.zi index fff282f22..6255b30ec 100644 --- a/src/screens/practice_screen.zi +++ b/src/screens/practice_screen.zi @@ -1,7 +1,7 @@ c3 :: #system_library "c"; #import "byte_text_linux" IsKeyPressed :: (key: s32) -> bool #foreign c3; -#import, file "../platform/trace_log.zi"; +#import "raylib_trace" KEY_LEFT :: 263; KEY_RIGHT :: 262; KEY_ENTER :: 257; diff --git a/src/screens/settings/settings_audio.zi b/src/screens/settings/settings_audio.zi index 504f74921..104cf26b5 100644 --- a/src/screens/settings/settings_audio.zi +++ b/src/screens/settings/settings_audio.zi @@ -42,11 +42,24 @@ using ButtonEmphasis; using AndroidImportKind; using AndroidImportResult; -settings_audio_log :: #system_library "c"; SETTINGS_AUDIO_LOG_INFO :: 3 #import, file "../../platform/trace_log.zi"; -settings_audio_pick_file :: (title: *u8, music: bool, - output: *u8, capacity: s32) -> s32 #foreign settings_audio_log "app_audio_pick_file"; +#import "file_picker" + +// Linux and BSD desktops choose audio with Kryon's file picker; Android uses +// its own import, and other platforms report that no picker ran. +SettingsAudioPick :: (title: string, music: bool, output: []u8) -> s32 { + #if #defined(_WIN32) || #defined(PLATFORM_WEB) || #defined(ANDROID_BUILD) { + unused title + unused music + return -1 + } + filter := "Sound files | *.ogg *.wav *.qoa" + if music { + filter = "Audio files | *.ogg *.wav *.qoa *.xm *.mod *.mp3 *.flac *.m4a *.opus" + } + return PickFile(FilePickerProps.{.title = title, .filter = filter}, output) +} SettingsAudioDialogOrigin :: struct { active: s32 @@ -416,17 +429,10 @@ settings_audio_start_import :: (app: *InnerBreeze, action: s32, practice: s32) { } return } - title: [128]u8 path: [FS_PATH_MAX]u8 - if !AppCopyText(LocaleText("audio_import_title"), title[:]) { - settings_audio_set_status_error(action, - LocaleText("audio_import_failed")) - return - } settings_audio_dialog_begin(app, action, practice) - selected := settings_audio_pick_file(*title[0], - action == SETTINGS_AUDIO_ACTION_MUSIC, - *path[0], FS_PATH_MAX) + selected := SettingsAudioPick(LocaleText("audio_import_title"), + action == SETTINGS_AUDIO_ACTION_MUSIC, path[:]) unused settings_audio_dialog_finish(app) if selected == 1 { if audio_import_path(app, action, diff --git a/src/screens/settings/settings_data_ui.zi b/src/screens/settings/settings_data_ui.zi index 9ebcf7b95..dfae6ad66 100644 --- a/src/screens/settings/settings_data_ui.zi +++ b/src/screens/settings/settings_data_ui.zi @@ -27,6 +27,7 @@ c :: #system_library "c"; #import, file "settings_status.zi"; #import, file "settings_status_view.zi"; #import "geometry" +#import "file_picker" #import "session" #import "layout" #import "tree" @@ -61,9 +62,6 @@ using AndroidImportResult; app_reload_after_import :: (app: *InnerBreeze, reload_settings: s32) #foreign c; -app_pick_file :: (title: *u8, filter: *u8, - suggested_name: *u8, save: bool, - output: *u8, capacity: s32) -> s32 #foreign c; malloc :: (size: usize) -> *void #foreign c; android_share_bytes :: (data: *u8, size: u64, filename: *u8, mime: *u8, title: *u8) -> s32 #foreign c; @@ -106,15 +104,8 @@ SettingsDataButtonProps :: (label: string, x: s32, y: s32, SettingsDataPick :: (title: string, filter: string, suggested: string, save: bool, output: []u8) -> s32 { - title_bytes: [256]u8 - filter_bytes: [128]u8 - suggested_bytes: [256]u8 - if output.count == 0 || output.count > 2147483647 || - !AppCopyText(title, title_bytes[:]) || - !AppCopyText(filter, filter_bytes[:]) || - !AppCopyText(suggested, suggested_bytes[:]) { return -1 } - return app_pick_file(*title_bytes[0], *filter_bytes[0], - *suggested_bytes[0], save, *output[0], cast(s32)output.count) + return PickFile(FilePickerProps.{.title = title, .filter = filter, + .suggested_name = suggested, .save = save}, output) } SettingsDataExportPath :: (filename: string, output: []u8) -> bool { diff --git a/src/web_host.js b/src/web_host.js index 9315323f4..6280138cb 100644 --- a/src/web_host.js +++ b/src/web_host.js @@ -41,54 +41,6 @@ addToLibrary({ HEAP32[(output + 4) >> 2] = Math.max(1, Math.round(height > 0 ? height : fallbackHeight)); }, - app_pick_file_web__deps: ['$Asyncify', '$FS', '$UTF8ToString', - '$lengthBytesUTF8', '$stringToUTF8'], - app_pick_file_web__async: true, - app_pick_file_web: (title, filter, suggested_name, save, output, capacity) => - Asyncify.handleAsync(async () => { - const titleText = UTF8ToString(title); - const filterText = UTF8ToString(filter); - const path = '/tmp/inbe-file-' + Date.now() + '-' + - Math.random().toString(36).slice(2); - if (capacity < 2 || lengthBytesUTF8(path) + 1 > capacity) { - return -1; - } - let input; - try { - if (save) { - stringToUTF8(path, output, capacity); - return 1; - } - input = document.createElement('input'); - input.type = 'file'; - input.setAttribute('aria-label', titleText); - input.accept = (filterText.match(/[*][.][a-z0-9]+/gi) || []) - .map(value => value.slice(1)).join(','); - input.style.display = 'none'; - document.body.appendChild(input); - const selected = await new Promise(resolve => { - input.addEventListener('change', () => - resolve(input.files && input.files[0] || null), {once: true}); - input.addEventListener('cancel', () => resolve(null), {once: true}); - input.click(); - }); - if (!selected) { - return 0; - } - const bytes = new Uint8Array(await selected.arrayBuffer()); - FS.writeFile(path, bytes); - stringToUTF8(path, output, capacity); - return 1; - } catch (error) { - console.error('Inbe file picker failed:', error); - return -1; - } finally { - if (input) { - input.remove(); - } - } - }), - browser_storage_wait__deps: ['$Asyncify'], browser_storage_wait__async: true, browser_storage_wait: (timeout_ms, log_success) => Asyncify.handleAsync(async () => { diff --git a/tests/activity_host_behavior.zi b/tests/activity_host_behavior.zi deleted file mode 100644 index 98d002d54..000000000 --- a/tests/activity_host_behavior.zi +++ /dev/null @@ -1,41 +0,0 @@ -#import, file "../src/platform/activity_host.zi"; -#import "c_string" - -c :: #system_library "c"; -ActivitySetEnv :: (name: *u8, value: *u8, overwrite: s32) -> s32 #foreign c "setenv"; -ActivityUnsetEnv :: (name: *u8) -> s32 #foreign c "unsetenv"; - -#program_export -main :: () -> s32 { - display_name: [24]u8 - session_name: [24]u8 - x11_name: [8]u8 - wayland_name: [16]u8 - if !CopyCString("WAYLAND_DISPLAY", display_name[:]) || - !CopyCString("XDG_SESSION_TYPE", session_name[:]) || - !CopyCString("x11", x11_name[:]) || - !CopyCString("wayland", wayland_name[:]) { - return 1 - } - if ActivityUnsetEnv(*display_name[0]) != 0 || - ActivitySetEnv(*session_name[0], *x11_name[0], 1) != 0 { - return 2 - } - if app_is_wayland() { - return 3 - } - if ActivitySetEnv(*session_name[0], *wayland_name[0], 1) != 0 { - return 4 - } - if !app_is_wayland() { - return 5 - } - if ActivitySetEnv(*session_name[0], *x11_name[0], 1) != 0 { - return 6 - } - if app_idle_milliseconds() != -1 || - app_idle_milliseconds() != -1 { - return 7 - } - return 0 -} diff --git a/tests/activity_host_zi_test.sh b/tests/activity_host_zi_test.sh deleted file mode 100644 index f9c469ab6..000000000 --- a/tests/activity_host_zi_test.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -set -eu - -root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) -bin=${1:-"$root/build/ziran-toolchain/bin"} -work="$root/build/activity-host-zi-test" -source="$root/tests/activity_host_behavior.zi" -mkdir -p "$work/c" - -gio_define= -gio_libraries= -if pkg-config --exists gio-2.0; then - gio_define="--define APP_HAVE_GIO" - gio_libraries=$(pkg-config --libs gio-2.0) -fi - -# The optional GIO branch is compiled when available. This test never -# connects to a real desktop bus or display. -# shellcheck disable=SC2086 -"$bin/zi2zir" --check-only --define PLATFORM_DESKTOP $gio_define \ - --root "$root/tests" --module-path "$root/src" \ - --module-path "$root/build/packages/ziran/std" "$source" -# shellcheck disable=SC2086 -"$bin/zi2c" --define PLATFORM_DESKTOP $gio_define \ - --entry activity_host_behavior:main --root "$root/tests" \ - --module-path "$root/src" --module-path "$root/build/packages/ziran/std" \ - -o "$work/c" "$source" -# shellcheck disable=SC2086 -"${CC:-cc}" -std=c11 -D_DEFAULT_SOURCE -O2 \ - -I"$root/build/packages/ziran/include" -iquote "$work/c" \ - "$work/c"/*.c $gio_libraries -o "$work/test" -env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u GDK_DISPLAY \ - DBUS_SESSION_BUS_ADDRESS=invalid: "$work/test" -echo "Inbe Ziran desktop activity host test passed" diff --git a/tests/app_chrome_zi_test.sh b/tests/app_chrome_zi_test.sh index 485d79161..cf882a35b 100644 --- a/tests/app_chrome_zi_test.sh +++ b/tests/app_chrome_zi_test.sh @@ -8,26 +8,31 @@ rm -rf "$work/c" mkdir -p "$work/c" "$bin/zi2zir" --check-only --root "$root/src" \ --module-path "$root/build/packages/kryon/src/ui" \ + --module-path "$root/build/packages/kryon/src/backend" \ --module-path "$root/build/packages/ziran/std" \ --module-path "oqs=$root/build/packages/oqs/src" \ "$root/src/app/app_chrome.zi" "$bin/zi2c" --no-main --root "$root/src" \ --module-path "$root/build/packages/kryon/src/ui" \ + --module-path "$root/build/packages/kryon/src/backend" \ --module-path "$root/build/packages/ziran/std" \ --module-path "oqs=$root/build/packages/oqs/src" \ -o "$work/c" "$root/src/app/app_chrome.zi" "$bin/zi2c" --no-main --root "$root/src" \ --module-path "$root/build/packages/kryon/src/ui" \ + --module-path "$root/build/packages/kryon/src/backend" \ --module-path "$root/build/packages/ziran/std" \ --module-path "oqs=$root/build/packages/oqs/src" \ -o "$work/c" "$root/src/app/practice_title_bar.zi" "$bin/zi2c" --no-main --root "$root/src" \ --module-path "$root/build/packages/kryon/src/ui" \ + --module-path "$root/build/packages/kryon/src/backend" \ --module-path "$root/build/packages/ziran/std" \ --module-path "oqs=$root/build/packages/oqs/src" \ -o "$work/c" "$root/src/app/assets.zi" "$bin/zi2c" --no-main --root "$root/src" \ --module-path "$root/build/packages/kryon/src/ui" \ + --module-path "$root/build/packages/kryon/src/backend" \ --module-path "$root/build/packages/ziran/std" \ --module-path "oqs=$root/build/packages/oqs/src" \ -o "$work/c" "$root/src/app/image_dimensions.zi" diff --git a/tests/audio_picker_host_test.c b/tests/audio_picker_host_test.c deleted file mode 100644 index bb999c309..000000000 --- a/tests/audio_picker_host_test.c +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include -#include -#include -#include - -extern int app_audio_pick_file(const uint8_t *title, bool music, - uint8_t *output, int32_t capacity); - -static int -expect_pick(const char *scenario, bool music, int expected, - const char *expected_path, int capacity) -{ - uint8_t path[128]; - memset(path, 0x7f, sizeof(path)); - if(setenv("PICKER_SCENARIO", scenario, 1) != 0) - return 1; - int result = app_audio_pick_file((const uint8_t *)"Choose audio", - music, path, capacity); - if(result != expected) { - fprintf(stderr, "%s: expected result %d, got %d\n", - scenario, expected, result); - return 1; - } - if(expected_path != NULL && strcmp((const char *)path, - expected_path) != 0) { - fprintf(stderr, "%s: unexpected path %s\n", scenario, path); - return 1; - } - if(expected_path == NULL && path[0] != 0) { - fprintf(stderr, "%s: unexpected partial path\n", scenario); - return 1; - } - return 0; -} - -int -main(void) -{ - if(getenv("DISPLAY") != NULL || getenv("WAYLAND_DISPLAY") != NULL) - return 1; - if(expect_pick("music", true, 1, "/tmp/custom song.ogg", 128) != 0) - return 2; - if(expect_pick("sound", false, 1, "/tmp/cue.wav", 128) != 0) - return 3; - if(expect_pick("cancel", true, 0, NULL, 128) != 0) - return 4; - if(expect_pick("unavailable", true, -1, NULL, 128) != 0) - return 5; - if(expect_pick("overflow", true, -1, NULL, 8) != 0) - return 6; - return 0; -} diff --git a/tests/file_picker_behavior.zi b/tests/file_picker_behavior.zi deleted file mode 100644 index 66eb29a78..000000000 --- a/tests/file_picker_behavior.zi +++ /dev/null @@ -1,62 +0,0 @@ -#import "file_picker" -#import "audio_picker_host" -#import "c_string" -#import "byte_text_linux" - -c :: #system_library "c"; -SetEnvironment :: (name: *u8, value: *u8, - overwrite: s32) -> s32 #foreign c "setenv"; - -ExpectSelection :: (scenario: string, save: bool, expected: s32, - path: string, capacity: s32) -> bool { - name: [32]u8 - value: [32]u8 - title: [32]u8 - filter: [64]u8 - suggested: [64]u8 - output: [128]u8 - if !CopyCString("PICKER_SCENARIO", name[:]) || - !CopyCString(scenario, value[:]) || - !CopyCString("Choose data", title[:]) || - !CopyCString("Data files | *.zip *.json", filter[:]) || - !CopyCString("backup ; literal.zip", suggested[:]) { - return false - } - if SetEnvironment(*name[0], *value[0], 1) != 0 { - return false - } - output[0] = 99 - actual := app_pick_file(*title[0], *filter[0], *suggested[0], - save, *output[0], capacity) - return actual == expected && TextFromCString(*output[0]) == path -} - -#program_export -main :: () -> s32 { - if !ExpectSelection("data", false, 1, "/tmp/data file.zip", 128) { - return 1 - } - if !ExpectSelection("save", true, 1, "/tmp/backup ; literal.zip", 128) { - return 2 - } - if !ExpectSelection("cancel", false, 0, "", 128) { - return 3 - } - if !ExpectSelection("unavailable", false, -1, "", 128) { - return 4 - } - if !ExpectSelection("overflow", false, -1, "", 8) { - return 5 - } - if !ExpectSelection("empty", false, -1, "", 128) { - return 6 - } - if !ExpectSelection("signal", false, -1, "", 128) { - return 7 - } - output: [128]u8 - if app_pick_file(null, null, null, false, *output[0], 128) != -1 { - return 8 - } - return 0 -} diff --git a/tests/file_picker_zi_test.sh b/tests/file_picker_zi_test.sh deleted file mode 100644 index 4f652afe0..000000000 --- a/tests/file_picker_zi_test.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -set -eu -root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) -bin=${1:-"$root/build/ziran-toolchain/bin"} -work=$(mktemp -d "$root/build/file-picker-zi.XXXXXX") -trap 'rm -rf "$work"' EXIT HUP INT TERM -cp "$root/tests/support/audio_picker_zenity.sh" "$work/zenity" -chmod +x "$work/zenity" -"$bin/zi2c" --no-main --define PLATFORM_DESKTOP --root "$root/tests" \ - --module-path "$root/src/platform" --module-path "$root/build/packages/ziran/std" \ - -o "$work/c" "$root/tests/file_picker_behavior.zi" -"${CC:-cc}" -std=c11 -D_DEFAULT_SOURCE -O2 -DZIRAN_BOUNDS_CHECK \ - -I"$root/build/packages/ziran/include" -iquote "$work/c" \ - "$work/c"/*.c -o "$work/test" -env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u GDK_DISPLAY \ - PATH="$work" "$work/test" -echo "Inbe Ziran file picker test passed" diff --git a/tests/main_platform_behavior.zi b/tests/main_platform_behavior.zi index 78db92965..0d207a0fd 100644 --- a/tests/main_platform_behavior.zi +++ b/tests/main_platform_behavior.zi @@ -1,6 +1,5 @@ #import "main_platform" -#import "trace_sink" -#import "trace_log" +#import "raylib_trace" #import "byte_text_linux" #import "c_string" @@ -58,7 +57,7 @@ main :: () -> s32 { if text.count < 200 { return 7 } - native_install_trace_log_filter() + RaylibTraceToConsole(RaylibTraceProps.{}) quiet: [32]u8 CopyCString("IMAGE: hidden", quiet[:]) HostTraceLog(3, *quiet[0]) @@ -68,11 +67,13 @@ main :: () -> s32 { return 8 } HostTraceLog(3, *format[0], 42, cast(float64)3.25, *app_id[0]) - InstallWindowsLogger() + if !RaylibTraceToFile("inbe.log") { + return 10 + } TraceLog(5, "WGL test failure") - if TraceRecentErrors() != "[ERROR] WGL test failure\n" { + if RaylibTraceRecentErrors() != "[ERROR] WGL test failure\n" { return 9 } - CloseTraceStreams() + RaylibTraceClose() return 0 } diff --git a/tests/main_platform_zi_test.sh b/tests/main_platform_zi_test.sh index facec257a..5fe22ab5e 100644 --- a/tests/main_platform_zi_test.sh +++ b/tests/main_platform_zi_test.sh @@ -6,7 +6,8 @@ raylib=${2:-"$root/vendor-builds/linux/x86_64/raylib/libraylib.a"} work=$(mktemp -d "$root/build/main-platform-zi.XXXXXX") trap 'rm -rf "$work"' EXIT HUP INT TERM "$bin/zi2c" --no-main --define PLATFORM_DESKTOP --root "$root/tests" \ - --module-path "$root/src/platform" --module-path "$root/build/packages/ziran/std" \ + --module-path "$root/src/platform" --module-path "$root/build/packages/kryon/src/backend" \ + --module-path "$root/build/packages/ziran/std" \ -o "$work/c" "$root/tests/main_platform_behavior.zi" "${CC:-cc}" -std=c11 -O2 -DZIRAN_BOUNDS_CHECK \ -ffunction-sections -fdata-sections -Wl,--gc-sections \ diff --git a/tests/raylib_log_behavior.zi b/tests/raylib_log_behavior.zi index 3370ac700..a68f728c0 100644 --- a/tests/raylib_log_behavior.zi +++ b/tests/raylib_log_behavior.zi @@ -1,4 +1,5 @@ #import, file "../src/platform/trace_log.zi"; +#import "raylib_trace" #program_export main :: () -> s32 { diff --git a/tests/session_results_behavior.zi b/tests/session_results_behavior.zi index 5c3d288d2..0ec222866 100644 --- a/tests/session_results_behavior.zi +++ b/tests/session_results_behavior.zi @@ -14,7 +14,7 @@ #import, file "../src/core/types.zi"; #import, file "../src/app/audio_meter_host.zi"; #import, file "../src/app/music_library_host.zi"; -#import, file "../src/platform/notification_host.zi"; +#import "notification_desktop" #import, file "../src/practices/session_results.zi"; #import, file "../src/practices/meditation/meditation_practice.zi"; #import, file "../src/practices/meditation/meditation_session.zi"; diff --git a/tests/support/audio_picker_zenity.sh b/tests/support/audio_picker_zenity.sh deleted file mode 100644 index ff8c423de..000000000 --- a/tests/support/audio_picker_zenity.sh +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh -filter= -save=false -overwrite=false -filename= -while [ "$#" -gt 0 ]; do - case "$1" in - --file-filter) - shift - filter=$1 - ;; - --save) - save=true - ;; - --confirm-overwrite) - overwrite=true - ;; - --filename) - shift - filename=$1 - ;; - esac - shift -done - -case "$PICKER_SCENARIO" in - data) - test "$filter" = 'Data files | *.zip *.json' || exit 2 - test "$save" = false || exit 2 - printf '%s\r\n' '/tmp/data file.zip' - exit 0 - ;; - save) - test "$save" = true || exit 2 - test "$overwrite" = true || exit 2 - test "$filename" = 'backup ; literal.zip' || exit 2 - printf '%s\n' '/tmp/backup ; literal.zip' - exit 0 - ;; - empty) - printf '\n' - exit 0 - ;; - signal) - kill -TERM "$$" - ;; - music) - case "$filter" in - *'*.mp3'*) printf '%s\n' '/tmp/custom song.ogg'; exit 0 ;; - esac - exit 2 - ;; - sound) - case "$filter" in - *'*.qoa'*) - case "$filter" in - *'*.mp3'*) exit 2 ;; - esac - printf '%s\n' '/tmp/cue.wav' - exit 0 - ;; - esac - exit 2 - ;; - cancel) - exit 1 - ;; - unavailable) - exit 127 - ;; - overflow) - printf '%s\n' '/tmp/a-very-long-audio-file-name-that-exceeds-the-small-test-buffer.ogg' - exit 0 - ;; -esac -exit 2 diff --git a/tests/web_host_test.mjs b/tests/web_host_test.mjs index 0c9a72b3d..c1008351e 100644 --- a/tests/web_host_test.mjs +++ b/tests/web_host_test.mjs @@ -52,59 +52,6 @@ assert.equal(host({}, { window: { location: { protocol: 'chrome-extension:' } }, chrome: { runtime: {} } }).web_extension_host_js(), 1); -async function pickFile(scenario, save = 0, capacity = 256) { - let selectedPath; - let removed = false; - const writes = []; - const callbacks = {}; - const input = { - style: {}, - files: scenario === 'cancel' ? [] : [{ - arrayBuffer: async () => { - if (scenario === 'read-error') { - throw new Error('read failed'); - } - return Uint8Array.from([1, 2, 3]).buffer; - } - }], - setAttribute(name, value) { - assert.equal(name, 'aria-label'); - assert.equal(value, 'Select data'); - }, - addEventListener(name, callback) { callbacks[name] = callback; }, - click() { callbacks[scenario === 'cancel' ? 'cancel' : 'change'](); }, - remove() { removed = true; } - }; - const picker = host({}, { - UTF8ToString: address => address === 1 ? 'Select data' : 'Data | *.zip *.json', - lengthBytesUTF8: value => Buffer.byteLength(value), - stringToUTF8: value => { selectedPath = value; }, - FS: { writeFile: (path, bytes) => { writes.push([path, [...bytes]]); } }, - document: { - createElement: () => input, - body: { appendChild() {} } - } - }); - const result = await picker.app_pick_file_web(1, 2, 0, save, 3, capacity); - return { result, selectedPath, removed, writes, input }; -} -const picked = await pickFile('selected'); -assert.equal(picked.result, 1); -assert.equal(picked.input.accept, '.zip,.json'); -assert.deepEqual(picked.writes, [[picked.selectedPath, [1, 2, 3]]]); -assert.equal(picked.removed, true); -const canceled = await pickFile('cancel'); -assert.equal(canceled.result, 0); -assert.equal(canceled.removed, true); -assert.equal(canceled.writes.length, 0); -const readError = await pickFile('read-error'); -assert.equal(readError.result, -1); -assert.equal(readError.removed, true); -const saved = await pickFile('selected', 1); -assert.equal(saved.result, 1); -assert.match(saved.selectedPath, /^\/tmp\/inbe-file-/); -assert.equal(saved.writes.length, 0); -assert.equal((await pickFile('selected', 0, 2)).result, -1); const measured = new Int32Array(4); host({}, { HEAP32: measured }).browser_viewport_size(640, 480, 0); assert.deepEqual([...measured.slice(0, 2)], [640, 480]); diff --git a/tests/web_storage_bridge_link.zi b/tests/web_storage_bridge_link.zi index c67186f53..ab7480397 100644 --- a/tests/web_storage_bridge_link.zi +++ b/tests/web_storage_bridge_link.zi @@ -1,7 +1,6 @@ #import, file "../src/platform/web_storage.zi"; #import, file "../src/platform/environment.zi"; #import, file "../src/platform/web_bridge.zi"; -#import, file "../src/platform/file_picker.zi"; #program_export Answer :: () -> s32 { @@ -33,17 +32,6 @@ main :: () -> s32 { } #if #defined(PLATFORM_WEB) { expected = 2 - title: [2]u8 = .[65, 0] - filter: [4]u8 = .[42, 46, 42, 0] - output: [256]u8 - if app_pick_file(*title[0], *filter[0], null, true, - *output[0], 256) != 1 { - return 4 - } - path := app_text_from_cstring(*output[0], 256) - if path.count < 15 || path[0:15] != "/tmp/inbe-file-" { - return 5 - } } return ifx PlatformFlags() == expected then 0 else 2 } diff --git a/tests/web_storage_bridge_zi_test.sh b/tests/web_storage_bridge_zi_test.sh index f7ce98130..0d4747001 100644 --- a/tests/web_storage_bridge_zi_test.sh +++ b/tests/web_storage_bridge_zi_test.sh @@ -14,6 +14,7 @@ for platform in desktop android; do fi "$bin/zi2c" --no-main \ --root "$root" --module-path "$root/src" \ + --module-path "$root/build/packages/kryon/src/backend" \ --module-path "$root/build/packages/ziran/std" "$@" \ -o "$work/$platform" "$root/tests/web_storage_bridge_link.zi" \ "$root/src/app/host_services.zi" "$root/src/platform/web_bridge.zi" diff --git a/tests/window_close_behavior.zi b/tests/window_close_behavior.zi deleted file mode 100644 index edce65943..000000000 --- a/tests/window_close_behavior.zi +++ /dev/null @@ -1,30 +0,0 @@ -#import, file "../src/platform/window_close_host.zi"; - -#program_export -main :: () -> s32 { - app_close_window_id = 42 - event: WindowEventHeader - event.event_type = 0x200 - event.window_id = 41 - event.event = 14 - AppWindowCloseEvent(null, cast(*void)(*event)) - if native_take_window_close() != 0 { - return 1 - } - - event.window_id = 42 - event.event = 4 - AppWindowCloseEvent(null, cast(*void)(*event)) - if native_take_window_close() != 0 { - return 2 - } - - event.event = 14 - AppWindowCloseEvent(null, cast(*void)(*event)) - if native_take_window_close() != 1 || - native_take_window_close() != 0 { - return 3 - } - app_close_window_id = 0 - return 0 -}