Commit 60a7a7ef authored by varkha@chromium.org's avatar varkha@chromium.org

Avoids releasing capture in EndMoveLoop if capture was switched to another window while dragging.

This variant relies on checking if a drag input window still has capture before releasing the grab.
A better alternative is in CL https://codereview.chromium.org/262893002/.

BUG=363503
TEST=Follow the exact steps in the bug description.
TEST=interactive_ui_tests --gtest_filter=*TabDragging*

Review URL: https://codereview.chromium.org/265843004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269593 0039d316-1c4b-4281-b951-d872f2087c98
parent 6d351d49
...@@ -62,6 +62,7 @@ X11WholeScreenMoveLoop::X11WholeScreenMoveLoop( ...@@ -62,6 +62,7 @@ X11WholeScreenMoveLoop::X11WholeScreenMoveLoop(
should_reset_mouse_flags_(false), should_reset_mouse_flags_(false),
grab_input_window_(None), grab_input_window_(None),
canceled_(false), canceled_(false),
has_grab_(false),
weak_factory_(this) { weak_factory_(this) {
last_xmotion_.type = LASTEvent; last_xmotion_.type = LASTEvent;
} }
...@@ -136,6 +137,11 @@ uint32_t X11WholeScreenMoveLoop::DispatchEvent(const ui::PlatformEvent& event) { ...@@ -136,6 +137,11 @@ uint32_t X11WholeScreenMoveLoop::DispatchEvent(const ui::PlatformEvent& event) {
} }
break; break;
} }
case FocusOut: {
if (xev->xfocus.mode != NotifyGrab)
has_grab_ = false;
break;
}
case GenericEvent: { case GenericEvent: {
ui::EventType type = ui::EventTypeFromNative(xev); ui::EventType type = ui::EventTypeFromNative(xev);
switch (type) { switch (type) {
...@@ -253,8 +259,11 @@ void X11WholeScreenMoveLoop::EndMoveLoop() { ...@@ -253,8 +259,11 @@ void X11WholeScreenMoveLoop::EndMoveLoop() {
// Ungrab before we let go of the window. // Ungrab before we let go of the window.
XDisplay* display = gfx::GetXDisplay(); XDisplay* display = gfx::GetXDisplay();
XUngrabPointer(display, CurrentTime); // Only ungrab pointer if capture was not switched to another window.
XUngrabKeyboard(display, CurrentTime); if (has_grab_) {
XUngrabPointer(display, CurrentTime);
XUngrabKeyboard(display, CurrentTime);
}
// Restore the previous dispatcher. // Restore the previous dispatcher.
nested_dispatcher_.reset(); nested_dispatcher_.reset();
...@@ -295,6 +304,7 @@ bool X11WholeScreenMoveLoop::GrabPointerAndKeyboard(gfx::NativeCursor cursor) { ...@@ -295,6 +304,7 @@ bool X11WholeScreenMoveLoop::GrabPointerAndKeyboard(gfx::NativeCursor cursor) {
DLOG(ERROR) << "Grabbing pointer for dragging failed: " DLOG(ERROR) << "Grabbing pointer for dragging failed: "
<< ui::GetX11ErrorString(display, ret); << ui::GetX11ErrorString(display, ret);
} else { } else {
has_grab_ = true;
XUngrabKeyboard(display, CurrentTime); XUngrabKeyboard(display, CurrentTime);
ret = XGrabKeyboard( ret = XGrabKeyboard(
display, display,
......
...@@ -91,6 +91,9 @@ class X11WholeScreenMoveLoop : public ui::PlatformEventDispatcher { ...@@ -91,6 +91,9 @@ class X11WholeScreenMoveLoop : public ui::PlatformEventDispatcher {
// pressing escape). // pressing escape).
bool canceled_; bool canceled_;
// Keeps track of whether we still have a pointer grab at the end of the loop.
bool has_grab_;
// A Widget is created during the drag if there is an image available to be // A Widget is created during the drag if there is an image available to be
// used during the drag. // used during the drag.
scoped_ptr<Widget> drag_widget_; scoped_ptr<Widget> drag_widget_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment