fix: NativeWindow.window_id() returns same value for all windows (#46588)

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 <charles@charleskerr.com>
This commit is contained in:
trop[bot]
2025-04-09 13:48:55 -05:00
committed by GitHub
parent d0594707de
commit 4e93d53942
2 changed files with 3 additions and 7 deletions

View File

@@ -96,8 +96,6 @@ const char kElectronNativeWindowKey[] = "__ELECTRON_NATIVE_WINDOW__";
NativeWindow::NativeWindow(const gin_helper::Dictionary& options,
NativeWindow* parent)
: widget_(std::make_unique<views::Widget>()), parent_(parent) {
++next_id_;
options.Get(options::kFrame, &has_frame_);
options.Get(options::kTransparent, &transparent_);
options.Get(options::kEnableLargerThanScreen, &enable_larger_than_screen_);
@@ -809,9 +807,6 @@ void NativeWindow::HandlePendingFullscreenTransitions() {
SetFullScreen(next_transition);
}
// static
int32_t NativeWindow::next_id_ = 0;
bool NativeWindow::IsTranslucent() const {
// Transparent windows are translucent
if (transparent()) {

View File

@@ -402,7 +402,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);
@@ -465,7 +465,8 @@ class NativeWindow : public base::SupportsUserData,
private:
std::unique_ptr<views::Widget> 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<views::View> content_view_ = nullptr;