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

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

Issue 140663013: Avoids releasing pointer grab prematurely (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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
« no previous file with comments | « no previous file | 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 87
88 return true; 88 return true;
89 } 89 }
90 90
91 //////////////////////////////////////////////////////////////////////////////// 91 ////////////////////////////////////////////////////////////////////////////////
92 // DesktopWindowTreeHostLinux, aura::client::WindowMoveClient implementation: 92 // DesktopWindowTreeHostLinux, aura::client::WindowMoveClient implementation:
93 93
94 bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source, 94 bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source,
95 gfx::NativeCursor cursor) { 95 gfx::NativeCursor cursor) {
96 // Start a capture on the host, so that it continues to receive events during 96 {
97 // the drag. 97 // A capture is started on the host, so that it continues to receive events
98 ScopedCapturer capturer(source->GetDispatcher()->host()); 98 // during the drag.
99 ScopedCapturer capturer(source->GetDispatcher()->host());
99 100
100 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time. 101 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time.
101 in_move_loop_ = true; 102 in_move_loop_ = true;
102 103
103 XDisplay* display = gfx::GetXDisplay(); 104 XDisplay* display = gfx::GetXDisplay();
104 105
105 grab_input_window_ = CreateDragInputWindow(display); 106 grab_input_window_ = CreateDragInputWindow(display);
106 if (!drag_image_.isNull()) 107 if (!drag_image_.isNull())
107 CreateDragImageWindow(); 108 CreateDragImageWindow();
108 base::MessagePumpX11::Current()->AddDispatcherForWindow( 109 base::MessagePumpX11::Current()->AddDispatcherForWindow(
109 this, grab_input_window_); 110 this, grab_input_window_);
110 111 // Releasing ScopedCapturer ensures that any other instance of
112 // X11ScopedCapture will not prematurely release grab that will be acquired
113 // below.
sadrul 2014/02/06 19:14:46 I do not understand what this means. Mind explaini
varkha 2014/02/06 19:22:55 There are three points where we set capture, all t
sadrul 2014/02/07 00:08:37 In the context of a drag, who calls this first Set
114 }
111 if (!GrabPointerWithCursor(cursor)) 115 if (!GrabPointerWithCursor(cursor))
112 return false; 116 return false;
113 117
114 // We are handling a mouse drag outside of the aura::RootWindow system. We 118 // We are handling a mouse drag outside of the aura::RootWindow system. We
115 // must manually make aura think that the mouse button is pressed so that we 119 // must manually make aura think that the mouse button is pressed so that we
116 // don't draw extraneous tooltips. 120 // don't draw extraneous tooltips.
117 aura::Env* env = aura::Env::GetInstance(); 121 aura::Env* env = aura::Env::GetInstance();
118 if (!env->IsMouseButtonDown()) { 122 if (!env->IsMouseButtonDown()) {
119 env->set_mouse_button_flags(ui::EF_LEFT_MOUSE_BUTTON); 123 env->set_mouse_button_flags(ui::EF_LEFT_MOUSE_BUTTON);
120 should_reset_mouse_flags_ = true; 124 should_reset_mouse_flags_ = true;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 image->SetBounds(0, 0, drag_image_.width(), drag_image_.height()); 240 image->SetBounds(0, 0, drag_image_.width(), drag_image_.height());
237 widget->SetContentsView(image); 241 widget->SetContentsView(image);
238 242
239 widget->Show(); 243 widget->Show();
240 widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false); 244 widget->GetNativeWindow()->layer()->SetFillsBoundsOpaquely(false);
241 245
242 drag_widget_.reset(widget); 246 drag_widget_.reset(widget);
243 } 247 }
244 248
245 } // namespace views 249 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698