summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-13 18:27:21 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-13 18:27:21 +0000
commit9394042fcd13abd50189f844f5fa84ce2f72b9e8 (patch)
treeda1101454d37250c26464ff9b922070b39c060a7 /ash
parentc4781e502e205f57d5b9d90178eb1b449f6bd611 (diff)
downloadchromium_src-9394042fcd13abd50189f844f5fa84ce2f72b9e8.zip
chromium_src-9394042fcd13abd50189f844f5fa84ce2f72b9e8.tar.gz
chromium_src-9394042fcd13abd50189f844f5fa84ce2f72b9e8.tar.bz2
Sets snap_type_ to SNAP_NONE when the mouse is moved to another window.
Resetting the phantom controller is not enough since snap_type_ rather determines the mouse-up behavior. BUG=146436 Review URL: https://chromiumcodereview.appspot.com/10928161 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/workspace/workspace_window_resizer.cc6
-rw-r--r--ash/wm/workspace/workspace_window_resizer.h1
-rw-r--r--ash/wm/workspace/workspace_window_resizer_unittest.cc42
3 files changed, 47 insertions, 2 deletions
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index c5a4659..f7e11ef 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -157,10 +157,12 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location, int event_flags) {
const bool in_original_root = (window()->GetRootWindow() == current_root);
// Hide a phantom window for snapping if the cursor is in another root window.
- if (in_original_root)
+ if (in_original_root) {
UpdateSnapPhantomWindow(location_in_parent, bounds);
- else
+ } else {
+ snap_type_ = SNAP_NONE;
snap_phantom_window_controller_.reset();
+ }
if (!attached_windows_.empty())
LayoutAttachedWindows(bounds);
diff --git a/ash/wm/workspace/workspace_window_resizer.h b/ash/wm/workspace/workspace_window_resizer.h
index 1c62420..098f7fb 100644
--- a/ash/wm/workspace/workspace_window_resizer.h
+++ b/ash/wm/workspace/workspace_window_resizer.h
@@ -75,6 +75,7 @@ class ASH_EXPORT WorkspaceWindowResizer : public WindowResizer {
private:
FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, PhantomStyle);
+ FRIEND_TEST_ALL_PREFIXES(WorkspaceWindowResizerTest, CancelSnapPhantom);
// Type of snapping.
enum SnapType {
diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc
index 1e0844a..77a7472 100644
--- a/ash/wm/workspace/workspace_window_resizer_unittest.cc
+++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc
@@ -141,11 +141,13 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
#define MAYBE_WindowDragWithMultiDisplaysRightToLeft \
DISABLED_WindowDragWithMultiDisplaysRightToLeft
#define MAYBE_PhantomStyle DISABLED_PhantomStyle
+#define MAYBE_CancelSnapPhantom DISABLED_CancelSnapPhantom
#else
#define MAYBE_WindowDragWithMultiDisplays WindowDragWithMultiDisplays
#define MAYBE_WindowDragWithMultiDisplaysRightToLeft \
WindowDragWithMultiDisplaysRightToLeft
#define MAYBE_PhantomStyle PhantomStyle
+#define MAYBE_CancelSnapPhantom CancelSnapPhantom
#endif
// Assertions around attached window resize dragging from the right with 2
@@ -635,6 +637,46 @@ TEST_F(WorkspaceWindowResizerTest, MAYBE_PhantomStyle) {
}
}
+// Verifies the style of the drag phantom window is correct.
+TEST_F(WorkspaceWindowResizerTest, MAYBE_CancelSnapPhantom) {
+ UpdateDisplay("800x600,800x600");
+ Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
+ ASSERT_EQ(2U, root_windows.size());
+
+ window_->SetBoundsInScreen(gfx::Rect(0, 0, 50, 60),
+ gfx::Screen::GetPrimaryDisplay());
+ EXPECT_EQ(root_windows[0], window_->GetRootWindow());
+ EXPECT_FLOAT_EQ(1.0f, window_->layer()->opacity());
+ {
+ scoped_ptr<WorkspaceWindowResizer> resizer(WorkspaceWindowResizer::Create(
+ window_.get(), gfx::Point(), HTCAPTION, empty_windows()));
+ ASSERT_TRUE(resizer.get());
+ EXPECT_FALSE(resizer->snap_phantom_window_controller_.get());
+ EXPECT_FALSE(resizer->drag_phantom_window_controller_.get());
+ EXPECT_EQ(WorkspaceWindowResizer::SNAP_NONE, resizer->snap_type_);
+
+ // The pointer is on the edge but not shared. Both controllers should be
+ // non-NULL.
+ resizer->Drag(CalculateDragPoint(*resizer, 799, 0), 0);
+ EXPECT_TRUE(resizer->snap_phantom_window_controller_.get());
+ EXPECT_EQ(WorkspaceWindowResizer::SNAP_RIGHT_EDGE, resizer->snap_type_);
+ PhantomWindowController* controller =
+ resizer->drag_phantom_window_controller_.get();
+ ASSERT_TRUE(controller);
+ EXPECT_EQ(PhantomWindowController::STYLE_DRAGGING, controller->style());
+
+ // Move the cursor across the edge. Now the snap phantom controller
+ // should be canceled.
+ resizer->Drag(CalculateDragPoint(*resizer, 800, 0), 0);
+ EXPECT_FALSE(resizer->snap_phantom_window_controller_.get());
+ EXPECT_EQ(WorkspaceWindowResizer::SNAP_NONE, resizer->snap_type_);
+ controller =
+ resizer->drag_phantom_window_controller_.get();
+ ASSERT_TRUE(controller);
+ EXPECT_EQ(PhantomWindowController::STYLE_DRAGGING, controller->style());
+ }
+}
+
// Verifies if the resizer sets and resets
// MouseCursorEventFilter::mouse_warp_mode_ as expected.
TEST_F(WorkspaceWindowResizerTest, WarpMousePointer) {