OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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_AURA_DESKTOP_WINDOW_TREE_HOST_WAYLAND_H_ |
| 6 #define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_WAYLAND_H_ |
| 7 |
| 8 #include <list> |
| 9 #include <set> |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/macros.h" |
| 14 #include "ui/aura/window_tree_host.h" |
| 15 #include "ui/platform_window/platform_window.h" |
| 16 #include "ui/platform_window/platform_window_delegate.h" |
| 17 #include "ui/views/widget/desktop_aura/desktop_window_tree_host.h" |
| 18 |
| 19 namespace views { |
| 20 |
| 21 namespace corewm { |
| 22 class Tooltip; |
| 23 } |
| 24 |
| 25 class DesktopDragDropClientWayland; |
| 26 |
| 27 class VIEWS_EXPORT DesktopWindowTreeHostWayland |
| 28 : public DesktopWindowTreeHost, |
| 29 public aura::WindowTreeHost, |
| 30 public ui::PlatformWindowDelegate { |
| 31 public: |
| 32 DesktopWindowTreeHostWayland( |
| 33 internal::NativeWidgetDelegate* native_widget_delegate, |
| 34 DesktopNativeWidgetAura* desktop_native_widget_aura); |
| 35 ~DesktopWindowTreeHostWayland() override; |
| 36 |
| 37 // Deallocates the internal list of open windows. |
| 38 static void CleanUpWindowList(); |
| 39 |
| 40 // Returns window bounds. This is used by Screen to determine if a point |
| 41 // belongs to a particular window. |
| 42 gfx::Rect GetBoundsInScreen() const; |
| 43 |
| 44 protected: |
| 45 // Overridden from DesktopWindowTreeHost: |
| 46 void Init(aura::Window* content_window, |
| 47 const views::Widget::InitParams& params) override; |
| 48 void OnNativeWidgetCreated(const views::Widget::InitParams& params) override; |
| 49 std::unique_ptr<corewm::Tooltip> CreateTooltip() override; |
| 50 std::unique_ptr<aura::client::DragDropClient> CreateDragDropClient( |
| 51 DesktopNativeCursorManager* cursor_manager) override; |
| 52 void Close() override; |
| 53 void CloseNow() override; |
| 54 aura::WindowTreeHost* AsWindowTreeHost() override; |
| 55 void ShowWindowWithState(ui::WindowShowState show_state) override; |
| 56 void ShowMaximizedWithBounds(const gfx::Rect& restored_bounds) override; |
| 57 bool IsVisible() const override; |
| 58 void SetSize(const gfx::Size& size) override; |
| 59 void StackAbove(aura::Window* window) override; |
| 60 void StackAtTop() override; |
| 61 void CenterWindow(const gfx::Size& size) override; |
| 62 void GetWindowPlacement(gfx::Rect* bounds, |
| 63 ui::WindowShowState* show_state) const override; |
| 64 gfx::Rect GetWindowBoundsInScreen() const override; |
| 65 gfx::Rect GetClientAreaBoundsInScreen() const override; |
| 66 gfx::Rect GetRestoredBounds() const override; |
| 67 std::string GetWorkspace() const override; |
| 68 gfx::Rect GetWorkAreaBoundsInScreen() const override; |
| 69 void SetShape(SkRegion* native_region) override; |
| 70 void Activate() override; |
| 71 void Deactivate() override; |
| 72 bool IsActive() const override; |
| 73 void Maximize() override; |
| 74 void Minimize() override; |
| 75 void Restore() override; |
| 76 bool IsMaximized() const override; |
| 77 bool IsMinimized() const override; |
| 78 bool HasCapture() const override; |
| 79 void SetAlwaysOnTop(bool always_on_top) override; |
| 80 bool IsAlwaysOnTop() const override; |
| 81 void SetVisibleOnAllWorkspaces(bool always_visible) override; |
| 82 bool SetWindowTitle(const base::string16& title) override; |
| 83 void ClearNativeFocus() override; |
| 84 views::Widget::MoveLoopResult RunMoveLoop( |
| 85 const gfx::Vector2d& drag_offset, |
| 86 views::Widget::MoveLoopSource source, |
| 87 views::Widget::MoveLoopEscapeBehavior escape_behavior) override; |
| 88 void EndMoveLoop() override; |
| 89 void SetVisibilityChangedAnimationsEnabled(bool value) override; |
| 90 bool ShouldUseNativeFrame() const override; |
| 91 bool ShouldWindowContentsBeTransparent() const override; |
| 92 void FrameTypeChanged() override; |
| 93 void SetFullscreen(bool fullscreen) override; |
| 94 bool IsFullscreen() const override; |
| 95 void SetOpacity(float opacity) override; |
| 96 void SetWindowIcons(const gfx::ImageSkia& window_icon, |
| 97 const gfx::ImageSkia& app_icon) override; |
| 98 void InitModalType(ui::ModalType modal_type) override; |
| 99 void FlashFrame(bool flash_frame) override; |
| 100 void OnRootViewLayout() override; |
| 101 void OnNativeWidgetFocus() override; |
| 102 void OnNativeWidgetBlur() override; |
| 103 bool IsAnimatingClosed() const override; |
| 104 bool IsTranslucentWindowOpacitySupported() const override; |
| 105 void SizeConstraintsChanged() override; |
| 106 |
| 107 // Overridden from aura::WindowTreeHost: |
| 108 gfx::Transform GetRootTransform() const override; |
| 109 ui::EventSource* GetEventSource() override; |
| 110 gfx::AcceleratedWidget GetAcceleratedWidget() override; |
| 111 void ShowImpl() override; |
| 112 void HideImpl() override; |
| 113 gfx::Rect GetBounds() const override; |
| 114 void SetBounds(const gfx::Rect& bounds) override; |
| 115 gfx::Point GetLocationOnNativeScreen() const override; |
| 116 void SetCapture() override; |
| 117 void ReleaseCapture() override; |
| 118 void SetCursorNative(gfx::NativeCursor cursor) override; |
| 119 void MoveCursorToNative(const gfx::Point& location) override; |
| 120 void OnCursorVisibilityChangedNative(bool show) override; |
| 121 |
| 122 // Overridden from ui::PlatformWindowDelegate: |
| 123 void OnBoundsChanged(const gfx::Rect&) override; |
| 124 void OnDamageRect(const gfx::Rect& damaged_region) override; |
| 125 void DispatchEvent(ui::Event* event) override; |
| 126 void OnCloseRequest() override; |
| 127 void OnClosed() override; |
| 128 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; |
| 129 void OnLostCapture() override; |
| 130 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, |
| 131 float device_pixel_ratio) override; |
| 132 void OnAcceleratedWidgetDestroyed() override; |
| 133 void OnActivationChanged(bool active) override; |
| 134 |
| 135 private: |
| 136 enum { |
| 137 Uninitialized = 0x00, |
| 138 Visible = 0x01, // Window is Visible. |
| 139 FullScreen = 0x02, // Window is in fullscreen mode. |
| 140 Maximized = 0x04, // Window is maximized, |
| 141 Minimized = 0x08, // Window is minimized. |
| 142 Active = 0x10 // Window is Active. |
| 143 }; |
| 144 |
| 145 typedef unsigned RootWindowState; |
| 146 |
| 147 void Relayout(); |
| 148 gfx::Size AdjustSize(const gfx::Size& requested_size); |
| 149 void ShowWindow(); |
| 150 |
| 151 static std::list<gfx::AcceleratedWidget>& open_windows(); |
| 152 gfx::Rect ToDIPRect(const gfx::Rect& rect_in_pixels) const; |
| 153 gfx::Rect ToPixelRect(const gfx::Rect& rect_in_dip) const; |
| 154 void ResetWindowRegion(); |
| 155 |
| 156 RootWindowState state_; |
| 157 bool has_capture_; |
| 158 bool custom_window_shape_; |
| 159 bool always_on_top_; |
| 160 |
| 161 // Original bounds of DRWH. |
| 162 gfx::Rect previous_bounds_; |
| 163 gfx::Rect previous_maximize_bounds_; |
| 164 gfx::AcceleratedWidget window_; |
| 165 base::string16 title_; |
| 166 |
| 167 // Owned by DesktopNativeWidgetAura. |
| 168 DesktopDragDropClientWayland* drag_drop_client_; |
| 169 views::internal::NativeWidgetDelegate* native_widget_delegate_; |
| 170 aura::Window* content_window_; |
| 171 |
| 172 views::DesktopNativeWidgetAura* desktop_native_widget_aura_; |
| 173 // We can optionally have a parent which can order us to close, or own |
| 174 // children who we're responsible for closing when we CloseNow(). |
| 175 DesktopWindowTreeHostWayland* window_parent_; |
| 176 std::set<DesktopWindowTreeHostWayland*> window_children_; |
| 177 |
| 178 // Platform-specific part of this DesktopWindowTreeHost. |
| 179 std::unique_ptr<ui::PlatformWindow> platform_window_; |
| 180 base::WeakPtrFactory<DesktopWindowTreeHostWayland> close_widget_factory_; |
| 181 |
| 182 // A list of all (top-level) windows that have been created but not yet |
| 183 // destroyed. |
| 184 static std::list<gfx::AcceleratedWidget>* open_windows_; |
| 185 // List of all open aura::Window. |
| 186 static std::vector<aura::Window*>* aura_windows_; |
| 187 |
| 188 DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostWayland); |
| 189 }; |
| 190 |
| 191 } // namespace views |
| 192 |
| 193 #endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_WINDOW_TREE_HOST_WAYLAND_H_ |
OLD | NEW |