| 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_X11_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_X11_H_ |
| 7 | 7 |
| 8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
| 9 | 9 |
| 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. | 10 // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. |
| 11 #undef RootWindow | 11 #undef RootWindow |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/observer_list.h" |
| 15 #include "ui/aura/client/cursor_client.h" | 16 #include "ui/aura/client/cursor_client.h" |
| 16 #include "ui/aura/root_window_host.h" | 17 #include "ui/aura/root_window_host.h" |
| 17 #include "ui/base/cursor/cursor_loader_x11.h" | 18 #include "ui/base/cursor/cursor_loader_x11.h" |
| 18 #include "ui/base/x/x11_atom_cache.h" | 19 #include "ui/base/x/x11_atom_cache.h" |
| 19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 20 #include "ui/views/views_export.h" | 21 #include "ui/views/views_export.h" |
| 21 #include "ui/views/widget/desktop_aura/desktop_root_window_host.h" | 22 #include "ui/views/widget/desktop_aura/desktop_root_window_host.h" |
| 22 | 23 |
| 23 namespace aura { | 24 namespace aura { |
| 24 namespace client { | 25 namespace client { |
| 25 class FocusClient; | 26 class FocusClient; |
| 26 class ScreenPositionClient; | 27 class ScreenPositionClient; |
| 27 } | 28 } |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace views { | 31 namespace views { |
| 31 class DesktopActivationClient; | 32 class DesktopActivationClient; |
| 32 class DesktopCaptureClient; | 33 class DesktopCaptureClient; |
| 33 class DesktopDragDropClientAuraX11; | 34 class DesktopDragDropClientAuraX11; |
| 34 class DesktopDispatcherClient; | 35 class DesktopDispatcherClient; |
| 36 class DesktopRootWindowHostObserverX11; |
| 35 class X11DesktopWindowMoveClient; | 37 class X11DesktopWindowMoveClient; |
| 36 class X11WindowEventFilter; | 38 class X11WindowEventFilter; |
| 37 | 39 |
| 38 namespace corewm { | 40 namespace corewm { |
| 39 class CursorManager; | 41 class CursorManager; |
| 40 } | 42 } |
| 41 | 43 |
| 42 class VIEWS_EXPORT DesktopRootWindowHostX11 : | 44 class VIEWS_EXPORT DesktopRootWindowHostX11 : |
| 43 public DesktopRootWindowHost, | 45 public DesktopRootWindowHost, |
| 44 public aura::RootWindowHost, | 46 public aura::RootWindowHost, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 57 static DesktopRootWindowHostX11* GetHostForXID(XID xid); | 59 static DesktopRootWindowHostX11* GetHostForXID(XID xid); |
| 58 | 60 |
| 59 // Get all open top-level windows. This includes windows that may not be | 61 // Get all open top-level windows. This includes windows that may not be |
| 60 // visible. | 62 // visible. |
| 61 static std::vector<aura::Window*> GetAllOpenWindows(); | 63 static std::vector<aura::Window*> GetAllOpenWindows(); |
| 62 | 64 |
| 63 // Called by X11DesktopHandler to notify us that the native windowing system | 65 // Called by X11DesktopHandler to notify us that the native windowing system |
| 64 // has changed our activation. | 66 // has changed our activation. |
| 65 void HandleNativeWidgetActivationChanged(bool active); | 67 void HandleNativeWidgetActivationChanged(bool active); |
| 66 | 68 |
| 69 void AddObserver(views::DesktopRootWindowHostObserverX11* observer); |
| 70 void RemoveObserver(views::DesktopRootWindowHostObserverX11* observer); |
| 71 |
| 67 // Deallocates the internal list of open windows. | 72 // Deallocates the internal list of open windows. |
| 68 static void CleanUpWindowList(); | 73 static void CleanUpWindowList(); |
| 69 | 74 |
| 70 private: | 75 protected: |
| 71 // Initializes our X11 surface to draw on. This method performs all | |
| 72 // initialization related to talking to the X11 server. | |
| 73 void InitX11Window(const Widget::InitParams& params); | |
| 74 | |
| 75 // Creates an aura::RootWindow to contain the |content_window|, along with | |
| 76 // all aura client objects that direct behavior. | |
| 77 aura::RootWindow* InitRootWindow(const Widget::InitParams& params); | |
| 78 | |
| 79 // Returns true if there's an X window manager present... in most cases. Some | |
| 80 // window managers (notably, ion3) don't implement enough of ICCCM for us to | |
| 81 // detect that they're there. | |
| 82 bool IsWindowManagerPresent(); | |
| 83 | |
| 84 // Sends a message to the x11 window manager, enabling or disabling the | |
| 85 // states |state1| and |state2|. | |
| 86 void SetWMSpecState(bool enabled, ::Atom state1, ::Atom state2); | |
| 87 | |
| 88 // Checks if the window manager has set a specific state. | |
| 89 bool HasWMSpecProperty(const char* property) const; | |
| 90 | |
| 91 // Called when another DRWHL takes capture, or when capture is released | |
| 92 // entirely. | |
| 93 void OnCaptureReleased(); | |
| 94 | |
| 95 // Dispatches a mouse event, taking mouse capture into account. If a | |
| 96 // different host has capture, we translate the event to its coordinate space | |
| 97 // and dispatch it to that host instead. | |
| 98 void DispatchMouseEvent(ui::MouseEvent* event); | |
| 99 | |
| 100 // See comment for variable open_windows_. | |
| 101 static std::list<XID>& open_windows(); | |
| 102 | |
| 103 // Overridden from DesktopRootWindowHost: | 76 // Overridden from DesktopRootWindowHost: |
| 104 virtual aura::RootWindow* Init(aura::Window* content_window, | 77 virtual aura::RootWindow* Init(aura::Window* content_window, |
| 105 const Widget::InitParams& params) OVERRIDE; | 78 const Widget::InitParams& params) OVERRIDE; |
| 106 virtual void InitFocus(aura::Window* window) OVERRIDE; | 79 virtual void InitFocus(aura::Window* window) OVERRIDE; |
| 107 virtual void Close() OVERRIDE; | 80 virtual void Close() OVERRIDE; |
| 108 virtual void CloseNow() OVERRIDE; | 81 virtual void CloseNow() OVERRIDE; |
| 109 virtual aura::RootWindowHost* AsRootWindowHost() OVERRIDE; | 82 virtual aura::RootWindowHost* AsRootWindowHost() OVERRIDE; |
| 110 virtual void ShowWindowWithState(ui::WindowShowState show_state) OVERRIDE; | 83 virtual void ShowWindowWithState(ui::WindowShowState show_state) OVERRIDE; |
| 111 virtual void ShowMaximizedWithBounds( | 84 virtual void ShowMaximizedWithBounds( |
| 112 const gfx::Rect& restored_bounds) OVERRIDE; | 85 const gfx::Rect& restored_bounds) OVERRIDE; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 virtual void OnCursorVisibilityChanged(bool show) OVERRIDE; | 146 virtual void OnCursorVisibilityChanged(bool show) OVERRIDE; |
| 174 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; | 147 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; |
| 175 virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; | 148 virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; |
| 176 virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, | 149 virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, |
| 177 const gfx::Point& dest_offset, | 150 const gfx::Point& dest_offset, |
| 178 SkCanvas* canvas) OVERRIDE; | 151 SkCanvas* canvas) OVERRIDE; |
| 179 virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; | 152 virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; |
| 180 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; | 153 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; |
| 181 virtual void PrepareForShutdown() OVERRIDE; | 154 virtual void PrepareForShutdown() OVERRIDE; |
| 182 | 155 |
| 156 private: |
| 157 // Initializes our X11 surface to draw on. This method performs all |
| 158 // initialization related to talking to the X11 server. |
| 159 void InitX11Window(const Widget::InitParams& params); |
| 160 |
| 161 // Creates an aura::RootWindow to contain the |content_window|, along with |
| 162 // all aura client objects that direct behavior. |
| 163 aura::RootWindow* InitRootWindow(const Widget::InitParams& params); |
| 164 |
| 165 // Returns true if there's an X window manager present... in most cases. Some |
| 166 // window managers (notably, ion3) don't implement enough of ICCCM for us to |
| 167 // detect that they're there. |
| 168 bool IsWindowManagerPresent(); |
| 169 |
| 170 // Sends a message to the x11 window manager, enabling or disabling the |
| 171 // states |state1| and |state2|. |
| 172 void SetWMSpecState(bool enabled, ::Atom state1, ::Atom state2); |
| 173 |
| 174 // Checks if the window manager has set a specific state. |
| 175 bool HasWMSpecProperty(const char* property) const; |
| 176 |
| 177 // Called when another DRWHL takes capture, or when capture is released |
| 178 // entirely. |
| 179 void OnCaptureReleased(); |
| 180 |
| 181 // Dispatches a mouse event, taking mouse capture into account. If a |
| 182 // different host has capture, we translate the event to its coordinate space |
| 183 // and dispatch it to that host instead. |
| 184 void DispatchMouseEvent(ui::MouseEvent* event); |
| 185 |
| 186 // See comment for variable open_windows_. |
| 187 static std::list<XID>& open_windows(); |
| 188 |
| 183 // Overridden from Dispatcher: | 189 // Overridden from Dispatcher: |
| 184 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; | 190 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; |
| 185 | 191 |
| 186 base::WeakPtrFactory<DesktopRootWindowHostX11> close_widget_factory_; | 192 base::WeakPtrFactory<DesktopRootWindowHostX11> close_widget_factory_; |
| 187 | 193 |
| 188 // X11 things | 194 // X11 things |
| 189 // The display and the native X window hosting the root window. | 195 // The display and the native X window hosting the root window. |
| 190 Display* xdisplay_; | 196 Display* xdisplay_; |
| 191 ::Window xwindow_; | 197 ::Window xwindow_; |
| 192 | 198 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 244 |
| 239 // TODO(beng): Consider providing an interface to DesktopNativeWidgetAura | 245 // TODO(beng): Consider providing an interface to DesktopNativeWidgetAura |
| 240 // instead of providing this route back to Widget. | 246 // instead of providing this route back to Widget. |
| 241 internal::NativeWidgetDelegate* native_widget_delegate_; | 247 internal::NativeWidgetDelegate* native_widget_delegate_; |
| 242 | 248 |
| 243 DesktopNativeWidgetAura* desktop_native_widget_aura_; | 249 DesktopNativeWidgetAura* desktop_native_widget_aura_; |
| 244 | 250 |
| 245 aura::RootWindowHostDelegate* root_window_host_delegate_; | 251 aura::RootWindowHostDelegate* root_window_host_delegate_; |
| 246 aura::Window* content_window_; | 252 aura::Window* content_window_; |
| 247 | 253 |
| 254 ObserverList<DesktopRootWindowHostObserverX11> observer_list_; |
| 255 |
| 248 // The current root window host that has capture. While X11 has something | 256 // The current root window host that has capture. While X11 has something |
| 249 // like Windows SetCapture()/ReleaseCapture(), it is entirely implicit and | 257 // like Windows SetCapture()/ReleaseCapture(), it is entirely implicit and |
| 250 // there are no notifications when this changes. We need to track this so we | 258 // there are no notifications when this changes. We need to track this so we |
| 251 // can notify widgets when they have lost capture, which controls a bunch of | 259 // can notify widgets when they have lost capture, which controls a bunch of |
| 252 // things in views like hiding menus. | 260 // things in views like hiding menus. |
| 253 static DesktopRootWindowHostX11* g_current_capture; | 261 static DesktopRootWindowHostX11* g_current_capture; |
| 254 | 262 |
| 255 // A list of all (top-level) windows that have been created but not yet | 263 // A list of all (top-level) windows that have been created but not yet |
| 256 // destroyed. | 264 // destroyed. |
| 257 static std::list<XID>* open_windows_; | 265 static std::list<XID>* open_windows_; |
| 258 | 266 |
| 259 DISALLOW_COPY_AND_ASSIGN(DesktopRootWindowHostX11); | 267 DISALLOW_COPY_AND_ASSIGN(DesktopRootWindowHostX11); |
| 260 }; | 268 }; |
| 261 | 269 |
| 262 } // namespace views | 270 } // namespace views |
| 263 | 271 |
| 264 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_ROOT_WINDOW_HOST_X11_H_ | 272 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_ROOT_WINDOW_HOST_X11_H_ |
| OLD | NEW |