notify_on_cmd_finish invisible now uses actual OS Window visibility as reported by the window manager

Fixes #8320
This commit is contained in:
Kovid Goyal
2025-02-12 10:30:18 +05:30
parent 4472d91fbb
commit d27e4f84b7
3 changed files with 17 additions and 3 deletions

View File

@@ -106,6 +106,10 @@ Detailed list of changes
terminal ecosystem for decades by allowing terminal programs to specify how terminal ecosystem for decades by allowing terminal programs to specify how
many cells to render a piece of text in (:iss:`8226`) 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 - 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 specifying which window is used as the data source and destination location independently of the
currently active window (:iss:`8295`) currently active window (:iss:`8295`)

View File

@@ -13,7 +13,16 @@ from typing import Any, NamedTuple, Set
from weakref import ReferenceType, ref from weakref import ReferenceType, ref
from .constants import cache_dir, config_dir, is_macos, logo_png_file, standard_icon_names, standard_sound_names 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 .types import run_once
from .typing import WindowType from .typing import WindowType
from .utils import get_custom_window_icon, log_error, sanitize_control_codes from .utils import get_custom_window_icon, log_error, sanitize_control_codes
@@ -794,7 +803,7 @@ class Channel:
if w := self.window_for_id(channel_id): if w := self.window_for_id(channel_id):
has_focus = w.is_active and w.os_window_id == current_focused_os_window_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 # 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) return UIState(has_focus, is_visible)
def send(self, channel_id: int, osc_escape_code: str) -> bool: def send(self, channel_id: int, osc_escape_code: str) -> bool:

View File

@@ -3306,7 +3306,8 @@ The possible values are:
:code:`invisible` :code:`invisible`
Only send a notification when the window both is unfocused and not visible 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 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` :code:`always`
Always send a notification, regardless of window state. Always send a notification, regardless of window state.