Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
.minimum_zig_version = "0.14.0",
.dependencies = .{
.webui = .{
.hash = "webui-2.5.0-beta.4-pxqD5Rb7NwBVEwKyEzxwKAprzUIYjN20Y_Wffl_SWVdg",
.url = "https://github.com/webui-dev/webui/archive/8d7c13895935f821f01d62dfc7e0243a99668925.tar.gz",
.hash = "webui-2.5.0-beta.4-pxqD5a53OADNensyGsjVC_i_ksZ_G1enGSSsVD6p2dgg",
.url = "https://github.com/webui-dev/webui/archive/62bed203df456cb150bc088ed4f1b173526e9776.tar.gz",
},
},
.paths = .{
Expand Down
17 changes: 17 additions & 0 deletions src/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ pub extern fn webui_show_wv(window: usize, content: [*:0]const u8) callconv(.c)
/// @example webui_set_kiosk(my_window, true);
pub extern fn webui_set_kiosk(window: usize, status: bool) callconv(.c) void;

/// @brief Bring a window to the front and focus it.
///
/// @param window The window number
///
/// @example webui_focus(myWindow);
pub extern fn webui_focus(window: usize) callconv(.c) void;

/// @brief Add a user-defined web browser's CLI parameters.
///
/// @param window The window number
Expand Down Expand Up @@ -215,6 +222,16 @@ pub extern fn webui_browser_exist(browser: Browser) callconv(.c) bool;
/// @example webui_wait();
pub extern fn webui_wait() callconv(.c) void;

/// @brief Wait asynchronously until all opened windows get closed.
/// Note: In WebView mode, you need to call this from the main thread.
///
/// @return Returns True if more windows are still opened, False otherwise.
///
/// @example while (webui_wait_async()) {
/// // Your main thread code here
/// }
pub extern fn webui_wait_async() callconv(.c) bool;

/// @brief Close a specific window only. The window object will still exist.
/// All clients.
///
Expand Down
11 changes: 11 additions & 0 deletions src/webui.zig
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ pub fn setKiosk(self: webui, status: bool) void {
c.webui_set_kiosk(self.window_handle, status);
}

/// Bring a window to the front and focus it.
pub fn focus(self: webui) void {
c.webui_focus(self.window_handle);
}

/// Add a user-defined web browser's CLI parameters.
pub fn setCustomParameters(self: webui, params: [:0]const u8) void {
c.webui_set_custom_parameters(self.window_handle, params.ptr);
Expand Down Expand Up @@ -196,6 +201,12 @@ pub fn wait() void {
c.webui_wait();
}

/// Wait asynchronously until all opened windows get closed.
/// Returns `true` while there are still windows open.
pub fn waitAsync() bool {
return c.webui_wait_async();
}

/// Set a custom logger function.
/// The logger callback receives the log level, message, and optional user data.
pub fn setLogger(comptime logger: fn (level: LoggerLevel, log: []const u8, user_data: ?*anyopaque) void, user_data: ?*anyopaque) void {
Expand Down
Loading