Index: ash/wm/workspace/workspace_window_resizer.cc |
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc |
index a6834654de388b8ab6f81776d5c6cb01c1966641..fd38024e254dbfaae496cdbd46d57d7b4de14636 100644 |
--- a/ash/wm/workspace/workspace_window_resizer.cc |
+++ b/ash/wm/workspace/workspace_window_resizer.cc |
@@ -7,6 +7,7 @@ |
#include <algorithm> |
#include <cmath> |
+#include "ash/display/display_controller.h" |
#include "ash/screen_ash.h" |
#include "ash/shell.h" |
#include "ash/wm/cursor_manager.h" |
@@ -14,9 +15,12 @@ |
#include "ash/wm/window_util.h" |
#include "ash/wm/workspace/phantom_window_controller.h" |
#include "ash/wm/workspace/snap_sizer.h" |
+#include "ui/aura/client/aura_constants.h" |
+#include "ui/aura/client/screen_position_client.h" |
#include "ui/aura/env.h" |
#include "ui/aura/window.h" |
#include "ui/aura/window_delegate.h" |
+#include "ui/aura/root_window.h" |
#include "ui/base/hit_test.h" |
#include "ui/compositor/layer.h" |
#include "ui/compositor/scoped_layer_animation_settings.h" |
@@ -46,7 +50,10 @@ const int WorkspaceWindowResizer::kMinOnscreenSize = 20; |
const int WorkspaceWindowResizer::kMinOnscreenHeight = 32; |
WorkspaceWindowResizer::~WorkspaceWindowResizer() { |
- ash::Shell::GetInstance()->cursor_manager()->UnlockCursor(); |
+ Shell* shell = Shell::GetInstance(); |
+ if (ShouldAllowCursorWarp()) |
+ shell->display_controller()->set_allow_warp_during_lock(false); |
+ shell->cursor_manager()->UnlockCursor(); |
} |
// static |
@@ -60,10 +67,21 @@ WorkspaceWindowResizer* WorkspaceWindowResizer::Create( |
new WorkspaceWindowResizer(details, attached_windows) : NULL; |
} |
-void WorkspaceWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
+void WorkspaceWindowResizer::Drag(const gfx::Point& location_in_screen, |
+ int event_flags) { |
+ // TODO(yusukes): Implement dragging a window from one display to another. |
+ aura::RootWindow* current_root = Shell::GetRootWindowAt(location_in_screen); |
+ if (current_root != window()->GetRootWindow()) |
+ return; |
+ |
+ gfx::Point location_in_root = location_in_screen; |
+ aura::client::GetScreenPositionClient(current_root)-> |
+ ConvertPointFromScreen(current_root, &location_in_root); |
+ |
int grid_size = event_flags & ui::EF_CONTROL_DOWN ? |
0 : ash::Shell::GetInstance()->GetGridSize(); |
- gfx::Rect bounds = CalculateBoundsForDrag(details_, location, grid_size); |
+ gfx::Rect bounds = |
+ CalculateBoundsForDrag(details_, location_in_root, grid_size); |
if (wm::IsWindowNormal(details_.window)) |
AdjustBoundsForMainWindow(&bounds, grid_size); |
@@ -72,7 +90,7 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location, int event_flags) { |
RestackWindows(); |
did_move_or_resize_ = true; |
} |
- UpdatePhantomWindow(location, bounds, grid_size); |
+ UpdatePhantomWindow(location_in_root, bounds, grid_size); |
if (!attached_windows_.empty()) |
LayoutAttachedWindows(bounds, grid_size); |
if (bounds != details_.window->bounds()) |
@@ -164,7 +182,11 @@ WorkspaceWindowResizer::WorkspaceWindowResizer( |
snap_type_(SNAP_NONE), |
num_mouse_moves_since_bounds_change_(0) { |
DCHECK(details_.is_resizable); |
- ash::Shell::GetInstance()->cursor_manager()->LockCursor(); |
+ |
+ Shell* shell = Shell::GetInstance(); |
+ shell->cursor_manager()->LockCursor(); |
+ if (ShouldAllowCursorWarp()) |
+ shell->display_controller()->set_allow_warp_during_lock(true); |
// Only support attaching to the right/bottom. |
DCHECK(attached_windows_.empty() || |
@@ -441,5 +463,11 @@ WorkspaceWindowResizer::SnapType WorkspaceWindowResizer::GetSnapType( |
return SNAP_NONE; |
} |
+bool WorkspaceWindowResizer::ShouldAllowCursorWarp() const { |
+ return (details_.window_component == HTCAPTION) && |
+ (window()->GetProperty(aura::client::kModalKey) == ui::MODAL_TYPE_NONE) && |
+ (window()->type() == aura::client::WINDOW_TYPE_NORMAL); |
+} |
+ |
} // namespace internal |
} // namespace ash |