diff options
author | pkotwicz <pkotwicz@chromium.org> | 2014-12-20 14:10:19 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-20 22:11:03 +0000 |
commit | 4882310f75d0a578c068b92dc2eaf163d761c03a (patch) | |
tree | 464bc70ed4e1f70d34d820b0fbf7f125a7d928f6 /ash | |
parent | 39046bbd1a81bccaa8f3a21166d0ba8b7e050117 (diff) | |
download | chromium_src-4882310f75d0a578c068b92dc2eaf163d761c03a.zip chromium_src-4882310f75d0a578c068b92dc2eaf163d761c03a.tar.gz chromium_src-4882310f75d0a578c068b92dc2eaf163d761c03a.tar.bz2 |
Set capture to the window being dragged when dragging a window on Ash
This CL sets capture to the window being dragged when dragging a window on
Ash. This allows state to be reset when a user opens the Ctrl+Alt+Delete dialog
on Windows Ash.
As a side effect, this CL fixes dragging windows from one screen to another on
ChromeOS ozone. Dragging windows from one screen to another
worked on X11 because X11 does an implicit grab when the mouse is pressed. This
implicit grab guarantees that events are sent to WindowTreeHost where the drag
started for the duration of the drag.
BUG=439703, 423383
TEST=None
Review URL: https://codereview.chromium.org/778043004
Cr-Commit-Position: refs/heads/master@{#309364}
Diffstat (limited to 'ash')
-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 { |