fix: abnormal behavior of windows background material (#47957)
This commit is contained in:
parent
c787127e91
commit
e6ac03d0ee
10 changed files with 195 additions and 107 deletions
|
@ -850,8 +850,8 @@ void BaseWindow::SetVibrancy(v8::Isolate* isolate,
|
|||
window_->SetVibrancy(type, animation_duration_ms);
|
||||
}
|
||||
|
||||
void BaseWindow::SetBackgroundMaterial(const std::string& material_type) {
|
||||
window_->SetBackgroundMaterial(material_type);
|
||||
void BaseWindow::SetBackgroundMaterial(const std::string& material) {
|
||||
window_->SetBackgroundMaterial(material);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
|
|
|
@ -196,7 +196,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
|
|||
virtual void SetVibrancy(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> value,
|
||||
gin_helper::Arguments* args);
|
||||
void SetBackgroundMaterial(const std::string& vibrancy);
|
||||
virtual void SetBackgroundMaterial(const std::string& material);
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
std::string GetAlwaysOnTopLevel() const;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include "shell/browser/api/electron_api_browser_window.h"
|
||||
|
||||
#include "base/containers/fixed_flat_set.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_owner_delegate.h" // nogncheck
|
||||
#include "content/browser/web_contents/web_contents_impl.h" // nogncheck
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
|
@ -247,6 +248,18 @@ void BrowserWindow::SetBackgroundColor(const std::string& color_name) {
|
|||
}
|
||||
}
|
||||
|
||||
void BrowserWindow::SetBackgroundMaterial(const std::string& material) {
|
||||
BaseWindow::SetBackgroundMaterial(material);
|
||||
static constexpr auto materialTypes =
|
||||
base::MakeFixedFlatSet<std::string_view>({"tabbed", "mica", "acrylic"});
|
||||
|
||||
if (materialTypes.contains(material)) {
|
||||
SetBackgroundColor(ToRGBAHex(SK_ColorTRANSPARENT));
|
||||
} else if (material == "none") {
|
||||
SetBackgroundColor(ToRGBAHex(SK_ColorWHITE));
|
||||
}
|
||||
}
|
||||
|
||||
void BrowserWindow::FocusOnWebView() {
|
||||
web_contents()->GetRenderViewHost()->GetWidget()->Focus();
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ class BrowserWindow : public BaseWindow,
|
|||
void Focus() override;
|
||||
void Blur() override;
|
||||
void SetBackgroundColor(const std::string& color_name) override;
|
||||
void SetBackgroundMaterial(const std::string& material) override;
|
||||
void OnWindowShow() override;
|
||||
void OnWindowHide() override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue