From c43fe38cf14773cccbe705dd61e6b64df3cebdfc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 27 Feb 2025 19:38:06 +0530 Subject: [PATCH] macOS: Fix waiting for result from desktop notification not working --- docs/changelog.rst | 2 ++ kitty/cocoa_window.m | 2 +- kitty/notifications.py | 10 ++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 2d5af9870..f98afa8e0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -139,6 +139,8 @@ Detailed list of changes - When dragging in rectangle select mode use a crosshair mouse cursor configurable via :opt:`pointer_shape_when_dragging` +- macOS: Fix waiting for result from desktop notification not working (:disc:`8379`) + 0.39.1 [2025-02-01] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/cocoa_window.m b/kitty/cocoa_window.m index 1e46817a3..8c61083eb 100644 --- a/kitty/cocoa_window.m +++ b/kitty/cocoa_window.m @@ -438,7 +438,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center void cocoa_report_live_notifications(const char* ident) { - do_notification_callback(ident, "live", ""); + do_notification_callback(ident, "live", ident ? ident : ""); } static bool diff --git a/kitty/notifications.py b/kitty/notifications.py index 024bd56d0..3c8be6adb 100644 --- a/kitty/notifications.py +++ b/kitty/notifications.py @@ -640,8 +640,10 @@ def notification_activated(self, event: str, ident: str, button_id: str) -> None return if event == 'created': n = self.notification_manager.notification_created(desktop_notification_id) - from .fast_data_types import cocoa_live_delivered_notifications - cocoa_live_delivered_notifications() # so that we purge dead notifications + # so that we purge dead notifications, check for live notifications + # after a few seconds, cant check right away as cocoa does not + # report the created notification as live. + add_timer(self.check_live_delivered_notifications, 5.0, False) if n and n.sound_name in standard_sound_names: from .fast_data_types import cocoa_play_system_sound_by_id_async cocoa_play_system_sound_by_id_async(standard_sound_names[n.sound_name][1]) @@ -666,6 +668,10 @@ def notification_activated(self, event: str, ident: str, button_id: str) -> None log_error('No category found with buttons:', n.buttons) log_error('Current categories:', self.current_categories) + def check_live_delivered_notifications(self, *a: object) -> None: + from .fast_data_types import cocoa_live_delivered_notifications + cocoa_live_delivered_notifications() + class FreeDesktopIntegration(DesktopIntegration):