mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-19 14:45:29 +00:00
Show bell indicator on the active tab when the OS window is unfocused
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
A bell in the active window was never marked as needing attention, even when the OS window did not have keyboard focus, so the tab bar bell symbol was not shown. Now a window needs attention unless it is both active and in the focused OS window. Since the active window can now need attention, also: - Clear needs_attention when the OS window gains focus, as focus_changed() is a no-op if the window became active while the OS window was unfocused, which would leave the indicator stuck. - Use the bell color for minimal borders of an active group needing attention, instead of the active color (or the fallback green when active_border_color is none). Fixes #10880
This commit is contained in:
parent
906627df8a
commit
291af51dfa
9 changed files with 50 additions and 21 deletions
|
|
@ -168,6 +168,9 @@ Detailed list of changes
|
|||
:code:`--base-dir` into account, and file name completion is relative to that
|
||||
directory (:pull:`10851`, :pull:`10852`, :disc:`10867`)
|
||||
|
||||
- Fix the bell indicator not being shown on the tab when a bell occurs in the
|
||||
active window while the OS window does not have keyboard focus (:iss:`10880`)
|
||||
|
||||
- Fix the display not being updated while the OS window is otherwise idle
|
||||
after changes made from timers, such as by a custom tab bar updated from a
|
||||
timer or by actions mapped to mouse clicks (:pull:`10878`)
|
||||
|
|
|
|||
|
|
@ -2187,6 +2187,10 @@ class Boss:
|
|||
w = tm.active_window
|
||||
if w is not None:
|
||||
w.focus_changed(focused)
|
||||
if focused:
|
||||
# focus_changed() is a no-op if the window became active while
|
||||
# the OS window was unfocused, so clear the bell indicator here as well
|
||||
w.clear_needs_attention()
|
||||
if is_macos and focused:
|
||||
cocoa_set_menubar_title(w.title or '')
|
||||
tm.mark_tab_bar_dirty()
|
||||
|
|
|
|||
|
|
@ -910,7 +910,6 @@ class Layout:
|
|||
def dock_borders(self, windows: WindowList) -> Iterator[BorderLine]:
|
||||
"Borders on the inner edges of docked groups, separating them from the content they are docked to"
|
||||
needs_borders_map = windows.compute_needs_borders_map(lgd.draw_active_borders)
|
||||
active_group = windows.active_group
|
||||
for g in windows.iter_dock_groups(only_visible=True):
|
||||
if g.dock is None or (geom := g.geometry) is None or not (bw := g.effective_border()):
|
||||
continue
|
||||
|
|
@ -931,7 +930,7 @@ class Layout:
|
|||
edges, horizontal, wid = Edges(left + margin, top, left + margin + bw, bottom), False, -wid
|
||||
color = BorderColor.inactive
|
||||
if needs_borders_map.get(g.id):
|
||||
color = BorderColor.active if g is active_group else BorderColor.bell
|
||||
color = BorderColor.bell if g.needs_attention else BorderColor.active
|
||||
yield BorderLine(edges, color, wid, horizontal)
|
||||
|
||||
def minimal_borders(self, windows: WindowList) -> Iterator[BorderLine]:
|
||||
|
|
|
|||
|
|
@ -239,7 +239,6 @@ class Grid(Layout):
|
|||
all_groups_in_order.append(wg)
|
||||
layout_data_map[wg.id] = xl, yl
|
||||
is_last_column = {groups[x].id for x in prev_col_windows}
|
||||
active_group = windows.active_group
|
||||
|
||||
def ends(yl: LayoutData) -> tuple[int, int]:
|
||||
return yl.content_pos - yl.space_before, yl.content_pos + yl.content_size + yl.space_after
|
||||
|
|
@ -266,7 +265,7 @@ class Grid(Layout):
|
|||
for wg in all_groups_in_order:
|
||||
color = BorderColor.inactive
|
||||
if needs_borders_map.get(wg.id):
|
||||
color = BorderColor.active if wg is active_group else BorderColor.bell
|
||||
color = BorderColor.bell if wg.needs_attention else BorderColor.active
|
||||
wid = wg.active_window_id
|
||||
yield from borders_for_window(wg.id, color, wid)
|
||||
|
||||
|
|
|
|||
|
|
@ -950,16 +950,12 @@ class Splits(Layout):
|
|||
if not lgd.draw_minimal_borders or window_count < 2:
|
||||
return
|
||||
needs_borders_map = windows.compute_needs_borders_map(lgd.draw_active_borders)
|
||||
ag = windows.active_group
|
||||
active_group_id = -1 if ag is None else ag.id
|
||||
|
||||
border_color_map = {}
|
||||
for grp_id, needs_borders in needs_borders_map.items():
|
||||
if needs_borders:
|
||||
wid = g.active_window_id if (g := windows.group_for_id(grp_id)) else 0
|
||||
if wid:
|
||||
color = BorderColor.active if grp_id is active_group_id else BorderColor.bell
|
||||
border_color_map[wid] = color
|
||||
if (g := windows.group_for_id(grp_id)) and (wid := g.active_window_id):
|
||||
border_color_map[wid] = BorderColor.bell if g.needs_attention else BorderColor.active
|
||||
|
||||
for pair in self.pairs_root.self_and_descendants():
|
||||
if pair.between_borders:
|
||||
|
|
|
|||
|
|
@ -322,7 +322,6 @@ class Tall(Layout):
|
|||
perp_borders: list[BorderLine] = []
|
||||
layouts = (self.simple_layout if num <= self.num_full_size_windows else self.full_layout)(windows)
|
||||
needs_borders_map = windows.compute_needs_borders_map(lgd.draw_active_borders)
|
||||
active_group = windows.active_group
|
||||
mirrored = self.layout_opts.mirrored
|
||||
for wg, xl, yl, is_full_size in layouts:
|
||||
if is_full_size:
|
||||
|
|
@ -330,7 +329,7 @@ class Tall(Layout):
|
|||
else:
|
||||
color = BorderColor.inactive
|
||||
if needs_borders_map.get(wg.id):
|
||||
color = BorderColor.active if wg is active_group else BorderColor.bell
|
||||
color = BorderColor.bell if wg.needs_attention else BorderColor.active
|
||||
wid = wg.active_window_id
|
||||
mult = 1 if mirrored else -1
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ def borders(
|
|||
data: Iterable[tuple[WindowGroup, LayoutData, LayoutData]], is_horizontal: bool, all_windows: WindowList, start_offset: int = 1, end_offset: int = 1
|
||||
) -> Generator[BorderLine, None, None]:
|
||||
borders: list[BorderLine] = []
|
||||
active_group = all_windows.active_group
|
||||
needs_borders_map = all_windows.compute_needs_borders_map(lgd.draw_active_borders)
|
||||
try:
|
||||
bw = next(all_windows.iter_all_layoutable_groups()).effective_border()
|
||||
|
|
@ -54,7 +53,7 @@ def borders(
|
|||
)
|
||||
color = BorderColor.inactive
|
||||
if needs_borders_map.get(wg.id):
|
||||
color = BorderColor.active if wg is active_group else BorderColor.bell
|
||||
color = BorderColor.bell if wg.needs_attention else BorderColor.active
|
||||
borders.append(BorderLine(e1, color, -wg.active_window_id, not is_horizontal))
|
||||
borders.append(BorderLine(e2, color, wg.active_window_id, not is_horizontal))
|
||||
|
||||
|
|
|
|||
|
|
@ -1675,12 +1675,7 @@ class Window:
|
|||
self.last_focused_at = monotonic()
|
||||
update_ime_position_for_window(self.id, False, 1)
|
||||
self.program_status_seen_by_user()
|
||||
changed = self.needs_attention
|
||||
self.needs_attention = False
|
||||
if changed:
|
||||
tab = self.tabref()
|
||||
if tab is not None:
|
||||
tab.relayout_borders()
|
||||
self.clear_needs_attention()
|
||||
if self.last_cmd_end_notification is not None:
|
||||
from .notifications import OnlyWhen
|
||||
|
||||
|
|
@ -1692,6 +1687,12 @@ class Window:
|
|||
# Cancel IME composition after loses focus
|
||||
update_ime_position_for_window(self.id, False, -1)
|
||||
|
||||
def clear_needs_attention(self) -> None:
|
||||
if self.needs_attention:
|
||||
self.needs_attention = False
|
||||
if (tab := self.tabref()) is not None:
|
||||
tab.relayout_borders()
|
||||
|
||||
def title_changed(self, new_title: memoryview | None, is_base64: bool = False) -> None:
|
||||
self.child_title = process_title_from_child(new_title or memoryview(b''), is_base64, self.default_title)
|
||||
self.call_watchers(self.watchers.on_title_change, {'title': self.child_title, 'from_child': True})
|
||||
|
|
@ -1763,7 +1764,10 @@ class Window:
|
|||
env = self.child.foreground_environ
|
||||
env['KITTY_CHILD_CMDLINE'] = ' '.join(map(shlex.quote, self.child.cmdline))
|
||||
subprocess.Popen(cb, env=env, cwd=self.child.foreground_cwd, preexec_fn=clear_handled_signals)
|
||||
if not self.is_active:
|
||||
# Mark as needing attention unless the user is looking at this window,
|
||||
# which requires both that it be the active window and that its OS
|
||||
# window have keyboard focus. Attention is cleared when the window gains focus.
|
||||
if not self.is_active or self.os_window_id != current_focused_os_window_id():
|
||||
changed = not self.needs_attention
|
||||
self.needs_attention = True
|
||||
tab = self.tabref()
|
||||
|
|
|
|||
|
|
@ -1083,6 +1083,32 @@ class TestSplitBorderResize(BaseSplitGeometryTest):
|
|||
self.assertIsNone(data.vertical_id)
|
||||
|
||||
|
||||
class BellWindow(Window):
|
||||
needs_attention = False
|
||||
|
||||
|
||||
class TestMinimalBorderColors(BaseSplitGeometryTest):
|
||||
def test_active_window_needing_attention_uses_bell_color(self):
|
||||
# The active window can need attention when its OS window is unfocused,
|
||||
# its minimal borders must then use the bell color not the active color
|
||||
for layout_class in (Tall, Fat, Grid, Horizontal, Vertical, Splits):
|
||||
for draw_active_borders in (True, False):
|
||||
with self.subTest(layout=layout_class.name, draw_active_borders=draw_active_borders):
|
||||
layout = create_layout(layout_class)
|
||||
windows = create_windows(layout, num=3, window_class=BellWindow)
|
||||
self.stub_dimensions(layout, Region((0, 0, 1499, 1099, 1500, 1100)))
|
||||
layout(windows)
|
||||
lgd.draw_active_borders = draw_active_borders
|
||||
active = windows.active_window
|
||||
|
||||
def colors():
|
||||
return {b.color for b in layout.get_minimal_borders(windows) if abs(b.window_id) == active.id}
|
||||
|
||||
self.ae(colors(), {BorderColor.active} if draw_active_borders else {BorderColor.inactive})
|
||||
active.needs_attention = True
|
||||
self.ae(colors(), {BorderColor.bell})
|
||||
|
||||
|
||||
class TestReservedSpaces(BaseSplitGeometryTest):
|
||||
def test_reserved_spaces_do_not_overlap(self):
|
||||
# Custom shaders treat the space a layout reserves around the active
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue