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

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: 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/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..cb96552447ef976fc9764f44ffa448f25f07ebf4 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -7,16 +7,21 @@
#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/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 +51,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
@@ -61,9 +69,23 @@ 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);
+
+ aura::RootWindow* current_root = actual_location.first;
+ gfx::Point location_in_root = actual_location.second;
+ gfx::Point location_in_screen = actual_location.second;
+ aura::client::GetScreenPositionClient(current_root)->
+ ConvertPointToScreen(current_root, &location_in_screen);
+
+ // TODO(yusukes): Implement dragging a window from one display to another.
+ 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);
+ gfx::Rect bounds =
+ CalculateBoundsForDrag(details_, location_in_root, grid_size);
if (wm::IsWindowNormal(details_.window))
AdjustBoundsForMainWindow(&bounds, grid_size);
@@ -72,7 +94,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 +186,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);
sky 2012/08/03 17:07:18 I don't get why we need this. Can't it be inferred
Yusuke Sato 2012/08/03 23:18:45 I think we need to confine a mouse pointer in one
// Only support attaching to the right/bottom.
DCHECK(attached_windows_.empty() ||
@@ -441,5 +467,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

Powered by Google App Engine
This is Rietveld 408576698