Allow specifying border sizes in either pt or px

Change the default to 1px borders as this works best with the new minimal border style.
This commit is contained in:
Kovid Goyal 2020-08-30 14:17:47 +05:30
parent 31d9f663fc
commit 3d60724651
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 28 additions and 4 deletions

View File

@ -10,6 +10,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- 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)

View File

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

View File

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