mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 10:20:07 +00:00
Merge branch 'amolenaar/macos-maximize-and-transparency' into 'main'
macos: Fix maximizing windows See merge request GNOME/gtk!7650
This commit is contained in:
commit
8054099d0e
@ -692,24 +692,9 @@ typedef NSString *CALayerContentsGravity;
|
||||
|
||||
-(void)setStyleMask:(NSWindowStyleMask)styleMask
|
||||
{
|
||||
gboolean was_opaque;
|
||||
gboolean is_opaque;
|
||||
|
||||
was_opaque = (([self styleMask] & NSWindowStyleMaskTitled) != 0);
|
||||
|
||||
[super setStyleMask:styleMask];
|
||||
|
||||
is_opaque = (([self styleMask] & NSWindowStyleMaskTitled) != 0);
|
||||
|
||||
_gdk_macos_surface_update_fullscreen_state (gdk_surface);
|
||||
|
||||
if (was_opaque != is_opaque)
|
||||
{
|
||||
[self setOpaque:is_opaque];
|
||||
|
||||
if (!is_opaque)
|
||||
[self setBackgroundColor:[NSColor clearColor]];
|
||||
}
|
||||
}
|
||||
|
||||
-(NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
|
||||
@ -785,13 +770,20 @@ typedef NSString *CALayerContentsGravity;
|
||||
|
||||
if (decorated)
|
||||
{
|
||||
style_mask |= NSWindowStyleMaskTitled;
|
||||
style_mask &= ~NSWindowStyleMaskFullSizeContentView;
|
||||
[self setTitleVisibility:NSWindowTitleVisible];
|
||||
}
|
||||
else
|
||||
{
|
||||
style_mask &= ~NSWindowStyleMaskTitled;
|
||||
style_mask |= NSWindowStyleMaskFullSizeContentView;
|
||||
[self setTitleVisibility:NSWindowTitleHidden];
|
||||
}
|
||||
|
||||
[self setTitlebarAppearsTransparent:!decorated];
|
||||
[[self standardWindowButton:NSWindowCloseButton] setHidden:!decorated];
|
||||
[[self standardWindowButton:NSWindowMiniaturizeButton] setHidden:!decorated];
|
||||
[[self standardWindowButton:NSWindowZoomButton] setHidden:!decorated];
|
||||
|
||||
[self setStyleMask:style_mask];
|
||||
}
|
||||
|
||||
|
@ -617,6 +617,14 @@ _gdk_macos_toplevel_surface_constructed (GObject *object)
|
||||
|
||||
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
|
||||
|
||||
[window setOpaque:NO];
|
||||
|
||||
/* Workaround: if we use full transparency, window rendering becomes slow,
|
||||
* because macOS tries to dynamically calculate the shadow.
|
||||
* Instead provide a tiny bit of alpha, so shadows are drawn around the window.
|
||||
*/
|
||||
[window setBackgroundColor:[[NSColor blackColor] colorWithAlphaComponent:0.00001]];
|
||||
|
||||
/* Allow NSWindow to go fullscreen */
|
||||
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user