| 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/common/ash_switches.h" | 7 #include "ash/common/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" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "ui/display/display.h" | 14 #include "ui/display/display.h" |
| 15 | 15 |
| 16 namespace ash { | 16 namespace ash { |
| 17 | 17 |
| 18 DisplayLayoutStore::DisplayLayoutStore() | 18 DisplayLayoutStore::DisplayLayoutStore() |
| 19 : default_display_placement_(display::DisplayPlacement::RIGHT, 0) { | 19 : default_display_placement_(display::DisplayPlacement::RIGHT, 0) { |
| 20 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 20 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 21 if (command_line->HasSwitch(switches::kAshSecondaryDisplayLayout)) { | 21 if (command_line->HasSwitch(switches::kAshSecondaryDisplayLayout)) { |
| 22 std::string value = command_line->GetSwitchValueASCII( | 22 std::string value = |
| 23 switches::kAshSecondaryDisplayLayout); | 23 command_line->GetSwitchValueASCII(switches::kAshSecondaryDisplayLayout); |
| 24 char layout; | 24 char layout; |
| 25 int offset = 0; | 25 int offset = 0; |
| 26 if (sscanf(value.c_str(), "%c,%d", &layout, &offset) == 2) { | 26 if (sscanf(value.c_str(), "%c,%d", &layout, &offset) == 2) { |
| 27 if (layout == 't') | 27 if (layout == 't') |
| 28 default_display_placement_.position = display::DisplayPlacement::TOP; | 28 default_display_placement_.position = display::DisplayPlacement::TOP; |
| 29 else if (layout == 'b') | 29 else if (layout == 'b') |
| 30 default_display_placement_.position = display::DisplayPlacement::BOTTOM; | 30 default_display_placement_.position = display::DisplayPlacement::BOTTOM; |
| 31 else if (layout == 'r') | 31 else if (layout == 'r') |
| 32 default_display_placement_.position = display::DisplayPlacement::RIGHT; | 32 default_display_placement_.position = display::DisplayPlacement::RIGHT; |
| 33 else if (layout == 'l') | 33 else if (layout == 'l') |
| 34 default_display_placement_.position = display::DisplayPlacement::LEFT; | 34 default_display_placement_.position = display::DisplayPlacement::LEFT; |
| 35 default_display_placement_.offset = offset; | 35 default_display_placement_.offset = offset; |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| 40 DisplayLayoutStore::~DisplayLayoutStore() { | 40 DisplayLayoutStore::~DisplayLayoutStore() {} |
| 41 } | |
| 42 | 41 |
| 43 void DisplayLayoutStore::SetDefaultDisplayPlacement( | 42 void DisplayLayoutStore::SetDefaultDisplayPlacement( |
| 44 const display::DisplayPlacement& placement) { | 43 const display::DisplayPlacement& placement) { |
| 45 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 44 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 46 if (!command_line->HasSwitch(switches::kAshSecondaryDisplayLayout)) | 45 if (!command_line->HasSwitch(switches::kAshSecondaryDisplayLayout)) |
| 47 default_display_placement_ = placement; | 46 default_display_placement_ = placement; |
| 48 } | 47 } |
| 49 | 48 |
| 50 void DisplayLayoutStore::RegisterLayoutForDisplayIdList( | 49 void DisplayLayoutStore::RegisterLayoutForDisplayIdList( |
| 51 const display::DisplayIdList& list, | 50 const display::DisplayIdList& list, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 placement.display_id = list[i + 1]; | 112 placement.display_id = list[i + 1]; |
| 114 placement.parent_display_id = list[i]; | 113 placement.parent_display_id = list[i]; |
| 115 layout->placement_list.push_back(placement); | 114 layout->placement_list.push_back(placement); |
| 116 } | 115 } |
| 117 layouts_[list] = std::move(layout); | 116 layouts_[list] = std::move(layout); |
| 118 auto iter = layouts_.find(list); | 117 auto iter = layouts_.find(list); |
| 119 return iter->second.get(); | 118 return iter->second.get(); |
| 120 } | 119 } |
| 121 | 120 |
| 122 } // namespace ash | 121 } // namespace ash |
| OLD | NEW |