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

@@ -13,7 +13,16 @@ from typing import Any, NamedTuple, Set
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 @@ class Channel:
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 @@ The possible values are:
: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.