| OLD | NEW |
| (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_NATIVE_WIDGET_AURA_H_ | |
| 6 #define UI_VIEWS_WIDGET_DESKTOP_NATIVE_WIDGET_AURA_H_ | |
| 7 | |
| 8 #include "base/memory/weak_ptr.h" | |
| 9 #include "ui/aura/client/activation_delegate.h" | |
| 10 #include "ui/aura/window_delegate.h" | |
| 11 #include "ui/views/widget/native_widget_private.h" | |
| 12 | |
| 13 namespace aura { | |
| 14 class RootWindow; | |
| 15 namespace client { | |
| 16 class StackingClient; | |
| 17 } | |
| 18 } | |
| 19 | |
| 20 namespace views { | |
| 21 | |
| 22 class DesktopRootWindowHost; | |
| 23 class NativeWidgetAuraWindowObserver; | |
| 24 | |
| 25 // TODO(erg): May also need to be a DragDropDelegate | |
| 26 class VIEWS_EXPORT DesktopNativeWidgetAura | |
| 27 : public internal::NativeWidgetPrivate, | |
| 28 public aura::WindowDelegate, | |
| 29 public aura::client::ActivationDelegate { | |
| 30 public: | |
| 31 explicit DesktopNativeWidgetAura(internal::NativeWidgetDelegate* delegate); | |
| 32 virtual ~DesktopNativeWidgetAura(); | |
| 33 | |
| 34 // Maps from window to DesktopNativeWidgetAura. | |
| 35 static DesktopNativeWidgetAura* ForWindow(aura::Window* window); | |
| 36 | |
| 37 // Called by our DesktopRootWindowHost after it has deleted native resources; | |
| 38 // this is the signal that we should start our shutdown. | |
| 39 void OnHostClosed(); | |
| 40 | |
| 41 protected: | |
| 42 // Overridden from internal::NativeWidgetPrivate: | |
| 43 virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; | |
| 44 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; | |
| 45 virtual bool ShouldUseNativeFrame() const OVERRIDE; | |
| 46 virtual void FrameTypeChanged() OVERRIDE; | |
| 47 virtual Widget* GetWidget() OVERRIDE; | |
| 48 virtual const Widget* GetWidget() const OVERRIDE; | |
| 49 virtual gfx::NativeView GetNativeView() const OVERRIDE; | |
| 50 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; | |
| 51 virtual Widget* GetTopLevelWidget() OVERRIDE; | |
| 52 virtual const ui::Compositor* GetCompositor() const OVERRIDE; | |
| 53 virtual ui::Compositor* GetCompositor() OVERRIDE; | |
| 54 virtual gfx::Vector2d CalculateOffsetToAncestorWithLayer( | |
| 55 ui::Layer** layer_parent) OVERRIDE; | |
| 56 virtual void ViewRemoved(View* view) OVERRIDE; | |
| 57 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; | |
| 58 virtual void* GetNativeWindowProperty(const char* name) const OVERRIDE; | |
| 59 virtual TooltipManager* GetTooltipManager() const OVERRIDE; | |
| 60 virtual bool IsScreenReaderActive() const OVERRIDE; | |
| 61 virtual void SendNativeAccessibilityEvent( | |
| 62 View* view, | |
| 63 ui::AccessibilityTypes::Event event_type) OVERRIDE; | |
| 64 virtual void SetCapture() OVERRIDE; | |
| 65 virtual void ReleaseCapture() OVERRIDE; | |
| 66 virtual bool HasCapture() const OVERRIDE; | |
| 67 virtual InputMethod* CreateInputMethod() OVERRIDE; | |
| 68 virtual internal::InputMethodDelegate* GetInputMethodDelegate() OVERRIDE; | |
| 69 virtual void CenterWindow(const gfx::Size& size) OVERRIDE; | |
| 70 virtual void GetWindowPlacement( | |
| 71 gfx::Rect* bounds, | |
| 72 ui::WindowShowState* maximized) const OVERRIDE; | |
| 73 virtual void SetWindowTitle(const string16& title) OVERRIDE; | |
| 74 virtual void SetWindowIcons(const gfx::ImageSkia& window_icon, | |
| 75 const gfx::ImageSkia& app_icon) OVERRIDE; | |
| 76 virtual void SetAccessibleName(const string16& name) OVERRIDE; | |
| 77 virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; | |
| 78 virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; | |
| 79 virtual void InitModalType(ui::ModalType modal_type) OVERRIDE; | |
| 80 virtual gfx::Rect GetWindowBoundsInScreen() const OVERRIDE; | |
| 81 virtual gfx::Rect GetClientAreaBoundsInScreen() const OVERRIDE; | |
| 82 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; | |
| 83 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | |
| 84 virtual void SetSize(const gfx::Size& size) OVERRIDE; | |
| 85 virtual void StackAbove(gfx::NativeView native_view) OVERRIDE; | |
| 86 virtual void StackAtTop() OVERRIDE; | |
| 87 virtual void StackBelow(gfx::NativeView native_view) OVERRIDE; | |
| 88 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; | |
| 89 virtual void Close() OVERRIDE; | |
| 90 virtual void CloseNow() OVERRIDE; | |
| 91 virtual void Show() OVERRIDE; | |
| 92 virtual void Hide() OVERRIDE; | |
| 93 virtual void ShowMaximizedWithBounds( | |
| 94 const gfx::Rect& restored_bounds) OVERRIDE; | |
| 95 virtual void ShowWithWindowState(ui::WindowShowState state) OVERRIDE; | |
| 96 virtual bool IsVisible() const OVERRIDE; | |
| 97 virtual void Activate() OVERRIDE; | |
| 98 virtual void Deactivate() OVERRIDE; | |
| 99 virtual bool IsActive() const OVERRIDE; | |
| 100 virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE; | |
| 101 virtual void Maximize() OVERRIDE; | |
| 102 virtual void Minimize() OVERRIDE; | |
| 103 virtual bool IsMaximized() const OVERRIDE; | |
| 104 virtual bool IsMinimized() const OVERRIDE; | |
| 105 virtual void Restore() OVERRIDE; | |
| 106 virtual void SetFullscreen(bool fullscreen) OVERRIDE; | |
| 107 virtual bool IsFullscreen() const OVERRIDE; | |
| 108 virtual void SetOpacity(unsigned char opacity) OVERRIDE; | |
| 109 virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE; | |
| 110 virtual void FlashFrame(bool flash_frame) OVERRIDE; | |
| 111 virtual bool IsAccessibleWidget() const OVERRIDE; | |
| 112 virtual void RunShellDrag(View* view, | |
| 113 const ui::OSExchangeData& data, | |
| 114 const gfx::Point& location, | |
| 115 int operation, | |
| 116 ui::DragDropTypes::DragEventSource source) OVERRIDE; | |
| 117 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; | |
| 118 virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; | |
| 119 virtual void ClearNativeFocus() OVERRIDE; | |
| 120 virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE; | |
| 121 virtual void SetInactiveRenderingDisabled(bool value) OVERRIDE; | |
| 122 virtual Widget::MoveLoopResult RunMoveLoop( | |
| 123 const gfx::Vector2d& drag_offset) OVERRIDE; | |
| 124 virtual void EndMoveLoop() OVERRIDE; | |
| 125 virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; | |
| 126 virtual ui::NativeTheme* GetNativeTheme() const OVERRIDE; | |
| 127 | |
| 128 // Overridden from aura::WindowDelegate: | |
| 129 virtual gfx::Size GetMinimumSize() const OVERRIDE; | |
| 130 virtual void OnBoundsChanged(const gfx::Rect& old_bounds, | |
| 131 const gfx::Rect& new_bounds) OVERRIDE; | |
| 132 virtual void OnFocus(aura::Window* old_focused_window) OVERRIDE; | |
| 133 virtual void OnBlur() OVERRIDE; | |
| 134 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE; | |
| 135 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; | |
| 136 virtual bool ShouldDescendIntoChildForEventHandling( | |
| 137 aura::Window* child, | |
| 138 const gfx::Point& location) OVERRIDE; | |
| 139 virtual bool CanFocus() OVERRIDE; | |
| 140 virtual void OnCaptureLost() OVERRIDE; | |
| 141 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | |
| 142 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; | |
| 143 virtual void OnWindowDestroying() OVERRIDE; | |
| 144 virtual void OnWindowDestroyed() OVERRIDE; | |
| 145 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE; | |
| 146 virtual bool HasHitTestMask() const OVERRIDE; | |
| 147 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE; | |
| 148 virtual scoped_refptr<ui::Texture> CopyTexture() OVERRIDE; | |
| 149 | |
| 150 // Overridden from ui::EventHandler: | |
| 151 virtual ui::EventResult OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | |
| 152 virtual ui::EventResult OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | |
| 153 virtual ui::EventResult OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | |
| 154 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | |
| 155 | |
| 156 // Overridden from aura::client::ActivationDelegate: | |
| 157 virtual bool ShouldActivate(const ui::Event* event) OVERRIDE; | |
| 158 virtual void OnActivated() OVERRIDE; | |
| 159 virtual void OnLostActive() OVERRIDE; | |
| 160 | |
| 161 private: | |
| 162 // See class documentation for Widget in widget.h for a note about ownership. | |
| 163 Widget::InitParams::Ownership ownership_; | |
| 164 | |
| 165 // The NativeWidget owns the RootWindow. Required because the RootWindow owns | |
| 166 // its RootWindowHost, so DesktopRootWindowHost can't own it. | |
| 167 scoped_ptr<aura::RootWindow> root_window_; | |
| 168 | |
| 169 // The following factory is used for calls to close the NativeWidgetAura | |
| 170 // instance. | |
| 171 base::WeakPtrFactory<DesktopNativeWidgetAura> close_widget_factory_; | |
| 172 | |
| 173 scoped_ptr<NativeWidgetAuraWindowObserver> active_window_observer_; | |
| 174 | |
| 175 // Can we be made active? | |
| 176 bool can_activate_; | |
| 177 | |
| 178 // Ownership passed to RootWindow on Init. | |
| 179 DesktopRootWindowHost* desktop_root_window_host_; | |
| 180 aura::Window* window_; | |
| 181 internal::NativeWidgetDelegate* native_widget_delegate_; | |
| 182 | |
| 183 scoped_ptr<aura::client::StackingClient> stacking_client_; | |
| 184 | |
| 185 DISALLOW_COPY_AND_ASSIGN(DesktopNativeWidgetAura); | |
| 186 }; | |
| 187 | |
| 188 } // namespace views | |
| 189 | |
| 190 #endif // UI_VIEWS_WIDGET_DESKTOP_NATIVE_WIDGET_AURA_H_ | |
| OLD | NEW |