mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 18:30:08 +00:00
macos: Set transparent background for toplevel window
Toplevel window background is almost transparent. For fully transparent windows the (macOS) shadow calculatation becomes really slow.
This commit is contained in:
parent
ffeca06bd6
commit
d23833285e
@ -692,24 +692,9 @@ typedef NSString *CALayerContentsGravity;
|
|||||||
|
|
||||||
-(void)setStyleMask:(NSWindowStyleMask)styleMask
|
-(void)setStyleMask:(NSWindowStyleMask)styleMask
|
||||||
{
|
{
|
||||||
gboolean was_opaque;
|
|
||||||
gboolean is_opaque;
|
|
||||||
|
|
||||||
was_opaque = (([self styleMask] & NSWindowStyleMaskTitled) != 0);
|
|
||||||
|
|
||||||
[super setStyleMask:styleMask];
|
[super setStyleMask:styleMask];
|
||||||
|
|
||||||
is_opaque = (([self styleMask] & NSWindowStyleMaskTitled) != 0);
|
|
||||||
|
|
||||||
_gdk_macos_surface_update_fullscreen_state (gdk_surface);
|
_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
|
-(NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
|
||||||
|
@ -617,6 +617,14 @@ _gdk_macos_toplevel_surface_constructed (GObject *object)
|
|||||||
|
|
||||||
_gdk_macos_surface_set_native (GDK_MACOS_SURFACE (self), window);
|
_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 */
|
/* Allow NSWindow to go fullscreen */
|
||||||
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user