| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_ | 5 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_ |
| 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_ | 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "ui/base/cursor/cursor.h" | 14 #include "ui/base/cursor/cursor.h" |
| 15 #include "ui/events/platform/platform_event_dispatcher.h" | 15 #include "ui/events/platform/platform_event_dispatcher.h" |
| 16 #include "ui/gfx/geometry/vector2d_f.h" | 16 #include "ui/gfx/geometry/vector2d_f.h" |
| 17 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
| 18 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
| 19 #include "ui/gfx/x/x11_types.h" | 19 #include "ui/gfx/x/x11_types.h" |
| 20 #include "ui/views/widget/desktop_aura/x11_move_loop.h" | 20 #include "ui/views/widget/desktop_aura/x11_move_loop.h" |
| 21 #include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h" | 21 #include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h" |
| 22 | 22 |
| 23 namespace aura { | 23 namespace aura { |
| 24 class Window; | 24 class Window; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace ui { | 27 namespace ui { |
| 28 class MouseEvent; | 28 class MouseEvent; |
| 29 class ScopedEventDispatcher; | 29 class ScopedEventDispatcher; |
| 30 class XScopedEventSelector; |
| 30 } | 31 } |
| 31 | 32 |
| 32 namespace views { | 33 namespace views { |
| 33 | 34 |
| 34 class Widget; | 35 class Widget; |
| 35 | 36 |
| 36 // Runs a nested message loop and grabs the mouse. This is used to implement | 37 // Runs a nested message loop and grabs the mouse. This is used to implement |
| 37 // dragging. | 38 // dragging. |
| 38 class X11WholeScreenMoveLoop : public X11MoveLoop, | 39 class X11WholeScreenMoveLoop : public X11MoveLoop, |
| 39 public ui::PlatformEventDispatcher { | 40 public ui::PlatformEventDispatcher { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 51 void EndMoveLoop() override; | 52 void EndMoveLoop() override; |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 // Grabs the pointer, setting the mouse cursor to |cursor|. Returns true if | 55 // Grabs the pointer, setting the mouse cursor to |cursor|. Returns true if |
| 55 // successful. | 56 // successful. |
| 56 bool GrabPointer(gfx::NativeCursor cursor); | 57 bool GrabPointer(gfx::NativeCursor cursor); |
| 57 | 58 |
| 58 void GrabEscKey(); | 59 void GrabEscKey(); |
| 59 | 60 |
| 60 // Creates an input-only window to be used during the drag. | 61 // Creates an input-only window to be used during the drag. |
| 61 XID CreateDragInputWindow(XDisplay* display); | 62 void CreateDragInputWindow(XDisplay* display); |
| 62 | 63 |
| 63 // Dispatch mouse movement event to |delegate_| in a posted task. | 64 // Dispatch mouse movement event to |delegate_| in a posted task. |
| 64 void DispatchMouseMovement(); | 65 void DispatchMouseMovement(); |
| 65 | 66 |
| 66 X11MoveLoopDelegate* delegate_; | 67 X11MoveLoopDelegate* delegate_; |
| 67 | 68 |
| 68 // Are we running a nested message loop from RunMoveLoop()? | 69 // Are we running a nested message loop from RunMoveLoop()? |
| 69 bool in_move_loop_; | 70 bool in_move_loop_; |
| 70 std::unique_ptr<ui::ScopedEventDispatcher> nested_dispatcher_; | 71 std::unique_ptr<ui::ScopedEventDispatcher> nested_dispatcher_; |
| 71 | 72 |
| 72 // Cursor in use prior to the move loop starting. Restored when the move loop | 73 // Cursor in use prior to the move loop starting. Restored when the move loop |
| 73 // quits. | 74 // quits. |
| 74 gfx::NativeCursor initial_cursor_; | 75 gfx::NativeCursor initial_cursor_; |
| 75 | 76 |
| 76 bool should_reset_mouse_flags_; | 77 bool should_reset_mouse_flags_; |
| 77 | 78 |
| 78 // An invisible InputOnly window. Keyboard grab and sometimes mouse grab | 79 // An invisible InputOnly window. Keyboard grab and sometimes mouse grab |
| 79 // are set on this window. | 80 // are set on this window. |
| 80 XID grab_input_window_; | 81 XID grab_input_window_; |
| 81 | 82 |
| 83 // Events selected on |grab_input_window_|. |
| 84 std::unique_ptr<ui::XScopedEventSelector> grab_input_window_events_; |
| 85 |
| 82 // Whether the pointer was grabbed on |grab_input_window_|. | 86 // Whether the pointer was grabbed on |grab_input_window_|. |
| 83 bool grabbed_pointer_; | 87 bool grabbed_pointer_; |
| 84 | 88 |
| 85 base::Closure quit_closure_; | 89 base::Closure quit_closure_; |
| 86 | 90 |
| 87 // Keeps track of whether the move-loop is cancled by the user (e.g. by | 91 // Keeps track of whether the move-loop is cancled by the user (e.g. by |
| 88 // pressing escape). | 92 // pressing escape). |
| 89 bool canceled_; | 93 bool canceled_; |
| 90 | 94 |
| 91 std::unique_ptr<ui::MouseEvent> last_motion_in_screen_; | 95 std::unique_ptr<ui::MouseEvent> last_motion_in_screen_; |
| 92 base::WeakPtrFactory<X11WholeScreenMoveLoop> weak_factory_; | 96 base::WeakPtrFactory<X11WholeScreenMoveLoop> weak_factory_; |
| 93 | 97 |
| 94 DISALLOW_COPY_AND_ASSIGN(X11WholeScreenMoveLoop); | 98 DISALLOW_COPY_AND_ASSIGN(X11WholeScreenMoveLoop); |
| 95 }; | 99 }; |
| 96 | 100 |
| 97 } // namespace views | 101 } // namespace views |
| 98 | 102 |
| 99 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_ | 103 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_ |
| OLD | NEW |