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_ROOT_WINDOW_HOST_LINUX_H_ | 5 #ifndef UI_VIEWS_WIDGET_DESKTOP_ROOT_WINDOW_HOST_LINUX_H_ |
6 #define UI_VIEWS_WIDGET_DESKTOP_ROOT_WINDOW_HOST_LINUX_H_ | 6 #define UI_VIEWS_WIDGET_DESKTOP_ROOT_WINDOW_HOST_LINUX_H_ |
7 | 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 |
8 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "ui/aura/root_window_host.h" |
| 15 #include "ui/gfx/rect.h" |
| 16 #include "ui/base/x/x11_atom_cache.h" |
9 #include "ui/views/widget/desktop_root_window_host.h" | 17 #include "ui/views/widget/desktop_root_window_host.h" |
10 | 18 |
| 19 namespace aura { |
| 20 class DesktopActivationClient; |
| 21 class DesktopDispatcherClient; |
| 22 class FocusManager; |
| 23 namespace shared { |
| 24 class CompoundEventFilter; |
| 25 class InputMethodEventFilter; |
| 26 } |
| 27 } |
| 28 |
11 namespace views { | 29 namespace views { |
| 30 class DesktopCaptureClient; |
| 31 class X11WindowEventFilter; |
12 | 32 |
13 class DesktopRootWindowHostLinux : public DesktopRootWindowHost { | 33 class DesktopRootWindowHostLinux : public DesktopRootWindowHost, |
| 34 public aura::RootWindowHost, |
| 35 public MessageLoop::Dispatcher { |
14 public: | 36 public: |
15 DesktopRootWindowHostLinux(); | 37 DesktopRootWindowHostLinux(); |
16 virtual ~DesktopRootWindowHostLinux(); | 38 virtual ~DesktopRootWindowHostLinux(); |
17 | 39 |
18 private: | 40 private: |
| 41 // Initializes our X11 surface to draw on. This method performs all |
| 42 // initialization related to talking to the X11 server. |
| 43 void InitX11Window(const gfx::Rect& bounds); |
| 44 |
| 45 // Creates an aura::RootWindow to contain the |content_window|, along with |
| 46 // all aura client objects that direct behavior. |
| 47 void InitRootWindow(const Widget::InitParams& params); |
| 48 |
| 49 // Returns true if there's an X window manager present... in most cases. Some |
| 50 // window managers (notably, ion3) don't implement enough of ICCCM for us to |
| 51 // detect that they're there. |
| 52 bool IsWindowManagerPresent(); |
| 53 |
19 // Overridden from DesktopRootWindowHost: | 54 // Overridden from DesktopRootWindowHost: |
20 virtual void Init(aura::Window* content_window, | 55 virtual void Init(aura::Window* content_window, |
21 const Widget::InitParams& params) OVERRIDE; | 56 const Widget::InitParams& params) OVERRIDE; |
22 virtual void Close() OVERRIDE; | 57 virtual void Close() OVERRIDE; |
23 virtual void CloseNow() OVERRIDE; | 58 virtual void CloseNow() OVERRIDE; |
24 virtual aura::RootWindowHost* AsRootWindowHost() OVERRIDE; | 59 virtual aura::RootWindowHost* AsRootWindowHost() OVERRIDE; |
25 virtual void ShowWindowWithState(ui::WindowShowState show_state) OVERRIDE; | 60 virtual void ShowWindowWithState(ui::WindowShowState show_state) OVERRIDE; |
26 virtual void ShowMaximizedWithBounds( | 61 virtual void ShowMaximizedWithBounds( |
27 const gfx::Rect& restored_bounds) OVERRIDE; | 62 const gfx::Rect& restored_bounds) OVERRIDE; |
28 virtual bool IsVisible() const OVERRIDE; | 63 virtual bool IsVisible() const OVERRIDE; |
(...skipping 14 matching lines...) Expand all Loading... |
43 virtual void Minimize() OVERRIDE; | 78 virtual void Minimize() OVERRIDE; |
44 virtual void Restore() OVERRIDE; | 79 virtual void Restore() OVERRIDE; |
45 virtual bool IsMaximized() const OVERRIDE; | 80 virtual bool IsMaximized() const OVERRIDE; |
46 virtual bool IsMinimized() const OVERRIDE; | 81 virtual bool IsMinimized() const OVERRIDE; |
47 virtual bool HasCapture() const OVERRIDE; | 82 virtual bool HasCapture() const OVERRIDE; |
48 virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE; | 83 virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE; |
49 virtual InputMethod* CreateInputMethod() OVERRIDE; | 84 virtual InputMethod* CreateInputMethod() OVERRIDE; |
50 virtual internal::InputMethodDelegate* GetInputMethodDelegate() OVERRIDE; | 85 virtual internal::InputMethodDelegate* GetInputMethodDelegate() OVERRIDE; |
51 virtual void SetWindowTitle(const string16& title) OVERRIDE; | 86 virtual void SetWindowTitle(const string16& title) OVERRIDE; |
52 | 87 |
| 88 // Overridden from aura::RootWindowHost: |
| 89 virtual aura::RootWindow* GetRootWindow() OVERRIDE; |
| 90 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; |
| 91 virtual void Show() OVERRIDE; |
| 92 virtual void Hide() OVERRIDE; |
| 93 virtual void ToggleFullScreen() OVERRIDE; |
| 94 virtual gfx::Rect GetBounds() const OVERRIDE; |
| 95 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
| 96 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; |
| 97 virtual void SetCapture() OVERRIDE; |
| 98 virtual void ReleaseCapture() OVERRIDE; |
| 99 virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; |
| 100 virtual void ShowCursor(bool show) OVERRIDE; |
| 101 virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE; |
| 102 virtual bool ConfineCursorToRootWindow() OVERRIDE; |
| 103 virtual void UnConfineCursor() OVERRIDE; |
| 104 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; |
| 105 virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; |
| 106 virtual bool GrabSnapshot( |
| 107 const gfx::Rect& snapshot_bounds, |
| 108 std::vector<unsigned char>* png_representation) OVERRIDE; |
| 109 virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; |
| 110 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; |
| 111 virtual void PrepareForShutdown() OVERRIDE; |
| 112 |
| 113 // Overridden from Dispatcher overrides: |
| 114 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; |
| 115 |
| 116 // X11 things |
| 117 // The display and the native X window hosting the root window. |
| 118 Display* xdisplay_; |
| 119 ::Window xwindow_; |
| 120 |
| 121 // The native root window. |
| 122 ::Window x_root_window_; |
| 123 |
| 124 ui::X11AtomCache atom_cache_; |
| 125 |
| 126 // Is the window mapped to the screen? |
| 127 bool window_mapped_; |
| 128 |
| 129 // The bounds of |xwindow_|. |
| 130 gfx::Rect bounds_; |
| 131 |
| 132 // True if the window should be focused when the window is shown. |
| 133 bool focus_when_shown_; |
| 134 |
| 135 // aura:: objects that we own. |
| 136 scoped_ptr<aura::RootWindow> root_window_; |
| 137 scoped_ptr<DesktopCaptureClient> capture_client_; |
| 138 scoped_ptr<aura::DesktopActivationClient> activation_client_; |
| 139 scoped_ptr<aura::DesktopDispatcherClient> dispatcher_client_; |
| 140 |
| 141 // Toplevel event filter which dispatches to other event filters. |
| 142 aura::shared::CompoundEventFilter* root_window_event_filter_; |
| 143 |
| 144 // An event filter that pre-handles all key events to send them to an IME. |
| 145 scoped_ptr<aura::shared::InputMethodEventFilter> input_method_filter_; |
| 146 scoped_ptr<X11WindowEventFilter> x11_window_event_filter_; |
| 147 |
| 148 aura::RootWindowHostDelegate* root_window_host_delegate_; |
| 149 aura::Window* content_window_; |
| 150 |
53 DISALLOW_COPY_AND_ASSIGN(DesktopRootWindowHostLinux); | 151 DISALLOW_COPY_AND_ASSIGN(DesktopRootWindowHostLinux); |
54 }; | 152 }; |
55 | 153 |
56 } // namespace views | 154 } // namespace views |
57 | 155 |
58 #endif // UI_VIEWS_WIDGET_DESKTOP_ROOT_WINDOW_HOST_LINUX_H_ | 156 #endif // UI_VIEWS_WIDGET_DESKTOP_ROOT_WINDOW_HOST_LINUX_H_ |
OLD | NEW |