Skip to content

Commit c1e1314

Browse files
committed
Merge pull request godotengine#114495 from bruvzg/mac_w_ord
[macOS] Fix non-focusable window order.
2 parents 16975f5 + 898e299 commit c1e1314

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

platform/macos/display_server_macos.mm

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,14 @@
17881788
if ([wd.window_object isMiniaturized]) {
17891789
return;
17901790
} else if (wd.no_focus) {
1791-
[wd.window_object orderFront:nil];
1791+
if (wd.transient_parent != INVALID_WINDOW_ID) {
1792+
WindowData &wd_parent = windows[wd.transient_parent];
1793+
[wd.window_object orderWindow:NSWindowAbove relativeTo:[wd_parent.window_object windowNumber]];
1794+
} else if (p_id != MAIN_WINDOW_ID) {
1795+
[wd.window_object orderWindow:NSWindowAbove relativeTo:[windows[MAIN_WINDOW_ID].window_object windowNumber]];
1796+
} else {
1797+
[wd.window_object orderFront:nil];
1798+
}
17921799
} else {
17931800
[wd.window_object makeKeyAndOrderFront:nil];
17941801
}
@@ -1980,7 +1987,14 @@
19801987
if ([[wd_parent.window_object childWindows] containsObject:wd.window_object]) {
19811988
[wd_parent.window_object removeChildWindow:wd.window_object];
19821989
[wd.window_object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
1983-
[wd.window_object orderFront:nil];
1990+
if (wd.transient_parent != INVALID_WINDOW_ID) {
1991+
WindowData &wd_parent = windows[wd.transient_parent];
1992+
[wd.window_object orderWindow:NSWindowAbove relativeTo:[wd_parent.window_object windowNumber]];
1993+
} else if (p_window != MAIN_WINDOW_ID) {
1994+
[wd.window_object orderWindow:NSWindowAbove relativeTo:[windows[MAIN_WINDOW_ID].window_object windowNumber]];
1995+
} else {
1996+
[wd.window_object orderFront:nil];
1997+
}
19841998
}
19851999
}
19862000
}
@@ -2577,7 +2591,14 @@
25772591
if ([wd.window_object isMiniaturized]) {
25782592
return;
25792593
} else if (wd.no_focus) {
2580-
[wd.window_object orderFront:nil];
2594+
if (wd.transient_parent != INVALID_WINDOW_ID) {
2595+
WindowData &wd_parent = windows[wd.transient_parent];
2596+
[wd.window_object orderWindow:NSWindowAbove relativeTo:[wd_parent.window_object windowNumber]];
2597+
} else if (p_window != MAIN_WINDOW_ID) {
2598+
[wd.window_object orderWindow:NSWindowAbove relativeTo:[windows[MAIN_WINDOW_ID].window_object windowNumber]];
2599+
} else {
2600+
[wd.window_object orderFront:nil];
2601+
}
25812602
} else {
25822603
[wd.window_object makeKeyAndOrderFront:nil];
25832604
}
@@ -2700,7 +2721,14 @@
27002721

27012722
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
27022723
if (wd.no_focus || wd.is_popup) {
2703-
[wd.window_object orderFront:nil];
2724+
if (wd.transient_parent != INVALID_WINDOW_ID) {
2725+
WindowData &wd_parent = windows[wd.transient_parent];
2726+
[wd.window_object orderWindow:NSWindowAbove relativeTo:[wd_parent.window_object windowNumber]];
2727+
} else if (p_window != MAIN_WINDOW_ID) {
2728+
[wd.window_object orderWindow:NSWindowAbove relativeTo:[windows[MAIN_WINDOW_ID].window_object windowNumber]];
2729+
} else {
2730+
[wd.window_object orderFront:nil];
2731+
}
27042732
} else {
27052733
[wd.window_object makeKeyAndOrderFront:nil];
27062734
}

0 commit comments

Comments
 (0)