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 "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "ui/base/cursor/cursor.h" |
11 #include "ui/events/platform/platform_event_dispatcher.h" | 12 #include "ui/events/platform/platform_event_dispatcher.h" |
12 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
13 #include "ui/gfx/native_widget_types.h" | 14 #include "ui/gfx/native_widget_types.h" |
14 #include "ui/gfx/vector2d_f.h" | 15 #include "ui/gfx/vector2d_f.h" |
15 #include "ui/views/widget/desktop_aura/x11_move_loop.h" | 16 #include "ui/views/widget/desktop_aura/x11_move_loop.h" |
16 #include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h" | 17 #include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h" |
17 | 18 |
18 typedef struct _XDisplay XDisplay; | 19 typedef struct _XDisplay XDisplay; |
19 | 20 |
20 namespace aura { | 21 namespace aura { |
(...skipping 20 matching lines...) Expand all Loading... |
41 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE; | 42 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE; |
42 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE; | 43 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE; |
43 | 44 |
44 // X11MoveLoop: | 45 // X11MoveLoop: |
45 virtual bool RunMoveLoop(aura::Window* window, | 46 virtual bool RunMoveLoop(aura::Window* window, |
46 gfx::NativeCursor cursor) OVERRIDE; | 47 gfx::NativeCursor cursor) OVERRIDE; |
47 virtual void UpdateCursor(gfx::NativeCursor cursor) OVERRIDE; | 48 virtual void UpdateCursor(gfx::NativeCursor cursor) OVERRIDE; |
48 virtual void EndMoveLoop() OVERRIDE; | 49 virtual void EndMoveLoop() OVERRIDE; |
49 | 50 |
50 private: | 51 private: |
51 // Grabs the pointer and keyboard, setting the mouse cursor to |cursor|. | 52 // Grabs the pointer, setting the mouse cursor to |cursor|. Returns true if |
52 // Returns true if the grab was successful. | 53 // successful. |
53 bool GrabPointerAndKeyboard(gfx::NativeCursor cursor); | 54 bool GrabPointer(gfx::NativeCursor cursor); |
| 55 |
| 56 // Grabs the keyboard. Returns true if successful. |
| 57 bool GrabKeyboard(); |
54 | 58 |
55 // Creates an input-only window to be used during the drag. | 59 // Creates an input-only window to be used during the drag. |
56 Window CreateDragInputWindow(XDisplay* display); | 60 Window CreateDragInputWindow(XDisplay* display); |
57 | 61 |
58 // Dispatch mouse movement event to |delegate_| in a posted task. | 62 // Dispatch mouse movement event to |delegate_| in a posted task. |
59 void DispatchMouseMovement(); | 63 void DispatchMouseMovement(); |
60 | 64 |
61 X11MoveLoopDelegate* delegate_; | 65 X11MoveLoopDelegate* delegate_; |
62 | 66 |
63 // Are we running a nested message loop from RunMoveLoop()? | 67 // Are we running a nested message loop from RunMoveLoop()? |
64 bool in_move_loop_; | 68 bool in_move_loop_; |
65 scoped_ptr<ui::ScopedEventDispatcher> nested_dispatcher_; | 69 scoped_ptr<ui::ScopedEventDispatcher> nested_dispatcher_; |
66 | 70 |
| 71 // Cursor in use prior to the move loop starting. Restored when the move loop |
| 72 // quits. |
| 73 gfx::NativeCursor initial_cursor_; |
| 74 |
67 bool should_reset_mouse_flags_; | 75 bool should_reset_mouse_flags_; |
68 | 76 |
69 // An invisible InputOnly window . We create this window so we can track the | 77 // An invisible InputOnly window. Keyboard grab and sometimes mouse grab |
70 // cursor wherever it goes on screen during a drag, since normal windows | 78 // are set on this window. |
71 // don't receive pointer motion events outside of their bounds. | |
72 ::Window grab_input_window_; | 79 ::Window grab_input_window_; |
73 | 80 |
| 81 // Whether the pointer was grabbed on |grab_input_window_|. |
| 82 bool grabbed_pointer_; |
| 83 |
74 base::Closure quit_closure_; | 84 base::Closure quit_closure_; |
75 | 85 |
76 // Keeps track of whether the move-loop is cancled by the user (e.g. by | 86 // Keeps track of whether the move-loop is cancled by the user (e.g. by |
77 // pressing escape). | 87 // pressing escape). |
78 bool canceled_; | 88 bool canceled_; |
79 | 89 |
80 // Keeps track of whether we still have a pointer grab at the end of the loop. | |
81 bool has_grab_; | |
82 | |
83 XMotionEvent last_xmotion_; | 90 XMotionEvent last_xmotion_; |
84 base::WeakPtrFactory<X11WholeScreenMoveLoop> weak_factory_; | 91 base::WeakPtrFactory<X11WholeScreenMoveLoop> weak_factory_; |
85 | 92 |
86 DISALLOW_COPY_AND_ASSIGN(X11WholeScreenMoveLoop); | 93 DISALLOW_COPY_AND_ASSIGN(X11WholeScreenMoveLoop); |
87 }; | 94 }; |
88 | 95 |
89 } // namespace views | 96 } // namespace views |
90 | 97 |
91 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_ | 98 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_ |
OLD | NEW |