Compare commits

..

4 commits

Author SHA1 Message Date
icefox
d72bee86f6
remove log statements
Some checks failed
CI / x86_64-linux (push) Has been cancelled
CI / x86_64-windows (push) Has been cancelled
CI / x86_64-macos (push) Has been cancelled
2026-01-10 16:38:12 -03:00
icefox
0c360e6e23
Allow setting XDG application ID on wayland
Some checks are pending
CI / x86_64-linux (push) Waiting to run
CI / x86_64-windows (push) Waiting to run
CI / x86_64-macos (push) Waiting to run
2026-01-10 16:32:30 -03:00
icefox
b31f471fb4
call c.xdg_toplevel_set_title before first commit of surface 2026-01-10 16:24:40 -03:00
icefox
bf291b79cb
wip: wayland resize
Some checks are pending
CI / x86_64-linux (push) Waiting to run
CI / x86_64-windows (push) Waiting to run
CI / x86_64-macos (push) Waiting to run
2026-01-10 10:26:37 -03:00
2 changed files with 39 additions and 10 deletions

View file

@ -24,6 +24,9 @@ windows: mach.Objects(
// TODO: allocation/free strategy // TODO: allocation/free strategy
title: [:0]const u8 = "Mach Window", title: [:0]const u8 = "Mach Window",
// XDG application ID of the window
app_id: [:0]const u8 = "",
/// Texture format of the framebuffer (read-only) /// Texture format of the framebuffer (read-only)
framebuffer_format: gpu.Texture.Format = .bgra8_unorm, framebuffer_format: gpu.Texture.Format = .bgra8_unorm,

View file

@ -173,12 +173,12 @@ pub fn initWindow(
return error.ListenerHasAlreadyBeenSet; return error.ListenerHasAlreadyBeenSet;
} }
// Wait for events to get pushed
_ = libwaylandclient.?.wl_display_roundtrip(wl.display);
core_window = core.windows.getValue(window_id); core_window = core.windows.getValue(window_id);
wl = &core_window.native.?.wayland; wl = &core_window.native.?.wayland;
c.xdg_toplevel_set_title(wl.toplevel, @ptrCast(core_window.title));
c.xdg_toplevel_set_app_id(wl.toplevel, @ptrCast(core_window.app_id));
// Commit changes to surface // Commit changes to surface
c.wl_surface_commit(wl.surface); c.wl_surface_commit(wl.surface);
@ -191,8 +191,6 @@ pub fn initWindow(
if (result != -1 and wl.configured) break; if (result != -1 and wl.configured) break;
} }
c.xdg_toplevel_set_title(wl.toplevel, @ptrCast(core_window.title));
const decoration = c.zxdg_decoration_manager_v1_get_toplevel_decoration( const decoration = c.zxdg_decoration_manager_v1_get_toplevel_decoration(
wl.interfaces.zxdg_decoration_manager_v1, wl.interfaces.zxdg_decoration_manager_v1,
wl.toplevel, wl.toplevel,
@ -203,10 +201,16 @@ pub fn initWindow(
// Commit changes to surface // Commit changes to surface
c.wl_surface_commit(wl.surface); c.wl_surface_commit(wl.surface);
_ = libwaylandclient.?.wl_display_roundtrip(wl.display); // _ = libwaylandclient.?.wl_display_roundtrip(wl.display);
// // Wait for events to get pushed
// _ = libwaylandclient.?.wl_display_roundtrip(wl.display);
core.windows.setValue(window_id, core_window); core.windows.setValue(window_id, core_window);
try core.initWindow(window_id); try core.initWindow(window_id);
_ = libwaylandclient.?.wl_display_roundtrip(wl.display);
core_window = core.windows.getValue(window_id);
core.windows.setValue(window_id, core_window);
} }
pub fn tick(window_id: mach.ObjectID) !void { pub fn tick(window_id: mach.ObjectID) !void {
@ -805,15 +809,37 @@ const xdg_surface_listener = struct {
var core_window = core_ptr.windows.getValue(window_id); var core_window = core_ptr.windows.getValue(window_id);
const wl = &core_window.native.?.wayland; const wl = &core_window.native.?.wayland;
if (wl.configured) { if (!wl.configured) {
c.wl_surface_commit(wl.surface);
} else {
wl.configured = true; wl.configured = true;
core_ptr.windows.setValue(window_id, core_window); core_ptr.windows.setValue(window_id, core_window);
core_window = core_ptr.windows.getValue(window_id); // core_window = core_ptr.windows.getValue(window_id);
return;
} }
setContentAreaOpaque(wl, Core.Size{ .width = core_window.width, .height = core_window.height }); setContentAreaOpaque(wl, Core.Size{ .width = core_window.width, .height = core_window.height });
if (core_window.framebuffer_width != core_window.width or core_window.framebuffer_height != core_window.height) {
core_window.framebuffer_width = core_window.width;
core_window.framebuffer_height = core_window.height;
core_window.swap_chain_descriptor.width = core_window.framebuffer_width;
core_window.swap_chain_descriptor.height = core_window.framebuffer_height;
core_window.swap_chain.release();
core_window.swap_chain = core_window.device.createSwapChain(core_window.surface, &core_window.swap_chain_descriptor);
core_ptr.windows.setValueRaw(window_id, core_window);
core_ptr.pushEvent(.{
.window_resize = .{
.window_id = window_id,
.size = .{
.width = core_window.width,
.height = core_window.height,
},
},
});
}
c.wl_surface_commit(wl.surface);
} }
const listener = c.xdg_surface_listener{ .configure = @ptrCast(&xdgSurfaceHandleConfigure) }; const listener = c.xdg_surface_listener{ .configure = @ptrCast(&xdgSurfaceHandleConfigure) };