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

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

Issue 276163002: Revert of Avoids releasing capture in EndMoveLoop if capture was switched to another window while .. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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),
66 weak_factory_(this) { 65 weak_factory_(this) {
67 last_xmotion_.type = LASTEvent; 66 last_xmotion_.type = LASTEvent;
68 } 67 }
69 68
70 X11WholeScreenMoveLoop::~X11WholeScreenMoveLoop() {} 69 X11WholeScreenMoveLoop::~X11WholeScreenMoveLoop() {}
71 70
72 void X11WholeScreenMoveLoop::DispatchMouseMovement() { 71 void X11WholeScreenMoveLoop::DispatchMouseMovement() {
73 if (!weak_factory_.HasWeakPtrs()) 72 if (!weak_factory_.HasWeakPtrs())
74 return; 73 return;
75 weak_factory_.InvalidateWeakPtrs(); 74 weak_factory_.InvalidateWeakPtrs();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return ui::POST_DISPATCH_NONE; 129 return ui::POST_DISPATCH_NONE;
131 } 130 }
132 case KeyPress: { 131 case KeyPress: {
133 if (ui::KeyboardCodeFromXKeyEvent(xev) == ui::VKEY_ESCAPE) { 132 if (ui::KeyboardCodeFromXKeyEvent(xev) == ui::VKEY_ESCAPE) {
134 canceled_ = true; 133 canceled_ = true;
135 EndMoveLoop(); 134 EndMoveLoop();
136 return ui::POST_DISPATCH_NONE; 135 return ui::POST_DISPATCH_NONE;
137 } 136 }
138 break; 137 break;
139 } 138 }
140 case FocusOut: {
141 if (xev->xfocus.mode != NotifyGrab)
142 has_grab_ = false;
143 break;
144 }
145 case GenericEvent: { 139 case GenericEvent: {
146 ui::EventType type = ui::EventTypeFromNative(xev); 140 ui::EventType type = ui::EventTypeFromNative(xev);
147 switch (type) { 141 switch (type) {
148 case ui::ET_MOUSE_MOVED: 142 case ui::ET_MOUSE_MOVED:
149 case ui::ET_MOUSE_DRAGGED: 143 case ui::ET_MOUSE_DRAGGED:
150 case ui::ET_MOUSE_RELEASED: { 144 case ui::ET_MOUSE_RELEASED: {
151 XEvent xevent = {0}; 145 XEvent xevent = {0};
152 if (type == ui::ET_MOUSE_RELEASED) { 146 if (type == ui::ET_MOUSE_RELEASED) {
153 xevent.type = ButtonRelease; 147 xevent.type = ButtonRelease;
154 xevent.xbutton.button = ui::EventButtonFromNative(xev); 148 xevent.xbutton.button = ui::EventButtonFromNative(xev);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 aura::Env::GetInstance()->set_mouse_button_flags(0); 246 aura::Env::GetInstance()->set_mouse_button_flags(0);
253 should_reset_mouse_flags_ = false; 247 should_reset_mouse_flags_ = false;
254 } 248 }
255 249
256 // TODO(erg): Is this ungrab the cause of having to click to give input focus 250 // TODO(erg): Is this ungrab the cause of having to click to give input focus
257 // on drawn out windows? Not ungrabbing here screws the X server until I kill 251 // on drawn out windows? Not ungrabbing here screws the X server until I kill
258 // the chrome process. 252 // the chrome process.
259 253
260 // Ungrab before we let go of the window. 254 // Ungrab before we let go of the window.
261 XDisplay* display = gfx::GetXDisplay(); 255 XDisplay* display = gfx::GetXDisplay();
262 // Only ungrab pointer if capture was not switched to another window. 256 XUngrabPointer(display, CurrentTime);
263 if (has_grab_) { 257 XUngrabKeyboard(display, CurrentTime);
264 XUngrabPointer(display, CurrentTime);
265 XUngrabKeyboard(display, CurrentTime);
266 }
267 258
268 // Restore the previous dispatcher. 259 // Restore the previous dispatcher.
269 nested_dispatcher_.reset(); 260 nested_dispatcher_.reset();
270 drag_widget_.reset(); 261 drag_widget_.reset();
271 delegate_->OnMoveLoopEnded(); 262 delegate_->OnMoveLoopEnded();
272 XDestroyWindow(display, grab_input_window_); 263 XDestroyWindow(display, grab_input_window_);
273 grab_input_window_ = None; 264 grab_input_window_ = None;
274 265
275 in_move_loop_ = false; 266 in_move_loop_ = false;
276 quit_closure_.Run(); 267 quit_closure_.Run();
(...skipping 20 matching lines...) Expand all
297 ButtonPressMask | ButtonReleaseMask | PointerMotionMask, 288 ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
298 GrabModeAsync, 289 GrabModeAsync,
299 GrabModeAsync, 290 GrabModeAsync,
300 None, 291 None,
301 cursor.platform(), 292 cursor.platform(),
302 CurrentTime); 293 CurrentTime);
303 if (ret != GrabSuccess) { 294 if (ret != GrabSuccess) {
304 DLOG(ERROR) << "Grabbing pointer for dragging failed: " 295 DLOG(ERROR) << "Grabbing pointer for dragging failed: "
305 << ui::GetX11ErrorString(display, ret); 296 << ui::GetX11ErrorString(display, ret);
306 } else { 297 } else {
307 has_grab_ = true;
308 XUngrabKeyboard(display, CurrentTime); 298 XUngrabKeyboard(display, CurrentTime);
309 ret = XGrabKeyboard( 299 ret = XGrabKeyboard(
310 display, 300 display,
311 grab_input_window_, 301 grab_input_window_,
312 False, 302 False,
313 GrabModeAsync, 303 GrabModeAsync,
314 GrabModeAsync, 304 GrabModeAsync,
315 CurrentTime); 305 CurrentTime);
316 if (ret != GrabSuccess) { 306 if (ret != GrabSuccess) {
317 DLOG(ERROR) << "Grabbing keyboard for dragging failed: " 307 DLOG(ERROR) << "Grabbing keyboard for dragging failed: "
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 for (int x = 0; x < in_bitmap->width(); ++x) { 374 for (int x = 0; x < in_bitmap->width(); ++x) {
385 if (SkColorGetA(in_row[x]) > kMinAlpha) 375 if (SkColorGetA(in_row[x]) > kMinAlpha)
386 return true; 376 return true;
387 } 377 }
388 } 378 }
389 379
390 return false; 380 return false;
391 } 381 }
392 382
393 } // namespace views 383 } // 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