From 9f06e74353b88b8c3acf0c27d9691cc39e0b6a1e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 10 Aug 2024 10:34:12 -0700 Subject: [PATCH] config: add window-padding-color=extend-always to force always --- src/config/Config.zig | 3 +++ src/renderer/Metal.zig | 29 +++++++++++++++++++++++++---- src/renderer/OpenGL.zig | 32 ++++++++++++++++++++++++-------- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/config/Config.zig b/src/config/Config.zig index 2e22d805a..29d496027 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -701,6 +701,8 @@ keybind: Keybinds = .{}, /// /// * `background` - The background color specified in `background`. /// * `extend` - Extend the background color of the nearest grid cell. +/// * `extend-always` - Same as "extend" but always extends without applying +/// any of the heuristics that disable extending noted below. /// /// The "extend" value will be disabled in certain scenarios. On primary /// screen applications (i.e. not something like Neovim), the color will not @@ -2729,6 +2731,7 @@ pub const OptionAsAlt = enum { pub const WindowPaddingColor = enum { background, extend, + @"extend-always", }; /// Color represents a color using RGB. diff --git a/src/renderer/Metal.zig b/src/renderer/Metal.zig index d22ab1cc3..b9f9cc93c 100644 --- a/src/renderer/Metal.zig +++ b/src/renderer/Metal.zig @@ -1964,7 +1964,14 @@ pub fn setScreenSize( padding_extend.right = true; }, - else => { + .@"extend-always" => { + padding_extend.up = true; + padding_extend.down = true; + padding_extend.left = true; + padding_extend.right = true; + }, + + .background => { // Otherwise, disable all padding extension. padding_extend = .{}; }, @@ -2146,10 +2153,20 @@ fn rebuildCells( // We also reset our padding extension depending on the screen type switch (self.config.padding_color) { .background => {}, + .extend => { self.uniforms.padding_extend.up = screen_type == .alternate; self.uniforms.padding_extend.down = screen_type == .alternate; }, + + .@"extend-always" => { + self.uniforms.padding_extend = .{ + .up = true, + .down = true, + .left = true, + .right = true, + }; + }, } } @@ -2187,12 +2204,16 @@ fn rebuildCells( // under certain conditions we feel are safe. This helps make some // scenarios look better while avoiding scenarios we know do NOT look // good. - if (self.config.padding_color == .extend) { - if (y == 0 and screen_type == .primary) { + switch (self.config.padding_color) { + // These already have the correct values set above. + .background, .@"extend-always" => {}, + + // Apply heuristics for padding extension. + .extend => if (y == 0 and screen_type == .primary) { self.uniforms.padding_extend.up = !row.neverExtendBg(); } else if (y == self.cells.size.rows - 1 and screen_type == .primary) { self.uniforms.padding_extend.down = !row.neverExtendBg(); - } + }, } // Split our row into runs and shape each one. diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index cb0d294c8..e35850874 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -169,7 +169,7 @@ const SetScreenSize = struct { // clear color. .background => .{}, - .extend => self.size.blankPadding(padding, grid_size, .{ + .extend, .@"extend-always" => self.size.blankPadding(padding, grid_size, .{ .width = r.grid_metrics.cell_width, .height = r.grid_metrics.cell_height, }).add(padding), @@ -1213,9 +1213,19 @@ pub fn rebuildCells( var cursor_cell: ?CellProgram.Cell = null; if (rebuild) { - // We also reset our padding extension depending on the screen type - self.padding_extend_top = screen_type == .alternate; - self.padding_extend_bottom = screen_type == .alternate; + switch (self.config.padding_color) { + .background => {}, + + .extend => { + self.padding_extend_top = screen_type == .alternate; + self.padding_extend_bottom = screen_type == .alternate; + }, + + .@"extend-always" => { + self.padding_extend_top = true; + self.padding_extend_bottom = true; + }, + } } // Build each cell @@ -1268,10 +1278,16 @@ pub fn rebuildCells( // under certain conditions we feel are safe. This helps make some // scenarios look better while avoiding scenarios we know do NOT look // good. - if (y == 0 and screen_type == .primary) { - self.padding_extend_top = !row.neverExtendBg(); - } else if (y == self.grid_size.rows - 1 and screen_type == .primary) { - self.padding_extend_bottom = !row.neverExtendBg(); + switch (self.config.padding_color) { + // These already have the correct values set above. + .background, .@"extend-always" => {}, + + // Apply heuristics for padding extension. + .extend => if (y == 0 and screen_type == .primary) { + self.padding_extend_top = !row.neverExtendBg(); + } else if (y == self.grid_size.rows - 1 and screen_type == .primary) { + self.padding_extend_bottom = !row.neverExtendBg(); + }, } // Split our row into runs and shape each one.