OLD | NEW |
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 } | 57 } |
58 | 58 |
59 //////////////////////////////////////////////////////////////////////////////// | 59 //////////////////////////////////////////////////////////////////////////////// |
60 // DesktopRootWindowHostLinux, aura::client::WindowMoveClient implementation: | 60 // DesktopRootWindowHostLinux, aura::client::WindowMoveClient implementation: |
61 | 61 |
62 bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source, | 62 bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source, |
63 gfx::NativeCursor cursor) { | 63 gfx::NativeCursor cursor) { |
64 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time. | 64 DCHECK(!in_move_loop_); // Can only handle one nested loop at a time. |
65 in_move_loop_ = true; | 65 in_move_loop_ = true; |
66 | 66 |
67 Display* display = base::MessagePumpX11::GetDefaultXDisplay(); | 67 Display* display = ui::GetXDisplay(); |
68 | 68 |
69 // Creates an invisible, InputOnly toplevel window. This window will receive | 69 // Creates an invisible, InputOnly toplevel window. This window will receive |
70 // all mouse movement for drags. It turns out that normal windows doing a | 70 // all mouse movement for drags. It turns out that normal windows doing a |
71 // grab doesn't redirect pointer motion events if the pointer isn't over the | 71 // grab doesn't redirect pointer motion events if the pointer isn't over the |
72 // grabbing window. But InputOnly windows are able to grab everything. This | 72 // grabbing window. But InputOnly windows are able to grab everything. This |
73 // is what GTK+ does, and I found a patch to KDE that did something similar. | 73 // is what GTK+ does, and I found a patch to KDE that did something similar. |
74 unsigned long attribute_mask = CWEventMask | CWOverrideRedirect; | 74 unsigned long attribute_mask = CWEventMask | CWOverrideRedirect; |
75 XSetWindowAttributes swa; | 75 XSetWindowAttributes swa; |
76 memset(&swa, 0, sizeof(swa)); | 76 memset(&swa, 0, sizeof(swa)); |
77 swa.event_mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | | 77 swa.event_mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 void X11WholeScreenMoveLoop::EndMoveLoop() { | 110 void X11WholeScreenMoveLoop::EndMoveLoop() { |
111 if (!in_move_loop_) | 111 if (!in_move_loop_) |
112 return; | 112 return; |
113 | 113 |
114 // TODO(erg): Is this ungrab the cause of having to click to give input focus | 114 // TODO(erg): Is this ungrab the cause of having to click to give input focus |
115 // on drawn out windows? Not ungrabbing here screws the X server until I kill | 115 // on drawn out windows? Not ungrabbing here screws the X server until I kill |
116 // the chrome process. | 116 // the chrome process. |
117 | 117 |
118 // Ungrab before we let go of the window. | 118 // Ungrab before we let go of the window. |
119 Display* display = base::MessagePumpX11::GetDefaultXDisplay(); | 119 Display* display = ui::GetXDisplay(); |
120 XUngrabPointer(display, CurrentTime); | 120 XUngrabPointer(display, CurrentTime); |
121 | 121 |
122 base::MessagePumpX11::Current()->RemoveDispatcherForWindow( | 122 base::MessagePumpX11::Current()->RemoveDispatcherForWindow( |
123 grab_input_window_); | 123 grab_input_window_); |
124 delegate_->OnMoveLoopEnded(); | 124 delegate_->OnMoveLoopEnded(); |
125 XDestroyWindow(display, grab_input_window_); | 125 XDestroyWindow(display, grab_input_window_); |
126 | 126 |
127 in_move_loop_ = false; | 127 in_move_loop_ = false; |
128 quit_closure_.Run(); | 128 quit_closure_.Run(); |
129 } | 129 } |
130 | 130 |
131 bool X11WholeScreenMoveLoop::GrabPointerWithCursor(gfx::NativeCursor cursor) { | 131 bool X11WholeScreenMoveLoop::GrabPointerWithCursor(gfx::NativeCursor cursor) { |
132 Display* display = base::MessagePumpX11::GetDefaultXDisplay(); | 132 Display* display = ui::GetXDisplay(); |
133 XGrabServer(display); | 133 XGrabServer(display); |
134 XUngrabPointer(display, CurrentTime); | 134 XUngrabPointer(display, CurrentTime); |
135 int ret = XGrabPointer( | 135 int ret = XGrabPointer( |
136 display, | 136 display, |
137 grab_input_window_, | 137 grab_input_window_, |
138 False, | 138 False, |
139 ButtonPressMask | ButtonReleaseMask | PointerMotionMask, | 139 ButtonPressMask | ButtonReleaseMask | PointerMotionMask, |
140 GrabModeAsync, | 140 GrabModeAsync, |
141 GrabModeAsync, | 141 GrabModeAsync, |
142 None, | 142 None, |
143 cursor.platform(), | 143 cursor.platform(), |
144 CurrentTime); | 144 CurrentTime); |
145 XUngrabServer(display); | 145 XUngrabServer(display); |
146 if (ret != GrabSuccess) { | 146 if (ret != GrabSuccess) { |
147 DLOG(ERROR) << "Grabbing new tab for dragging failed: " | 147 DLOG(ERROR) << "Grabbing new tab for dragging failed: " |
148 << ui::GetX11ErrorString(display, ret); | 148 << ui::GetX11ErrorString(display, ret); |
149 return false; | 149 return false; |
150 } | 150 } |
151 | 151 |
152 return true; | 152 return true; |
153 } | 153 } |
154 | 154 |
155 } // namespace views | 155 } // namespace views |
OLD | NEW |