Compare commits
4 commits
main
...
wayland-re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d72bee86f6 | ||
|
|
0c360e6e23 | ||
|
|
b31f471fb4 | ||
|
|
bf291b79cb |
2 changed files with 39 additions and 10 deletions
|
|
@ -24,6 +24,9 @@ windows: mach.Objects(
|
|||
// TODO: allocation/free strategy
|
||||
title: [:0]const u8 = "Mach Window",
|
||||
|
||||
// XDG application ID of the window
|
||||
app_id: [:0]const u8 = "",
|
||||
|
||||
/// Texture format of the framebuffer (read-only)
|
||||
framebuffer_format: gpu.Texture.Format = .bgra8_unorm,
|
||||
|
||||
|
|
|
|||
|
|
@ -173,12 +173,12 @@ pub fn initWindow(
|
|||
return error.ListenerHasAlreadyBeenSet;
|
||||
}
|
||||
|
||||
// Wait for events to get pushed
|
||||
_ = libwaylandclient.?.wl_display_roundtrip(wl.display);
|
||||
|
||||
core_window = core.windows.getValue(window_id);
|
||||
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
|
||||
c.wl_surface_commit(wl.surface);
|
||||
|
||||
|
|
@ -191,8 +191,6 @@ pub fn initWindow(
|
|||
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(
|
||||
wl.interfaces.zxdg_decoration_manager_v1,
|
||||
wl.toplevel,
|
||||
|
|
@ -203,10 +201,16 @@ pub fn initWindow(
|
|||
// Commit changes to 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);
|
||||
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 {
|
||||
|
|
@ -805,15 +809,37 @@ const xdg_surface_listener = struct {
|
|||
var core_window = core_ptr.windows.getValue(window_id);
|
||||
const wl = &core_window.native.?.wayland;
|
||||
|
||||
if (wl.configured) {
|
||||
c.wl_surface_commit(wl.surface);
|
||||
} else {
|
||||
if (!wl.configured) {
|
||||
wl.configured = true;
|
||||
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 });
|
||||
|
||||
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) };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue