| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/display/display_layout_store.h" | 8 #include "ash/display/display_layout_store.h" |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/display/display_util.h" | 10 #include "ash/display/display_util.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 DisplayLayoutStore::~DisplayLayoutStore() { | 39 DisplayLayoutStore::~DisplayLayoutStore() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 void DisplayLayoutStore::SetDefaultDisplayLayout(const DisplayLayout& layout) { | 42 void DisplayLayoutStore::SetDefaultDisplayLayout(const DisplayLayout& layout) { |
| 43 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 43 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 44 if (!command_line->HasSwitch(switches::kAshSecondaryDisplayLayout)) | 44 if (!command_line->HasSwitch(switches::kAshSecondaryDisplayLayout)) |
| 45 default_display_layout_ = layout; | 45 default_display_layout_ = layout; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void DisplayLayoutStore::RegisterLayoutForDisplayIdPair( | 48 void DisplayLayoutStore::RegisterLayoutForDisplayIdList( |
| 49 int64_t id1, | 49 int64_t id1, |
| 50 int64_t id2, | 50 int64_t id2, |
| 51 const DisplayLayout& layout) { | 51 const DisplayLayout& layout) { |
| 52 auto key = CreateDisplayIdPair(id1, id2); | 52 auto key = CreateDisplayIdList(id1, id2); |
| 53 | 53 |
| 54 // Do not overwrite the valid data with old invalid date. | 54 // Do not overwrite the valid data with old invalid date. |
| 55 if (paired_layouts_.count(key) && !CompareDisplayIds(id1, id2)) | 55 if (layouts_.count(key) && !CompareDisplayIds(id1, id2)) |
| 56 return; | 56 return; |
| 57 | 57 |
| 58 paired_layouts_[key] = layout; | 58 layouts_[key] = layout; |
| 59 } | 59 } |
| 60 | 60 |
| 61 DisplayLayout DisplayLayoutStore::GetRegisteredDisplayLayout( | 61 DisplayLayout DisplayLayoutStore::GetRegisteredDisplayLayout( |
| 62 const DisplayIdPair& pair) { | 62 const DisplayIdList& list) { |
| 63 std::map<DisplayIdPair, DisplayLayout>::const_iterator iter = | 63 std::map<DisplayIdList, DisplayLayout>::const_iterator iter = |
| 64 paired_layouts_.find(pair); | 64 layouts_.find(list); |
| 65 return | 65 return iter != layouts_.end() ? iter->second : CreateDisplayLayout(list); |
| 66 iter != paired_layouts_.end() ? iter->second : CreateDisplayLayout(pair); | |
| 67 } | 66 } |
| 68 | 67 |
| 69 DisplayLayout DisplayLayoutStore::ComputeDisplayLayoutForDisplayIdPair( | 68 DisplayLayout DisplayLayoutStore::ComputeDisplayLayoutForDisplayIdList( |
| 70 const DisplayIdPair& pair) { | 69 const DisplayIdList& list) { |
| 71 DisplayLayout layout = GetRegisteredDisplayLayout(pair); | 70 DisplayLayout layout = GetRegisteredDisplayLayout(list); |
| 72 DCHECK_NE(layout.primary_id, gfx::Display::kInvalidDisplayID); | 71 DCHECK_NE(layout.primary_id, gfx::Display::kInvalidDisplayID); |
| 73 // Invert if the primary was swapped. If mirrored, first is always | 72 // Invert if the primary was swapped. If mirrored, first is always |
| 74 // primary. | 73 // primary. |
| 75 return (layout.primary_id == gfx::Display::kInvalidDisplayID || | 74 return (layout.primary_id == gfx::Display::kInvalidDisplayID || |
| 76 pair.first == layout.primary_id) ? layout : layout.Invert(); | 75 list[0] == layout.primary_id) |
| 76 ? layout |
| 77 : layout.Invert(); |
| 77 } | 78 } |
| 78 | 79 |
| 79 void DisplayLayoutStore::UpdateMultiDisplayState(const DisplayIdPair& pair, | 80 void DisplayLayoutStore::UpdateMultiDisplayState(const DisplayIdList& list, |
| 80 bool mirrored, | 81 bool mirrored, |
| 81 bool default_unified) { | 82 bool default_unified) { |
| 82 if (paired_layouts_.find(pair) == paired_layouts_.end()) | 83 if (layouts_.find(list) == layouts_.end()) |
| 83 CreateDisplayLayout(pair); | 84 CreateDisplayLayout(list); |
| 84 paired_layouts_[pair].mirrored = mirrored; | 85 layouts_[list].mirrored = mirrored; |
| 85 paired_layouts_[pair].default_unified = default_unified; | 86 layouts_[list].default_unified = default_unified; |
| 86 } | 87 } |
| 87 | 88 |
| 88 void DisplayLayoutStore::UpdatePrimaryDisplayId(const DisplayIdPair& pair, | 89 void DisplayLayoutStore::UpdatePrimaryDisplayId(const DisplayIdList& list, |
| 89 int64_t display_id) { | 90 int64_t display_id) { |
| 90 if (paired_layouts_.find(pair) == paired_layouts_.end()) | 91 if (layouts_.find(list) == layouts_.end()) |
| 91 CreateDisplayLayout(pair); | 92 CreateDisplayLayout(list); |
| 92 paired_layouts_[pair].primary_id = display_id; | 93 layouts_[list].primary_id = display_id; |
| 93 } | 94 } |
| 94 | 95 |
| 95 DisplayLayout DisplayLayoutStore::CreateDisplayLayout( | 96 DisplayLayout DisplayLayoutStore::CreateDisplayLayout( |
| 96 const DisplayIdPair& pair) { | 97 const DisplayIdList& list) { |
| 97 DisplayLayout layout = default_display_layout_; | 98 DisplayLayout layout = default_display_layout_; |
| 98 layout.primary_id = pair.first; | 99 layout.primary_id = list[0]; |
| 99 paired_layouts_[pair] = layout; | 100 layouts_[list] = layout; |
| 100 return layout; | 101 return layout; |
| 101 } | 102 } |
| 102 | 103 |
| 103 } // namespace ash | 104 } // namespace ash |
| OLD | NEW |