refactor: make NativeWindow::transparent_ const (#47198)

* refactor: use in-class member initialization for NativeWindow::widget_

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* refactor: make NativeWindow::transparent_ const

refactor: make NativeWindow::enable_larger_than_screen_ const

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* chore: make linter happy after rebase

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2025-05-21 15:32:52 -05:00 committed by GitHub
parent c78be76176
commit 28c5f7026f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 12 deletions

View file

@ -97,10 +97,11 @@ gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) {
NativeWindow::NativeWindow(const gin_helper::Dictionary& options,
NativeWindow* parent)
: widget_(std::make_unique<views::Widget>()), parent_(parent) {
: transparent_{options.ValueOrDefault(options::kTransparent, false)},
enable_larger_than_screen_{
options.ValueOrDefault(options::kEnableLargerThanScreen, false)},
parent_{parent} {
options.Get(options::kFrame, &has_frame_);
options.Get(options::kTransparent, &transparent_);
options.Get(options::kEnableLargerThanScreen, &enable_larger_than_screen_);
options.Get(options::kTitleBarStyle, &title_bar_style_);
#if BUILDFLAG(IS_WIN)
options.Get(options::kBackgroundMaterial, &background_material_);

View file

@ -400,8 +400,11 @@ class NativeWindow : public base::SupportsUserData,
[[nodiscard]] bool has_client_frame() const { return has_client_frame_; }
bool transparent() const { return transparent_; }
bool enable_larger_than_screen() const { return enable_larger_than_screen_; }
[[nodiscard]] bool transparent() const { return transparent_; }
[[nodiscard]] bool enable_larger_than_screen() const {
return enable_larger_than_screen_;
}
NativeWindow* parent() const { return parent_; }
bool is_modal() const { return is_modal_; }
@ -478,11 +481,17 @@ class NativeWindow : public base::SupportsUserData,
private:
static bool PlatformHasClientFrame();
std::unique_ptr<views::Widget> widget_;
std::unique_ptr<views::Widget> widget_ = std::make_unique<views::Widget>();
static inline int32_t next_id_ = 0;
const int32_t window_id_ = ++next_id_;
// Whether window is transparent.
const bool transparent_;
// Whether window can be resized larger than screen.
const bool enable_larger_than_screen_;
// The content view, weak ref.
raw_ptr<views::View> content_view_ = nullptr;
@ -498,12 +507,6 @@ class NativeWindow : public base::SupportsUserData,
// Wayland hosts.
const bool has_client_frame_ = PlatformHasClientFrame();
// Whether window is transparent.
bool transparent_ = false;
// Whether window can be resized larger than screen.
bool enable_larger_than_screen_ = false;
// The windows has been closed.
bool is_closed_ = false;