diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2020-04-11 14:24:20 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-04-11 14:24:20 +0200 |
| commit | ff833a07d3ffc5916fdfb814f2896e82a97e91d9 (patch) | |
| tree | a2e5e5176e901420787bb67f97707e64908ed133 /src/view.zig | |
| parent | ad8e13df412cc2b6d813644ecdb04c3bc22880ff (diff) | |
| download | river-ff833a07d3ffc5916fdfb814f2896e82a97e91d9.tar.gz river-ff833a07d3ffc5916fdfb814f2896e82a97e91d9.tar.xz | |
Move output specific code out of root
This is in preperation of proper output event handling and eventual
multi output support.
Diffstat (limited to 'src/view.zig')
| -rw-r--r-- | src/view.zig | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/view.zig b/src/view.zig index b8368da..9ff03ec 100644 --- a/src/view.zig +++ b/src/view.zig @@ -2,13 +2,14 @@ const std = @import("std"); const c = @import("c.zig"); const Box = @import("box.zig").Box; +const Output = @import("output.zig").Output; const Root = @import("root.zig").Root; const ViewStack = @import("view_stack.zig").ViewStack; pub const View = struct { const Self = @This(); - root: *Root, + output: *Output, wlr_xdg_surface: *c.wlr_xdg_surface, mapped: bool, @@ -31,8 +32,8 @@ pub const View = struct { // listen_request_move: c.wl_listener, // listen_request_resize: c.wl_listener, - pub fn init(self: *Self, root: *Root, wlr_xdg_surface: *c.wlr_xdg_surface, tags: u32) void { - self.root = root; + pub fn init(self: *Self, output: *Output, wlr_xdg_surface: *c.wlr_xdg_surface, tags: u32) void { + self.output = output; self.wlr_xdg_surface = wlr_xdg_surface; // Inform the xdg toplevel that it is tiled. @@ -85,8 +86,8 @@ pub const View = struct { pub fn configurePending(self: *Self) void { if (self.pending_box) |pending_box| { - const border_width = self.root.server.config.border_width; - const view_padding = self.root.server.config.view_padding; + const border_width = self.output.root.server.config.border_width; + const view_padding = self.output.root.server.config.view_padding; self.pending_serial = c.wlr_xdg_toplevel_set_size( self.wlr_xdg_surface, pending_box.width - border_width * 2 - view_padding * 2, @@ -132,12 +133,12 @@ pub const View = struct { const view = @fieldParentPtr(View, "listen_map", listener.?); view.mapped = true; view.focus(view.wlr_xdg_surface.surface); - view.root.arrange(); + view.output.root.arrange(); } fn handleUnmap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void { const view = @fieldParentPtr(View, "listen_unmap", listener.?); - const root = view.root; + const root = view.output.root; view.mapped = false; if (root.focused_view) |current_focus| { @@ -153,18 +154,18 @@ pub const View = struct { fn handleDestroy(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void { const view = @fieldParentPtr(View, "listen_destroy", listener.?); - const root = view.root; + const output = view.output; const node = @fieldParentPtr(ViewStack.Node, "view", view); - root.views.remove(node); - root.server.allocator.destroy(node); + output.views.remove(node); + output.root.server.allocator.destroy(node); } fn handleCommit(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void { const view = @fieldParentPtr(View, "listen_commit", listener.?); if (view.pending_serial) |s| { if (s == view.wlr_xdg_surface.configure_serial) { - view.root.notifyConfigured(); + view.output.root.notifyConfigured(); view.pending_serial = null; } } @@ -180,7 +181,7 @@ pub const View = struct { // } fn focus(self: *Self, surface: *c.wlr_surface) void { - const root = self.root; + const root = self.output.root; const wlr_seat = root.server.seat.wlr_seat; const prev_surface = wlr_seat.keyboard_state.focused_surface; |
