Merge branch 'v0.37.0-patched' of https://github.com/ein-shved/kitty

This commit is contained in:
Kovid Goyal 2024-12-05 09:35:03 +05:30
commit ecb607c31d
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 25 additions and 1 deletions

View file

@ -1062,5 +1062,8 @@ class NotificationManager:
n.title, n.body = parts[0], (parts[1] if len(parts) > 1 else '')
self.notify_with_command(n, channel_id)
def close_notification(self, desktop_notification_id: int) -> None:
self.desktop_integration.close_notification(desktop_notification_id)
def cleanup(self) -> None:
del self.icon_data_cache

View file

@ -630,6 +630,7 @@ class Window:
self.current_mouse_event_button = 0
self.current_clipboard_read_ask: Optional[bool] = None
self.last_cmd_output_start_time = 0.
self.last_notification_id: Optional[int] = None
self.open_url_handler: 'OpenUrlHandler' = None
self.last_cmd_cmdline = ''
self.last_cmd_exit_status = 0
@ -1213,6 +1214,13 @@ class Window:
tab = self.tabref()
if tab is not None:
tab.relayout_borders()
if self.last_notification_id:
# Notification id is saved withing handle_cmd_end so it
# configured to be close upon focus is gained and visibility
# change. When window is focused, it is visible for sure.
nm = get_boss().notification_manager
nm.close_notification(self.last_notification_id)
self.last_notification_id = None
elif self.os_window_id == current_focused_os_window_id():
# Cancel IME composition after loses focus
update_ime_position_for_window(self.id, False, -1)
@ -1523,7 +1531,20 @@ class Window:
if not nm.is_notification_allowed(cmd, self.id):
return
if action == 'notify':
nm.notify_with_command(cmd, self.id)
# Notification id is saved, so configuration was checked on
# previous pass and saved to be cleared upon focus. But that
# action was missed somehow and we should clear it here.
if self.last_notification_id:
nm.close_notification(self.last_notification_id)
self.last_notification_id = None
notification_id = nm.notify_with_command(cmd, self.id)
# Saving notification id only when we are going to close it in
# future.
# TODO(Shvedov): We should close notification not only when
# gather focus, but when window become visible if `when` equals
# to "invisible".
if cmd.only_when is OnlyWhen.unfocused or cmd.only_when is OnlyWhen.invisible:
self.last_notification_id = notification_id
elif action == 'bell':
self.screen.bell()
elif action == 'command':