fix: window accentColor
should adhere to native window behavior (#47802)
* fix: window accentColor should adhere to native window behavior Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * fix: address review feedback Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> * chore: remove duplicate UpdateWindowAccentColor call in ctor Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
bfdc318d56
commit
673ec5d39e
3 changed files with 11 additions and 7 deletions
|
@ -422,8 +422,6 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
|
||||||
last_window_state_ = ui::mojom::WindowShowState::kFullscreen;
|
last_window_state_ = ui::mojom::WindowShowState::kFullscreen;
|
||||||
else
|
else
|
||||||
last_window_state_ = ui::mojom::WindowShowState::kNormal;
|
last_window_state_ = ui::mojom::WindowShowState::kNormal;
|
||||||
|
|
||||||
UpdateWindowAccentColor();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Listen to mouse events.
|
// Listen to mouse events.
|
||||||
|
@ -1746,6 +1744,12 @@ void NativeWindowViews::OnWidgetActivationChanged(views::Widget* changed_widget,
|
||||||
NativeWindow::NotifyWindowBlur();
|
NativeWindow::NotifyWindowBlur();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BUILDFLAG(IS_WIN)
|
||||||
|
// Update accent color based on activation state when no explicit color is
|
||||||
|
// set.
|
||||||
|
UpdateWindowAccentColor(active);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Hide menu bar when window is blurred.
|
// Hide menu bar when window is blurred.
|
||||||
if (!active && IsMenuBarAutoHide() && IsMenuBarVisible())
|
if (!active && IsMenuBarAutoHide() && IsMenuBarVisible())
|
||||||
SetMenuBarVisibility(false);
|
SetMenuBarVisibility(false);
|
||||||
|
|
|
@ -222,7 +222,7 @@ class NativeWindowViews : public NativeWindow,
|
||||||
void ResetWindowControls();
|
void ResetWindowControls();
|
||||||
void SetRoundedCorners(bool rounded);
|
void SetRoundedCorners(bool rounded);
|
||||||
void SetForwardMouseMessages(bool forward);
|
void SetForwardMouseMessages(bool forward);
|
||||||
void UpdateWindowAccentColor();
|
void UpdateWindowAccentColor(bool active);
|
||||||
static LRESULT CALLBACK SubclassProc(HWND hwnd,
|
static LRESULT CALLBACK SubclassProc(HWND hwnd,
|
||||||
UINT msg,
|
UINT msg,
|
||||||
WPARAM w_param,
|
WPARAM w_param,
|
||||||
|
|
|
@ -499,7 +499,7 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case WM_DWMCOLORIZATIONCOLORCHANGED: {
|
case WM_DWMCOLORIZATIONCOLORCHANGED: {
|
||||||
UpdateWindowAccentColor();
|
UpdateWindowAccentColor(IsActive());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case WM_SETTINGCHANGE: {
|
case WM_SETTINGCHANGE: {
|
||||||
|
@ -507,7 +507,7 @@ bool NativeWindowViews::PreHandleMSG(UINT message,
|
||||||
const wchar_t* setting_name = reinterpret_cast<const wchar_t*>(l_param);
|
const wchar_t* setting_name = reinterpret_cast<const wchar_t*>(l_param);
|
||||||
std::wstring setting_str(setting_name);
|
std::wstring setting_str(setting_name);
|
||||||
if (setting_str == L"ImmersiveColorSet")
|
if (setting_str == L"ImmersiveColorSet")
|
||||||
UpdateWindowAccentColor();
|
UpdateWindowAccentColor(IsActive());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,7 @@ void NativeWindowViews::HandleSizeEvent(WPARAM w_param, LPARAM l_param) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::UpdateWindowAccentColor() {
|
void NativeWindowViews::UpdateWindowAccentColor(bool active) {
|
||||||
if (base::win::GetVersion() < base::win::Version::WIN11)
|
if (base::win::GetVersion() < base::win::Version::WIN11)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -589,7 +589,7 @@ void NativeWindowViews::UpdateWindowAccentColor() {
|
||||||
should_apply_accent = std::get<bool>(accent_color_);
|
should_apply_accent = std::get<bool>(accent_color_);
|
||||||
} else if (std::holds_alternative<std::monostate>(accent_color_)) {
|
} else if (std::holds_alternative<std::monostate>(accent_color_)) {
|
||||||
// If no explicit color was set, default to the system accent color.
|
// If no explicit color was set, default to the system accent color.
|
||||||
should_apply_accent = IsAccentColorOnTitleBarsEnabled();
|
should_apply_accent = IsAccentColorOnTitleBarsEnabled() && active;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use system accent color as fallback if no explicit color was set.
|
// Use system accent color as fallback if no explicit color was set.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue