This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch reproducible-widget-previews
in repository efl.

View the commit online.

commit d53cd85bdd9df4625025180ec4acda6664ff03f6
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Mar 25 10:30:59 2026 -0600

    feat(ecore_cocoa): add reopen callback for macOS Dock/Spotlight re-launch
    
    Implement the applicationShouldHandleReopen:hasVisibleWindows: NSApplicationDelegate
    method to respond when the user re-launches an already-running application from
    Spotlight, Launchpad, or clicks its Dock icon. These events were previously
    silently ignored.
    
    Add Ecore_Cocoa_Reopen_Cb callback typedef and ecore_cocoa_reopen_cb_set() public
    API following the same pattern as the existing terminate callback. The reopen
    callback receives has_visible (whether the app has visible windows) and returns
    EINA_TRUE to handle the event or EINA_FALSE for default macOS behaviour.
    
    This enables applications like Terminology to respond to reopen requests by
    creating new windows in-process instead of being unresponsive.
---
 src/lib/ecore_cocoa/Ecore_Cocoa.h     | 28 ++++++++++++++++++++++++++++
 src/lib/ecore_cocoa/ecore_cocoa.m     |  6 ++++++
 src/lib/ecore_cocoa/ecore_cocoa_app.h |  3 +++
 src/lib/ecore_cocoa/ecore_cocoa_app.m | 21 +++++++++++++++++++++
 4 files changed, 58 insertions(+)

diff --git a/src/lib/ecore_cocoa/Ecore_Cocoa.h b/src/lib/ecore_cocoa/Ecore_Cocoa.h
index 58e35956b3..31c2fdee17 100644
--- a/src/lib/ecore_cocoa/Ecore_Cocoa.h
+++ b/src/lib/ecore_cocoa/Ecore_Cocoa.h
@@ -91,6 +91,22 @@ typedef struct _Ecore_Cocoa_Event_Window_Destroy Ecore_Cocoa_Event_Window_Destro
  */
 typedef Eina_Bool (*Ecore_Cocoa_Terminate_Cb)(Ecore_Cocoa_Object *sender);
 
+/**
+ * @typedef Ecore_Cocoa_Reopen_Cb
+ * Callback called when the application is asked to reopen (e.g. the user
+ * clicks the Dock icon or re-launches from Spotlight while the application
+ * is already running). This corresponds to the
+ * @c applicationShouldHandleReopen:hasVisibleWindows: NSApplicationDelegate
+ * method.
+ * Return EINA_TRUE to indicate the event was handled (macOS will not apply
+ * default behaviour). Return EINA_FALSE to let macOS apply its default
+ * behaviour (bring existing visible windows to front, or do nothing).
+ * @param has_visible EINA_TRUE if the application has at least one visible
+ * window at the time of the reopen request.
+ * @since 1.20
+ */
+typedef Eina_Bool (*Ecore_Cocoa_Reopen_Cb)(Eina_Bool has_visible);
+
 /**
  * @typedef Ecore_Cocoa_Cursor
  * Values of the Cocoa cursors handled by Ecore_Cocoa
@@ -548,6 +564,18 @@ EAPI void ecore_cocoa_terminate_cb_set(Ecore_Cocoa_Terminate_Cb cb)
  */
 EAPI Eina_Bool ecore_cocoa_app_icon_set(const char *path)
    EINA_ARG_NONNULL(1);
+ 
+/**
+ * Registers a callback to be invoked when the application is asked to reopen.
+ * This occurs when the user clicks the running application's Dock icon or
+ * re-launches it from Spotlight / Launchpad while it is already running.
+ * If @c cb is NULL the default macOS reopen behaviour is restored (bring
+ * visible windows to front).
+ * @param cb The reopen callback to set, or NULL to clear it.
+ * @see Ecore_Cocoa_Reopen_Cb
+ * @since 1.20
+ */
+EAPI void ecore_cocoa_reopen_cb_set(Ecore_Cocoa_Reopen_Cb cb);
 
 
 /*
diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m b/src/lib/ecore_cocoa/ecore_cocoa.m
index dc544ac23b..336718da9c 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa.m
@@ -516,3 +516,9 @@ ecore_cocoa_app_icon_set(const char *path)
    }
    return EINA_TRUE;
 }
+
+EAPI void
+ecore_cocoa_reopen_cb_set(Ecore_Cocoa_Reopen_Cb cb)
+{
+   [(Ecore_Cocoa_Application *)NSApp setReopenCb:cb];
+}
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_app.h b/src/lib/ecore_cocoa/ecore_cocoa_app.h
index 4eb9e7d752..338170075a 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_app.h
+++ b/src/lib/ecore_cocoa/ecore_cocoa_app.h
@@ -9,6 +9,7 @@
    Ecore_Timer  *_timer;
    NSDate       *_expiration;
    Ecore_Cocoa_Terminate_Cb _terminate_cb;
+   Ecore_Cocoa_Reopen_Cb    _reopen_cb;
    BOOL          _is_running;
 }
 
@@ -21,6 +22,8 @@
 - (void)internalUpdate;
 - (void)setTerminateCb:(Ecore_Cocoa_Terminate_Cb)cb;
 - (Ecore_Cocoa_Terminate_Cb)terminateCb;
+- (void)setReopenCb:(Ecore_Cocoa_Reopen_Cb)cb;
+- (Ecore_Cocoa_Reopen_Cb)reopenCb;
 
 - (void) pauseNSRunLoopMonitoring;
 - (void) resumeNSRunLoopMonitoring;
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_app.m b/src/lib/ecore_cocoa/ecore_cocoa_app.m
index de94c6debe..105e9bc668 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_app.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa_app.m
@@ -131,6 +131,16 @@ _ecore_cocoa_run_loop_cb(void *data EINA_UNUSED)
    return _terminate_cb;
 }
 
+- (void)setReopenCb:(Ecore_Cocoa_Reopen_Cb)cb
+{
+   _reopen_cb = cb;
+}
+
+- (Ecore_Cocoa_Reopen_Cb)reopenCb
+{
+   return _reopen_cb;
+}
+
 @end
 
 
@@ -185,4 +195,15 @@ static Ecore_Cocoa_AppDelegate *_appDelegate = nil;
    return status;
 }
 
+- (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag
+{
+   Ecore_Cocoa_Reopen_Cb cb = [(Ecore_Cocoa_Application *)sender reopenCb];
+   if (cb)
+     {
+        Eina_Bool handled = cb(flag ? EINA_TRUE : EINA_FALSE);
+        return handled ? YES : NO;
+     }
+   return NO;
+}
+
 @end

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to