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

Side by Side Diff: ui/views/widget/desktop_root_window_host_linux.h

Issue 11369220: Move the desktop aura classes into a desktop subdir to make the gyp simpler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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_VIEWS_WIDGET_DESKTOP_ROOT_WINDOW_HOST_LINUX_H_
6 #define UI_VIEWS_WIDGET_DESKTOP_ROOT_WINDOW_HOST_LINUX_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/basictypes.h"
14 #include "base/memory/weak_ptr.h"
15 #include "ui/aura/client/cursor_client.h"
16 #include "ui/aura/root_window_host.h"
17 #include "ui/gfx/rect.h"
18 #include "ui/base/cursor/cursor_loader_x11.h"
19 #include "ui/base/x/x11_atom_cache.h"
20 #include "ui/views/ime/input_method_delegate.h"
21 #include "ui/views/views_export.h"
22 #include "ui/views/widget/desktop_root_window_host.h"
23
24 namespace aura {
25 class FocusManager;
26 namespace client {
27 class DefaultCaptureClient;
28 class ScreenPositionClient;
29 }
30 }
31
32 namespace views {
33 class DesktopActivationClient;
34 class DesktopCursorClient;
35 class DesktopDispatcherClient;
36 class X11DesktopWindowMoveClient;
37 class X11WindowEventFilter;
38 namespace corewm {
39 class CompoundEventFilter;
40 class InputMethodEventFilter;
41 }
42
43 class VIEWS_EXPORT DesktopRootWindowHostLinux
44 : public DesktopRootWindowHost,
45 public aura::RootWindowHost,
46 public views::internal::InputMethodDelegate,
47 public MessageLoop::Dispatcher {
48 public:
49 DesktopRootWindowHostLinux(
50 internal::NativeWidgetDelegate* native_widget_delegate,
51 DesktopNativeWidgetAura* desktop_native_widget_aura,
52 const gfx::Rect& initial_bounds);
53 virtual ~DesktopRootWindowHostLinux();
54
55 // A way of converting an X11 |xid| host window into a |content_window_|.
56 static aura::Window* GetContentWindowForXID(XID xid);
57
58 // A way of converting an X11 |xid| host window into this object.
59 static DesktopRootWindowHostLinux* GetHostForXID(XID xid);
60
61 // Called by X11DesktopHandler to notify us that the native windowing system
62 // has changed our activation.
63 void HandleNativeWidgetActivationChanged(bool active);
64
65 private:
66 // Initializes our X11 surface to draw on. This method performs all
67 // initialization related to talking to the X11 server.
68 void InitX11Window(const Widget::InitParams& params);
69
70 // Creates an aura::RootWindow to contain the |content_window|, along with
71 // all aura client objects that direct behavior.
72 aura::RootWindow* InitRootWindow(const Widget::InitParams& params);
73
74 // 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
76 // detect that they're there.
77 bool IsWindowManagerPresent();
78
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
87 // entirely.
88 void OnCaptureReleased();
89
90 // Dispatches a mouse event, taking mouse capture into account. If a
91 // different host has capture, we translate the event to its coordinate space
92 // and dispatch it to that host instead.
93 void DispatchMouseEvent(ui::MouseEvent* event);
94
95 // Overridden from DesktopRootWindowHost:
96 virtual aura::RootWindow* Init(aura::Window* content_window,
97 const Widget::InitParams& params) OVERRIDE;
98 virtual void Close() OVERRIDE;
99 virtual void CloseNow() OVERRIDE;
100 virtual aura::RootWindowHost* AsRootWindowHost() OVERRIDE;
101 virtual void ShowWindowWithState(ui::WindowShowState show_state) OVERRIDE;
102 virtual void ShowMaximizedWithBounds(
103 const gfx::Rect& restored_bounds) OVERRIDE;
104 virtual bool IsVisible() const OVERRIDE;
105 virtual void SetSize(const gfx::Size& size) OVERRIDE;
106 virtual void CenterWindow(const gfx::Size& size) OVERRIDE;
107 virtual void GetWindowPlacement(
108 gfx::Rect* bounds,
109 ui::WindowShowState* show_state) const OVERRIDE;
110 virtual gfx::Rect GetWindowBoundsInScreen() const OVERRIDE;
111 virtual gfx::Rect GetClientAreaBoundsInScreen() const OVERRIDE;
112 virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
113 virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE;
114 virtual void SetShape(gfx::NativeRegion native_region) OVERRIDE;
115 virtual void Activate() OVERRIDE;
116 virtual void Deactivate() OVERRIDE;
117 virtual bool IsActive() const OVERRIDE;
118 virtual void Maximize() OVERRIDE;
119 virtual void Minimize() OVERRIDE;
120 virtual void Restore() OVERRIDE;
121 virtual bool IsMaximized() const OVERRIDE;
122 virtual bool IsMinimized() const OVERRIDE;
123 virtual bool HasCapture() const OVERRIDE;
124 virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
125 virtual InputMethod* CreateInputMethod() OVERRIDE;
126 virtual internal::InputMethodDelegate* GetInputMethodDelegate() OVERRIDE;
127 virtual void SetWindowTitle(const string16& title) OVERRIDE;
128 virtual void ClearNativeFocus() OVERRIDE;
129 virtual Widget::MoveLoopResult RunMoveLoop(
130 const gfx::Vector2d& drag_offset) OVERRIDE;
131 virtual void EndMoveLoop() OVERRIDE;
132 virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE;
133 virtual bool ShouldUseNativeFrame() OVERRIDE;
134 virtual void FrameTypeChanged() OVERRIDE;
135 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
136 virtual void SetFullscreen(bool fullscreen) OVERRIDE;
137 virtual bool IsFullscreen() const OVERRIDE;
138 virtual void SetOpacity(unsigned char opacity) OVERRIDE;
139 virtual void SetWindowIcons(const gfx::ImageSkia& window_icon,
140 const gfx::ImageSkia& app_icon) OVERRIDE;
141 virtual void SetAccessibleName(const string16& name) OVERRIDE;
142 virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE;
143 virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE;
144 virtual void InitModalType(ui::ModalType modal_type) OVERRIDE;
145 virtual void FlashFrame(bool flash_frame) OVERRIDE;
146 virtual void OnNativeWidgetFocus() OVERRIDE;
147 virtual void OnNativeWidgetBlur() OVERRIDE;
148
149 // Overridden from aura::RootWindowHost:
150 virtual void SetDelegate(aura::RootWindowHostDelegate* delegate) OVERRIDE;
151 virtual aura::RootWindow* GetRootWindow() OVERRIDE;
152 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
153 virtual void Show() OVERRIDE;
154 virtual void Hide() OVERRIDE;
155 virtual void ToggleFullScreen() OVERRIDE;
156 virtual gfx::Rect GetBounds() const OVERRIDE;
157 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
158 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE;
159 virtual void SetCapture() OVERRIDE;
160 virtual void ReleaseCapture() OVERRIDE;
161 virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE;
162 virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE;
163 virtual bool ConfineCursorToRootWindow() OVERRIDE;
164 virtual void UnConfineCursor() OVERRIDE;
165 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE;
166 virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE;
167 virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds,
168 const gfx::Point& dest_offset,
169 SkCanvas* canvas) OVERRIDE;
170 virtual bool GrabSnapshot(
171 const gfx::Rect& snapshot_bounds,
172 std::vector<unsigned char>* png_representation) OVERRIDE;
173 virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE;
174 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
175 virtual void PrepareForShutdown() OVERRIDE;
176
177 // Overridden from views::internal::InputMethodDelegate:
178 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE;
179
180 // Overridden from Dispatcher:
181 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE;
182
183 base::WeakPtrFactory<DesktopRootWindowHostLinux> close_widget_factory_;
184
185 // X11 things
186 // The display and the native X window hosting the root window.
187 Display* xdisplay_;
188 ::Window xwindow_;
189
190 // The native root window.
191 ::Window x_root_window_;
192
193 ui::X11AtomCache atom_cache_;
194
195 // Is the window mapped to the screen?
196 bool window_mapped_;
197
198 // The bounds of |xwindow_|.
199 gfx::Rect bounds_;
200
201 // True if the window should be focused when the window is shown.
202 bool focus_when_shown_;
203
204 // The window manager state bits.
205 std::set< ::Atom> window_properties_;
206
207 // We are owned by the RootWindow, but we have to have a back pointer to it.
208 aura::RootWindow* root_window_;
209
210 // aura:: objects that we own.
211 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
212 scoped_ptr<aura::FocusManager> focus_manager_;
213 scoped_ptr<DesktopActivationClient> activation_client_;
214 scoped_ptr<DesktopCursorClient> cursor_client_;
215 scoped_ptr<DesktopDispatcherClient> dispatcher_client_;
216 scoped_ptr<aura::client::ScreenPositionClient> position_client_;
217
218 // Current Aura cursor.
219 gfx::NativeCursor current_cursor_;
220
221 // The invisible cursor.
222 ::Cursor invisible_cursor_;
223
224 // Toplevel event filter which dispatches to other event filters.
225 corewm::CompoundEventFilter* root_window_event_filter_;
226
227 // An event filter that pre-handles all key events to send them to an IME.
228 scoped_ptr<corewm::InputMethodEventFilter> input_method_filter_;
229 scoped_ptr<X11WindowEventFilter> x11_window_event_filter_;
230 scoped_ptr<X11DesktopWindowMoveClient> x11_window_move_client_;
231
232 // TODO(beng): Consider providing an interface to DesktopNativeWidgetAura
233 // instead of providing this route back to Widget.
234 internal::NativeWidgetDelegate* native_widget_delegate_;
235
236 DesktopNativeWidgetAura* desktop_native_widget_aura_;
237
238 aura::RootWindowHostDelegate* root_window_host_delegate_;
239 aura::Window* content_window_;
240
241 // The current root window host that has capture. While X11 has something
242 // like Windows SetCapture()/ReleaseCapture(), it is entirely implicit and
243 // there are no notifications when this changes. We need to track this so we
244 // can notify widgets when they have lost capture, which controls a bunch of
245 // things in views like hiding menus.
246 static DesktopRootWindowHostLinux* g_current_capture;
247
248 DISALLOW_COPY_AND_ASSIGN(DesktopRootWindowHostLinux);
249 };
250
251 } // namespace views
252
253 #endif // UI_VIEWS_WIDGET_DESKTOP_ROOT_WINDOW_HOST_LINUX_H_
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_root_window_host.h ('k') | ui/views/widget/desktop_root_window_host_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698