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 3 // found in the LICENSE file. 4 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_ 7 8 #include "base/compiler_specific.h" 9 #include "base/message_loop/message_loop.h" 10 #include "ui/gfx/native_widget_types.h" 11 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop_delegate.h" 12 13 namespace aura { 14 class Window; 15 } 16 17 namespace views { 18 19 // Runs a nested message loop and grabs the mouse. This is used to implement 20 // dragging. 21 class X11WholeScreenMoveLoop : public base::MessageLoop::Dispatcher { 22 public: 23 explicit X11WholeScreenMoveLoop(X11WholeScreenMoveLoopDelegate* delegate); 24 virtual ~X11WholeScreenMoveLoop(); 25 26 // Overridden from base::MessageLoop::Dispatcher: 27 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; 28 29 // Runs the nested message loop. While the mouse is grabbed, use |cursor| as 30 // the mouse cursor. Returns true if there we were able to grab the pointer 31 // and run the move loop. 32 bool RunMoveLoop(aura::Window* window, gfx::NativeCursor cursor); 33 34 // Updates the cursor while the move loop is running. 35 void UpdateCursor(gfx::NativeCursor cursor); 36 37 // Ends the RunMoveLoop() that's currently in progress. 38 void EndMoveLoop(); 39 40 private: 41 // Grabs the pointer, setting the mouse cursor to |cursor|. Returns true if 42 // the grab was successful. 43 bool GrabPointerWithCursor(gfx::NativeCursor cursor); 44 45 X11WholeScreenMoveLoopDelegate* delegate_; 46 47 // Are we running a nested message loop from RunMoveLoop()? 48 bool in_move_loop_; 49 50 // An invisible InputOnly window . We create this window so we can track the 51 // cursor wherever it goes on screen during a drag, since normal windows 52 // don't receive pointer motion events outside of their bounds. 53 ::Window grab_input_window_; 54 55 base::Closure quit_closure_; 56 57 DISALLOW_COPY_AND_ASSIGN(X11WholeScreenMoveLoop); 58 }; 59 60 } // namespace views 61 62 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_ 63