Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] Use occlusionState instead of isOnActiveSpace to determine when window is drawable. #83096

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platform/macos/display_server_macos.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class DisplayServerMacOS : public DisplayServer {
bool is_popup = false;
bool mpass = false;
bool focused = false;
bool is_visible = true;

Rect2i parent_safe_rect;
};
Expand Down
4 changes: 2 additions & 2 deletions platform/macos/display_server_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3562,14 +3562,14 @@ - (void)popupAction:(id)sender {
}

bool DisplayServerMacOS::window_can_draw(WindowID p_window) const {
return (window_get_mode(p_window) != WINDOW_MODE_MINIMIZED) && [windows[p_window].window_object isOnActiveSpace];
return windows[p_window].is_visible;
}

bool DisplayServerMacOS::can_any_window_draw() const {
_THREAD_SAFE_METHOD_

for (const KeyValue<WindowID, WindowData> &E : windows) {
if ((window_get_mode(E.key) != WINDOW_MODE_MINIMIZED) && [E.value.window_object isOnActiveSpace]) {
if (E.value.is_visible) {
return true;
}
}
Expand Down
9 changes: 9 additions & 0 deletions platform/macos/godot_window_delegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,13 @@ - (void)windowDidDeminiaturize:(NSNotification *)notification {
}
}

- (void)windowDidChangeOcclusionState:(NSNotification *)notification {
DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton();
if (!ds || !ds->has_window(window_id)) {
return;
}
DisplayServerMacOS::WindowData &wd = ds->get_window(window_id);
wd.is_visible = ([wd.window_object occlusionState] & NSWindowOcclusionStateVisible) && [wd.window_object isVisible];
}

@end
Loading