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
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
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
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`)

View file

@ -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:

View file

@ -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.