Chromium Code Reviews| Index: ui/ozone/platform/dri/chromeos/display_message_handler.cc |
| diff --git a/ui/ozone/platform/dri/chromeos/display_message_handler.cc b/ui/ozone/platform/dri/chromeos/display_message_handler.cc |
| index fec666ef2b353e4940c7a1bc82a9ea7d7b5185eb..6e68b82aeea32d4a02e0ca47abad55da6f867e62 100644 |
| --- a/ui/ozone/platform/dri/chromeos/display_message_handler.cc |
| +++ b/ui/ozone/platform/dri/chromeos/display_message_handler.cc |
| @@ -13,6 +13,22 @@ |
| namespace ui { |
| +namespace { |
| + |
| +class FindDisplayById { |
| + public: |
| + FindDisplayById(int64_t display_id) : display_id_(display_id) {} |
| + |
| + bool operator()(const DisplaySnapshot_Params& display) const { |
| + return display.display_id == display_id_; |
| + } |
| + |
| + private: |
| + int64_t display_id_; |
| +}; |
| + |
| +} // namespace |
| + |
| DisplayMessageHandler::DisplayMessageHandler( |
| scoped_ptr<NativeDisplayDelegateDri> ndd) |
| : sender_(NULL), |
| @@ -45,9 +61,28 @@ void DisplayMessageHandler::OnForceDPMSOn() { |
| ndd_->ForceDPMSOn(); |
| } |
| -void DisplayMessageHandler::OnRefreshNativeDisplays() { |
| +void DisplayMessageHandler::OnRefreshNativeDisplays( |
|
spang
2014/09/08 22:49:17
There's now a big overlap between RefreshNativeDis
dnicoara
2014/09/09 14:29:28
Not quite. RefreshNativeDisplays is passed a stale
spang
2014/09/09 14:44:25
What do you mean by stale configuration? Does it a
dnicoara
2014/09/09 15:10:00
The configuration could be nothing (since CrOS jus
|
| + const std::vector<DisplaySnapshot_Params>& cached_displays) { |
| std::vector<DisplaySnapshot_Params> displays; |
| std::vector<DisplaySnapshot*> native_displays = ndd_->GetDisplays(); |
| + |
| + // If any of the cached displays are in the list of new displays then apply |
| + // their configuration immediately. |
| + for (size_t i = 0; i < native_displays.size(); ++i) { |
| + std::vector<DisplaySnapshot_Params>::const_iterator it = |
| + std::find_if(cached_displays.begin(), |
| + cached_displays.end(), |
| + FindDisplayById(native_displays[i]->display_id())); |
| + |
| + if (it == cached_displays.end()) |
| + continue; |
| + |
| + if (it->has_current_mode) |
| + OnConfigureNativeDisplay(it->display_id, it->current_mode, it->origin); |
| + else |
| + OnDisableNativeDisplay(it->display_id); |
| + } |
| + |
| for (size_t i = 0; i < native_displays.size(); ++i) |
| displays.push_back(GetDisplaySnapshotParams(*native_displays[i])); |