Skip to content

Commit d06b198

Browse files
Merge pull request #747 from foxnne/transparent_option
App: Add option to start with transparent flag, currently only affect…
2 parents 0519d24 + 0d42c6c commit d06b198

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/App.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ pub const StartOptions = struct {
8585
icon: ?[]const u8 = null,
8686
/// use when running tests
8787
hidden: bool = false,
88+
/// Set the window to be transparent
89+
transparent: bool = false,
8890
/// Will be passed to `dvui.Window.init`
8991
///
9092
/// Options like `keybinds` should be used with care as it will

src/backends/sdl.zig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub const InitOptions = struct {
6262
/// use when running tests
6363
hidden: bool = false,
6464
fullscreen: bool = false,
65+
transparent: bool = false,
6566
};
6667

6768
pub fn initWindow(options: InitOptions) !SDLBackend {
@@ -99,12 +100,13 @@ pub fn initWindow(options: InitOptions) !SDLBackend {
99100

100101
const hidden_flag = if (hidden) c.SDL_WINDOW_HIDDEN else 0;
101102
const fullscreen_flag = if (options.fullscreen) c.SDL_WINDOW_FULLSCREEN else 0;
103+
const transparent_flag = if (options.transparent and sdl3) c.SDL_WINDOW_TRANSPARENT else 0;
102104
const window: *c.SDL_Window = if (sdl3)
103105
c.SDL_CreateWindow(
104106
options.title,
105107
@as(c_int, @intFromFloat(options.size.w)),
106108
@as(c_int, @intFromFloat(options.size.h)),
107-
@intCast(c.SDL_WINDOW_HIGH_PIXEL_DENSITY | c.SDL_WINDOW_RESIZABLE | c.SDL_WINDOW_TRANSPARENT | hidden_flag | fullscreen_flag),
109+
@intCast(c.SDL_WINDOW_HIGH_PIXEL_DENSITY | c.SDL_WINDOW_RESIZABLE | transparent_flag | hidden_flag | fullscreen_flag),
108110
) orelse return logErr("SDL_CreateWindow in initWindow")
109111
else
110112
c.SDL_CreateWindow(
@@ -1563,6 +1565,7 @@ pub fn main() !u8 {
15631565
.title = init_opts.title,
15641566
.icon = init_opts.icon,
15651567
.hidden = init_opts.hidden,
1568+
.transparent = init_opts.transparent,
15661569
});
15671570
defer back.deinit();
15681571

@@ -1665,6 +1668,7 @@ fn appInit(appstate: ?*?*anyopaque, argc: c_int, argv: ?[*:null]?[*:0]u8) callco
16651668
.title = init_opts.title,
16661669
.icon = init_opts.icon,
16671670
.hidden = init_opts.hidden,
1671+
.transparent = init_opts.transparent,
16681672
}) catch |err| {
16691673
log.err("initWindow failed: {any}", .{err});
16701674
return c.SDL_APP_FAILURE;

0 commit comments

Comments
 (0)