diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2020-04-02 13:44:24 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2020-04-02 13:44:24 +0200 |
| commit | 57f27f7cc6a232827a774c3f36035d9290f3b6ce (patch) | |
| tree | 4d2fd98b9a989888c77016550c66470dd6679069 /src/view.zig | |
| parent | 26a5aaca69fecbf818d247fc7d838d7482431f20 (diff) | |
| download | river-57f27f7cc6a232827a774c3f36035d9290f3b6ce.tar.gz river-57f27f7cc6a232827a774c3f36035d9290f3b6ce.tar.xz | |
Implement tag assignment
There are a few bugs with this, but the core logic is sound
Diffstat (limited to 'src/view.zig')
| -rw-r--r-- | src/view.zig | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/view.zig b/src/view.zig index 56ee513..8344a8b 100644 --- a/src/view.zig +++ b/src/view.zig @@ -11,16 +11,18 @@ pub const View = struct { mapped: bool, - pub const State = struct { + pub const Box = struct { x: i32, y: i32, width: u32, height: u32, - tags: u32, }; - current_state: State, - pending_state: ?State, + current_box: Box, + pending_box: ?Box, + + current_tags: u32, + pending_tags: ?u32, pending_serial: ?u32, @@ -45,14 +47,16 @@ pub const View = struct { self.mapped = false; - self.current_state = State{ + self.current_box = Box{ .x = 0, .y = 0, .height = 0, .width = 0, - .tags = tags, }; - self.pending_state = null; + self.pending_box = null; + + self.current_tags = tags; + self.pending_tags = null; self.pending_serial = null; @@ -76,20 +80,20 @@ pub const View = struct { } pub fn needsConfigure(self: Self) bool { - if (self.pending_state) |pending_state| { - return pending_state.width != self.current_state.width or - pending_state.height != self.current_state.height; + if (self.pending_box) |pending_box| { + return pending_box.width != self.current_box.width or + pending_box.height != self.current_box.height; } else { return false; } } pub fn configurePending(self: *Self) void { - if (self.pending_state) |pending_state| { + if (self.pending_box) |pending_box| { self.pending_serial = c.wlr_xdg_toplevel_set_size( self.wlr_xdg_surface, - pending_state.width, - pending_state.height, + pending_box.width, + pending_box.height, ); } else { // TODO: log warning @@ -133,11 +137,6 @@ pub const View = struct { view.root.arrange(); } - /// Returns true if the view is shown given the current state of tags - pub fn isVisible(self: Self, tags: u32) bool { - return tags & self.current_state.tags != 0; - } - fn handleUnmap(listener: ?*c.wl_listener, data: ?*c_void) callconv(.C) void { const view = @fieldParentPtr(View, "listen_unmap", listener.?); const root = view.root; @@ -236,11 +235,11 @@ pub const View = struct { // coordinates lx and ly (in output Layout Coordinates). If so, it sets the // surface pointer to that wlr_surface and the sx and sy coordinates to the // coordinates relative to that surface's top-left corner. - const view_sx = lx - @intToFloat(f64, self.current_state.x); - const view_sy = ly - @intToFloat(f64, self.current_state.y); + const view_sx = lx - @intToFloat(f64, self.current_box.x); + const view_sy = ly - @intToFloat(f64, self.current_box.y); // This variable seems to have been unsued in TinyWL - // struct wlr_surface_state *state = &view->xdg_surface->surface->current; + // struct wlr_surface_box *state = &view->xdg_surface->surface->current; var _sx: f64 = undefined; var _sy: f64 = undefined; |
