mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
fix: abnormal behavior of windows background material (#47814)
* fix: abnormal behavior of windows background material Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> Co-authored-by: zoy <zoy-l@outlook.com> * chore: update patches Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com> * fix: setting background material after init Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: zoy <zoy-l@outlook.com> Co-authored-by: patchup[bot] <73610968+patchup[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user