diff options
-rw-r--r-- | ash/wm/system_gesture_event_filter_unittest.cc | 35 | ||||
-rw-r--r-- | ash/wm/toplevel_window_event_handler.cc | 23 |
2 files changed, 18 insertions, 40 deletions
diff --git a/ash/wm/system_gesture_event_filter_unittest.cc b/ash/wm/system_gesture_event_filter_unittest.cc index 58a89f8..59f30a1 100644 --- a/ash/wm/system_gesture_event_filter_unittest.cc +++ b/ash/wm/system_gesture_event_filter_unittest.cc @@ -288,41 +288,6 @@ TEST_F(SystemGestureEventFilterTest, TwoFingerDrag) { EXPECT_EQ(current_bounds.ToString(), right_tile_bounds.ToString()); } -TEST_F(SystemGestureEventFilterTest, TwoFingerDragTwoWindows) { - aura::Window* root_window = Shell::GetPrimaryRootWindow(); - ui::GestureConfiguration::GetInstance() - ->set_max_separation_for_gesture_touches_in_pixels(0); - views::Widget* first = views::Widget::CreateWindowWithContextAndBounds( - new ResizableWidgetDelegate, root_window, gfx::Rect(10, 0, 50, 100)); - first->Show(); - views::Widget* second = views::Widget::CreateWindowWithContextAndBounds( - new ResizableWidgetDelegate, root_window, gfx::Rect(100, 0, 100, 100)); - second->Show(); - - // Start a two-finger drag on |first|, and then try to use another two-finger - // drag to move |second|. The attempt to move |second| should fail. - const gfx::Rect& first_bounds = first->GetWindowBoundsInScreen(); - const gfx::Rect& second_bounds = second->GetWindowBoundsInScreen(); - const int kSteps = 15; - const int kTouchPoints = 4; - gfx::Point points[kTouchPoints] = { - first_bounds.origin() + gfx::Vector2d(5, 5), - first_bounds.origin() + gfx::Vector2d(30, 10), - second_bounds.origin() + gfx::Vector2d(5, 5), - second_bounds.origin() + gfx::Vector2d(40, 20) - }; - - ui::test::EventGenerator generator(root_window); - // Do not drag too fast to avoid fling. - generator.GestureMultiFingerScroll(kTouchPoints, points, - 50, kSteps, 0, 150); - - EXPECT_NE(first_bounds.ToString(), - first->GetWindowBoundsInScreen().ToString()); - EXPECT_EQ(second_bounds.ToString(), - second->GetWindowBoundsInScreen().ToString()); -} - TEST_F(SystemGestureEventFilterTest, WindowsWithMaxSizeDontSnap) { gfx::Rect bounds(250, 150, 100, 100); aura::Window* root_window = Shell::GetPrimaryRootWindow(); diff --git a/ash/wm/toplevel_window_event_handler.cc b/ash/wm/toplevel_window_event_handler.cc index 610261f..cc0362e 100644 --- a/ash/wm/toplevel_window_event_handler.cc +++ b/ash/wm/toplevel_window_event_handler.cc @@ -110,6 +110,9 @@ class ToplevelWindowEventHandler::ScopedWindowResizer ToplevelWindowEventHandler* handler_; scoped_ptr<WindowResizer> resizer_; + // Whether ScopedWindowResizer grabbed capture. + bool grabbed_capture_; + DISALLOW_COPY_AND_ASSIGN(ScopedWindowResizer); }; @@ -117,14 +120,24 @@ ToplevelWindowEventHandler::ScopedWindowResizer::ScopedWindowResizer( ToplevelWindowEventHandler* handler, WindowResizer* resizer) : handler_(handler), - resizer_(resizer) { - resizer_->GetTarget()->AddObserver(this); - wm::GetWindowState(resizer_->GetTarget())->AddObserver(this); + resizer_(resizer), + grabbed_capture_(false) { + aura::Window* target = resizer_->GetTarget(); + target->AddObserver(this); + wm::GetWindowState(target)->AddObserver(this); + + if (!target->HasCapture()) { + grabbed_capture_ = true; + target->SetCapture(); + } } ToplevelWindowEventHandler::ScopedWindowResizer::~ScopedWindowResizer() { - resizer_->GetTarget()->RemoveObserver(this); - wm::GetWindowState(resizer_->GetTarget())->RemoveObserver(this); + aura::Window* target = resizer_->GetTarget(); + target->RemoveObserver(this); + wm::GetWindowState(target)->RemoveObserver(this); + if (grabbed_capture_) + target->ReleaseCapture(); } bool ToplevelWindowEventHandler::ScopedWindowResizer::IsMove() const { |