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

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

Issue 2319933002: X11: Remove calls to XSelectInput (Closed)
Patch Set: Comments Created 4 years, 3 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 | « 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 <stddef.h> 7 #include <stddef.h>
8 #include <X11/keysym.h> 8 #include <X11/keysym.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/single_thread_task_runner.h" 16 #include "base/single_thread_task_runner.h"
17 #include "ui/aura/client/capture_client.h" 17 #include "ui/aura/client/capture_client.h"
18 #include "ui/aura/env.h" 18 #include "ui/aura/env.h"
19 #include "ui/aura/window.h" 19 #include "ui/aura/window.h"
20 #include "ui/aura/window_event_dispatcher.h" 20 #include "ui/aura/window_event_dispatcher.h"
21 #include "ui/aura/window_tree_host.h" 21 #include "ui/aura/window_tree_host.h"
22 #include "ui/base/x/x11_util.h" 22 #include "ui/base/x/x11_util.h"
23 #include "ui/base/x/x11_window_event_manager.h"
23 #include "ui/events/event.h" 24 #include "ui/events/event.h"
24 #include "ui/events/event_utils.h" 25 #include "ui/events/event_utils.h"
25 #include "ui/events/keycodes/keyboard_code_conversion_x.h" 26 #include "ui/events/keycodes/keyboard_code_conversion_x.h"
26 #include "ui/events/platform/platform_event_source.h" 27 #include "ui/events/platform/platform_event_source.h"
27 #include "ui/events/platform/scoped_event_dispatcher.h" 28 #include "ui/events/platform/scoped_event_dispatcher.h"
28 #include "ui/events/platform/x11/x11_event_source.h" 29 #include "ui/events/platform/x11/x11_event_source.h"
29 #include "ui/views/widget/desktop_aura/x11_pointer_grab.h" 30 #include "ui/views/widget/desktop_aura/x11_pointer_grab.h"
30 31
31 namespace views { 32 namespace views {
32 33
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 131 }
131 132
132 bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source, 133 bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source,
133 gfx::NativeCursor cursor) { 134 gfx::NativeCursor cursor) {
134 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time. 135 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time.
135 136
136 // Query the mouse cursor prior to the move loop starting so that it can be 137 // Query the mouse cursor prior to the move loop starting so that it can be
137 // restored when the move loop finishes. 138 // restored when the move loop finishes.
138 initial_cursor_ = source->GetHost()->last_cursor(); 139 initial_cursor_ = source->GetHost()->last_cursor();
139 140
140 grab_input_window_ = CreateDragInputWindow(gfx::GetXDisplay()); 141 CreateDragInputWindow(gfx::GetXDisplay());
141 142
142 // Only grab mouse capture of |grab_input_window_| if |source| does not have 143 // Only grab mouse capture of |grab_input_window_| if |source| does not have
143 // capture. 144 // capture.
144 // - The caller may intend to transfer capture to a different aura::Window 145 // - The caller may intend to transfer capture to a different aura::Window
145 // when the move loop ends and not release capture. 146 // when the move loop ends and not release capture.
146 // - Releasing capture and X window destruction are both asynchronous. We drop 147 // - Releasing capture and X window destruction are both asynchronous. We drop
147 // events targeted at |grab_input_window_| in the time between the move 148 // events targeted at |grab_input_window_| in the time between the move
148 // loop ends and |grab_input_window_| loses capture. 149 // loop ends and |grab_input_window_| loses capture.
149 grabbed_pointer_ = false; 150 grabbed_pointer_ = false;
150 if (!source->HasCapture()) { 151 if (!source->HasCapture()) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 222
222 XDisplay* display = gfx::GetXDisplay(); 223 XDisplay* display = gfx::GetXDisplay();
223 unsigned int esc_keycode = XKeysymToKeycode(display, XK_Escape); 224 unsigned int esc_keycode = XKeysymToKeycode(display, XK_Escape);
224 for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) { 225 for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) {
225 XUngrabKey(display, esc_keycode, kModifiersMasks[i], grab_input_window_); 226 XUngrabKey(display, esc_keycode, kModifiersMasks[i], grab_input_window_);
226 } 227 }
227 228
228 // Restore the previous dispatcher. 229 // Restore the previous dispatcher.
229 nested_dispatcher_.reset(); 230 nested_dispatcher_.reset();
230 delegate_->OnMoveLoopEnded(); 231 delegate_->OnMoveLoopEnded();
232 grab_input_window_events_.reset();
231 XDestroyWindow(display, grab_input_window_); 233 XDestroyWindow(display, grab_input_window_);
232 grab_input_window_ = None; 234 grab_input_window_ = None;
233 235
234 in_move_loop_ = false; 236 in_move_loop_ = false;
235 quit_closure_.Run(); 237 quit_closure_.Run();
236 } 238 }
237 239
238 bool X11WholeScreenMoveLoop::GrabPointer(gfx::NativeCursor cursor) { 240 bool X11WholeScreenMoveLoop::GrabPointer(gfx::NativeCursor cursor) {
239 XDisplay* display = gfx::GetXDisplay(); 241 XDisplay* display = gfx::GetXDisplay();
240 XGrabServer(display); 242 XGrabServer(display);
(...skipping 12 matching lines...) Expand all
253 255
254 void X11WholeScreenMoveLoop::GrabEscKey() { 256 void X11WholeScreenMoveLoop::GrabEscKey() {
255 XDisplay* display = gfx::GetXDisplay(); 257 XDisplay* display = gfx::GetXDisplay();
256 unsigned int esc_keycode = XKeysymToKeycode(display, XK_Escape); 258 unsigned int esc_keycode = XKeysymToKeycode(display, XK_Escape);
257 for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) { 259 for (size_t i = 0; i < arraysize(kModifiersMasks); ++i) {
258 XGrabKey(display, esc_keycode, kModifiersMasks[i], grab_input_window_, 260 XGrabKey(display, esc_keycode, kModifiersMasks[i], grab_input_window_,
259 False, GrabModeAsync, GrabModeAsync); 261 False, GrabModeAsync, GrabModeAsync);
260 } 262 }
261 } 263 }
262 264
263 Window X11WholeScreenMoveLoop::CreateDragInputWindow(XDisplay* display) { 265 void X11WholeScreenMoveLoop::CreateDragInputWindow(XDisplay* display) {
264 unsigned long attribute_mask = CWEventMask | CWOverrideRedirect; 266 unsigned long attribute_mask = CWEventMask | CWOverrideRedirect;
265 XSetWindowAttributes swa; 267 XSetWindowAttributes swa;
266 memset(&swa, 0, sizeof(swa)); 268 memset(&swa, 0, sizeof(swa));
267 swa.event_mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask |
268 KeyPressMask | KeyReleaseMask | StructureNotifyMask;
269 swa.override_redirect = True; 269 swa.override_redirect = True;
270 Window window = XCreateWindow(display, 270 grab_input_window_ = XCreateWindow(display, DefaultRootWindow(display), -100,
271 DefaultRootWindow(display), 271 -100, 10, 10, 0, CopyFromParent, InputOnly,
272 -100, -100, 10, 10, 272 CopyFromParent, attribute_mask, &swa);
273 0, CopyFromParent, InputOnly, CopyFromParent, 273 uint32_t event_mask = ButtonPressMask | ButtonReleaseMask |
274 attribute_mask, &swa); 274 PointerMotionMask | KeyPressMask | KeyReleaseMask |
275 XMapRaised(display, window); 275 StructureNotifyMask;
276 ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(window); 276 grab_input_window_events_.reset(
277 return window; 277 new ui::XScopedEventSelector(grab_input_window_, event_mask));
278
279 XMapRaised(display, grab_input_window_);
280 ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(grab_input_window_);
278 } 281 }
279 282
280 } // namespace views 283 } // 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