| OLD | NEW |
| 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 allow_warp_during_lock_(false) { |
| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 123 bool DisplayController::WarpMouseCursorIfNecessary( | 124 bool DisplayController::WarpMouseCursorIfNecessary( |
| 124 aura::RootWindow* current_root, | 125 aura::RootWindow* current_root, |
| 125 const gfx::Point& point_in_root) { | 126 const gfx::Point& point_in_root, |
| 127 bool is_cursor_locked) { |
| 128 if (is_cursor_locked && !allow_warp_during_lock_) |
| 129 return false; |
| 130 |
| 126 if (root_windows_.size() < 2) | 131 if (root_windows_.size() < 2) |
| 127 return false; | 132 return false; |
| 128 | 133 |
| 129 gfx::Rect root_bounds = current_root->bounds(); | 134 gfx::Rect root_bounds = current_root->bounds(); |
| 130 int offset_x = 0; | 135 int offset_x = 0; |
| 131 int offset_y = 0; | 136 int offset_y = 0; |
| 132 if (point_in_root.x() <= root_bounds.x()) { | 137 if (point_in_root.x() <= root_bounds.x()) { |
| 133 offset_x = -1; | 138 // Use -2, not -1, to avoid infinite loop of pointer warp. |
| 139 offset_x = -2; |
| 134 } else if (point_in_root.x() >= root_bounds.right() - 1) { | 140 } else if (point_in_root.x() >= root_bounds.right() - 1) { |
| 135 offset_x = 1; | 141 offset_x = 2; |
| 136 } else if (point_in_root.y() <= root_bounds.y()) { | 142 } else if (point_in_root.y() <= root_bounds.y()) { |
| 137 offset_y = -1; | 143 offset_y = -2; |
| 138 } else if (point_in_root.y() >= root_bounds.bottom() - 1) { | 144 } else if (point_in_root.y() >= root_bounds.bottom() - 1) { |
| 139 offset_y = 1; | 145 offset_y = 2; |
| 140 } else { | 146 } else { |
| 141 return false; | 147 return false; |
| 142 } | 148 } |
| 143 | 149 |
| 144 gfx::Point point_in_screen(point_in_root); | 150 gfx::Point point_in_screen(point_in_root); |
| 145 aura::client::ScreenPositionClient* screen_position_client = | 151 aura::client::ScreenPositionClient* screen_position_client = |
| 146 aura::client::GetScreenPositionClient(current_root); | 152 aura::client::GetScreenPositionClient(current_root); |
| 147 screen_position_client->ConvertPointToScreen(current_root, | 153 screen_position_client->ConvertPointToScreen(current_root, |
| 148 &point_in_screen); | 154 &point_in_screen); |
| 149 point_in_screen.Offset(offset_x, offset_y); | 155 point_in_screen.Offset(offset_x, offset_y); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 break; | 256 break; |
| 251 } | 257 } |
| 252 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); | 258 gfx::Insets insets = secondary_display->GetWorkAreaInsets(); |
| 253 secondary_display->set_bounds( | 259 secondary_display->set_bounds( |
| 254 gfx::Rect(new_secondary_origin, secondary_bounds.size())); | 260 gfx::Rect(new_secondary_origin, secondary_bounds.size())); |
| 255 secondary_display->UpdateWorkAreaFromInsets(insets); | 261 secondary_display->UpdateWorkAreaFromInsets(insets); |
| 256 } | 262 } |
| 257 | 263 |
| 258 } // namespace internal | 264 } // namespace internal |
| 259 } // namespace ash | 265 } // namespace ash |
| OLD | NEW |