mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 23:14:55 +02:00
Fix border/margin/padding sizes not being recalculated on DPI change
Fixes #2346 Fixes #2347
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user