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

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

Issue 10909043: Cancel drag if display configuration changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
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/multi_display_manager.h" 5 #include "ash/display/multi_display_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/display/display_controller.h" 10 #include "ash/display/display_controller.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 gfx::Display::kInvalidDisplayID); 46 gfx::Display::kInvalidDisplayID);
47 47
48 MultiDisplayManager::MultiDisplayManager() { 48 MultiDisplayManager::MultiDisplayManager() {
49 Init(); 49 Init();
50 } 50 }
51 51
52 MultiDisplayManager::~MultiDisplayManager() { 52 MultiDisplayManager::~MultiDisplayManager() {
53 } 53 }
54 54
55 // static 55 // static
56 void MultiDisplayManager::AddRemoveDisplay() {
57 MultiDisplayManager* manager = static_cast<MultiDisplayManager*>(
58 aura::Env::GetInstance()->display_manager());
59 manager->AddRemoveDisplayImpl();
60 }
61
62 void MultiDisplayManager::CycleDisplay() { 56 void MultiDisplayManager::CycleDisplay() {
63 MultiDisplayManager* manager = static_cast<MultiDisplayManager*>( 57 MultiDisplayManager* manager = static_cast<MultiDisplayManager*>(
64 aura::Env::GetInstance()->display_manager()); 58 aura::Env::GetInstance()->display_manager());
65 manager->CycleDisplayImpl(); 59 manager->CycleDisplayImpl();
66 } 60 }
67 61
62 // static
68 void MultiDisplayManager::ToggleDisplayScale() { 63 void MultiDisplayManager::ToggleDisplayScale() {
69 MultiDisplayManager* manager = static_cast<MultiDisplayManager*>( 64 MultiDisplayManager* manager = static_cast<MultiDisplayManager*>(
70 aura::Env::GetInstance()->display_manager()); 65 aura::Env::GetInstance()->display_manager());
71 manager->ScaleDisplayImpl(); 66 manager->ScaleDisplayImpl();
72 } 67 }
73 68
74 bool MultiDisplayManager::UpdateWorkAreaOfDisplayNearestWindow( 69 bool MultiDisplayManager::UpdateWorkAreaOfDisplayNearestWindow(
75 const aura::Window* window, 70 const aura::Window* window,
76 const gfx::Insets& insets) { 71 const gfx::Insets& insets) {
77 const RootWindow* root = window->GetRootWindow(); 72 const RootWindow* root = window->GetRootWindow();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 204 }
210 #endif 205 #endif
211 206
212 return base::StringPrintf("Display %d", static_cast<int>(index + 1)); 207 return base::StringPrintf("Display %d", static_cast<int>(index + 1));
213 } 208 }
214 209
215 void MultiDisplayManager::OnRootWindowResized(const aura::RootWindow* root, 210 void MultiDisplayManager::OnRootWindowResized(const aura::RootWindow* root,
216 const gfx::Size& old_size) { 211 const gfx::Size& old_size) {
217 if (!use_fullscreen_host_window()) { 212 if (!use_fullscreen_host_window()) {
218 gfx::Display& display = FindDisplayForRootWindow(root); 213 gfx::Display& display = FindDisplayForRootWindow(root);
219 display.SetSize(root->GetHostSize()); 214 if (display.size() != root->GetHostSize()) {
220 NotifyBoundsChanged(display); 215 display.SetSize(root->GetHostSize());
216 NotifyBoundsChanged(display);
217 }
221 } 218 }
222 } 219 }
223 220
224 void MultiDisplayManager::Init() { 221 void MultiDisplayManager::Init() {
225 // TODO(oshima): Move this logic to DisplayChangeObserver. 222 // TODO(oshima): Move this logic to DisplayChangeObserver.
226 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 223 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
227 switches::kAuraHostWindowSize); 224 switches::kAuraHostWindowSize);
228 vector<string> parts; 225 vector<string> parts;
229 base::SplitString(size_str, ',', &parts); 226 base::SplitString(size_str, ',', &parts);
230 for (vector<string>::const_iterator iter = parts.begin(); 227 for (vector<string>::const_iterator iter = parts.begin();
231 iter != parts.end(); ++iter) { 228 iter != parts.end(); ++iter) {
232 AddDisplayFromSpec(*iter); 229 AddDisplayFromSpec(*iter);
233 } 230 }
234 if (displays_.empty()) 231 if (displays_.empty())
235 AddDisplayFromSpec(std::string() /* default */); 232 AddDisplayFromSpec(std::string() /* default */);
236 } 233 }
237 234
238 void MultiDisplayManager::AddRemoveDisplayImpl() { 235 void MultiDisplayManager::CycleDisplayImpl() {
239 std::vector<gfx::Display> new_displays; 236 std::vector<gfx::Display> new_displays;
240 if (displays_.size() > 1) { 237 if (displays_.size() > 1) {
241 // Remove if there is more than one display. 238 // Remove if there is more than one display.
242 int count = displays_.size() - 1; 239 int count = displays_.size() - 1;
243 for (Displays::const_iterator iter = displays_.begin(); count-- > 0; ++iter) 240 for (Displays::const_iterator iter = displays_.begin(); count-- > 0; ++iter)
244 new_displays.push_back(*iter); 241 new_displays.push_back(*iter);
245 } else { 242 } else {
246 // Add if there is only one display. 243 // Add if there is only one display.
247 new_displays.push_back(displays_[0]); 244 new_displays.push_back(displays_[0]);
248 new_displays.push_back(CreateDisplayFromSpec("50+50-1280x768")); 245 new_displays.push_back(CreateDisplayFromSpec("50+50-1280x768"));
249 } 246 }
250 if (new_displays.size()) 247 if (new_displays.size())
251 OnNativeDisplaysChanged(new_displays); 248 OnNativeDisplaysChanged(new_displays);
252 } 249 }
253 250
254 void MultiDisplayManager::CycleDisplayImpl() {
255 if (displays_.size() > 1) {
256 std::vector<gfx::Display> new_displays;
257 for (Displays::const_iterator iter = displays_.begin() + 1;
258 iter != displays_.end(); ++iter) {
259 gfx::Display display = *iter;
260 new_displays.push_back(display);
261 }
262 new_displays.push_back(displays_.front());
263 OnNativeDisplaysChanged(new_displays);
264 }
265 }
266
267 void MultiDisplayManager::ScaleDisplayImpl() { 251 void MultiDisplayManager::ScaleDisplayImpl() {
268 if (displays_.size() > 0) { 252 if (displays_.size() > 0) {
269 std::vector<gfx::Display> new_displays; 253 std::vector<gfx::Display> new_displays;
270 for (Displays::const_iterator iter = displays_.begin(); 254 for (Displays::const_iterator iter = displays_.begin();
271 iter != displays_.end(); ++iter) { 255 iter != displays_.end(); ++iter) {
272 gfx::Display display = *iter; 256 gfx::Display display = *iter;
273 float factor = display.device_scale_factor() == 1.0f ? 2.0f : 1.0f; 257 float factor = display.device_scale_factor() == 1.0f ? 2.0f : 1.0f;
274 display.SetScaleAndBounds( 258 display.SetScaleAndBounds(
275 factor, gfx::Rect(display.bounds_in_pixel().origin(), 259 factor, gfx::Rect(display.bounds_in_pixel().origin(),
276 display.size().Scale(factor))); 260 display.size().Scale(factor)));
(...skipping 20 matching lines...) Expand all
297 281
298 const gfx::Insets insets = display.GetWorkAreaInsets(); 282 const gfx::Insets insets = display.GetWorkAreaInsets();
299 const gfx::Rect& native_bounds = display.bounds_in_pixel(); 283 const gfx::Rect& native_bounds = display.bounds_in_pixel();
300 display.SetScaleAndBounds(display.device_scale_factor(), native_bounds); 284 display.SetScaleAndBounds(display.device_scale_factor(), native_bounds);
301 display.UpdateWorkAreaFromInsets(insets); 285 display.UpdateWorkAreaFromInsets(insets);
302 displays_.push_back(display); 286 displays_.push_back(display);
303 } 287 }
304 288
305 } // namespace internal 289 } // namespace internal
306 } // namespace ash 290 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698