Merge pull request #5334 from miniak/fix-screen-events
Fix #3075 by not caching the displays (id is not persistent on Windows)
This commit is contained in:
commit
4001f10e2d
2 changed files with 1 additions and 14 deletions
|
@ -49,7 +49,6 @@ std::vector<std::string> 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<gfx::Display> 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));
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@ class Screen : public mate::EventEmitter<Screen>,
|
|||
|
||||
private:
|
||||
gfx::Screen* screen_;
|
||||
std::vector<gfx::Display> displays_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Screen);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue