Repository: electron/electron
File: shell/browser/native_window_views_win.cc (C++)

Code before:
  std::optional<COLORREF> border_color;
  bool should_apply_accent = false;

  if (std::holds_alternative<SkColor>(accent_color_)) {
    // If the user has explicitly set an accent color, use it
    // regardless of whether the system accent color is enabled.
    SkColor color = std::get<SkColor>(accent_color_);
    border_color =
        RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color));
    should_apply_accent = true;
  } else if (std::holds_alternative<bool>(accent_color_)) {
    // Allow the user to optionally force system color on/off.
    should_apply_accent = std::get<bool>(accent_color_);
  } else if (std::holds_alternative<std::monostate>(accent_color_)) {
    // If no explicit color was set, default to the system accent color.
    should_apply_accent = IsAccentColorOnTitleBarsEnabled();
  }

  // Use system accent color as fallback if no explicit color was set.
  if (!border_color.has_value() && should_apply_accent) {
    std::optional<DWORD> system_accent_color = GetAccentColor();
    if (system_accent_color.has_value()) {
      border_color = RGB(GetRValue(system_accent_color.value()),
                         GetGValue(system_accent_color.value()),
                         GetBValue(system_accent_color.value()));
    } else {
      should_apply_accent = false;
    }
  }

  COLORREF final_color = should_apply_accent && border_color.has_value()
                             ? border_color.value()
                             : DWMWA_COLOR_DEFAULT;
  SetWindowBorderAndCaptionColor(GetAcceleratedWidget(), final_color);
}

void NativeWindowViews::ResetWindowControls() {
  // If a given window was minimized and has since been
  // unminimized (restored/maximized), ensure the WCO buttons
  // are reset to their default unpressed state.
  auto* ncv = widget()->non_client_view();
  if (IsWindowControlsOverlayEnabled() && ncv) {
    auto* frame_view = static_cast<WinFrameView*>(ncv->frame_view());
    frame_view->caption_button_container()->ResetWindowControls();
  }
}

// Windows with |backgroundMaterial| expand to the same dimensions and
// placement as the display to approximate maximization - unless we remove
// rounded corners there will be a gap between the window and the display
// at the corners noticable to users.

Review comment (suggestion):
Shouldn't be needed. 

```suggestion

```

Then the below can just be, is there a case where we have border_color and we don't want to apply accent ?

```
COLORREF final_color = border_color.value_or(DWMWA_COLOR_DEFAULT);
```

Code after:
  std::optional<COLORREF> border_color;
  bool should_apply_accent = false;

  if (std::holds_alternative<SkColor>(accent_color_)) {
    // If the user has explicitly set an accent color, use it
    // regardless of whether the system accent color is enabled.
    SkColor color = std::get<SkColor>(accent_color_);
    border_color =
        RGB(SkColorGetR(color), SkColorGetG(color), SkColorGetB(color));
    should_apply_accent = true;
  } else if (std::holds_alternative<bool>(accent_color_)) {
    // Allow the user to optionally force system color on/off.
    should_apply_accent = std::get<bool>(accent_color_);
  } else if (std::holds_alternative<std::monostate>(accent_color_)) {
    // If no explicit color was set, default to the system accent color.
    should_apply_accent = IsAccentColorOnTitleBarsEnabled();
  }

  // Use system accent color as fallback if no explicit color was set.
  if (!border_color.has_value() && should_apply_accent) {
    std::optional<DWORD> system_accent_color = GetAccentColor();
    if (system_accent_color.has_value()) {
      border_color = RGB(GetRValue(system_accent_color.value()),
                         GetGValue(system_accent_color.value()),
                         GetBValue(system_accent_color.value()));
    }
  }

  COLORREF final_color = border_color.value_or(DWMWA_COLOR_DEFAULT);
  SetWindowBorderAndCaptionColor(GetAcceleratedWidget(), final_color);
}

void NativeWindowViews::ResetWindowControls() {
  // If a given window was minimized and has since been
  // unminimized (restored/maximized), ensure the WCO buttons
  // are reset to their default unpressed state.
  auto* ncv = widget()->non_client_view();
  if (IsWindowControlsOverlayEnabled() && ncv) {
    auto* frame_view = static_cast<WinFrameView*>(ncv->frame_view());
    frame_view->caption_button_container()->ResetWindowControls();
  }
}

// Windows with |backgroundMaterial| expand to the same dimensions and
// placement as the display to approximate maximization - unless we remove
// rounded corners there will be a gap between the window and the display
// at the corners noticable to users.
void NativeWindowViews::SetRoundedCorners(bool rounded) {
  // DWMWA_WINDOW_CORNER_PREFERENCE is supported after Windows 11 Build 22000.
  if (base::win::GetVersion() < base::win::Version::WIN11)
    return;