From 340b7220f126e8f9d590a76b34604a085c833cab Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Thu, 28 Apr 2016 17:46:41 +0200 Subject: [PATCH] Fix #3075 by not caching the displays (id is not persistent on Windows) --- atom/browser/api/atom_api_screen.cc | 14 +------------- atom/browser/api/atom_api_screen.h | 1 - 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/atom/browser/api/atom_api_screen.cc b/atom/browser/api/atom_api_screen.cc index 61b722d..9d845e3 100644 --- a/atom/browser/api/atom_api_screen.cc +++ b/atom/browser/api/atom_api_screen.cc @@ -49,7 +49,6 @@ std::vector MetricsToArray(uint32_t metrics) { Screen::Screen(v8::Isolate* isolate, gfx::Screen* screen) : screen_(screen) { - displays_ = screen_->GetAllDisplays(); screen_->AddObserver(this); Init(isolate); } @@ -67,7 +66,7 @@ gfx::Display Screen::GetPrimaryDisplay() { } std::vector Screen::GetAllDisplays() { - return displays_; + return screen_->GetAllDisplays(); } gfx::Display Screen::GetDisplayNearestPoint(const gfx::Point& point) { @@ -79,26 +78,15 @@ gfx::Display Screen::GetDisplayMatching(const gfx::Rect& match_rect) { } void Screen::OnDisplayAdded(const gfx::Display& new_display) { - displays_.push_back(new_display); Emit("display-added", new_display); } void Screen::OnDisplayRemoved(const gfx::Display& old_display) { - auto iter = FindById(&displays_, old_display.id()); - if (iter == displays_.end()) - return; - - displays_.erase(iter); Emit("display-removed", old_display); } void Screen::OnDisplayMetricsChanged(const gfx::Display& display, uint32_t changed_metrics) { - auto iter = FindById(&displays_, display.id()); - if (iter == displays_.end()) - return; - - *iter = display; Emit("display-metrics-changed", display, MetricsToArray(changed_metrics)); } diff --git a/atom/browser/api/atom_api_screen.h b/atom/browser/api/atom_api_screen.h index 14fc8ce..c17b612 100644 --- a/atom/browser/api/atom_api_screen.h +++ b/atom/browser/api/atom_api_screen.h @@ -47,7 +47,6 @@ class Screen : public mate::EventEmitter, private: gfx::Screen* screen_; - std::vector displays_; DISALLOW_COPY_AND_ASSIGN(Screen); }; -- 2.7.4