Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ozone / ui / desktop_aura / desktop_window_tree_host_wayland.h
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Copyright 2013 Intel Corporation. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5
6 #ifndef OZONE_IMPL_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_WAYLAND_H_
7 #define OZONE_IMPL_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_WAYLAND_H_
8
9 #include <set>
10 #include <vector>
11
12 #include "base/basictypes.h"
13 #include "ui/aura/window_tree_host.h"
14 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h"
15
16 namespace views {
17
18 namespace corewm {
19 class Tooltip;
20 }
21
22 class DesktopDragDropClientWayland;
23 class WindowTreeHostDelegateWayland;
24
25 class VIEWS_EXPORT DesktopWindowTreeHostWayland
26     : public DesktopWindowTreeHost,
27       public aura::WindowTreeHost {
28  public:
29   DesktopWindowTreeHostWayland(
30       internal::NativeWidgetDelegate* native_widget_delegate,
31       DesktopNativeWidgetAura* desktop_native_widget_aura);
32   virtual ~DesktopWindowTreeHostWayland();
33
34   // Accepts a opaque handle widget and returns associated
35   // DesktopWindowTreeHostWayland.
36   static DesktopWindowTreeHostWayland* GetHostForAcceleratedWidget(
37       gfx::AcceleratedWidget widget);
38
39   // Get all open top-level windows. This includes windows that may not be
40   // visible. This list is sorted in their stacking order, i.e. the first window
41   // is the topmost window.
42   static const std::vector<aura::Window*>& GetAllOpenWindows();
43
44   // Accepts a opaque handle widget and returns associated aura::Window.
45   static aura::Window* GetContentWindowForAcceleratedWidget(
46       gfx::AcceleratedWidget widget);
47
48   // Returns window bounds. This is used by Screen to determine if a point
49   // belongs to a particular window.
50   gfx::Rect GetBoundsInScreen() const;
51
52  private:
53   enum {
54     Uninitialized = 0x00,
55     Visible = 0x01,  // Window is Visible.
56     FullScreen = 0x02,  // Window is in fullscreen mode.
57     Maximized = 0x04,  // Window is maximized,
58     Minimized = 0x08,  // Window is minimized.
59     Normal = 0x10,  // Window is in Normal Mode.
60     Active = 0x20  // Window is Active.
61   };
62
63   typedef unsigned RootWindowState;
64
65   // Initializes our Ozone surface to draw on. This method performs all
66   // initialization related to talking to the Ozone server.
67   void InitWaylandWindow(const views::Widget::InitParams& params);
68
69   // Called when another DRWHL takes capture, or when capture is released
70   // entirely.
71   void OnCaptureReleased();
72
73   // Overridden from DesktopWindowTreeHost:
74   virtual void Init(
75       aura::Window* content_window,
76       const views::Widget::InitParams& params) OVERRIDE;
77   virtual void OnNativeWidgetCreated(
78       const views::Widget::InitParams& params) OVERRIDE;
79   virtual scoped_ptr<views::corewm::Tooltip> CreateTooltip() OVERRIDE;
80   virtual scoped_ptr<aura::client::DragDropClient> CreateDragDropClient(
81       views::DesktopNativeCursorManager* cursor_manager) OVERRIDE;
82   virtual void Close() OVERRIDE;
83   virtual void CloseNow() OVERRIDE;
84   virtual aura::WindowTreeHost* AsWindowTreeHost() OVERRIDE;
85   virtual void ShowWindowWithState(ui::WindowShowState show_state) OVERRIDE;
86   virtual void ShowMaximizedWithBounds(
87       const gfx::Rect& restored_bounds) OVERRIDE;
88   virtual bool IsVisible() const OVERRIDE;
89   virtual void SetSize(const gfx::Size& size) OVERRIDE;
90   virtual void StackAtTop() OVERRIDE;
91   virtual void CenterWindow(const gfx::Size& size) OVERRIDE;
92   virtual void GetWindowPlacement(
93       gfx::Rect* bounds,
94       ui::WindowShowState* show_state) const OVERRIDE;
95   virtual gfx::Rect GetWindowBoundsInScreen() const OVERRIDE;
96   virtual gfx::Rect GetClientAreaBoundsInScreen() const OVERRIDE;
97   virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
98   virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE;
99   virtual void SetShape(gfx::NativeRegion native_region) OVERRIDE;
100   virtual void Activate() OVERRIDE;
101   virtual void Deactivate() OVERRIDE;
102   virtual bool IsActive() const OVERRIDE;
103   virtual void Maximize() OVERRIDE;
104   virtual void Minimize() OVERRIDE;
105   virtual void Restore() OVERRIDE;
106   virtual bool IsMaximized() const OVERRIDE;
107   virtual bool IsMinimized() const OVERRIDE;
108   virtual bool HasCapture() const OVERRIDE;
109   virtual bool IsAlwaysOnTop() const OVERRIDE;
110   virtual void SetVisibleOnAllWorkspaces(bool always_visible) OVERRIDE;
111   virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
112   virtual bool SetWindowTitle(const base::string16& title) OVERRIDE;
113   virtual void ClearNativeFocus() OVERRIDE;
114   virtual views::Widget::MoveLoopResult RunMoveLoop(
115       const gfx::Vector2d& drag_offset,
116       views::Widget::MoveLoopSource source,
117       views::Widget::MoveLoopEscapeBehavior escape_behavior) OVERRIDE;
118   virtual void EndMoveLoop() OVERRIDE;
119   virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE;
120   virtual bool ShouldUseNativeFrame() const OVERRIDE;
121   virtual bool ShouldWindowContentsBeTransparent() const OVERRIDE;
122   virtual void FrameTypeChanged() OVERRIDE;
123   virtual views::NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
124   virtual void SetFullscreen(bool fullscreen) OVERRIDE;
125   virtual bool IsFullscreen() const OVERRIDE;
126   virtual void SetOpacity(unsigned char opacity) OVERRIDE;
127   virtual void SetWindowIcons(const gfx::ImageSkia& window_icon,
128                               const gfx::ImageSkia& app_icon) OVERRIDE;
129   virtual void InitModalType(ui::ModalType modal_type) OVERRIDE;
130   virtual void FlashFrame(bool flash_frame) OVERRIDE;
131   virtual void OnRootViewLayout() const OVERRIDE;
132   virtual void OnNativeWidgetFocus() OVERRIDE;
133   virtual void OnNativeWidgetBlur() OVERRIDE;
134   virtual bool IsAnimatingClosed() const OVERRIDE;
135
136   // Overridden from aura::WindowTreeHost:
137   virtual ui::EventSource* GetEventSource() OVERRIDE;
138   virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
139   virtual void Show() OVERRIDE;
140   virtual void Hide() OVERRIDE;
141   virtual gfx::Rect GetBounds() const OVERRIDE;
142   virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
143   virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
144   virtual void SetCapture() OVERRIDE;
145   virtual void ReleaseCapture() OVERRIDE;
146   virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE;
147   virtual void OnCursorVisibilityChangedNative(bool show) OVERRIDE;
148   virtual void MoveCursorToNative(const gfx::Point& location) OVERRIDE;
149   virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
150   virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
151
152   void HandleNativeWidgetActivationChanged(bool active);
153   void HandleWindowResize(unsigned width, unsigned height);
154
155   RootWindowState state_;
156
157   // Current bounds of DRWH.
158   gfx::Rect bounds_;
159   // Original bounds of DRWH.
160   gfx::Rect previous_bounds_;
161   gfx::Rect previous_maximize_bounds_;
162   gfx::AcceleratedWidget window_;
163   base::string16 title_;
164
165   base::WeakPtrFactory<DesktopWindowTreeHostWayland> close_widget_factory_;
166
167   // Owned by DesktopNativeWidgetAura.
168   DesktopDragDropClientWayland* drag_drop_client_;
169   views::internal::NativeWidgetDelegate* native_widget_delegate_;
170   aura::Window* content_window_;
171
172   views::DesktopNativeWidgetAura* desktop_native_widget_aura_;
173   // We can optionally have a parent which can order us to close, or own
174   // children who we're responsible for closing when we CloseNow().
175   DesktopWindowTreeHostWayland* window_parent_;
176   std::set<DesktopWindowTreeHostWayland*> window_children_;
177
178   static WindowTreeHostDelegateWayland* g_delegate_ozone_wayland_;
179   friend class WindowTreeHostDelegateWayland;
180   DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostWayland);
181 };
182
183 }  // namespace views
184
185 #endif  // OZONE_IMPL_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_WAYLAND_H_