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

Unified Diff: ash/wm/workspace/workspace_window_resizer.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: style fix 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
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer.h ('k') | chrome/browser/ui/ash/tabs/dock_info_ash.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..000260c0399eb55341aeaffe356806ce55e4603e 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -7,14 +7,18 @@
#include <algorithm>
#include <cmath>
+#include "ash/display/display_controller.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
+#include "ash/wm/coordinate_conversion.h"
#include "ash/wm/cursor_manager.h"
#include "ash/wm/property_util.h"
#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/env.h"
+#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/base/hit_test.h"
@@ -46,7 +50,9 @@ const int WorkspaceWindowResizer::kMinOnscreenSize = 20;
const int WorkspaceWindowResizer::kMinOnscreenHeight = 32;
WorkspaceWindowResizer::~WorkspaceWindowResizer() {
- ash::Shell::GetInstance()->cursor_manager()->UnlockCursor();
+ Shell* shell = Shell::GetInstance();
+ shell->display_controller()->set_dont_warp_mouse(false);
+ shell->cursor_manager()->UnlockCursor();
}
// static
@@ -61,6 +67,14 @@ WorkspaceWindowResizer* WorkspaceWindowResizer::Create(
}
void WorkspaceWindowResizer::Drag(const gfx::Point& location, int event_flags) {
+ std::pair<aura::RootWindow*, gfx::Point> actual_location =
+ wm::GetRootWindowRelativeToWindow(window()->parent(), location);
+
+ // TODO(yusukes): Implement dragging a window from one display to another.
+ aura::RootWindow* current_root = actual_location.first;
+ if (current_root != window()->GetRootWindow())
+ return;
+
int grid_size = event_flags & ui::EF_CONTROL_DOWN ?
0 : ash::Shell::GetInstance()->GetGridSize();
gfx::Rect bounds = CalculateBoundsForDrag(details_, location, grid_size);
@@ -164,7 +178,16 @@ 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();
+
+ // The pointer should be confined in one display during resizing a window
+ // because the window cannot span two displays at the same time anyway. The
+ // exception is window/tab dragging operation. During that operation,
+ // |dont_warp_mouse_| should be set to false so that the user could move a
+ // window/tab to another display.
+ shell->display_controller()->set_dont_warp_mouse(!ShouldAllowMouseWarp());
// Only support attaching to the right/bottom.
DCHECK(attached_windows_.empty() ||
@@ -441,5 +464,11 @@ WorkspaceWindowResizer::SnapType WorkspaceWindowResizer::GetSnapType(
return SNAP_NONE;
}
+bool WorkspaceWindowResizer::ShouldAllowMouseWarp() 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
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer.h ('k') | chrome/browser/ui/ash/tabs/dock_info_ash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698