Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: ash/display/display_manager.cc

Issue 18413002: [Cleanup] Factor out layout store code from DisplayController (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/display/display_manager.h ('k') | ash/display/display_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/display/display_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "ash/ash_switches.h" 12 #include "ash/ash_switches.h"
13 #include "ash/display/display_controller.h" 13 #include "ash/display/display_controller.h"
14 #include "ash/display/display_layout_store.h"
14 #include "ash/display/mirror_window_controller.h" 15 #include "ash/display/mirror_window_controller.h"
15 #include "ash/screen_ash.h" 16 #include "ash/screen_ash.h"
16 #include "ash/shell.h" 17 #include "ash/shell.h"
17 #include "base/auto_reset.h" 18 #include "base/auto_reset.h"
18 #include "base/command_line.h" 19 #include "base/command_line.h"
19 #include "base/logging.h" 20 #include "base/logging.h"
20 #include "base/stl_util.h" 21 #include "base/stl_util.h"
21 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_split.h" 23 #include "base/strings/string_split.h"
23 #include "base/strings/stringprintf.h" 24 #include "base/strings/stringprintf.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 131
131 using aura::RootWindow; 132 using aura::RootWindow;
132 using aura::Window; 133 using aura::Window;
133 using std::string; 134 using std::string;
134 using std::vector; 135 using std::vector;
135 136
136 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey, 137 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey,
137 gfx::Display::kInvalidDisplayID); 138 gfx::Display::kInvalidDisplayID);
138 139
139 DisplayManager::DisplayManager() 140 DisplayManager::DisplayManager()
140 : first_display_id_(gfx::Display::kInvalidDisplayID), 141 : layout_store_(new DisplayLayoutStore),
142 first_display_id_(gfx::Display::kInvalidDisplayID),
141 num_connected_displays_(0), 143 num_connected_displays_(0),
142 force_bounds_changed_(false), 144 force_bounds_changed_(false),
143 change_display_upon_host_resize_(false), 145 change_display_upon_host_resize_(false),
144 software_mirroring_enabled_(false) { 146 software_mirroring_enabled_(false) {
145 #if defined(OS_CHROMEOS) 147 #if defined(OS_CHROMEOS)
146 change_display_upon_host_resize_ = !base::chromeos::IsRunningOnChromeOS(); 148 change_display_upon_host_resize_ = !base::chromeos::IsRunningOnChromeOS();
147 #endif 149 #endif
148 Init(); 150 Init();
149 } 151 }
150 152
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 new_display.set_rotation(display_info.rotation()); 914 new_display.set_rotation(display_info.rotation());
913 return new_display; 915 return new_display;
914 } 916 }
915 917
916 bool DisplayManager::UpdateSecondaryDisplayBoundsForLayout( 918 bool DisplayManager::UpdateSecondaryDisplayBoundsForLayout(
917 DisplayList* displays, 919 DisplayList* displays,
918 size_t* updated_index) const { 920 size_t* updated_index) const {
919 if (displays->size() != 2U) 921 if (displays->size() != 2U)
920 return false; 922 return false;
921 923
922 DisplayController* controller = Shell::GetInstance()->display_controller();
923 int64 id_at_zero = displays->at(0).id(); 924 int64 id_at_zero = displays->at(0).id();
924 DisplayIdPair pair = 925 DisplayIdPair pair =
925 (id_at_zero == first_display_id_ || 926 (id_at_zero == first_display_id_ ||
926 id_at_zero == gfx::Display::InternalDisplayId()) ? 927 id_at_zero == gfx::Display::InternalDisplayId()) ?
927 std::make_pair(id_at_zero, displays->at(1).id()) : 928 std::make_pair(id_at_zero, displays->at(1).id()) :
928 std::make_pair(displays->at(1).id(), id_at_zero) ; 929 std::make_pair(displays->at(1).id(), id_at_zero) ;
929 DisplayLayout layout = 930 DisplayLayout layout =
930 controller->ComputeDisplayLayoutForDisplayIdPair(pair); 931 layout_store_->ComputeDisplayLayoutForDisplayIdPair(pair);
931 932
932 // Ignore if a user has a old format (should be extremely rare) 933 // Ignore if a user has a old format (should be extremely rare)
933 // and this will be replaced with DCHECK. 934 // and this will be replaced with DCHECK.
934 if (layout.primary_id != gfx::Display::kInvalidDisplayID) { 935 if (layout.primary_id != gfx::Display::kInvalidDisplayID) {
935 size_t primary_index, secondary_index; 936 size_t primary_index, secondary_index;
936 if (displays->at(0).id() == layout.primary_id) { 937 if (displays->at(0).id() == layout.primary_id) {
937 primary_index = 0; 938 primary_index = 0;
938 secondary_index = 1; 939 secondary_index = 1;
939 } else { 940 } else {
940 primary_index = 1; 941 primary_index = 1;
941 secondary_index = 0; 942 secondary_index = 0;
942 } 943 }
943 gfx::Rect bounds = 944 gfx::Rect bounds =
944 GetDisplayForId(displays->at(secondary_index).id()).bounds(); 945 GetDisplayForId(displays->at(secondary_index).id()).bounds();
945 UpdateDisplayBoundsForLayout( 946 UpdateDisplayBoundsForLayout(
946 layout, displays->at(primary_index), &displays->at(secondary_index)); 947 layout, displays->at(primary_index), &displays->at(secondary_index));
947 *updated_index = secondary_index; 948 *updated_index = secondary_index;
948 return bounds != displays->at(secondary_index).bounds(); 949 return bounds != displays->at(secondary_index).bounds();
949 } 950 }
950 return false; 951 return false;
951 } 952 }
952 953
953 } // namespace internal 954 } // namespace internal
954 } // namespace ash 955 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager.h ('k') | ash/display/display_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698