Index: ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc |
diff --git a/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc b/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc |
index e0840cc43e84fc5bd0ac1abb2094c692dc7ed1bf..265c1c896530232ae29ab37f793fdb5cc869554e 100644 |
--- a/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc |
+++ b/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc |
@@ -39,7 +39,6 @@ const unsigned int kModifiersMasks[] = { |
X11WholeScreenMoveLoop::X11WholeScreenMoveLoop(X11MoveLoopDelegate* delegate) |
: delegate_(delegate), |
in_move_loop_(false), |
- initial_cursor_(ui::kCursorNull), |
should_reset_mouse_flags_(false), |
grab_input_window_(None), |
grabbed_pointer_(false), |
@@ -144,14 +143,9 @@ uint32_t X11WholeScreenMoveLoop::DispatchEvent(const ui::PlatformEvent& event) { |
return ui::POST_DISPATCH_PERFORM_DEFAULT; |
} |
-bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source, |
- gfx::NativeCursor cursor) { |
+bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source) { |
DCHECK(!in_move_loop_); // Can only handle one nested loop at a time. |
- // Query the mouse cursor prior to the move loop starting so that it can be |
- // restored when the move loop finishes. |
- initial_cursor_ = source->GetHost()->last_cursor(); |
- |
grab_input_window_ = CreateDragInputWindow(gfx::GetXDisplay()); |
// Only grab mouse capture of |grab_input_window_| if |source| does not have |
@@ -166,7 +160,7 @@ bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source, |
aura::client::CaptureClient* capture_client = |
aura::client::GetCaptureClient(source->GetRootWindow()); |
CHECK(capture_client->GetGlobalCaptureWindow() == NULL); |
- grabbed_pointer_ = GrabPointer(cursor); |
+ grabbed_pointer_ = GrabPointer(); |
if (!grabbed_pointer_) { |
XDestroyWindow(gfx::GetXDisplay(), grab_input_window_); |
return false; |
@@ -202,13 +196,12 @@ bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source, |
void X11WholeScreenMoveLoop::UpdateCursor(gfx::NativeCursor cursor) { |
if (in_move_loop_) { |
- // We cannot call GrabPointer() because we do not want to change the |
- // "owner_events" property of the active pointer grab. |
- XChangeActivePointerGrab( |
- gfx::GetXDisplay(), |
- ButtonPressMask | ButtonReleaseMask | PointerMotionMask, |
- cursor.platform(), |
- CurrentTime); |
+ if (grabbed_pointer_) { |
+ // Do not grab the server. We already have pointer grab. |
+ ui::GrabPointer(grab_input_window_, false, cursor.platform()); |
+ } else { |
+ NOTREACHED(); |
+ } |
} |
} |
@@ -231,12 +224,10 @@ void X11WholeScreenMoveLoop::EndMoveLoop() { |
// the chrome process. |
// Ungrab before we let go of the window. |
- XDisplay* display = gfx::GetXDisplay(); |
if (grabbed_pointer_) |
- XUngrabPointer(display, CurrentTime); |
- else |
- UpdateCursor(initial_cursor_); |
+ ui::UngrabPointer(); |
+ XDisplay* display = gfx::GetXDisplay(); |
unsigned int esc_keycode = XKeysymToKeycode(display, XK_Escape); |
for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) { |
XUngrabKey(display, esc_keycode, kModifiersMasks[i], grab_input_window_); |
@@ -252,22 +243,13 @@ void X11WholeScreenMoveLoop::EndMoveLoop() { |
quit_closure_.Run(); |
} |
-bool X11WholeScreenMoveLoop::GrabPointer(gfx::NativeCursor cursor) { |
+bool X11WholeScreenMoveLoop::GrabPointer() { |
XDisplay* display = gfx::GetXDisplay(); |
XGrabServer(display); |
// Pass "owner_events" as false so that X sends all mouse events to |
// |grab_input_window_|. |
- int ret = XGrabPointer( |
- display, |
- grab_input_window_, |
- False, // owner_events |
- ButtonPressMask | ButtonReleaseMask | PointerMotionMask, |
- GrabModeAsync, |
- GrabModeAsync, |
- None, |
- cursor.platform(), |
- CurrentTime); |
+ int ret = ui::GrabPointer(grab_input_window_, false, None); |
sadrul
2014/12/22 21:08:59
Should you send cursor.platform() for cursor?
|
if (ret != GrabSuccess) { |
DLOG(ERROR) << "Grabbing pointer for dragging failed: " |
<< ui::GetX11ErrorString(display, ret); |