This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch fix-modern-macos
in repository efl.
View the commit online.
commit 8b660c25cce436da7c5aaa6bd20da5c5e09f0ca0
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Apr 29 16:51:19 2026 -0600
feat(elementary): add elm_app_new_window_cb_* and default-menu-disable API
New portable API:
- elm_app_new_window_cb_set/get
- elm_app_new_window_request
- elm_app_default_menu_disable
Apps register a single callback for 'platform asks for a new top-level
window'. On macOS this fires for both Dock-reopen and File/New Window
menu clicks (wiring lands in a follow-up). On Linux/Windows the symbol
exists but is currently never invoked by EFL.
Replaces the need for apps to use ecore_cocoa_reopen_cb_set directly
behind #ifdef __APPLE__.
---
src/lib/elementary/elm_app.h | 64 +++++++++++++++++++++++++++++++++++++++++++
src/lib/elementary/elm_main.c | 54 ++++++++++++++++++++++++++++++++++++
src/lib/elementary/elm_priv.h | 9 ++++++
3 files changed, 127 insertions(+)
diff --git a/src/lib/elementary/elm_app.h b/src/lib/elementary/elm_app.h
index a169f7c988..e33daadd18 100644
--- a/src/lib/elementary/elm_app.h
+++ b/src/lib/elementary/elm_app.h
@@ -195,6 +195,70 @@ EAPI void elm_app_compile_locale_set(const char *dir);
*/
EAPI const char *elm_app_name_get(void);
+/**
+ * @typedef Elm_App_New_Window_Cb
+ * Callback fired when the platform requests a new top-level window.
+ *
+ * On macOS this is invoked when the user clicks the Dock icon while the
+ * app is already running, and when the user clicks "File → New Window"
+ * in the auto-populated menu bar.
+ *
+ * On Linux and Windows the symbol exists but is currently never called by
+ * EFL (forward-compatible).
+ *
+ * @param data User data registered alongside the callback.
+ * @return EINA_TRUE if the new window was created (or creation was
+ * dispatched), EINA_FALSE on failure. The return value is
+ * informational; EFL does not retry.
+ *
+ * @since 1.28
+ * @ingroup Elm_App
+ */
+typedef Eina_Bool (*Elm_App_New_Window_Cb)(void *data);
+
+/**
+ * Registers a callback to be invoked when the platform requests a new
+ * top-level window. Pass NULL to clear.
+ *
+ * @param cb The callback, or NULL to clear.
+ * @param data Opaque user data passed to @c cb.
+ * @since 1.28
+ * @ingroup Elm_App
+ */
+EAPI void elm_app_new_window_cb_set(Elm_App_New_Window_Cb cb, void *data);
+
+/**
+ * Retrieves the currently registered new-window callback and data.
+ * Either argument may be NULL if you are interested in only one.
+ *
+ * @param[out] cb Set to the registered callback, or NULL if none.
+ * @param[out] data Set to the registered user data pointer, or NULL.
+ * @since 1.28
+ * @ingroup Elm_App
+ */
+EAPI void elm_app_new_window_cb_get(Elm_App_New_Window_Cb *cb, void **data);
+
+/**
+ * Programmatically request a new window using the registered callback.
+ *
+ * @return EINA_FALSE if no callback is set; otherwise the callback's
+ * return value.
+ * @since 1.28
+ * @ingroup Elm_App
+ */
+EAPI Eina_Bool elm_app_new_window_request(void);
+
+/**
+ * Disables auto-population of the platform's default menu bar (macOS).
+ * Must be called before the first window is created.
+ *
+ * On platforms with no native menu bar this is a no-op.
+ *
+ * @since 1.28
+ * @ingroup Elm_App
+ */
+EAPI void elm_app_default_menu_disable(void);
+
/**
* Get the path to the '.desktop' file, as set by
* elm_app_desktop_entry_set().
diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c
index b1a355ab69..27823d3fef 100644
--- a/src/lib/elementary/elm_main.c
+++ b/src/lib/elementary/elm_main.c
@@ -163,6 +163,10 @@ static const char *app_data_dir = NULL;
static const char *app_locale_dir = NULL;
static double app_base_scale = 1.0;
+static Elm_App_New_Window_Cb _app_new_window_cb = NULL;
+static void *_app_new_window_data = NULL;
+static Eina_Bool _app_default_menu_disabled = EINA_FALSE;
+
static Eina_Prefix *app_pfx = NULL;
static Ecore_Event_Handler *system_handlers[2] = { NULL, NULL };
@@ -632,6 +636,56 @@ elm_app_base_scale_get(void)
return 1.0;
}
+EAPI void
+elm_app_new_window_cb_set(Elm_App_New_Window_Cb cb, void *data)
+{
+ Eina_Bool was_set = (_app_new_window_cb != NULL);
+ Eina_Bool now_set = (cb != NULL);
+
+ _app_new_window_cb = cb;
+ _app_new_window_data = cb ? data : NULL;
+
+ if (was_set != now_set)
+ _elm_app_new_window_cb_changed(now_set);
+}
+
+EAPI void
+elm_app_new_window_cb_get(Elm_App_New_Window_Cb *cb, void **data)
+{
+ if (cb) *cb = _app_new_window_cb;
+ if (data) *data = ""
+}
+
+EAPI Eina_Bool
+elm_app_new_window_request(void)
+{
+ if (!_app_new_window_cb) return EINA_FALSE;
+ return _app_new_window_cb(_app_new_window_data);
+}
+
+EAPI void
+elm_app_default_menu_disable(void)
+{
+ _app_default_menu_disabled = EINA_TRUE;
+}
+
+Eina_Bool
+_elm_app_default_menu_disabled_get(void)
+{
+ return _app_default_menu_disabled;
+}
+
+/* Default no-op definition. The Cocoa menu bridge (elm_cocoa_menu.c)
+ * provides a real implementation in Cocoa builds; until that lands in
+ * a follow-up commit, this stub is the only definition and prevents
+ * a link error. When the Cocoa implementation arrives this stub will
+ * be removed (or guarded) so there is exactly one definition. */
+void
+_elm_app_new_window_cb_changed(Eina_Bool now_set EINA_UNUSED)
+{
+ /* No-op: only the Cocoa menu bridge cares about live cb changes. */
+}
+
static Eina_Bool _elm_need_e_dbus = EINA_FALSE;
static void *e_dbus_handle = NULL;
diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h
index 4b62842a7f..6f85d60113 100644
--- a/src/lib/elementary/elm_priv.h
+++ b/src/lib/elementary/elm_priv.h
@@ -892,6 +892,15 @@ void _elm_widget_full_eval_children(Eo *obj, Elm_Widget_Smart_Da
Eina_Bool _elm_config_accel_preference_parse(const char *pref, Eina_Stringshare **accel, int *gl_depth, int *gl_stencil, int *gl_msaa);
extern char *_elm_appname;
+
+/* Internal: notify Cocoa menu bridge that the new-window callback has
+ * been added or removed, so the default File menu can be added/removed
+ * live. No-op stub on non-Cocoa platforms. Defined in elm_cocoa_menu.c
+ * (Cocoa) or in elm_main.c (other platforms). */
+void _elm_app_new_window_cb_changed(Eina_Bool now_set);
+
+/* Internal: read the elm_app_default_menu_disable() flag. */
+Eina_Bool _elm_app_default_menu_disabled_get(void);
extern Elm_Config *_elm_config;
extern Efl_Config *_efl_config_obj;
extern const char *_elm_data_dir;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.