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

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

Issue 10836046: Allow offset for secondary display position in chrome://settings/display. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/display_controller.h" 5 #include "ash/display/display_controller.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/display/multi_display_manager.h" 8 #include "ash/display/multi_display_manager.h"
9 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/screen_ash.h" 10 #include "ash/screen_ash.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/wm/property_util.h" 12 #include "ash/wm/property_util.h"
13 #include "ash/wm/window_util.h" 13 #include "ash/wm/window_util.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "ui/aura/client/screen_position_client.h" 15 #include "ui/aura/client/screen_position_client.h"
16 #include "ui/aura/env.h" 16 #include "ui/aura/env.h"
17 #include "ui/aura/root_window.h" 17 #include "ui/aura/root_window.h"
18 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
19 #include "ui/gfx/display.h" 19 #include "ui/gfx/display.h"
20 #include "ui/gfx/screen.h" 20 #include "ui/gfx/screen.h"
21 21
22 namespace ash { 22 namespace ash {
23 namespace internal { 23 namespace internal {
24 24
25 DisplayController::DisplayController() 25 DisplayController::DisplayController()
26 : secondary_display_layout_(RIGHT) { 26 : secondary_display_layout_(RIGHT),
27 secondary_display_offset_(0) {
27 aura::Env::GetInstance()->display_manager()->AddObserver(this); 28 aura::Env::GetInstance()->display_manager()->AddObserver(this);
28 } 29 }
29 30
30 DisplayController::~DisplayController() { 31 DisplayController::~DisplayController() {
31 aura::Env::GetInstance()->display_manager()->RemoveObserver(this); 32 aura::Env::GetInstance()->display_manager()->RemoveObserver(this);
32 // Delete all root window controllers, which deletes root window 33 // Delete all root window controllers, which deletes root window
33 // from the last so that the primary root window gets deleted last. 34 // from the last so that the primary root window gets deleted last.
34 for (std::map<int, aura::RootWindow*>::const_reverse_iterator it = 35 for (std::map<int, aura::RootWindow*>::const_reverse_iterator it =
35 root_windows_.rbegin(); it != root_windows_.rend(); ++it) { 36 root_windows_.rbegin(); it != root_windows_.rend(); ++it) {
36 internal::RootWindowController* controller = 37 internal::RootWindowController* controller =
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 114 }
114 return controllers; 115 return controllers;
115 } 116 }
116 117
117 void DisplayController::SetSecondaryDisplayLayout( 118 void DisplayController::SetSecondaryDisplayLayout(
118 SecondaryDisplayLayout layout) { 119 SecondaryDisplayLayout layout) {
119 secondary_display_layout_ = layout; 120 secondary_display_layout_ = layout;
120 UpdateDisplayBoundsForLayout(); 121 UpdateDisplayBoundsForLayout();
121 } 122 }
122 123
124 void DisplayController::SetSecondaryDisplayOffset(int offset) {
125 secondary_display_offset_ = offset;
126 UpdateDisplayBoundsForLayout();
127 }
128
123 bool DisplayController::WarpMouseCursorIfNecessary( 129 bool DisplayController::WarpMouseCursorIfNecessary(
124 aura::RootWindow* current_root, 130 aura::RootWindow* current_root,
125 const gfx::Point& point_in_root) { 131 const gfx::Point& point_in_root) {
126 if (root_windows_.size() < 2) 132 if (root_windows_.size() < 2)
127 return false; 133 return false;
128 134
129 gfx::Rect root_bounds = current_root->bounds(); 135 gfx::Rect root_bounds = current_root->bounds();
130 int offset_x = 0; 136 int offset_x = 0;
131 int offset_y = 0; 137 int offset_y = 0;
132 if (point_in_root.x() <= root_bounds.x()) { 138 if (point_in_root.x() <= root_bounds.x()) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 aura::DisplayManager* display_manager = 236 aura::DisplayManager* display_manager =
231 aura::Env::GetInstance()->display_manager(); 237 aura::Env::GetInstance()->display_manager();
232 const gfx::Rect& primary_bounds = display_manager->GetDisplayAt(0)->bounds(); 238 const gfx::Rect& primary_bounds = display_manager->GetDisplayAt(0)->bounds();
233 gfx::Display* secondary_display = display_manager->GetDisplayAt(1); 239 gfx::Display* secondary_display = display_manager->GetDisplayAt(1);
234 const gfx::Rect& secondary_bounds = secondary_display->bounds(); 240 const gfx::Rect& secondary_bounds = secondary_display->bounds();
235 gfx::Point new_secondary_origin = primary_bounds.origin(); 241 gfx::Point new_secondary_origin = primary_bounds.origin();
236 242
237 // TODO(oshima|mukai): Implement more flexible layout. 243 // TODO(oshima|mukai): Implement more flexible layout.
238 switch (secondary_display_layout_) { 244 switch (secondary_display_layout_) {
239 case TOP: 245 case TOP:
240 new_secondary_origin.Offset(0, -secondary_bounds.height()); 246 new_secondary_origin.Offset(
247 secondary_display_offset_, -secondary_bounds.height());
241 break; 248 break;
242 case RIGHT: 249 case RIGHT:
243 new_secondary_origin.Offset(primary_bounds.width(), 0); 250 new_secondary_origin.Offset(
251 primary_bounds.width(), secondary_display_offset_);
244 break; 252 break;
245 case BOTTOM: 253 case BOTTOM:
246 new_secondary_origin.Offset(0, primary_bounds.height()); 254 new_secondary_origin.Offset(
255 secondary_display_offset_, primary_bounds.height());
247 break; 256 break;
248 case LEFT: 257 case LEFT:
249 new_secondary_origin.Offset(-secondary_bounds.width(), 0); 258 new_secondary_origin.Offset(
259 -secondary_bounds.width(), secondary_display_offset_);
250 break; 260 break;
251 } 261 }
oshima 2012/08/06 04:15:55 you need to check & adjust the offset if the secon
Jun Mukai 2012/08/06 05:27:27 Added the check for offset value above.
252 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); 262 gfx::Insets insets = secondary_display->GetWorkAreaInsets();
253 secondary_display->set_bounds( 263 secondary_display->set_bounds(
254 gfx::Rect(new_secondary_origin, secondary_bounds.size())); 264 gfx::Rect(new_secondary_origin, secondary_bounds.size()));
255 secondary_display->UpdateWorkAreaFromInsets(insets); 265 secondary_display->UpdateWorkAreaFromInsets(insets);
256 } 266 }
257 267
258 } // namespace internal 268 } // namespace internal
259 } // namespace ash 269 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698