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

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: do not move modal windows to another display Created 8 years, 5 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..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
« ash/wm/default_window_resizer.h ('K') | « ash/wm/workspace/workspace_window_resizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698