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

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 5 years, 11 months 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 cf259d3598a309f17f3158631290344da345568f..ea2d5c65a4fe786d1b3918e1aeee0dc84d78d143 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
@@ -21,6 +21,7 @@
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
#include "ui/events/platform/scoped_event_dispatcher.h"
#include "ui/events/platform/x11/x11_event_source.h"
+#include "ui/views/widget/desktop_aura/x11_pointer_grab.h"
namespace views {
@@ -39,7 +40,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),
@@ -123,14 +123,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
@@ -145,7 +140,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;
@@ -187,13 +182,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.
+ ::views::GrabPointer(grab_input_window_, false, cursor.platform());
+ } else {
+ NOTREACHED();
sadrul 2015/01/15 23:41:20 Add a comment like so: NOTREACHED() << "You mus
pkotwicz 2015/01/16 15:22:46 This message would be incorrect. We reach here if
sadrul 2015/01/16 15:25:14 The point is, add a correct comment that explains
+ }
}
}
@@ -215,12 +209,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_);
+ 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_);
@@ -236,22 +228,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 = ::views::GrabPointer(grab_input_window_, false, None);
if (ret != GrabSuccess) {
DLOG(ERROR) << "Grabbing pointer for dragging failed: "
<< ui::GetX11ErrorString(display, ret);

Powered by Google App Engine
This is Rietveld 408576698