From 50513390ce4b135785b6731cabcac90add083643 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 1 Mar 2023 16:12:27 +0100 Subject: [PATCH] View: move borders state to State struct This state affects rendering, so it should pass through the transaction system like the rest. --- river/Cursor.zig | 2 +- river/LayoutDemand.zig | 2 +- river/View.zig | 9 ++++----- river/XdgToplevel.zig | 2 +- river/command/filter.zig | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/river/Cursor.zig b/river/Cursor.zig index 829afe7..b6c34b8 100644 --- a/river/Cursor.zig +++ b/river/Cursor.zig @@ -748,7 +748,7 @@ fn processMotion(self: *Self, device: *wlr.InputDevice, time: u32, delta_x: f64, data.delta_x = dx - @trunc(dx); data.delta_y = dy - @trunc(dy); - const border_width = if (data.view.draw_borders) server.config.border_width else 0; + const border_width = if (data.view.pending.borders) server.config.border_width else 0; // Set width/height of view, clamp to view size constraints and output dimensions data.view.pending.box.width += @floatToInt(i32, dx); diff --git a/river/LayoutDemand.zig b/river/LayoutDemand.zig index 6bf637b..a6f8ffa 100644 --- a/river/LayoutDemand.zig +++ b/river/LayoutDemand.zig @@ -132,7 +132,7 @@ pub fn apply(self: *Self, layout: *Layout) void { // Here we apply the offset to align the coords with the origin of the // usable area and shrink the dimensions to accommodate the border size. - const border_width = if (view.draw_borders) server.config.border_width else 0; + const border_width = if (view.inflight.borders) server.config.border_width else 0; view.inflight.box = .{ .x = proposed.x + output.usable_box.x + border_width, .y = proposed.y + output.usable_box.y + border_width, diff --git a/river/View.zig b/river/View.zig index 45d8906..5f78cf3 100644 --- a/river/View.zig +++ b/river/View.zig @@ -65,6 +65,7 @@ const State = struct { float: bool = false, fullscreen: bool = false, urgent: bool = false, + borders: bool = true, }; /// The implementation of this view @@ -106,8 +107,6 @@ float_box: wlr.Box = undefined, /// exiting fullscreen if there is no active layout. post_fullscreen_box: wlr.Box = undefined, -draw_borders: bool = true, - request_activate: wl.Listener(*wlr.XdgActivationV1.event.RequestActivate) = wl.Listener(*wlr.XdgActivationV1.event.RequestActivate).init(handleRequestActivate), @@ -193,7 +192,7 @@ pub fn updateCurrent(view: *Self) void { view.tree.node.setPosition(box.x, box.y); view.popup_tree.node.setPosition(box.x, box.y); - const enable_borders = view.draw_borders and !view.current.fullscreen; + const enable_borders = view.current.borders and !view.current.fullscreen; const border_width: c_int = config.border_width; view.borders.left.node.setEnabled(enable_borders); @@ -303,7 +302,7 @@ pub fn setPendingOutput(view: *Self, output: *Output) void { var output_height: i32 = undefined; output.wlr_output.effectiveResolution(&output_width, &output_height); - const border_width = if (view.draw_borders) server.config.border_width else 0; + const border_width = if (view.pending.borders) server.config.border_width else 0; view.pending.box.width = math.min(view.pending.box.width, output_width - (2 * border_width)); view.pending.box.height = math.min(view.pending.box.height, output_height - (2 * border_width)); @@ -401,7 +400,7 @@ pub fn getConstraints(self: Self) Constraints { /// Modify the pending x/y of the view by the given deltas, clamping to the /// bounds of the output. pub fn move(self: *Self, delta_x: i32, delta_y: i32) void { - const border_width = if (self.draw_borders) server.config.border_width else 0; + const border_width = if (self.pending.borders) server.config.border_width else 0; var output_width: i32 = math.maxInt(i32); var output_height: i32 = math.maxInt(i32); diff --git a/river/XdgToplevel.zig b/river/XdgToplevel.zig index 2435486..0969f80 100644 --- a/river/XdgToplevel.zig +++ b/river/XdgToplevel.zig @@ -196,7 +196,7 @@ fn handleMap(listener: *wl.Listener(void)) void { // If the view has an app_id or title which is not configured to use client // side decorations, inform it that it is tiled. if (server.config.csdAllowed(view)) { - view.draw_borders = false; + view.pending.borders = false; } else { _ = self.xdg_toplevel.setTiled(.{ .top = true, .bottom = true, .left = true, .right = true }); } diff --git a/river/command/filter.zig b/river/command/filter.zig index 88034c8..37d2cd2 100644 --- a/river/command/filter.zig +++ b/river/command/filter.zig @@ -126,12 +126,12 @@ fn csdFilterUpdateViews(kind: FilterKind, pattern: []const u8, operation: enum { switch (operation) { .add => { _ = xdg_toplevel_decoration.setMode(.client_side); - view.draw_borders = false; + view.pending.borders = false; _ = toplevel.setTiled(.{ .top = false, .bottom = false, .left = false, .right = false }); }, .remove => { _ = xdg_toplevel_decoration.setMode(.server_side); - view.draw_borders = true; + view.pending.borders = true; _ = toplevel.setTiled(.{ .top = true, .bottom = true, .left = true, .right = true }); }, }