Draw only the minimum borders needed for inactive windows
Fixes #699 Note that currently this is only implemented by the Tall layout.
This commit is contained in:
parent
18804efb7e
commit
aa12a65a8f
@ -6,6 +6,12 @@ Changelog
|
|||||||
0.11.3 [future]
|
0.11.3 [future]
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
|
- Draw only the minimum borders needed for inactive windows. That is only the borders
|
||||||
|
that separate the inactive window from a neighbor. Note that setting
|
||||||
|
a non-zero window margin overrides this and causes all borders to be drawn.
|
||||||
|
The old behavior of drawing all borders can be restored via the
|
||||||
|
:opt:`draw_minimal_borders` setting in kitty.conf.
|
||||||
|
|
||||||
- macOS: Add an option :opt:`macos_window_resizable` to control if kitty
|
- macOS: Add an option :opt:`macos_window_resizable` to control if kitty
|
||||||
top-level windows are resizable using the mouse or not (:iss:`698`)
|
top-level windows are resizable using the mouse or not (:iss:`698`)
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ from .fast_data_types import (
|
|||||||
set_clipboard_string, set_in_sequence_mode, toggle_fullscreen
|
set_clipboard_string, set_in_sequence_mode, toggle_fullscreen
|
||||||
)
|
)
|
||||||
from .keys import get_shortcut, shortcut_matches
|
from .keys import get_shortcut, shortcut_matches
|
||||||
|
from .layout import set_draw_minimal_borders
|
||||||
from .remote_control import handle_cmd
|
from .remote_control import handle_cmd
|
||||||
from .rgb import Color, color_from_int
|
from .rgb import Color, color_from_int
|
||||||
from .session import create_session
|
from .session import create_session
|
||||||
@ -76,6 +77,7 @@ class DumpCommands: # {{{
|
|||||||
class Boss:
|
class Boss:
|
||||||
|
|
||||||
def __init__(self, os_window_id, opts, args, cached_values, new_os_window_trigger):
|
def __init__(self, os_window_id, opts, args, cached_values, new_os_window_trigger):
|
||||||
|
set_draw_minimal_borders(opts)
|
||||||
self.window_id_map = WeakValueDictionary()
|
self.window_id_map = WeakValueDictionary()
|
||||||
self.startup_colors = {k: opts[k] for k in opts if isinstance(opts[k], Color)}
|
self.startup_colors = {k: opts[k] for k in opts if isinstance(opts[k], Color)}
|
||||||
self.pending_sequences = None
|
self.pending_sequences = None
|
||||||
|
|||||||
@ -449,6 +449,13 @@ 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.
|
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.'''))
|
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
|
||||||
|
needed borders for inactive windows are drawn. That is only the borders
|
||||||
|
that separate the inactive window from a neighbor. Note that setting
|
||||||
|
a non-zero window margin overrides this and causes all borders to be drawn.
|
||||||
|
'''))
|
||||||
|
|
||||||
o('window_margin_width', 0.0, option_type=positive_float, long_text=_('''
|
o('window_margin_width', 0.0, option_type=positive_float, long_text=_('''
|
||||||
The window margin (in pts) (blank area outside the border)'''))
|
The window margin (in pts) (blank area outside the border)'''))
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ central = Region((0, 0, 199, 199, 200, 200))
|
|||||||
cell_width = cell_height = 20
|
cell_width = cell_height = 20
|
||||||
all_borders = True, True, True, True
|
all_borders = True, True, True, True
|
||||||
no_borders = False, False, False, False
|
no_borders = False, False, False, False
|
||||||
|
draw_minimal_borders = False
|
||||||
|
|
||||||
|
|
||||||
def idx_for_id(win_id, windows):
|
def idx_for_id(win_id, windows):
|
||||||
@ -28,6 +29,11 @@ def window_needs_borders(window, active_window):
|
|||||||
return window is active_window or window.needs_attention
|
return window is active_window or window.needs_attention
|
||||||
|
|
||||||
|
|
||||||
|
def set_draw_minimal_borders(opts):
|
||||||
|
global draw_minimal_borders
|
||||||
|
draw_minimal_borders = opts.draw_minimal_borders and opts.window_margin_width == 0
|
||||||
|
|
||||||
|
|
||||||
def layout_dimension(start_at, length, cell_length, decoration_pairs, left_align=False, bias=None):
|
def layout_dimension(start_at, length, cell_length, decoration_pairs, left_align=False, bias=None):
|
||||||
number_of_windows = len(decoration_pairs)
|
number_of_windows = len(decoration_pairs)
|
||||||
number_of_cells = length // cell_length
|
number_of_cells = length // cell_length
|
||||||
@ -367,7 +373,10 @@ class Layout: # {{{
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def resolve_borders(self, windows, active_window):
|
def resolve_borders(self, windows, active_window):
|
||||||
yield from self.do_resolve_borders(windows, active_window)
|
if draw_minimal_borders:
|
||||||
|
yield from self.do_resolve_borders(windows, active_window)
|
||||||
|
else:
|
||||||
|
yield from Layout.do_resolve_borders(self, windows, active_window)
|
||||||
|
|
||||||
def do_resolve_borders(self, windows, active_window):
|
def do_resolve_borders(self, windows, active_window):
|
||||||
for w in windows:
|
for w in windows:
|
||||||
@ -461,6 +470,26 @@ class Tall(Layout): # {{{
|
|||||||
# left bottom blank rect
|
# left bottom blank rect
|
||||||
self.bottom_blank_rect(windows[0])
|
self.bottom_blank_rect(windows[0])
|
||||||
|
|
||||||
|
def do_resolve_borders(self, windows, active_window):
|
||||||
|
only_bottom_border = False, False, False, True
|
||||||
|
last_i = len(windows) - 1
|
||||||
|
for i, w in enumerate(windows):
|
||||||
|
if window_needs_borders(w, active_window):
|
||||||
|
yield all_borders
|
||||||
|
continue
|
||||||
|
if i == 0:
|
||||||
|
if last_i == 1 and window_needs_borders(windows[1], active_window):
|
||||||
|
yield no_borders
|
||||||
|
else:
|
||||||
|
yield False, False, True, False
|
||||||
|
continue
|
||||||
|
if i == last_i:
|
||||||
|
yield no_borders
|
||||||
|
break
|
||||||
|
if active_window is windows[i+1] or windows[i+1].needs_attention:
|
||||||
|
yield no_borders
|
||||||
|
else:
|
||||||
|
yield only_bottom_border
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user