Skip to content

Commit aad8f57

Browse files
committed
Merge pull request #106355 from bruvzg/mac_emb_trans
[macOS] Fix transparent window state detection for embedded process.
2 parents 22a0e81 + 887fa78 commit aad8f57

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

platform/macos/display_server_embedded.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class DisplayServerEmbedded : public DisplayServer {
6666

6767
WindowID window_id_counter = MAIN_WINDOW_ID;
6868

69+
bool transparent = false;
70+
6971
CAContext *ca_context = nullptr;
7072
// Either be a CAMetalLayer or a CALayer depending on the rendering driver.
7173
CALayer *layer = nullptr;

platform/macos/display_server_embedded.mm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@
192192
layer.contentsScale = scale;
193193
layer.magnificationFilter = kCAFilterNearest;
194194
layer.minificationFilter = kCAFilterNearest;
195-
layer.opaque = NO; // Never opaque when embedded, clear color is drawn by control under the view.
195+
transparent = ((p_flags & WINDOW_FLAG_TRANSPARENT_BIT) == WINDOW_FLAG_TRANSPARENT_BIT);
196+
layer.opaque = !(OS::get_singleton()->is_layered_allowed() && transparent);
196197
layer.actions = @{ @"contents" : [NSNull null] }; // Disable implicit animations for contents.
197198
// AppKit frames, bounds and positions are always in points.
198199
CGRect bounds = CGRectMake(0, 0, p_resolution.width, p_resolution.height);
@@ -654,10 +655,16 @@
654655
}
655656

656657
void DisplayServerEmbedded::window_set_flag(WindowFlags p_flag, bool p_enabled, WindowID p_window) {
657-
// Not supported
658+
if (p_flag == WINDOW_FLAG_TRANSPARENT && p_window == MAIN_WINDOW_ID) {
659+
transparent = p_enabled;
660+
layer.opaque = !(OS::get_singleton()->is_layered_allowed() && transparent);
661+
}
658662
}
659663

660664
bool DisplayServerEmbedded::window_get_flag(WindowFlags p_flag, WindowID p_window) const {
665+
if (p_flag == WINDOW_FLAG_TRANSPARENT && p_window == MAIN_WINDOW_ID) {
666+
return transparent;
667+
}
661668
return false;
662669
}
663670

0 commit comments

Comments
 (0)