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_DESKTOP_ROOT_WINDOW_HOST_X11_H_ | 5 #ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_ROOT_WINDOW_HOST_WAYLAND_H_ |
6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_ROOT_WINDOW_HOST_X11_H_ | 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_ROOT_WINDOW_HOST_WAYLAND_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 | 7 |
13 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
14 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
15 #include "ui/aura/client/cursor_client.h" | 10 #include "ui/aura/client/cursor_client.h" |
16 #include "ui/aura/root_window_host.h" | 11 #include "ui/aura/root_window_host.h" |
17 #include "ui/base/cursor/cursor_loader_x11.h" | |
18 #include "ui/base/dragdrop/desktop_selection_provider_aurax11.h" | |
19 #include "ui/base/x/x11_atom_cache.h" | |
20 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
21 #include "ui/views/views_export.h" | 13 #include "ui/views/views_export.h" |
22 #include "ui/views/widget/desktop_aura/desktop_root_window_host.h" | 14 #include "ui/views/widget/desktop_aura/desktop_root_window_host.h" |
23 | 15 |
24 namespace aura { | 16 namespace aura { |
25 namespace client { | 17 namespace client { |
26 class FocusClient; | 18 class FocusClient; |
27 class ScreenPositionClient; | 19 class ScreenPositionClient; |
28 } | 20 } |
29 } | 21 } |
30 | 22 |
31 namespace views { | 23 namespace views { |
32 class DesktopActivationClient; | 24 class DesktopActivationClient; |
33 class DesktopCaptureClient; | 25 class DesktopCaptureClient; |
34 class DesktopDragDropClientAuraX11; | 26 class DesktopDragDropClientAuraWayland; |
35 class DesktopDispatcherClient; | 27 class DesktopDispatcherClient; |
36 class X11DesktopWindowMoveClient; | 28 class WaylandDesktopWindowMoveClient; |
37 class X11WindowEventFilter; | 29 class WaylandWindowEventFilter; |
38 | 30 |
39 namespace corewm { | 31 namespace corewm { |
40 class CursorManager; | 32 class CursorManager; |
41 } | 33 } |
42 | 34 |
43 class VIEWS_EXPORT DesktopRootWindowHostX11 : | 35 class VIEWS_EXPORT DesktopRootWindowHostWayland : |
44 public DesktopRootWindowHost, | 36 public DesktopRootWindowHost, |
45 public aura::RootWindowHost, | 37 public aura::RootWindowHost, |
46 public ui::DesktopSelectionProviderAuraX11, | |
47 public base::MessageLoop::Dispatcher { | 38 public base::MessageLoop::Dispatcher { |
48 public: | 39 public: |
49 DesktopRootWindowHostX11( | 40 DesktopRootWindowHostWayland( |
50 internal::NativeWidgetDelegate* native_widget_delegate, | 41 internal::NativeWidgetDelegate* native_widget_delegate, |
51 DesktopNativeWidgetAura* desktop_native_widget_aura, | 42 DesktopNativeWidgetAura* desktop_native_widget_aura, |
52 const gfx::Rect& initial_bounds); | 43 const gfx::Rect& bounds); |
53 virtual ~DesktopRootWindowHostX11(); | 44 virtual ~DesktopRootWindowHostWayland(); |
54 | 45 |
55 // A way of converting an X11 |xid| host window into a |content_window_|. | 46 // Called by WaylandDesktopHandler to notify us that the native windowing syst
em |
56 static aura::Window* GetContentWindowForXID(XID xid); | |
57 | |
58 // A way of converting an X11 |xid| host window into this object. | |
59 static DesktopRootWindowHostX11* GetHostForXID(XID xid); | |
60 | |
61 // Called by X11DesktopHandler to notify us that the native windowing system | |
62 // has changed our activation. | 47 // has changed our activation. |
63 void HandleNativeWidgetActivationChanged(bool active); | 48 void HandleNativeWidgetActivationChanged(bool active); |
64 | 49 |
65 private: | 50 private: |
66 // Initializes our X11 surface to draw on. This method performs all | 51 // Initializes our Wayland surface to draw on. This method performs all |
67 // initialization related to talking to the X11 server. | 52 // initialization related to talking to the Wayland server. |
68 void InitX11Window(const Widget::InitParams& params); | 53 void InitWaylandWindow(const Widget::InitParams& params); |
69 | 54 |
70 // Creates an aura::RootWindow to contain the |content_window|, along with | 55 // Creates an aura::RootWindow to contain the |content_window|, along with |
71 // all aura client objects that direct behavior. | 56 // all aura client objects that direct behavior. |
72 aura::RootWindow* InitRootWindow(const Widget::InitParams& params); | 57 aura::RootWindow* InitRootWindow(const Widget::InitParams& params); |
73 | 58 |
74 // Returns true if there's an X window manager present... in most cases. Some | 59 // Returns true if there's an X window manager present... in most cases. Some |
75 // window managers (notably, ion3) don't implement enough of ICCCM for us to | 60 // window managers (notably, ion3) don't implement enough of ICCCM for us to |
76 // detect that they're there. | 61 // detect that they're there. |
77 bool IsWindowManagerPresent(); | 62 bool IsWindowManagerPresent(); |
78 | 63 |
79 // Sends a message to the x11 window manager, enabling or disabling the | |
80 // states |state1| and |state2|. | |
81 void SetWMSpecState(bool enabled, ::Atom state1, ::Atom state2); | |
82 | |
83 // Checks if the window manager has set a specific state. | |
84 bool HasWMSpecProperty(const char* property) const; | |
85 | |
86 // Called when another DRWHL takes capture, or when capture is released | 64 // Called when another DRWHL takes capture, or when capture is released |
87 // entirely. | 65 // entirely. |
88 void OnCaptureReleased(); | 66 void OnCaptureReleased(); |
89 | 67 |
90 // Dispatches a mouse event, taking mouse capture into account. If a | 68 // Dispatches a mouse event, taking mouse capture into account. If a |
91 // different host has capture, we translate the event to its coordinate space | 69 // different host has capture, we translate the event to its coordinate space |
92 // and dispatch it to that host instead. | 70 // and dispatch it to that host instead. |
93 void DispatchMouseEvent(ui::MouseEvent* event); | 71 void DispatchMouseEvent(ui::MouseEvent* event); |
94 | 72 |
95 // Overridden from DesktopRootWindowHost: | 73 // Overridden from DesktopRootWindowHost: |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; | 139 virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; |
162 virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE; | 140 virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE; |
163 virtual bool ConfineCursorToRootWindow() OVERRIDE; | 141 virtual bool ConfineCursorToRootWindow() OVERRIDE; |
164 virtual void UnConfineCursor() OVERRIDE; | 142 virtual void UnConfineCursor() OVERRIDE; |
165 virtual void OnCursorVisibilityChanged(bool show) OVERRIDE; | 143 virtual void OnCursorVisibilityChanged(bool show) OVERRIDE; |
166 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; | 144 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; |
167 virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; | 145 virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; |
168 virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, | 146 virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, |
169 const gfx::Point& dest_offset, | 147 const gfx::Point& dest_offset, |
170 SkCanvas* canvas) OVERRIDE; | 148 SkCanvas* canvas) OVERRIDE; |
| 149 virtual bool GrabSnapshot( |
| 150 const gfx::Rect& snapshot_bounds, |
| 151 std::vector<unsigned char>* png_representation) OVERRIDE; |
171 virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; | 152 virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; |
172 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; | 153 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; |
173 virtual void PrepareForShutdown() OVERRIDE; | 154 virtual void PrepareForShutdown() OVERRIDE; |
174 | 155 |
175 // Overridden from DesktopSelectionProviderAuraX11: | 156 // Overridden from DesktopSelectionProviderAuraWayland: |
176 virtual void SetDropHandler( | 157 //virtual void SetDropHandler( |
177 ui::OSExchangeDataProviderAuraX11* handler) OVERRIDE; | 158 // ui::OSExchangeDataProviderAuraWayland* handler) OVERRIDE; |
178 | 159 |
179 // Overridden from Dispatcher: | 160 // Overridden from Dispatcher: |
180 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; | 161 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; |
181 | 162 |
182 base::WeakPtrFactory<DesktopRootWindowHostX11> close_widget_factory_; | 163 base::WeakPtrFactory<DesktopRootWindowHostWayland> close_widget_factory_; |
183 | |
184 // X11 things | |
185 // The display and the native X window hosting the root window. | |
186 Display* xdisplay_; | |
187 ::Window xwindow_; | |
188 | |
189 // The native root window. | |
190 ::Window x_root_window_; | |
191 | |
192 ui::X11AtomCache atom_cache_; | |
193 | |
194 // Is the window mapped to the screen? | |
195 bool window_mapped_; | |
196 | |
197 // The bounds of |xwindow_|. | |
198 gfx::Rect bounds_; | |
199 | |
200 // True if the window should be focused when the window is shown. | |
201 bool focus_when_shown_; | |
202 | |
203 // The window manager state bits. | |
204 std::set< ::Atom> window_properties_; | |
205 | 164 |
206 // We are owned by the RootWindow, but we have to have a back pointer to it. | 165 // We are owned by the RootWindow, but we have to have a back pointer to it. |
207 aura::RootWindow* root_window_; | 166 aura::RootWindow* root_window_; |
208 | 167 |
209 // aura:: objects that we own. | 168 // aura:: objects that we own. |
210 scoped_ptr<DesktopCaptureClient> capture_client_; | 169 scoped_ptr<DesktopCaptureClient> capture_client_; |
211 scoped_ptr<aura::client::FocusClient> focus_client_; | 170 scoped_ptr<aura::client::FocusClient> focus_client_; |
212 scoped_ptr<DesktopActivationClient> activation_client_; | 171 scoped_ptr<DesktopActivationClient> activation_client_; |
213 scoped_ptr<views::corewm::CursorManager> cursor_client_; | 172 scoped_ptr<views::corewm::CursorManager> cursor_client_; |
214 scoped_ptr<DesktopDispatcherClient> dispatcher_client_; | 173 scoped_ptr<DesktopDispatcherClient> dispatcher_client_; |
215 scoped_ptr<aura::client::ScreenPositionClient> position_client_; | |
216 scoped_ptr<DesktopDragDropClientAuraX11> drag_drop_client_; | |
217 | 174 |
218 // Current Aura cursor. | |
219 gfx::NativeCursor current_cursor_; | |
220 | |
221 scoped_ptr<X11WindowEventFilter> x11_window_event_filter_; | |
222 scoped_ptr<X11DesktopWindowMoveClient> x11_window_move_client_; | |
223 | |
224 // TODO(beng): Consider providing an interface to DesktopNativeWidgetAura | |
225 // instead of providing this route back to Widget. | |
226 internal::NativeWidgetDelegate* native_widget_delegate_; | 175 internal::NativeWidgetDelegate* native_widget_delegate_; |
227 | 176 |
228 DesktopNativeWidgetAura* desktop_native_widget_aura_; | 177 // The display and the native window hosting the root window. |
| 178 ui::WaylandDisplay* display_; |
| 179 ui::WaylandWindow* window_; |
| 180 |
| 181 // Is the window mapped to the screen? |
| 182 bool window_mapped_; |
| 183 |
| 184 gfx::Rect bounds_; |
229 | 185 |
230 aura::RootWindowHostDelegate* root_window_host_delegate_; | 186 aura::RootWindowHostDelegate* root_window_host_delegate_; |
231 aura::Window* content_window_; | 187 aura::Window* content_window_; |
232 | 188 |
233 // We forward drop related messages to this object. | 189 DesktopNativeWidgetAura* desktop_native_widget_aura_; |
234 ui::OSExchangeDataProviderAuraX11* drop_handler_; | |
235 | 190 |
236 // The current root window host that has capture. While X11 has something | 191 // The current root window host that has capture. While X11 has something |
237 // like Windows SetCapture()/ReleaseCapture(), it is entirely implicit and | 192 // like Windows SetCapture()/ReleaseCapture(), it is entirely implicit and |
238 // there are no notifications when this changes. We need to track this so we | 193 // there are no notifications when this changes. We need to track this so we |
239 // can notify widgets when they have lost capture, which controls a bunch of | 194 // can notify widgets when they have lost capture, which controls a bunch of |
240 // things in views like hiding menus. | 195 // things in views like hiding menus. |
241 static DesktopRootWindowHostX11* g_current_capture; | 196 static DesktopRootWindowHostWayland* g_current_capture; |
242 | 197 |
243 DISALLOW_COPY_AND_ASSIGN(DesktopRootWindowHostX11); | 198 DISALLOW_COPY_AND_ASSIGN(DesktopRootWindowHostWayland); |
244 }; | 199 }; |
245 | 200 |
246 } // namespace views | 201 } // namespace views |
247 | 202 |
248 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_ROOT_WINDOW_HOST_X11_H_ | 203 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_ROOT_WINDOW_HOST_WAYLAND_H_ |
OLD | NEW |