Fix border/margin/padding sizes not being recalculated on DPI change
Fixes #2346 Fixes #2347
This commit is contained in:
parent
53f7eebc4d
commit
c1abb7038d
@ -28,6 +28,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
- Fix a bug that prevented using custom functions with the new marks feature
|
||||
(:iss:`2344`)
|
||||
|
||||
- Fix border/margin/padding sizes not being recalculated on DPI change
|
||||
(:iss:`2346`)
|
||||
|
||||
|
||||
0.16.0 [2020-01-28]
|
||||
--------------------
|
||||
|
||||
@ -48,11 +48,9 @@ def load_borders_program():
|
||||
|
||||
class Borders:
|
||||
|
||||
def __init__(self, os_window_id, tab_id, opts, border_width, padding_width):
|
||||
def __init__(self, os_window_id, tab_id, opts):
|
||||
self.os_window_id = os_window_id
|
||||
self.tab_id = tab_id
|
||||
self.border_width = border_width
|
||||
self.padding_width = padding_width
|
||||
self.draw_active_borders = opts.active_border_color is not None
|
||||
|
||||
def __call__(
|
||||
@ -61,6 +59,8 @@ class Borders:
|
||||
active_window,
|
||||
current_layout,
|
||||
extra_blank_rects,
|
||||
padding_width,
|
||||
border_width,
|
||||
draw_window_borders=True,
|
||||
):
|
||||
add_borders_rect(self.os_window_id, self.tab_id, 0, 0, 0, 0, BorderColor.default_bg)
|
||||
@ -68,7 +68,7 @@ class Borders:
|
||||
if not has_background_image:
|
||||
for br in chain(current_layout.blank_rects, extra_blank_rects):
|
||||
add_borders_rect(self.os_window_id, self.tab_id, *br, BorderColor.default_bg)
|
||||
bw, pw = self.border_width, self.padding_width
|
||||
bw, pw = border_width, padding_width
|
||||
if bw + pw <= 0:
|
||||
return
|
||||
draw_borders = bw > 0 and draw_window_borders
|
||||
|
||||
@ -484,6 +484,7 @@ class Boss:
|
||||
sz = os_window_font_size(os_window_id)
|
||||
if sz:
|
||||
os_window_font_size(os_window_id, sz, True)
|
||||
tm.update_dpi_based_sizes()
|
||||
tm.resize()
|
||||
|
||||
def _set_os_window_background_opacity(self, os_window_id, opacity):
|
||||
|
||||
@ -180,6 +180,12 @@ class Layout: # {{{
|
||||
self.full_name = self.name + ((':' + layout_opts) if layout_opts else '')
|
||||
self.remove_all_biases()
|
||||
|
||||
def update_sizes(self, margin_width, single_window_margin_width, padding_width, border_width):
|
||||
self.border_width = border_width
|
||||
self.margin_width = margin_width
|
||||
self.single_window_margin_width = single_window_margin_width
|
||||
self.padding_width = padding_width
|
||||
|
||||
def bias_increment_for_cell(self, is_horizontal):
|
||||
self._set_dimensions()
|
||||
if is_horizontal:
|
||||
|
||||
@ -46,12 +46,10 @@ class Tab: # {{{
|
||||
if not self.id:
|
||||
raise Exception('No OS window with id {} found, or tab counter has wrapped'.format(self.os_window_id))
|
||||
self.opts, self.args = tab_manager.opts, tab_manager.args
|
||||
self.margin_width, self.padding_width, self.single_window_margin_width = map(
|
||||
lambda x: pt_to_px(getattr(self.opts, x), self.os_window_id), (
|
||||
'window_margin_width', 'window_padding_width', 'single_window_margin_width'))
|
||||
self.recalculate_sizes(update_layout=False)
|
||||
self.name = getattr(session_tab, 'name', '')
|
||||
self.enabled_layouts = [x.lower() for x in getattr(session_tab, 'enabled_layouts', None) or self.opts.enabled_layouts]
|
||||
self.borders = Borders(self.os_window_id, self.id, self.opts, pt_to_px(self.opts.window_border_width, self.os_window_id), self.padding_width)
|
||||
self.borders = Borders(self.os_window_id, self.id, self.opts)
|
||||
self.windows = deque()
|
||||
for i, which in enumerate('first second third fourth fifth sixth seventh eighth ninth tenth'.split()):
|
||||
setattr(self, which + '_window', partial(self.nth_window, num=i))
|
||||
@ -73,6 +71,15 @@ class Tab: # {{{
|
||||
self._set_current_layout(l0)
|
||||
self.startup(session_tab)
|
||||
|
||||
def recalculate_sizes(self, update_layout=True):
|
||||
self.margin_width, self.padding_width, self.single_window_margin_width = map(
|
||||
lambda x: pt_to_px(getattr(self.opts, x), self.os_window_id), (
|
||||
'window_margin_width', 'window_padding_width', 'single_window_margin_width'))
|
||||
self.border_width = pt_to_px(self.opts.window_border_width, self.os_window_id)
|
||||
if update_layout and self.current_layout:
|
||||
self.current_layout.update_sizes(
|
||||
self.margin_width, self.single_window_margin_width, self.padding_width, self.border_width)
|
||||
|
||||
def take_over_from(self, other_tab):
|
||||
self.name, self.cwd = other_tab.name, other_tab.cwd
|
||||
self.enabled_layouts = list(other_tab.enabled_layouts)
|
||||
@ -176,8 +183,12 @@ class Tab: # {{{
|
||||
if tm is not None:
|
||||
visible_windows = [w for w in self.windows if w.is_visible_in_layout]
|
||||
w = self.active_window
|
||||
self.borders(visible_windows, w, self.current_layout,
|
||||
tm.blank_rects, self.current_layout.needs_window_borders and len(visible_windows) > 1)
|
||||
self.borders(
|
||||
windows=visible_windows, active_window=w,
|
||||
current_layout=self.current_layout, extra_blank_rects=tm.blank_rects,
|
||||
padding_width=self.padding_width, border_width=self.border_width,
|
||||
draw_window_borders=self.current_layout.needs_window_borders and len(visible_windows) > 1
|
||||
)
|
||||
if w is not None:
|
||||
w.change_titlebar_color()
|
||||
|
||||
@ -185,7 +196,7 @@ class Tab: # {{{
|
||||
return create_layout_object_for(
|
||||
name, self.os_window_id, self.id, self.margin_width,
|
||||
self.single_window_margin_width, self.padding_width,
|
||||
self.borders.border_width)
|
||||
self.border_width)
|
||||
|
||||
def next_layout(self):
|
||||
if len(self.enabled_layouts) > 1:
|
||||
@ -542,6 +553,10 @@ class TabManager: # {{{
|
||||
def update_tab_bar_data(self):
|
||||
self.tab_bar.update(self.tab_bar_data)
|
||||
|
||||
def update_dpi_based_sizes(self):
|
||||
for tab in self.tabs:
|
||||
tab.recalculate_sizes()
|
||||
|
||||
def resize(self, only_tabs=False):
|
||||
if not only_tabs:
|
||||
if not self.tab_bar_hidden:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user