|
@@ -270,53 +270,46 @@ void DisplayServerMacOS::_update_window_style(WindowData p_wd) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void DisplayServerMacOS::_set_window_per_pixel_transparency_enabled(bool p_enabled, WindowID p_window) {
|
|
|
+void DisplayServerMacOS::set_window_per_pixel_transparency_enabled(bool p_enabled, WindowID p_window) {
|
|
|
ERR_FAIL_COND(!windows.has(p_window));
|
|
|
WindowData &wd = windows[p_window];
|
|
|
|
|
|
if (!OS::get_singleton()->is_layered_allowed()) {
|
|
|
return;
|
|
|
}
|
|
|
- if (wd.layered_window != p_enabled) {
|
|
|
- if (p_enabled) {
|
|
|
- [wd.window_object setBackgroundColor:[NSColor clearColor]];
|
|
|
- [wd.window_object setOpaque:NO];
|
|
|
- [wd.window_object setHasShadow:NO];
|
|
|
- CALayer *layer = [(NSView *)wd.window_view layer];
|
|
|
- if (layer) {
|
|
|
- [layer setBackgroundColor:[NSColor clearColor].CGColor];
|
|
|
- [layer setOpaque:NO];
|
|
|
- }
|
|
|
+ if (p_enabled) {
|
|
|
+ [wd.window_object setBackgroundColor:[NSColor clearColor]];
|
|
|
+ [wd.window_object setOpaque:NO];
|
|
|
+ [wd.window_object setHasShadow:NO];
|
|
|
+ CALayer *layer = [(NSView *)wd.window_view layer];
|
|
|
+ if (layer) {
|
|
|
+ [layer setBackgroundColor:[NSColor clearColor].CGColor];
|
|
|
+ [layer setOpaque:NO];
|
|
|
+ }
|
|
|
#if defined(GLES3_ENABLED)
|
|
|
- if (gl_manager_legacy) {
|
|
|
- gl_manager_legacy->window_set_per_pixel_transparency_enabled(p_window, true);
|
|
|
- }
|
|
|
+ if (gl_manager_legacy) {
|
|
|
+ gl_manager_legacy->window_set_per_pixel_transparency_enabled(p_window, true);
|
|
|
+ }
|
|
|
#endif
|
|
|
- wd.layered_window = true;
|
|
|
- } else {
|
|
|
- NSColor *bg_color = [NSColor windowBackgroundColor];
|
|
|
- Color _bg_color;
|
|
|
- if (_get_window_early_clear_override(_bg_color)) {
|
|
|
- bg_color = [NSColor colorWithCalibratedRed:_bg_color.r green:_bg_color.g blue:_bg_color.b alpha:1.f];
|
|
|
- }
|
|
|
- [wd.window_object setBackgroundColor:bg_color];
|
|
|
- [wd.window_object setOpaque:YES];
|
|
|
- [wd.window_object setHasShadow:YES];
|
|
|
- CALayer *layer = [(NSView *)wd.window_view layer];
|
|
|
- if (layer) {
|
|
|
- [layer setBackgroundColor:bg_color.CGColor];
|
|
|
- [layer setOpaque:YES];
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ NSColor *bg_color = [NSColor windowBackgroundColor];
|
|
|
+ Color _bg_color;
|
|
|
+ if (_get_window_early_clear_override(_bg_color)) {
|
|
|
+ bg_color = [NSColor colorWithCalibratedRed:_bg_color.r green:_bg_color.g blue:_bg_color.b alpha:1.f];
|
|
|
+ }
|
|
|
+ [wd.window_object setBackgroundColor:bg_color];
|
|
|
+ [wd.window_object setOpaque:YES];
|
|
|
+ [wd.window_object setHasShadow:YES];
|
|
|
+ CALayer *layer = [(NSView *)wd.window_view layer];
|
|
|
+ if (layer) {
|
|
|
+ [layer setBackgroundColor:bg_color.CGColor];
|
|
|
+ [layer setOpaque:YES];
|
|
|
+ }
|
|
|
#if defined(GLES3_ENABLED)
|
|
|
- if (gl_manager_legacy) {
|
|
|
- gl_manager_legacy->window_set_per_pixel_transparency_enabled(p_window, false);
|
|
|
- }
|
|
|
-#endif
|
|
|
- wd.layered_window = false;
|
|
|
+ if (gl_manager_legacy) {
|
|
|
+ gl_manager_legacy->window_set_per_pixel_transparency_enabled(p_window, false);
|
|
|
}
|
|
|
- NSRect frameRect = [wd.window_object frame];
|
|
|
- [wd.window_object setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:YES];
|
|
|
- [wd.window_object setFrame:frameRect display:YES];
|
|
|
+#endif
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -3295,7 +3288,6 @@ void DisplayServerMacOS::window_set_mode(WindowMode p_mode, WindowID p_window) {
|
|
|
}
|
|
|
|
|
|
[(NSWindow *)wd.window_object setLevel:NSNormalWindowLevel];
|
|
|
- _set_window_per_pixel_transparency_enabled(true, p_window);
|
|
|
if (wd.resize_disabled) { // Restore resize disabled.
|
|
|
[wd.window_object setStyleMask:[wd.window_object styleMask] & ~NSWindowStyleMaskResizable];
|
|
|
}
|
|
@@ -3332,7 +3324,6 @@ void DisplayServerMacOS::window_set_mode(WindowMode p_mode, WindowID p_window) {
|
|
|
} break;
|
|
|
case WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
|
|
|
case WINDOW_MODE_FULLSCREEN: {
|
|
|
- _set_window_per_pixel_transparency_enabled(false, p_window);
|
|
|
if (wd.resize_disabled) { // Fullscreen window should be resizable to work.
|
|
|
[wd.window_object setStyleMask:[wd.window_object styleMask] | NSWindowStyleMaskResizable];
|
|
|
}
|
|
@@ -3489,6 +3480,7 @@ void DisplayServerMacOS::window_set_flag(WindowFlags p_flag, bool p_enabled, Win
|
|
|
} break;
|
|
|
case WINDOW_FLAG_EXTEND_TO_TITLE: {
|
|
|
NSRect rect = [wd.window_object frame];
|
|
|
+ wd.extend_to_title = p_enabled;
|
|
|
if (p_enabled) {
|
|
|
[wd.window_object setTitlebarAppearsTransparent:YES];
|
|
|
[wd.window_object setStyleMask:[wd.window_object styleMask] | NSWindowStyleMaskFullSizeContentView];
|
|
@@ -3508,6 +3500,9 @@ void DisplayServerMacOS::window_set_flag(WindowFlags p_flag, bool p_enabled, Win
|
|
|
send_window_event(wd, DisplayServerMacOS::WINDOW_EVENT_TITLEBAR_CHANGE);
|
|
|
} break;
|
|
|
case WINDOW_FLAG_BORDERLESS: {
|
|
|
+ if (wd.fullscreen) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
// OrderOut prevents a lose focus bug with the window.
|
|
|
bool was_visible = false;
|
|
|
if ([wd.window_object isVisible]) {
|
|
@@ -3518,8 +3513,11 @@ void DisplayServerMacOS::window_set_flag(WindowFlags p_flag, bool p_enabled, Win
|
|
|
if (p_enabled) {
|
|
|
[wd.window_object setStyleMask:NSWindowStyleMaskBorderless];
|
|
|
} else {
|
|
|
- _set_window_per_pixel_transparency_enabled(false, p_window);
|
|
|
- [wd.window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (wd.resize_disabled ? 0 : NSWindowStyleMaskResizable)];
|
|
|
+ if (wd.layered_window) {
|
|
|
+ wd.layered_window = false;
|
|
|
+ set_window_per_pixel_transparency_enabled(false, p_window);
|
|
|
+ }
|
|
|
+ [wd.window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (wd.extend_to_title ? NSWindowStyleMaskFullSizeContentView : 0) | (wd.resize_disabled ? 0 : NSWindowStyleMaskResizable)];
|
|
|
// Force update of the window styles.
|
|
|
NSRect frameRect = [wd.window_object frame];
|
|
|
[wd.window_object setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
|
|
@@ -3548,12 +3546,20 @@ void DisplayServerMacOS::window_set_flag(WindowFlags p_flag, bool p_enabled, Win
|
|
|
}
|
|
|
} break;
|
|
|
case WINDOW_FLAG_TRANSPARENT: {
|
|
|
+ if (wd.fullscreen) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (p_enabled) {
|
|
|
[wd.window_object setStyleMask:NSWindowStyleMaskBorderless]; // Force borderless.
|
|
|
} else if (!wd.borderless) {
|
|
|
- [wd.window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (wd.resize_disabled ? 0 : NSWindowStyleMaskResizable)];
|
|
|
+ [wd.window_object setStyleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | (wd.extend_to_title ? NSWindowStyleMaskFullSizeContentView : 0) | (wd.resize_disabled ? 0 : NSWindowStyleMaskResizable)];
|
|
|
}
|
|
|
- _set_window_per_pixel_transparency_enabled(p_enabled, p_window);
|
|
|
+ wd.layered_window = p_enabled;
|
|
|
+ set_window_per_pixel_transparency_enabled(p_enabled, p_window);
|
|
|
+ // Force update of the window styles.
|
|
|
+ NSRect frameRect = [wd.window_object frame];
|
|
|
+ [wd.window_object setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO];
|
|
|
+ [wd.window_object setFrame:frameRect display:NO];
|
|
|
} break;
|
|
|
case WINDOW_FLAG_NO_FOCUS: {
|
|
|
wd.no_focus = p_enabled;
|