From c6e6a03a2421dc3da6a67d3976cb6fbcce342592 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 9 Apr 2025 10:45:06 -0500 Subject: [PATCH] fix: `NativeWindow.window_id()` returns same value for all windows (#46562) fix: NativeWindow.window_id() returns same value for all windows --- shell/browser/native_window.cc | 5 ----- shell/browser/native_window.h | 5 +++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index 241577383e1f..d8a0e49c83f6 100644 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -94,8 +94,6 @@ gfx::Size GetExpandedWindowSize(const NativeWindow* window, gfx::Size size) { NativeWindow::NativeWindow(const gin_helper::Dictionary& options, NativeWindow* parent) : widget_(std::make_unique()), parent_(parent) { - ++next_id_; - options.Get(options::kFrame, &has_frame_); options.Get(options::kTransparent, &transparent_); options.Get(options::kEnableLargerThanScreen, &enable_larger_than_screen_); @@ -820,9 +818,6 @@ void NativeWindow::HandlePendingFullscreenTransitions() { SetFullScreen(next_transition); } -// static -int32_t NativeWindow::next_id_ = 0; - bool NativeWindow::IsTranslucent() const { // Transparent windows are translucent if (transparent()) { diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h index 0d675b4f70dc..cc4d150ca72b 100644 --- a/shell/browser/native_window.h +++ b/shell/browser/native_window.h @@ -409,7 +409,7 @@ class NativeWindow : public base::SupportsUserData, NativeWindow* parent() const { return parent_; } bool is_modal() const { return is_modal_; } - int32_t window_id() const { return next_id_; } + int32_t window_id() const { return window_id_; } void add_child_window(NativeWindow* child) { child_windows_.push_back(child); @@ -472,7 +472,8 @@ class NativeWindow : public base::SupportsUserData, private: std::unique_ptr widget_; - static int32_t next_id_; + static inline int32_t next_id_ = 0; + const int32_t window_id_ = ++next_id_; // The content view, weak ref. raw_ptr content_view_ = nullptr;