Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc

Issue 821803002: Use XGrabPointer instead of XChangeActivatePointerGrab() to change the cursor during a pointer grab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_capture
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 8c20313bf87401e6513e9d30177b3adbb7699d3e..7cc104eff28904312051a0dcf2f3001b2a9ccd5f 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),
@@ -122,14 +121,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
@@ -144,7 +138,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;
@@ -180,13 +174,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();
+ }
}
}
@@ -209,12 +202,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_);
@@ -230,22 +221,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);
pkotwicz 2014/12/22 23:44:16 Passing None for the Cursor argument seems like th
sadrul 2014/12/23 16:53:50 This is different from what we do now though, righ
pkotwicz 2014/12/23 18:22:22 I do not understand. If X11WholeScreenMoveLoop::Ru
sadrul 2015/01/14 20:34:01 Why not continue to do the same (i.e. why should w
pkotwicz 2015/01/14 20:50:07 The problem is that if RunMoveLoop() takes a curso
if (ret != GrabSuccess) {
DLOG(ERROR) << "Grabbing pointer for dragging failed: "
<< ui::GetX11ErrorString(display, ret);
« ui/base/x/x11_util.cc ('K') | « ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698