Browse Source

fix: do not set layer explicitly for frameless window (#14730)

Cheng Zhao 6 years ago
parent
commit
6f494b3c58
1 changed files with 10 additions and 4 deletions
  1. 10 4
      atom/browser/native_window_mac.mm

+ 10 - 4
atom/browser/native_window_mac.mm

@@ -1349,10 +1349,16 @@ void NativeWindowMac::AddContentViewLayers() {
   // http://crbug.com/396264. But do not enable it on OS X 10.9 for transparent
   // window, otherwise a semi-transparent frame would show.
   if (!(transparent() && base::mac::IsOS10_9()) && !is_modal()) {
-    base::scoped_nsobject<CALayer> background_layer([[CALayer alloc] init]);
-    [background_layer
-        setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
-    [[window_ contentView] setLayer:background_layer];
+    // For normal window, we need to explicitly set layer for contentView to
+    // make setBackgroundColor work correctly.
+    // There is no need to do so for frameless window, and doing so would make
+    // titleBarStyle stop working.
+    if (has_frame()) {
+      base::scoped_nsobject<CALayer> background_layer([[CALayer alloc] init]);
+      [background_layer
+          setAutoresizingMask:kCALayerWidthSizable | kCALayerHeightSizable];
+      [[window_ contentView] setLayer:background_layer];
+    }
     [[window_ contentView] setWantsLayer:YES];
   }