Repository: electron/electron (language: cpp)

Issue:
Setting vibrancy removes window border style
### Preflight Checklist

- [x] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [x] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [x] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.

### Electron Version

35.1.4

### What operating system(s) are you using?

macOS

### Operating System Version

macOS 15.2

### What arch are you using?

x64

### Last Known Working Electron version

34.0.0

### Expected Behavior

In previous version (34.0.0), when I had vibrancy set to `"sidebar"` and frame to `false`, window did look like this:

(it has macOS style border frame)

![Image](https://github.com/user-attachments/assets/755227cf-30dc-473d-a220-bca0535477bb)

### Actual Behavior

Now, with exactly the same settings, the window looks like this (vibrancy set to `"sidebar"` and frame to `false`):

macOS style border of the window disappears

![Image](https://github.com/user-attachments/assets/4071ee03-cfd1-4ad4-830a-ac66ed654ae3)

Even if I enable `frame` to `true` (which I dont want to do as it enables traffic lights), it doesnt help:

![Image](https://github.com/user-attachments/assets/f1abc4fd-9968-45b2-b583-0fd4a444e453)

### Testcase Gist URL

_No response_

### Additional Information

_No response_


Discussion / hints:
<!-- blocked/need-repro -->

Hello @pie6k. Thanks for reporting this and helping to make Electron better!

Would it be possible for you to make a standalone testcase with only the code necessary to reproduce the issue? For example, [Electron Fiddle](https://www.electronjs.org/fiddle) is a great tool for making small test cases and makes it easy to publish your test case to a [gist](https://gist.github.com) that Electron maintainers can use.

Stand-alone test cases make fixing issues go more smoothly: it ensure everyone's looking at the same issue, it removes all unnecessary variables from the equation, and it can also provide the basis for automated regression tests.

Now adding the https://github.com/electron/electron/labels/blocked%2Fneed-repro label for this reason. After you make a test case, please link to it in a followup comment. This issue will be closed in 10 days if the above is not addressed.
@clavin tracked this to https://github.com/electron/electron/pull/46392 - could you take a look?
Thx for the ping. Tracked it down to [this line in Chromium](https://source.chromium.org/chromium/chromium/src/+/main:components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm;l=1321;drc=3b2367f544f1fbf07f2790c81b02546f73f47467) now getting triggered. Working on a fix.

Fix patch:
diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h
index 590ac6d8bb7cd..5420e14aecd7d 100644
--- a/shell/browser/native_window_mac.h
+++ b/shell/browser/native_window_mac.h
@@ -225,6 +225,7 @@ class NativeWindowMac : public NativeWindow,
   bool CanMaximize() const override;
   std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
       views::Widget* widget) override;
+  void OnWidgetInitialized() override;
 
   // ui::NativeThemeObserver:
   void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm
index 8bb7d5b51fa43..a895f26446213 100644
--- a/shell/browser/native_window_mac.mm
+++ b/shell/browser/native_window_mac.mm
@@ -1861,6 +1861,28 @@ int NonClientHitTest(const gfx::Point& point) override {
   return std::nullopt;
 }
 
+void NativeWindowMac::OnWidgetInitialized() {
+  // |window_| is not yet assigned when this function is called, so we need to
+  // get the window from the widget.
+  NSWindow* window = widget()->GetNativeWindow().GetNativeNSWindow();
+
+  // In |NativeWidgetNSWindowBridge::InitCompositorView| in Chromium,
+  // translucent windows are assigned a clear background color. This causes
+  // undesirable side effects, such as a window with vibrancy losing its natural
+  // system border highlight. We undo that behavior here.
+  //
+  // Ref:
+  // https://source.chromium.org/chromium/chromium/src/+/main:components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm;l=1341-1342;drc=e7c8be576285195257b0813326b3bab154dc7e73
+  if (!transparent()) {
+    if ([[window backgroundColor] isEqual:NSColor.clearColor]) {
+      [window setBackgroundColor:NSColor.windowBackgroundColor];
+    }
+    if (![window isOpaque]) {
+      [window setOpaque:YES];
+    }
+  }
+}
+
 // static
 std::unique_ptr<NativeWindow> NativeWindow::Create(
     const gin_helper::Dictionary& options,


Test patch: