Compare commits
No commits in common. "wayland-resize" and "main" have entirely different histories.
wayland-re
...
main
2 changed files with 10 additions and 39 deletions
|
|
@ -24,9 +24,6 @@ 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,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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,6 +191,8 @@ 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,
|
||||||
|
|
@ -201,16 +203,10 @@ 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 {
|
||||||
|
|
@ -809,37 +805,15 @@ 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) };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue