- add sources.
[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 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class.
11 #undef RootWindow
12
13 #include "base/callback.h"
14 #include "base/compiler_specific.h"
15 #include "base/message_loop/message_loop.h"
16 #include "ui/aura/client/window_move_client.h"
17 #include "ui/gfx/point.h"
18 #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_delegate.h"
21
22 namespace aura {
23 class RootWindow;
24 }
25
26 namespace views {
27
28 // When we're dragging tabs, we need to manually position our window.
29 class VIEWS_EXPORT X11DesktopWindowMoveClient :
30       public views::X11WholeScreenMoveLoopDelegate,
31       public aura::client::WindowMoveClient {
32  public:
33   X11DesktopWindowMoveClient();
34   virtual ~X11DesktopWindowMoveClient();
35
36   // Overridden from X11WholeScreenMoveLoopDelegate:
37   virtual void OnMouseMovement(XMotionEvent* event) OVERRIDE;
38   virtual void OnMouseReleased() OVERRIDE;
39   virtual void OnMoveLoopEnded() OVERRIDE;
40
41   // Overridden from aura::client::WindowMoveClient:
42   virtual aura::client::WindowMoveResult RunMoveLoop(
43       aura::Window* window,
44       const gfx::Vector2d& drag_offset,
45       aura::client::WindowMoveSource move_source) OVERRIDE;
46   virtual void EndMoveLoop() OVERRIDE;
47
48  private:
49   X11WholeScreenMoveLoop move_loop_;
50
51   // We need to keep track of this so we can actually move it when reacting to
52   // mouse events.
53   aura::RootWindow* root_window_;
54
55   // 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
57   // location of the cursor.
58   gfx::Vector2d window_offset_;
59 };
60
61 }  // namespace views
62
63 #endif  // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_