Skip to content

Commit

Permalink
Merge pull request #41286 from bruvzg/macos_on_top_3
Browse files Browse the repository at this point in the history
[macOS] Fix "on top" not set on init, and resetting on window update.
  • Loading branch information
akien-mga authored Aug 15, 2020
2 parents 13a615b + 2b1cfad commit 72d1228
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions platform/osx/os_osx.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class OS_OSX : public OS_Unix {
bool zoomed;
bool resizable;
bool window_focused;
bool on_top;

Size2 window_size;
Rect2 restore_rect;
Expand Down
14 changes: 13 additions & 1 deletion platform/osx/os_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,11 @@ static void displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplay

[window_object makeKeyAndOrderFront:nil];

on_top = p_desired.always_on_top;
if (p_desired.always_on_top) {
[window_object setLevel:NSFloatingWindowLevel];
}

if (p_desired.fullscreen)
zoomed = true;

Expand Down Expand Up @@ -2501,7 +2506,11 @@ static int get_screen_index(NSScreen *screen) {
[window_object setHidesOnDeactivate:YES];
} else {
// Reset these when our window is not a borderless window that covers up the screen
[window_object setLevel:NSNormalWindowLevel];
if (on_top) {
[window_object setLevel:NSFloatingWindowLevel];
} else {
[window_object setLevel:NSNormalWindowLevel];
}
[window_object setHidesOnDeactivate:NO];
}
}
Expand Down Expand Up @@ -2736,6 +2745,8 @@ static int get_screen_index(NSScreen *screen) {
}

void OS_OSX::set_window_always_on_top(bool p_enabled) {
on_top = p_enabled;

if (is_window_always_on_top() == p_enabled)
return;

Expand Down Expand Up @@ -3320,6 +3331,7 @@ void _update_keyboard_layouts() {
zoomed = false;
resizable = false;
window_focused = true;
on_top = false;

Vector<Logger *> loggers;
loggers.push_back(memnew(OSXTerminalLogger));
Expand Down

0 comments on commit 72d1228

Please sign in to comment.