diff --git a/docs/changelog.rst b/docs/changelog.rst index aa0f834c2..15d41662f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,9 @@ To update |kitty|, :doc:`follow the instructions `. - Improve rendering of borders when using minimal borders. Use less space and does not display a box around active windows. +- Allow specifying border sizes in either pts or pixels. Change the default to + 1px borders as this works best with the new minimal border style. + - Add support for displaying correct colors with non-sRGB PNG files (Adds a dependency on liblcms2) diff --git a/kitty/config_data.py b/kitty/config_data.py index 7457ebe9a..6cc13af71 100644 --- a/kitty/config_data.py +++ b/kitty/config_data.py @@ -670,9 +670,25 @@ for vertical resizing. ''')) o('window_resize_step_lines', 2, option_type=positive_int) -o('window_border_width', 1.0, option_type=positive_float, long_text=_(''' -The width (in pts) of window borders. Will be rounded to the nearest number of pixels based on screen resolution. -Note that borders are displayed only when more than one window is visible. They are meant to separate multiple windows.''')) + +def window_border_width(x: Union[str, int, float]) -> Tuple[float, str]: + unit = 'pt' + if isinstance(x, str): + trailer = x[-2:] + if trailer in ('px', 'pt'): + unit = trailer + val = float(x[:-2]) + else: + val = float(x) + return max(0, val), unit + + +o('window_border_width', '1px', option_type=window_border_width, long_text=_(''' +The width of window borders. Can be either in pixels (px) or pts (pt). Values +in pts will be rounded to the nearest number of pixels based on screen +resolution. If not specified the unit is assumed to be pts. +Note that borders are displayed only when more than one window +is visible. They are meant to separate multiple windows.''')) o('draw_minimal_borders', True, long_text=_(''' Draw only the minimum borders needed. This means that only the minimum diff --git a/kitty/window.py b/kitty/window.py index a631180b0..541ce11f3 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -330,7 +330,12 @@ class Window: self.update_effective_padding() def effective_border(self) -> int: - return pt_to_px(self.opts.window_border_width, self.os_window_id) + val, unit = self.opts.window_border_width + if unit == 'pt': + val = pt_to_px(val, self.os_window_id) + else: + val = round(val) + return int(val) @property def title(self) -> str: