Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: ui/aura/hostwm/host_window_manager_x11.h

Issue 10789018: aura: Add X11 host window management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Keep ash switches alphabetized. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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_AURA_HOSTWM_HOST_WINDOW_MANAGER_X11_H
6 #define UI_AURA_HOSTWM_HOST_WINDOW_MANAGER_X11_H
7
8 #include <X11/Xlib.h>
9
10 // Xlib.h defines RootWindow.
11 #undef RootWindow
12
13 #include "base/basictypes.h"
14 #include "base/message_loop.h"
15 #include "ui/aura/env_observer.h"
16 #include "ui/aura/focus_change_observer.h"
17 #include "ui/aura/hostwm/host_window_delegate.h"
18 #include "ui/aura/hostwm/host_window_manager_client.h"
19 #include "ui/aura/root_window_observer.h"
20 #include "ui/aura/x11_atom_cache.h"
21 #include "ui/aura/window_observer.h"
22
23 #include <map>
24
25 namespace aura {
26 class HostWindowManagerX11;
27 class RedirectedHostWindowX11;
28
29 void SetBaseX11ErrorHandler(XErrorHandler error_handler);
30 int CallBaseX11ErrorHandler(Display* d, XErrorEvent* e);
31
32 class HostWindowManagerX11WindowObserver : public EnvObserver,
33 public WindowObserver {
34 public:
35 HostWindowManagerX11WindowObserver(HostWindowManagerX11* manager);
36 virtual ~HostWindowManagerX11WindowObserver() {}
37
38 // Implements EnvObserver:
39 virtual void OnWindowInitialized(Window* window) OVERRIDE;
40
41 // Implements WindowObserver:
42 virtual void OnWillRemoveWindow(Window* window) OVERRIDE;
43 virtual void OnWindowDestroyed(Window* window) OVERRIDE;
44 virtual void OnWindowStackingChanged(Window* window) OVERRIDE;
45 virtual void OnWindowVisibilityChanged(Window* window, bool visible)
46 OVERRIDE;
47 virtual void OnWindowBoundsChanged(Window* window,
48 const gfx::Rect& old_bounds,
49 const gfx::Rect& new_bounds) OVERRIDE;
50
51 private:
52 HostWindowManagerX11* host_window_manager_;
53
54 DISALLOW_COPY_AND_ASSIGN(HostWindowManagerX11WindowObserver);
55 };
56
57 class HostWindowX11
58 : public base::RefCounted<HostWindowX11>,
59 public HostWindowDelegate {
60 public:
61 HostWindowX11(::XID xwindow, unsigned state);
62
63 // Implements HostWindowDelegate:
64 virtual void CloseWindow() OVERRIDE {}
65 virtual bool CanResize() OVERRIDE;
66
67 virtual bool CanConfigure();
68 virtual bool CanActivate();
69 virtual void OnMapNotify() {}
70 virtual void OnUnmapNotify() {}
71 virtual void OnConfigureNotify(gfx::Rect bounds, ::Window above) {}
72
73 ::XID xid() { return xwindow_; }
74
75 unsigned state() { return state_; }
76 // TODO(reveman): Update WM_STATE property.
77 void set_state(unsigned state) { state_ = state; }
78
79 protected:
80 virtual ~HostWindowX11();
81
82 Display* xdisplay_;
83 ::XID xwindow_;
84 unsigned state_;
85
86 private:
87 friend class base::RefCounted<HostWindowX11>;
88
89 DISALLOW_COPY_AND_ASSIGN(HostWindowX11);
90 };
91
92 class InputHostWindowX11 : public HostWindowX11 {
93 public:
94 InputHostWindowX11(::XID xwindow);
95
96 // Implements HostWindowDelegate:
97 virtual void CloseWindow() OVERRIDE;
98 virtual bool CanResize() OVERRIDE;
99
100 // Overridden from HostWindowX11:
101 virtual bool CanConfigure() OVERRIDE;
102 virtual bool CanActivate() OVERRIDE;
103
104 private:
105 virtual ~InputHostWindowX11();
106
107 DISALLOW_COPY_AND_ASSIGN(InputHostWindowX11);
108 };
109
110 class RedirectedHostWindowX11 : public HostWindowX11,
111 public MessageLoop::Dispatcher {
112 public:
113 RedirectedHostWindowX11(HostWindowManagerX11* manager,
114 ::Window xwindow,
115 const gfx::Size& size);
116
117 // Implements HostWindowDelegate:
118 virtual void CloseWindow() OVERRIDE {}
119 virtual bool CanResize() OVERRIDE;
120
121 // Overridden from HostWindowX11:
122 virtual bool CanConfigure() OVERRIDE;
123 virtual bool CanActivate() OVERRIDE;
124 virtual void OnMapNotify() OVERRIDE;
125 virtual void OnUnmapNotify() OVERRIDE;
126 virtual void OnConfigureNotify(gfx::Rect bounds, ::Window above) OVERRIDE;
127
128 // Overridden from Dispatcher:
129 virtual bool Dispatch(const base::NativeEvent& xev) OVERRIDE;
130
131 void UpdateExternalTexture();
132 void SetSize(const gfx::Size& size);
133 void SetVisible(bool visible);
134
135 protected:
136 virtual ~RedirectedHostWindowX11();
137
138 HostWindowManagerX11* host_window_manager_;
139 gfx::Size size_;
140 bool visible_;
141
142 DISALLOW_COPY_AND_ASSIGN(RedirectedHostWindowX11);
143 };
144
145 class ManagedRedirectedHostWindowX11 : public RedirectedHostWindowX11 {
146 public:
147 ManagedRedirectedHostWindowX11(HostWindowManagerX11* manager,
148 ::Window xwindow,
149 const gfx::Size& size);
150
151 // Implements HostWindowDelegate:
152 virtual void CloseWindow() OVERRIDE;
153 virtual bool CanResize() OVERRIDE;
154
155 // Overridden from HostWindowX11:
156 virtual bool CanConfigure() OVERRIDE;
157 virtual bool CanActivate() OVERRIDE;
158 virtual void OnMapNotify() OVERRIDE;
159 virtual void OnUnmapNotify() OVERRIDE;
160 virtual void OnConfigureNotify(gfx::Rect bounds, ::Window above) OVERRIDE;
161
162 private:
163 virtual ~ManagedRedirectedHostWindowX11();
164
165 DISALLOW_COPY_AND_ASSIGN(ManagedRedirectedHostWindowX11);
166 };
167
168 class HostWindowManagerX11RootEventObserver
169 : public MessageLoop::Dispatcher,
170 public RootWindowObserver,
171 public FocusChangeObserver {
172 public:
173 HostWindowManagerX11RootEventObserver(HostWindowManagerX11* manager);
174 virtual ~HostWindowManagerX11RootEventObserver() {}
175
176 // Overridden from Dispatcher:
177 virtual bool Dispatch(const base::NativeEvent& xev) OVERRIDE;
178
179 // Overridden from RootWindowObserver:
180 virtual void OnCursorChanged(
181 const RootWindow* root, ui::PlatformCursor cursor) OVERRIDE;
182
183 // Overridden from FocusChangeObserver:
184 virtual void OnWindowFocused(Window* window) OVERRIDE;
185
186 private:
187 HostWindowManagerX11* host_window_manager_;
188 Display* xdisplay_;
189
190 bool ProcessHostWindowUpdate(const base::NativeEvent& xev);
191 bool ProcessHostWindowRequest(const base::NativeEvent& xev);
192
193 DISALLOW_COPY_AND_ASSIGN(HostWindowManagerX11RootEventObserver);
194 };
195
196 class AURA_EXPORT HostWindowManagerX11
197 : public base::SupportsWeakPtr<HostWindowManagerX11> {
198 public:
199 HostWindowManagerX11(client::HostWindowManagerClient* client);
200 virtual ~HostWindowManagerX11();
201
202 void Init();
203 void HostWindowNeedsConfigure(Window* window);
204
205 int damage_event_base() { return damage_event_base_; };
206
207 private:
208 void RegisterNewTopLevel(::Window xwindow);
209 void RegisterNewTopLevel(
210 ::Window xwindow, const gfx::Rect bounds, bool managed);
211 ::Window GetTopHostWindow(Window* window);
212 ::Window FindHostWindowToStackAbove(Window* window);
213 void RecursiveConfigureHostWindow(
214 Window* window,
215 gfx::Point origin,
216 ::Window& sibling_to_stack_above,
217 ::Window& focus_window,
218 bool has_focus);
219 void CreateHostInputWindowIfNeeded(Window* window);
220
221 // Configure all host windows in |configure_window_| subtree.
222 void ConfigureHostWindows();
223
224 Display* xdisplay_;
225
226 ::Window x_root_window_;
227 Window* configure_window_;
228 int damage_event_base_;
229
230 scoped_ptr<HostWindowManagerX11WindowObserver> window_observer_;
231 scoped_ptr<HostWindowManagerX11RootEventObserver> event_observer_;
232
233 // This holds all host windows being redirected, with a mapping from native
234 // representation to the host window id.
235 std::map<gfx::NativeWindow, ::Window> host_windows_;
236
237 // Holds a TopLevel struct for each redirected window, with a mapping from
238 // host window id to struct.
239 std::map< ::Window, scoped_refptr<HostWindowX11> >
240 top_level_windows_;
241
242 // Mapping from the native representation to host window id.
243 std::map< ::Window, gfx::NativeWindow> native_windows_;
244
245 // This holds all input only host windows, with a mapping from the native
246 // representation to host window struct.
247 std::map<gfx::NativeWindow, scoped_refptr<InputHostWindowX11> >
248 input_host_windows_;
249
250 X11AtomCache atom_cache_;
251
252 client::HostWindowManagerClient* client_;
253
254 friend class HostWindowManagerX11WindowObserver;
255 friend class HostWindowManagerX11RootEventObserver;
256 friend class RedirectedHostWindowX11;
257 friend class ManagedRedirectedHostWindowX11;
258 };
259
260 } // namespace aura
261
262 #endif // UI_AURA_HOSTWM_HOST_WINDOW_MANAGER_X11_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698