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