refactor: make NativeWindow::has_client_frame_ const (#47178)

* refactor: make NativeWindow::has_client_frame_ const

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

* refactor: make NativeWindow::has_client_frame_ const but not constexpr

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-20 19:39:15 -05:00
committed by GitHub
parent 406f4eded6
commit 2b96789b23
2 changed files with 21 additions and 13 deletions

View File

@@ -123,17 +123,6 @@ NativeWindow::NativeWindow(const gin_helper::Dictionary& options,
if (parent)
options.Get("modal", &is_modal_);
#if defined(USE_OZONE)
// Ozone X11 likes to prefer custom frames, but we don't need them unless
// on Wayland.
if (base::FeatureList::IsEnabled(features::kWaylandWindowDecorations) &&
!ui::OzonePlatform::GetInstance()
->GetPlatformRuntimeProperties()
.supports_server_side_window_decorations) {
has_client_frame_ = true;
}
#endif
WindowList::AddWindow(this);
}
@@ -838,6 +827,22 @@ bool NativeWindow::IsTranslucent() const {
return false;
}
// static
bool NativeWindow::PlatformHasClientFrame() {
#if defined(USE_OZONE)
// Ozone X11 likes to prefer custom frames,
// but we don't need them unless on Wayland.
static const bool has_client_frame =
base::FeatureList::IsEnabled(features::kWaylandWindowDecorations) &&
!ui::OzonePlatform::GetInstance()
->GetPlatformRuntimeProperties()
.supports_server_side_window_decorations;
return has_client_frame;
#else
return false;
#endif
}
// static
void NativeWindowRelay::CreateForWebContents(
content::WebContents* web_contents,

View File

@@ -400,7 +400,8 @@ class NativeWindow : public base::SupportsUserData,
bool has_frame() const { return has_frame_; }
void set_has_frame(bool has_frame) { has_frame_ = has_frame; }
bool has_client_frame() const { return has_client_frame_; }
[[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_; }
@@ -468,6 +469,8 @@ class NativeWindow : public base::SupportsUserData,
std::list<NativeWindow*> child_windows_;
private:
static bool PlatformHasClientFrame();
std::unique_ptr<views::Widget> widget_;
static inline int32_t next_id_ = 0;
@@ -482,7 +485,7 @@ class NativeWindow : public base::SupportsUserData,
// Whether window has standard frame, but it's drawn by Electron (the client
// application) instead of the OS. Currently only has meaning on Linux for
// Wayland hosts.
bool has_client_frame_ = false;
const bool has_client_frame_ = PlatformHasClientFrame();
// Whether window is transparent.
bool transparent_ = false;