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

Side by Side Diff: ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc

Issue 265843004: Avoids releasing capture in EndMoveLoop if capture was switched to another window while dragging (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoids releasing capture in EndMoveLoop if capture was switched to another window (comments) Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h" 5 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. 8 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
9 #undef RootWindow 9 #undef RootWindow
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 } // namespace 56 } // namespace
57 57
58 X11WholeScreenMoveLoop::X11WholeScreenMoveLoop( 58 X11WholeScreenMoveLoop::X11WholeScreenMoveLoop(
59 X11WholeScreenMoveLoopDelegate* delegate) 59 X11WholeScreenMoveLoopDelegate* delegate)
60 : delegate_(delegate), 60 : delegate_(delegate),
61 in_move_loop_(false), 61 in_move_loop_(false),
62 should_reset_mouse_flags_(false), 62 should_reset_mouse_flags_(false),
63 grab_input_window_(None), 63 grab_input_window_(None),
64 canceled_(false), 64 canceled_(false),
65 has_grab_(false),
65 weak_factory_(this) { 66 weak_factory_(this) {
66 last_xmotion_.type = LASTEvent; 67 last_xmotion_.type = LASTEvent;
67 } 68 }
68 69
69 X11WholeScreenMoveLoop::~X11WholeScreenMoveLoop() {} 70 X11WholeScreenMoveLoop::~X11WholeScreenMoveLoop() {}
70 71
71 void X11WholeScreenMoveLoop::DispatchMouseMovement() { 72 void X11WholeScreenMoveLoop::DispatchMouseMovement() {
72 if (!weak_factory_.HasWeakPtrs()) 73 if (!weak_factory_.HasWeakPtrs())
73 return; 74 return;
74 weak_factory_.InvalidateWeakPtrs(); 75 weak_factory_.InvalidateWeakPtrs();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 return ui::POST_DISPATCH_NONE; 130 return ui::POST_DISPATCH_NONE;
130 } 131 }
131 case KeyPress: { 132 case KeyPress: {
132 if (ui::KeyboardCodeFromXKeyEvent(xev) == ui::VKEY_ESCAPE) { 133 if (ui::KeyboardCodeFromXKeyEvent(xev) == ui::VKEY_ESCAPE) {
133 canceled_ = true; 134 canceled_ = true;
134 EndMoveLoop(); 135 EndMoveLoop();
135 return ui::POST_DISPATCH_NONE; 136 return ui::POST_DISPATCH_NONE;
136 } 137 }
137 break; 138 break;
138 } 139 }
140 case FocusOut: {
141 if (xev->xfocus.mode != NotifyGrab)
142 has_grab_ = false;
143 break;
144 }
139 case GenericEvent: { 145 case GenericEvent: {
140 ui::EventType type = ui::EventTypeFromNative(xev); 146 ui::EventType type = ui::EventTypeFromNative(xev);
141 switch (type) { 147 switch (type) {
142 case ui::ET_MOUSE_MOVED: 148 case ui::ET_MOUSE_MOVED:
143 case ui::ET_MOUSE_DRAGGED: 149 case ui::ET_MOUSE_DRAGGED:
144 case ui::ET_MOUSE_RELEASED: { 150 case ui::ET_MOUSE_RELEASED: {
145 XEvent xevent = {0}; 151 XEvent xevent = {0};
146 if (type == ui::ET_MOUSE_RELEASED) { 152 if (type == ui::ET_MOUSE_RELEASED) {
147 xevent.type = ButtonRelease; 153 xevent.type = ButtonRelease;
148 xevent.xbutton.button = ui::EventButtonFromNative(xev); 154 xevent.xbutton.button = ui::EventButtonFromNative(xev);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 aura::Env::GetInstance()->set_mouse_button_flags(0); 252 aura::Env::GetInstance()->set_mouse_button_flags(0);
247 should_reset_mouse_flags_ = false; 253 should_reset_mouse_flags_ = false;
248 } 254 }
249 255
250 // TODO(erg): Is this ungrab the cause of having to click to give input focus 256 // TODO(erg): Is this ungrab the cause of having to click to give input focus
251 // on drawn out windows? Not ungrabbing here screws the X server until I kill 257 // on drawn out windows? Not ungrabbing here screws the X server until I kill
252 // the chrome process. 258 // the chrome process.
253 259
254 // Ungrab before we let go of the window. 260 // Ungrab before we let go of the window.
255 XDisplay* display = gfx::GetXDisplay(); 261 XDisplay* display = gfx::GetXDisplay();
256 XUngrabPointer(display, CurrentTime); 262 // Only ungrab pointer if capture was not switched to another window.
257 XUngrabKeyboard(display, CurrentTime); 263 if (has_grab_) {
264 XUngrabPointer(display, CurrentTime);
265 XUngrabKeyboard(display, CurrentTime);
266 }
258 267
259 // Restore the previous dispatcher. 268 // Restore the previous dispatcher.
260 nested_dispatcher_.reset(); 269 nested_dispatcher_.reset();
261 drag_widget_.reset(); 270 drag_widget_.reset();
262 delegate_->OnMoveLoopEnded(); 271 delegate_->OnMoveLoopEnded();
263 XDestroyWindow(display, grab_input_window_); 272 XDestroyWindow(display, grab_input_window_);
264 grab_input_window_ = None; 273 grab_input_window_ = None;
265 274
266 in_move_loop_ = false; 275 in_move_loop_ = false;
267 quit_closure_.Run(); 276 quit_closure_.Run();
(...skipping 20 matching lines...) Expand all
288 ButtonPressMask | ButtonReleaseMask | PointerMotionMask, 297 ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
289 GrabModeAsync, 298 GrabModeAsync,
290 GrabModeAsync, 299 GrabModeAsync,
291 None, 300 None,
292 cursor.platform(), 301 cursor.platform(),
293 CurrentTime); 302 CurrentTime);
294 if (ret != GrabSuccess) { 303 if (ret != GrabSuccess) {
295 DLOG(ERROR) << "Grabbing pointer for dragging failed: " 304 DLOG(ERROR) << "Grabbing pointer for dragging failed: "
296 << ui::GetX11ErrorString(display, ret); 305 << ui::GetX11ErrorString(display, ret);
297 } else { 306 } else {
307 has_grab_ = true;
298 XUngrabKeyboard(display, CurrentTime); 308 XUngrabKeyboard(display, CurrentTime);
299 ret = XGrabKeyboard( 309 ret = XGrabKeyboard(
300 display, 310 display,
301 grab_input_window_, 311 grab_input_window_,
302 False, 312 False,
303 GrabModeAsync, 313 GrabModeAsync,
304 GrabModeAsync, 314 GrabModeAsync,
305 CurrentTime); 315 CurrentTime);
306 if (ret != GrabSuccess) { 316 if (ret != GrabSuccess) {
307 DLOG(ERROR) << "Grabbing keyboard for dragging failed: " 317 DLOG(ERROR) << "Grabbing keyboard for dragging failed: "
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 for (int x = 0; x < in_bitmap->width(); ++x) { 384 for (int x = 0; x < in_bitmap->width(); ++x) {
375 if (SkColorGetA(in_row[x]) > kMinAlpha) 385 if (SkColorGetA(in_row[x]) > kMinAlpha)
376 return true; 386 return true;
377 } 387 }
378 } 388 }
379 389
380 return false; 390 return false;
381 } 391 }
382 392
383 } // namespace views 393 } // namespace views
OLDNEW
« no previous file with comments | « 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