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

Unified Diff: ash/display/display_controller.cc

Issue 10835047: Allow the cursor to warp even when a window is dragged (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments 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 side-by-side diff with in-line comments
Download patch
Index: ash/display/display_controller.cc
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index a4eceb48bb21abb1c6697eb46ab5557eebcdd370..0c41139d8bd00b6d173b996f3630f17ed86b7391 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -9,6 +9,7 @@
#include "ash/root_window_controller.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
+#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/property_util.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
@@ -23,7 +24,8 @@ namespace ash {
namespace internal {
DisplayController::DisplayController()
- : secondary_display_layout_(RIGHT) {
+ : secondary_display_layout_(RIGHT),
+ allow_warp_during_lock_(false) {
aura::Env::GetInstance()->display_manager()->AddObserver(this);
}
@@ -122,32 +124,45 @@ void DisplayController::SetSecondaryDisplayLayout(
bool DisplayController::WarpMouseCursorIfNecessary(
aura::RootWindow* current_root,
- const gfx::Point& point_in_root) {
+ const gfx::Point& point_in_root,
+ bool is_cursor_locked) {
sky 2012/08/03 17:07:18 Can't DisplayController determine if the cursor is
Yusuke Sato 2012/08/03 23:18:45 Done.
+ if (is_cursor_locked && !allow_warp_during_lock_)
+ return false;
+
if (root_windows_.size() < 2)
return false;
+ // The cursor might be outside the |current_root|. Get the root window where
+ // the cursor is currently on.
+ std::pair<aura::RootWindow*, gfx::Point> actual_location =
+ wm::GetRootWindowRelativeToWindow(current_root, point_in_root);
+ current_root = actual_location.first;
+ // Don't use |point_in_root| below. Instead, use |actual_location.second|
+ // which is in |actual_location.first|'s coordinates.
+
gfx::Rect root_bounds = current_root->bounds();
int offset_x = 0;
int offset_y = 0;
- if (point_in_root.x() <= root_bounds.x()) {
- offset_x = -1;
- } else if (point_in_root.x() >= root_bounds.right() - 1) {
- offset_x = 1;
- } else if (point_in_root.y() <= root_bounds.y()) {
- offset_y = -1;
- } else if (point_in_root.y() >= root_bounds.bottom() - 1) {
- offset_y = 1;
+ if (actual_location.second.x() <= root_bounds.x()) {
+ // Use -2, not -1, to avoid infinite loop of pointer warp.
+ offset_x = -2;
+ } else if (actual_location.second.x() >= root_bounds.right() - 1) {
+ offset_x = 2;
+ } else if (actual_location.second.y() <= root_bounds.y()) {
+ offset_y = -2;
+ } else if (actual_location.second.y() >= root_bounds.bottom() - 1) {
+ offset_y = 2;
} else {
return false;
}
- gfx::Point point_in_screen(point_in_root);
+ gfx::Point point_in_screen(actual_location.second);
aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(current_root);
screen_position_client->ConvertPointToScreen(current_root,
&point_in_screen);
point_in_screen.Offset(offset_x, offset_y);
- aura::RootWindow* dst_root = Shell::GetRootWindowAt(point_in_screen);
+ aura::RootWindow* dst_root = wm::GetRootWindowAt(point_in_screen);
gfx::Point point_in_dst_root(point_in_screen);
screen_position_client->ConvertPointFromScreen(dst_root,

Powered by Google App Engine
This is Rietveld 408576698