Make DecorationManager a toplevel struct
This commit is contained in:
parent
5dbff2c018
commit
fb766fe09c
3 changed files with 29 additions and 30 deletions
|
@ -1,7 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const c = @import("c.zig");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
const DecorationManager = @import("decoration_manager.zig").DecorationManager;
|
const DecorationManager = @import("decoration_manager.zig");
|
||||||
|
|
||||||
// TODO: this needs to listen for destroy and free nodes from the deco list
|
// TODO: this needs to listen for destroy and free nodes from the deco list
|
||||||
pub const Decoration = struct {
|
pub const Decoration = struct {
|
||||||
|
|
|
@ -1,41 +1,40 @@
|
||||||
|
const Self = @This();
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
const c = @import("c.zig");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
const Decoration = @import("decoration.zig").Decoration;
|
const Decoration = @import("decoration.zig").Decoration;
|
||||||
const Server = @import("server.zig");
|
const Server = @import("server.zig");
|
||||||
|
|
||||||
pub const DecorationManager = struct {
|
server: *Server,
|
||||||
const Self = @This();
|
|
||||||
|
|
||||||
server: *Server,
|
wlr_xdg_decoration_manager: *c.wlr_xdg_decoration_manager_v1,
|
||||||
|
|
||||||
wlr_xdg_decoration_manager: *c.wlr_xdg_decoration_manager_v1,
|
decorations: std.SinglyLinkedList(Decoration),
|
||||||
|
|
||||||
decorations: std.SinglyLinkedList(Decoration),
|
listen_new_toplevel_decoration: c.wl_listener,
|
||||||
|
|
||||||
listen_new_toplevel_decoration: c.wl_listener,
|
pub fn init(self: *Self, server: *Server) !void {
|
||||||
|
self.server = server;
|
||||||
|
self.wlr_xdg_decoration_manager = c.wlr_xdg_decoration_manager_v1_create(server.wl_display) orelse
|
||||||
|
return error.CantCreateWlrXdgDecorationManager;
|
||||||
|
|
||||||
pub fn init(self: *Self, server: *Server) !void {
|
self.listen_new_toplevel_decoration.notify = handleNewToplevelDecoration;
|
||||||
self.server = server;
|
c.wl_signal_add(
|
||||||
self.wlr_xdg_decoration_manager = c.wlr_xdg_decoration_manager_v1_create(server.wl_display) orelse
|
&self.wlr_xdg_decoration_manager.events.new_toplevel_decoration,
|
||||||
return error.CantCreateWlrXdgDecorationManager;
|
&self.listen_new_toplevel_decoration,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
self.listen_new_toplevel_decoration.notify = handleNewToplevelDecoration;
|
fn handleNewToplevelDecoration(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
||||||
c.wl_signal_add(
|
const self = @fieldParentPtr(Self, "listen_new_toplevel_decoration", listener.?);
|
||||||
&self.wlr_xdg_decoration_manager.events.new_toplevel_decoration,
|
const wlr_xdg_toplevel_decoration = @ptrCast(
|
||||||
&self.listen_new_toplevel_decoration,
|
*c.wlr_xdg_toplevel_decoration_v1,
|
||||||
);
|
@alignCast(@alignOf(*c.wlr_xdg_toplevel_decoration_v1), data),
|
||||||
}
|
);
|
||||||
|
|
||||||
fn handleNewToplevelDecoration(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void {
|
const node = self.decorations.allocateNode(self.server.allocator) catch unreachable;
|
||||||
const self = @fieldParentPtr(Self, "listen_new_toplevel_decoration", listener.?);
|
node.data.init(self, wlr_xdg_toplevel_decoration);
|
||||||
const wlr_xdg_toplevel_decoration = @ptrCast(
|
self.decorations.prepend(node);
|
||||||
*c.wlr_xdg_toplevel_decoration_v1,
|
}
|
||||||
@alignCast(@alignOf(*c.wlr_xdg_toplevel_decoration_v1), data),
|
|
||||||
);
|
|
||||||
|
|
||||||
const node = self.decorations.allocateNode(self.server.allocator) catch unreachable;
|
|
||||||
node.data.init(self, wlr_xdg_toplevel_decoration);
|
|
||||||
self.decorations.prepend(node);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ const std = @import("std");
|
||||||
const c = @import("c.zig");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
const Config = @import("config.zig").Config;
|
const Config = @import("config.zig").Config;
|
||||||
const DecorationManager = @import("decoration_manager.zig").DecorationManager;
|
const DecorationManager = @import("decoration_manager.zig");
|
||||||
const InputManager = @import("input_manager.zig").InputManager;
|
const InputManager = @import("input_manager.zig").InputManager;
|
||||||
const Log = @import("log.zig").Log;
|
const Log = @import("log.zig").Log;
|
||||||
const Output = @import("output.zig").Output;
|
const Output = @import("output.zig").Output;
|
||||||
|
|
Loading…
Reference in a new issue