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

Side by Side Diff: ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h

Issue 262893002: Removes grab input window and extra grab and ungrab in X11WholeScreenMoveLoop Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removes grab input window and extra grab and ungrab in X11WholeScreenMoveLoop (null image case) Created 6 years, 7 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
OLDNEW
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/events/platform/platform_event_dispatcher.h" 11 #include "ui/events/platform/platform_event_dispatcher.h"
12 #include "ui/gfx/image/image_skia.h" 12 #include "ui/gfx/image/image_skia.h"
13 #include "ui/gfx/native_widget_types.h" 13 #include "ui/gfx/native_widget_types.h"
14 #include "ui/gfx/vector2d_f.h" 14 #include "ui/gfx/vector2d_f.h"
pkotwicz 2014/05/12 16:04:29 Nit: The include for native_widget_types.h and vec
varkha 2014/05/20 17:13:35 Done.
15 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop_delegate.h" 15 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop_delegate.h"
16 16
17 typedef struct _XDisplay XDisplay; 17 typedef struct _XDisplay XDisplay;
pkotwicz 2014/05/12 16:04:29 The typedef is unnecessary?
varkha 2014/05/20 17:13:35 Done.
18 18
19 namespace aura { 19 namespace aura {
20 class Window; 20 class Window;
21 } 21 }
22 22
23 namespace ui { 23 namespace ui {
24 class ScopedEventDispatcher; 24 class ScopedEventDispatcher;
25 } 25 }
26 26
27 namespace views { 27 namespace views {
28 28
29 class Widget; 29 class Widget;
pkotwicz 2014/05/12 16:04:29 The Window and Widget forward declarations are unn
varkha 2014/05/20 17:13:35 Done.
30 30
31 // Runs a nested message loop and grabs the mouse. This is used to implement 31 // Runs a nested message loop and grabs the mouse. This is used to implement
32 // dragging. 32 // dragging.
pkotwicz 2014/05/12 16:04:29 Nit: Update this comment
varkha 2014/05/20 17:13:35 Done.
33 class X11WholeScreenMoveLoop : public ui::PlatformEventDispatcher { 33 class X11WholeScreenMoveLoop : public ui::PlatformEventDispatcher {
34 public: 34 public:
35 explicit X11WholeScreenMoveLoop(X11WholeScreenMoveLoopDelegate* delegate); 35 explicit X11WholeScreenMoveLoop(X11WholeScreenMoveLoopDelegate* delegate);
36 virtual ~X11WholeScreenMoveLoop(); 36 virtual ~X11WholeScreenMoveLoop();
37 37
38 // ui:::PlatformEventDispatcher: 38 // ui:::PlatformEventDispatcher:
39 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE; 39 virtual bool CanDispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
40 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE; 40 virtual uint32_t DispatchEvent(const ui::PlatformEvent& event) OVERRIDE;
41 41
42 // Runs the nested message loop. While the mouse is grabbed, use |cursor| as 42 // Runs a nested message loop. Returns true if the move-loop is completed
43 // the mouse cursor. Returns true if the move-loop is completed successfully. 43 // successfully. Returns false if the pointer-grab fails or the move-loop is
pkotwicz 2014/05/12 16:04:29 Nit: Remove the portion about the pointer-grab fai
varkha 2014/05/20 17:13:35 Done.
44 // If the pointer-grab fails, or the move-loop is canceled by the user (e.g. 44 // canceled by the user (e.g. by pressing Esc).
45 // by pressing escape), then returns false. 45 bool RunMoveLoop();
46 bool RunMoveLoop(aura::Window* window, gfx::NativeCursor cursor);
47
48 // Updates the cursor while the move loop is running.
49 void UpdateCursor(gfx::NativeCursor cursor);
50 46
51 // Ends the RunMoveLoop() that's currently in progress. 47 // Ends the RunMoveLoop() that's currently in progress.
52 void EndMoveLoop(); 48 void EndMoveLoop();
53 49
54 // Sets an image to be used during the drag.
55 void SetDragImage(const gfx::ImageSkia& image, gfx::Vector2dF offset);
56
57 private: 50 private:
58 // Grabs the pointer and keyboard, setting the mouse cursor to |cursor|.
59 // Returns true if the grab was successful.
60 bool GrabPointerAndKeyboard(gfx::NativeCursor cursor);
61
62 // Creates an input-only window to be used during the drag.
63 Window CreateDragInputWindow(XDisplay* display);
64
65 // Creates a window to show the drag image during the drag.
66 void CreateDragImageWindow();
67
68 // Checks to see if |in_image| is an image that has any visible regions
69 // (defined as having a pixel with alpha > 32). If so, return true.
70 bool CheckIfIconValid();
71
72 // Dispatch mouse movement event to |delegate_| in a posted task. 51 // Dispatch mouse movement event to |delegate_| in a posted task.
73 void DispatchMouseMovement(); 52 void DispatchMouseMovement();
74 53
75 X11WholeScreenMoveLoopDelegate* delegate_; 54 X11WholeScreenMoveLoopDelegate* delegate_;
76 55
77 // Are we running a nested message loop from RunMoveLoop()? 56 // Are we running a nested message loop from RunMoveLoop()?
78 bool in_move_loop_; 57 bool in_move_loop_;
79 scoped_ptr<ui::ScopedEventDispatcher> nested_dispatcher_; 58 scoped_ptr<ui::ScopedEventDispatcher> nested_dispatcher_;
80 59
81 bool should_reset_mouse_flags_; 60 bool should_reset_mouse_flags_;
82 61
83 // An invisible InputOnly window . We create this window so we can track the
84 // cursor wherever it goes on screen during a drag, since normal windows
85 // don't receive pointer motion events outside of their bounds.
86 ::Window grab_input_window_;
87
88 base::Closure quit_closure_; 62 base::Closure quit_closure_;
89 63
90 // Keeps track of whether the move-loop is cancled by the user (e.g. by 64 // Keeps track of whether the move-loop is canceled by the user (e.g. by
91 // pressing escape). 65 // pressing escape).
92 bool canceled_; 66 bool canceled_;
93 67
94 // A Widget is created during the drag if there is an image available to be
95 // used during the drag.
96 scoped_ptr<Widget> drag_widget_;
97 gfx::ImageSkia drag_image_;
98 gfx::Vector2dF drag_offset_;
99 XMotionEvent last_xmotion_; 68 XMotionEvent last_xmotion_;
100 base::WeakPtrFactory<X11WholeScreenMoveLoop> weak_factory_; 69 base::WeakPtrFactory<X11WholeScreenMoveLoop> weak_factory_;
101 70
102 DISALLOW_COPY_AND_ASSIGN(X11WholeScreenMoveLoop); 71 DISALLOW_COPY_AND_ASSIGN(X11WholeScreenMoveLoop);
103 }; 72 };
104 73
105 } // namespace views 74 } // namespace views
106 75
107 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_ 76 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698