river-status: fix crash due to bad alignment
Using an ArrayList to back the wl_array we need to pass to libwayland is much safer and avoids this kind of bug.
This commit is contained in:
parent
c5de1641dc
commit
42f8076cec
@ -57,19 +57,23 @@ fn destroy(wl_client: ?*c.wl_client, wl_resource: ?*c.wl_resource) callconv(.C)
|
|||||||
|
|
||||||
/// Send the current tags of each view on the output to the client.
|
/// Send the current tags of each view on the output to the client.
|
||||||
pub fn sendViewTags(self: Self) void {
|
pub fn sendViewTags(self: Self) void {
|
||||||
var view_tags: c.wl_array = undefined;
|
var view_tags = std.ArrayList(u32).init(util.allocator);
|
||||||
c.wl_array_init(&view_tags);
|
defer view_tags.deinit();
|
||||||
|
|
||||||
var it = ViewStack(View).iterator(self.output.views.first, std.math.maxInt(u32));
|
var it = ViewStack(View).iterator(self.output.views.first, std.math.maxInt(u32));
|
||||||
while (it.next()) |node| {
|
while (it.next()) |node|
|
||||||
const ptr = c.wl_array_add(&view_tags, @sizeOf(u32)) orelse {
|
view_tags.append(node.view.current_tags) catch {
|
||||||
c.wl_resource_post_no_memory(self.wl_resource);
|
c.wl_resource_post_no_memory(self.wl_resource);
|
||||||
Log.Error.log("out of memory", .{});
|
Log.Error.log("out of memory", .{});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
const ptr_u32 = util.voidCast(u32, ptr);
|
|
||||||
ptr_u32.* = node.view.current_tags;
|
var wl_array = c.wl_array{
|
||||||
}
|
.size = view_tags.items.len,
|
||||||
c.zriver_output_status_v1_send_view_tags(self.wl_resource, &view_tags);
|
.alloc = view_tags.capacity,
|
||||||
|
.data = view_tags.items.ptr,
|
||||||
|
};
|
||||||
|
c.zriver_output_status_v1_send_view_tags(self.wl_resource, &wl_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send the currently focused tags of the output to the client.
|
/// Send the currently focused tags of the output to the client.
|
||||||
|
Loading…
Reference in New Issue
Block a user