From abef5d6eede6dca9900b60e74e6583705e8d0a6d Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 16:05:41 -0500 Subject: [PATCH] fix: `NativeWindow.window_id()` returns same value for all windows (#46591) fix: NativeWindow.window_id() returns same value for all windows Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- 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 3ecd370caa..38386ab0e7 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_); @@ -816,9 +814,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 b2cc8512b1..8eee441a05 100644 --- a/shell/browser/native_window.h +++ b/shell/browser/native_window.h @@ -407,7 +407,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); @@ -470,7 +470,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;