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 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_ | 5 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_ |
6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_ | 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_ |
7 | 7 |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 | 9 |
10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. |
11 #undef RootWindow | 11 #undef RootWindow |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/timer/timer.h" |
16 #include "ui/aura/client/window_move_client.h" | 17 #include "ui/aura/client/window_move_client.h" |
17 #include "ui/gfx/point.h" | 18 #include "ui/gfx/point.h" |
18 #include "ui/views/views_export.h" | 19 #include "ui/views/views_export.h" |
19 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h" | 20 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h" |
20 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop_delegate.h" | 21 #include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop_delegate.h" |
21 | 22 |
22 namespace aura { | 23 namespace aura { |
23 class RootWindow; | 24 class RootWindow; |
24 } | 25 } |
25 | 26 |
| 27 namespace gfx { |
| 28 class Rect; |
| 29 } |
| 30 |
26 namespace views { | 31 namespace views { |
27 | 32 |
28 // When we're dragging tabs, we need to manually position our window. | 33 // When we're dragging tabs, we need to manually position our window. |
29 class VIEWS_EXPORT X11DesktopWindowMoveClient : | 34 class VIEWS_EXPORT X11DesktopWindowMoveClient : |
30 public views::X11WholeScreenMoveLoopDelegate, | 35 public views::X11WholeScreenMoveLoopDelegate, |
31 public aura::client::WindowMoveClient { | 36 public aura::client::WindowMoveClient { |
32 public: | 37 public: |
33 X11DesktopWindowMoveClient(); | 38 X11DesktopWindowMoveClient(); |
34 virtual ~X11DesktopWindowMoveClient(); | 39 virtual ~X11DesktopWindowMoveClient(); |
35 | 40 |
36 // Overridden from X11WholeScreenMoveLoopDelegate: | 41 // Overridden from X11WholeScreenMoveLoopDelegate: |
37 virtual void OnMouseMovement(XMotionEvent* event) OVERRIDE; | 42 virtual void OnMouseMovement(XMotionEvent* event) OVERRIDE; |
38 virtual void OnMouseReleased() OVERRIDE; | 43 virtual void OnMouseReleased() OVERRIDE; |
39 virtual void OnMoveLoopEnded() OVERRIDE; | 44 virtual void OnMoveLoopEnded() OVERRIDE; |
40 | 45 |
41 // Overridden from aura::client::WindowMoveClient: | 46 // Overridden from aura::client::WindowMoveClient: |
42 virtual aura::client::WindowMoveResult RunMoveLoop( | 47 virtual aura::client::WindowMoveResult RunMoveLoop( |
43 aura::Window* window, | 48 aura::Window* window, |
44 const gfx::Vector2d& drag_offset, | 49 const gfx::Vector2d& drag_offset, |
45 aura::client::WindowMoveSource move_source) OVERRIDE; | 50 aura::client::WindowMoveSource move_source) OVERRIDE; |
46 virtual void EndMoveLoop() OVERRIDE; | 51 virtual void EndMoveLoop() OVERRIDE; |
47 | 52 |
48 private: | 53 private: |
| 54 // Callback from |window_move_timer_|. |
| 55 void SetHostBounds(const gfx::Rect& rect); |
| 56 |
49 X11WholeScreenMoveLoop move_loop_; | 57 X11WholeScreenMoveLoop move_loop_; |
50 | 58 |
51 // We need to keep track of this so we can actually move it when reacting to | 59 // We need to keep track of this so we can actually move it when reacting to |
52 // mouse events. | 60 // mouse events. |
53 aura::RootWindow* root_window_; | 61 aura::RootWindow* root_window_; |
54 | 62 |
55 // Our cursor offset from the top left window origin when the drag | 63 // Our cursor offset from the top left window origin when the drag |
56 // started. Used to calculate the window's new bounds relative to the current | 64 // started. Used to calculate the window's new bounds relative to the current |
57 // location of the cursor. | 65 // location of the cursor. |
58 gfx::Vector2d window_offset_; | 66 gfx::Vector2d window_offset_; |
| 67 |
| 68 base::OneShotTimer<X11DesktopWindowMoveClient> window_move_timer_; |
59 }; | 69 }; |
60 | 70 |
61 } // namespace views | 71 } // namespace views |
62 | 72 |
63 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_ | 73 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_ |
OLD | NEW |