| 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/keysym.h> | 8 #include <X11/keysym.h> |
| 8 #include <X11/Xlib.h> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/bind.h" | 11 #include "base/bind.h" |
| 11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 13 #include "ui/aura/client/capture_client.h" | 14 #include "ui/aura/client/capture_client.h" |
| 14 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
| 15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 16 #include "ui/aura/window_event_dispatcher.h" | 17 #include "ui/aura/window_event_dispatcher.h" |
| 17 #include "ui/aura/window_tree_host.h" | 18 #include "ui/aura/window_tree_host.h" |
| 18 #include "ui/base/x/x11_util.h" | 19 #include "ui/base/x/x11_util.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 grabbed_pointer_ = GrabPointer(cursor); | 150 grabbed_pointer_ = GrabPointer(cursor); |
| 150 if (!grabbed_pointer_) { | 151 if (!grabbed_pointer_) { |
| 151 XDestroyWindow(gfx::GetXDisplay(), grab_input_window_); | 152 XDestroyWindow(gfx::GetXDisplay(), grab_input_window_); |
| 152 return false; | 153 return false; |
| 153 } | 154 } |
| 154 } | 155 } |
| 155 | 156 |
| 156 GrabEscKey(); | 157 GrabEscKey(); |
| 157 | 158 |
| 158 scoped_ptr<ui::ScopedEventDispatcher> old_dispatcher = | 159 scoped_ptr<ui::ScopedEventDispatcher> old_dispatcher = |
| 159 nested_dispatcher_.Pass(); | 160 std::move(nested_dispatcher_); |
| 160 nested_dispatcher_ = | 161 nested_dispatcher_ = |
| 161 ui::PlatformEventSource::GetInstance()->OverrideDispatcher(this); | 162 ui::PlatformEventSource::GetInstance()->OverrideDispatcher(this); |
| 162 | 163 |
| 163 // We are handling a mouse drag outside of the aura::Window system. We must | 164 // We are handling a mouse drag outside of the aura::Window system. We must |
| 164 // manually make aura think that the mouse button is pressed so that we don't | 165 // manually make aura think that the mouse button is pressed so that we don't |
| 165 // draw extraneous tooltips. | 166 // draw extraneous tooltips. |
| 166 aura::Env* env = aura::Env::GetInstance(); | 167 aura::Env* env = aura::Env::GetInstance(); |
| 167 if (!env->IsMouseButtonDown()) { | 168 if (!env->IsMouseButtonDown()) { |
| 168 env->set_mouse_button_flags(ui::EF_LEFT_MOUSE_BUTTON); | 169 env->set_mouse_button_flags(ui::EF_LEFT_MOUSE_BUTTON); |
| 169 should_reset_mouse_flags_ = true; | 170 should_reset_mouse_flags_ = true; |
| 170 } | 171 } |
| 171 | 172 |
| 172 base::WeakPtr<X11WholeScreenMoveLoop> alive(weak_factory_.GetWeakPtr()); | 173 base::WeakPtr<X11WholeScreenMoveLoop> alive(weak_factory_.GetWeakPtr()); |
| 173 | 174 |
| 174 in_move_loop_ = true; | 175 in_move_loop_ = true; |
| 175 canceled_ = false; | 176 canceled_ = false; |
| 176 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); | 177 base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
| 177 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); | 178 base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); |
| 178 base::RunLoop run_loop; | 179 base::RunLoop run_loop; |
| 179 quit_closure_ = run_loop.QuitClosure(); | 180 quit_closure_ = run_loop.QuitClosure(); |
| 180 run_loop.Run(); | 181 run_loop.Run(); |
| 181 | 182 |
| 182 if (!alive) | 183 if (!alive) |
| 183 return false; | 184 return false; |
| 184 | 185 |
| 185 nested_dispatcher_ = old_dispatcher.Pass(); | 186 nested_dispatcher_ = std::move(old_dispatcher); |
| 186 return !canceled_; | 187 return !canceled_; |
| 187 } | 188 } |
| 188 | 189 |
| 189 void X11WholeScreenMoveLoop::UpdateCursor(gfx::NativeCursor cursor) { | 190 void X11WholeScreenMoveLoop::UpdateCursor(gfx::NativeCursor cursor) { |
| 190 if (in_move_loop_) | 191 if (in_move_loop_) |
| 191 ChangeActivePointerGrabCursor(cursor.platform()); | 192 ChangeActivePointerGrabCursor(cursor.platform()); |
| 192 } | 193 } |
| 193 | 194 |
| 194 void X11WholeScreenMoveLoop::EndMoveLoop() { | 195 void X11WholeScreenMoveLoop::EndMoveLoop() { |
| 195 if (!in_move_loop_) | 196 if (!in_move_loop_) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 DefaultRootWindow(display), | 267 DefaultRootWindow(display), |
| 267 -100, -100, 10, 10, | 268 -100, -100, 10, 10, |
| 268 0, CopyFromParent, InputOnly, CopyFromParent, | 269 0, CopyFromParent, InputOnly, CopyFromParent, |
| 269 attribute_mask, &swa); | 270 attribute_mask, &swa); |
| 270 XMapRaised(display, window); | 271 XMapRaised(display, window); |
| 271 ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(window); | 272 ui::X11EventSource::GetInstance()->BlockUntilWindowMapped(window); |
| 272 return window; | 273 return window; |
| 273 } | 274 } |
| 274 | 275 |
| 275 } // namespace views | 276 } // namespace views |
| OLD | NEW |