summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-16 14:21:16 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-16 14:21:16 +0000
commit940bf05b402781894eb56ffd2a2aea7bb4eea315 (patch)
tree24edd7ae4a9216d5ff4f9e4d002c3fdd7f7a9338
parentf9c0820773d2f3f40ef279336ddfb6913e12a2f0 (diff)
downloadchromium_src-940bf05b402781894eb56ffd2a2aea7bb4eea315.zip
chromium_src-940bf05b402781894eb56ffd2a2aea7bb4eea315.tar.gz
chromium_src-940bf05b402781894eb56ffd2a2aea7bb4eea315.tar.bz2
Merge 281448 "[M-37]: Fix dragging tab via mouse when touch is d..."
> [M-37]: Fix dragging tab via mouse when touch is down on ChromeOS > > Do not change value of |ToplevelWindowEventHandler::drag_reverted_| if > ET_MOUSE_CAPTURE_CHANGED is received after ET_MOUSE_RELEASED but before > the move loop has ended. This is currently the case with views::Widget. > > This CL does not fix all of the possible places where CompleteDrag() may be > called after the drag was completed for the sake of being easier to merge > back to M-37 > > BUG=380481 > TEST=ToplevelWindowEventHandlerTest.CaptureLossAfterMouseRelease > > Review URL: https://codereview.chromium.org/354343002 TBR=pkotwicz@chromium.org Review URL: https://codereview.chromium.org/483433003 git-svn-id: svn://svn.chromium.org/chrome/branches/2062/src@290145 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/wm/toplevel_window_event_handler.cc7
-rw-r--r--ash/wm/toplevel_window_event_handler_unittest.cc32
2 files changed, 37 insertions, 2 deletions
diff --git a/ash/wm/toplevel_window_event_handler.cc b/ash/wm/toplevel_window_event_handler.cc
index 5d9ce4b..a759e8b 100644
--- a/ash/wm/toplevel_window_event_handler.cc
+++ b/ash/wm/toplevel_window_event_handler.cc
@@ -494,8 +494,11 @@ void ToplevelWindowEventHandler::HandleMouseReleased(
if (event->phase() != ui::EP_PRETARGET)
return;
- CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ?
- DRAG_COMPLETE : DRAG_REVERT);
+ if (window_resizer_) {
+ CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ?
+ DRAG_COMPLETE : DRAG_REVERT);
+ }
+
// Completing the drag may result in hiding the window. If this happens
// mark the event as handled so no other handlers/observers act upon the
// event. They should see the event on a hidden window, to determine targets
diff --git a/ash/wm/toplevel_window_event_handler_unittest.cc b/ash/wm/toplevel_window_event_handler_unittest.cc
index 3aa25ba..74497f7 100644
--- a/ash/wm/toplevel_window_event_handler_unittest.cc
+++ b/ash/wm/toplevel_window_event_handler_unittest.cc
@@ -16,6 +16,7 @@
#include "ash/wm/workspace_controller.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/message_loop/message_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/test/aura_test_base.h"
@@ -705,6 +706,37 @@ TEST_F(ToplevelWindowEventHandlerTest, RunMoveLoopFailsDuringInProgressDrag) {
EXPECT_EQ("10,11 100x100", window1->bounds().ToString());
}
+namespace {
+
+void SendMouseReleaseAndReleaseCapture(aura::test::EventGenerator* generator,
+ aura::Window* window) {
+ generator->ReleaseLeftButton();
+ window->ReleaseCapture();
+}
+
+} // namespace
+
+// Test that a drag is successful even if ET_MOUSE_CAPTURE_CHANGED is sent
+// immediately after the mouse release. views::Widget has this behavior.
+TEST_F(ToplevelWindowEventHandlerTest, CaptureLossAfterMouseRelease) {
+ scoped_ptr<aura::Window> window(CreateWindow(HTNOWHERE));
+ aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
+ window.get());
+ generator.PressLeftButton();
+ window->SetCapture();
+
+ aura::client::WindowMoveClient* move_client =
+ aura::client::GetWindowMoveClient(window->GetRootWindow());
+ base::MessageLoopForUI::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&SendMouseReleaseAndReleaseCapture,
+ base::Unretained(&generator),
+ base::Unretained(window.get())));
+ EXPECT_EQ(aura::client::MOVE_SUCCESSFUL,
+ move_client->RunMoveLoop(window.get(), gfx::Vector2d(),
+ aura::client::WINDOW_MOVE_SOURCE_MOUSE));
+}
+
// Showing the resize shadows when the mouse is over the window edges is tested
// in resize_shadow_and_cursor_test.cc