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 ad37ccb7b597d0bb99eb829806177e44b389bcc1
Author: Cedric BAIL <[email protected]>
AuthorDate: Mon Mar 23 12:18:15 2026 -0600
ecore_evas/cocoa: center new windows on the display containing the mouse
When an EFL application is launched from Spotlight on a secondary display,
the window defaults to the primary screen. This is because Cocoa places
new windows on the main display unless told otherwise.
Before showing a window for the first time, if no explicit position was
requested, find the screen containing the mouse pointer and center the
window there. This makes all EFL applications behave correctly in
multi-monitor setups when launched from Spotlight or other launchers.
Made-with: Cursor
---
src/lib/ecore_cocoa/ecore_cocoa_window.m | 20 ++++++++++++++++++++
.../ecore_evas/engines/cocoa/ecore_evas_cocoa.c | 5 +++++
2 files changed, 25 insertions(+)
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_window.m b/src/lib/ecore_cocoa/ecore_cocoa_window.m
index 8dda3f098c..d00884c6ce 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_window.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa_window.m
@@ -665,6 +665,26 @@ ecore_cocoa_window_backing_scale_get(const Ecore_Cocoa_Window *window)
return [window->window backingScaleFactor];
}
+void
+_ecore_cocoa_window_center_on_mouse_screen(Ecore_Cocoa_Window *window)
+{
+ EINA_SAFETY_ON_NULL_RETURN(window);
+
+ NSPoint mouse = [NSEvent mouseLocation];
+ for (NSScreen *screen in [NSScreen screens])
+ {
+ if (NSMouseInRect(mouse, [screen frame], NO))
+ {
+ NSRect vf = [screen visibleFrame];
+ NSRect wf = [window->window frame];
+ wf.origin.x = NSMinX(vf) + (NSWidth(vf) - wf.size.width) / 2;
+ wf.origin.y = NSMinY(vf) + (NSHeight(vf) - wf.size.height) / 2;
+ [window->window setFrame:wf display:YES];
+ break;
+ }
+ }
+}
+
Eina_Bool
_ecore_cocoa_window_init(void)
{
diff --git a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c
index 360966522b..16b8d9cc9e 100644
--- a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c
+++ b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c
@@ -14,6 +14,8 @@
#include "ecore_evas_private.h"
#include "ecore_evas_cocoa.h"
+extern void _ecore_cocoa_window_center_on_mouse_screen(Ecore_Cocoa_Window *window);
+
#ifdef _WIN32
# ifndef EFL_MODULE_STATIC
# define EMODAPI __declspec(dllexport)
@@ -272,6 +274,9 @@ _ecore_evas_show(Ecore_Evas *ee)
{
DBG("%p", ee);
+ if (!ee->visible && !ee->prop.request_pos)
+ _ecore_cocoa_window_center_on_mouse_screen((Ecore_Cocoa_Window *)ee->prop.window);
+
ecore_cocoa_window_show((Ecore_Cocoa_Window *)ee->prop.window);
evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.