diff --git a/docs/changelog.rst b/docs/changelog.rst index 66af34f7f..ffa99db85 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -106,6 +106,10 @@ Detailed list of changes terminal ecosystem for decades by allowing terminal programs to specify how many cells to render a piece of text in (:iss:`8226`) +- **Behavior change**: The :opt:`notify_on_cmd_finish` option now uses OS + Window visibility instead of focus state when set to ``invisible`` + (:iss:`8320`) + - launch: Add options :option:`launch --source-window` and :option:`launch --next-to` to allow specifying which window is used as the data source and destination location independently of the currently active window (:iss:`8295`) diff --git a/kitty/notifications.py b/kitty/notifications.py index 87769d19f..c3a6637c4 100644 --- a/kitty/notifications.py +++ b/kitty/notifications.py @@ -13,7 +13,16 @@ from weakref import ReferenceType, ref from .constants import cache_dir, config_dir, is_macos, logo_png_file, standard_icon_names, standard_sound_names -from .fast_data_types import ESC_OSC, StreamingBase64Decoder, add_timer, base64_decode, current_focused_os_window_id, get_boss, get_options +from .fast_data_types import ( + ESC_OSC, + StreamingBase64Decoder, + add_timer, + base64_decode, + current_focused_os_window_id, + get_boss, + get_options, + os_window_is_invisible, +) from .types import run_once from .typing import WindowType from .utils import get_custom_window_icon, log_error, sanitize_control_codes @@ -794,7 +803,7 @@ def ui_state(self, channel_id: int) -> UIState: if w := self.window_for_id(channel_id): has_focus = w.is_active and w.os_window_id == current_focused_os_window_id() # window is in the active OS window and the active tab and is visible in the tab layout - is_visible = w.os_window_id == current_focused_os_window_id() and w.tabref() is boss.active_tab and w.is_visible_in_layout + is_visible = not os_window_is_invisible(w.os_window_id) and w.tabref() is boss.active_tab and w.is_visible_in_layout return UIState(has_focus, is_visible) def send(self, channel_id: int, osc_escape_code: str) -> bool: diff --git a/kitty/options/definition.py b/kitty/options/definition.py index 1b97def29..695726423 100644 --- a/kitty/options/definition.py +++ b/kitty/options/definition.py @@ -3306,7 +3306,8 @@ :code:`invisible` Only send a notification when the window both is unfocused and not visible to the user, for example, because it is in an inactive tab or its OS window - is not currently active. + is not currently visible (note that OS Window visibility is not implemented + by some Wayland compositors such as sway). :code:`always` Always send a notification, regardless of window state.