View: move borders state to State struct

This state affects rendering, so it should pass through the transaction
system like the rest.
This commit is contained in:
Isaac Freund 2023-03-01 16:12:27 +01:00
parent c1c72e23a3
commit 50513390ce
No known key found for this signature in database
GPG Key ID: 86DED400DDFD7A11
5 changed files with 9 additions and 10 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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);

View File

@ -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 });
}

View File

@ -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 });
},
}