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

Side by Side Diff: ui/views/widget/x11_desktop_window_move_client.cc

Issue 10909043: Cancel drag if display configuration changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/widget/x11_desktop_window_move_client.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/x11_desktop_window_move_client.h" 5 #include "ui/views/widget/x11_desktop_window_move_client.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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 ui::TouchEvent* event) { 62 ui::TouchEvent* event) {
63 return ui::TOUCH_STATUS_UNKNOWN; 63 return ui::TOUCH_STATUS_UNKNOWN;
64 } 64 }
65 65
66 ui::EventResult X11DesktopWindowMoveClient::PreHandleGestureEvent( 66 ui::EventResult X11DesktopWindowMoveClient::PreHandleGestureEvent(
67 aura::Window* target, 67 aura::Window* target,
68 ui::GestureEvent* event) { 68 ui::GestureEvent* event) {
69 return ui::ER_UNHANDLED; 69 return ui::ER_UNHANDLED;
70 } 70 }
71 71
72 void X11DesktopWindowMoveClient::RunMoveLoop(aura::Window* source, 72 aura::client::WindowMoveResult X11DesktopWindowMoveClient::RunMoveLoop(
73 const gfx::Point& drag_offset) { 73 aura::Window* source,
74 const gfx::Point& drag_offset) {
74 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time. 75 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time.
75 in_move_loop_ = true; 76 in_move_loop_ = true;
76 window_offset_ = drag_offset; 77 window_offset_ = drag_offset;
77 78
78 source->GetRootWindow()->ShowRootWindow(); 79 source->GetRootWindow()->ShowRootWindow();
79 80
80 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); 81 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
81 XGrabServer(display); 82 XGrabServer(display);
82 XUngrabPointer(display, CurrentTime); 83 XUngrabPointer(display, CurrentTime);
83 84
84 aura::RootWindow* root_window = source->GetRootWindow(); 85 aura::RootWindow* root_window = source->GetRootWindow();
85 int ret = XGrabPointer(display, 86 int ret = XGrabPointer(display,
86 root_window->GetAcceleratedWidget(), 87 root_window->GetAcceleratedWidget(),
87 False, 88 False,
88 ButtonReleaseMask | PointerMotionMask, 89 ButtonReleaseMask | PointerMotionMask,
89 GrabModeAsync, 90 GrabModeAsync,
90 GrabModeAsync, 91 GrabModeAsync,
91 None, 92 None,
92 None, 93 None,
93 CurrentTime); 94 CurrentTime);
94 XUngrabServer(display); 95 XUngrabServer(display);
95 if (ret != GrabSuccess) { 96 if (ret != GrabSuccess) {
96 DLOG(ERROR) << "Grabbing new tab for dragging failed: " << ret; 97 DLOG(ERROR) << "Grabbing new tab for dragging failed: " << ret;
97 return; 98 return aura::client::MOVE_CANCELED;
98 } 99 }
99 100
100 MessageLoopForUI* loop = MessageLoopForUI::current(); 101 MessageLoopForUI* loop = MessageLoopForUI::current();
101 MessageLoop::ScopedNestableTaskAllower allow_nested(loop); 102 MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
102 base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher()); 103 base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher());
103 quit_closure_ = run_loop.QuitClosure(); 104 quit_closure_ = run_loop.QuitClosure();
104 run_loop.Run(); 105 run_loop.Run();
106 return aura::client::MOVE_SUCCESSFUL;
105 } 107 }
106 108
107 void X11DesktopWindowMoveClient::EndMoveLoop() { 109 void X11DesktopWindowMoveClient::EndMoveLoop() {
108 if (!in_move_loop_) 110 if (!in_move_loop_)
109 return; 111 return;
110 112
111 // TODO(erg): Is this ungrab the cause of having to click to give input focus 113 // TODO(erg): Is this ungrab the cause of having to click to give input focus
112 // on drawn out windows? Not ungrabbing here screws the X server until I kill 114 // on drawn out windows? Not ungrabbing here screws the X server until I kill
113 // the chrome process. 115 // the chrome process.
114 116
115 // Ungrab before we let go of the window. 117 // Ungrab before we let go of the window.
116 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); 118 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
117 XUngrabPointer(display, CurrentTime); 119 XUngrabPointer(display, CurrentTime);
118 120
119 in_move_loop_ = false; 121 in_move_loop_ = false;
120 quit_closure_.Run(); 122 quit_closure_.Run();
121 } 123 }
122 124
123 } // namespace views 125 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/x11_desktop_window_move_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698