glfw: add Window.requestAttention
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
aaa7747e18
commit
477240681b
1 changed files with 36 additions and 0 deletions
|
@ -734,6 +734,26 @@ pub inline fn focus(self: Window) Error!void {
|
|||
try getError();
|
||||
}
|
||||
|
||||
/// Requests user attention to the specified window.
|
||||
///
|
||||
/// This function requests user attention to the specified window. On platforms where this is not
|
||||
/// supported, attention is requested to the application as a whole.
|
||||
///
|
||||
/// Once the user has given attention, usually by focusing the window or application, the system will end the request automatically.
|
||||
///
|
||||
/// Possible errors include glfw.Error.NotInitialized and glfw.Error.PlatformError.
|
||||
///
|
||||
/// macos: Attention is requested to the application as a whole, not the
|
||||
/// specific window.
|
||||
///
|
||||
/// @thread_safety This function must only be called from the main thread.
|
||||
///
|
||||
/// see also: window_attention
|
||||
pub inline fn requestAttention(self: Window) Error!void {
|
||||
c.glfwRequestWindowAttention(self.handle);
|
||||
try getError();
|
||||
}
|
||||
|
||||
test "defaultHints" {
|
||||
const glfw = @import("main.zig");
|
||||
try glfw.init();
|
||||
|
@ -1096,3 +1116,19 @@ test "focus" {
|
|||
|
||||
_ = window.focus() catch |err| std.debug.print("can't focus window, wayland maybe? error={}\n", .{err});
|
||||
}
|
||||
|
||||
test "requestAttention" {
|
||||
const glfw = @import("main.zig");
|
||||
try glfw.init();
|
||||
defer glfw.terminate();
|
||||
|
||||
const window = glfw.Window.create(640, 480, "Hello, Zig!", null, null) catch |err| {
|
||||
// return without fail, because most of our CI environments are headless / we cannot open
|
||||
// windows on them.
|
||||
std.debug.print("note: failed to create window: {}\n", .{err});
|
||||
return;
|
||||
};
|
||||
defer window.destroy();
|
||||
|
||||
_ = window.requestAttention() catch |err| std.debug.print("can't request attention for window, not supported by OS maybe? error={}\n", .{err});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue