| 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_ROOT_WINDOW_HOST_WIN_H_ | |
| 6 #define UI_VIEWS_WIDGET_DESKTOP_ROOT_WINDOW_HOST_WIN_H_ | |
| 7 | |
| 8 #include "ui/aura/root_window_host.h" | |
| 9 #include "ui/views/views_export.h" | |
| 10 #include "ui/views/widget/desktop_root_window_host.h" | |
| 11 #include "ui/views/win/hwnd_message_handler_delegate.h" | |
| 12 | |
| 13 namespace aura { | |
| 14 class FocusManager; | |
| 15 namespace client { | |
| 16 class DefaultCaptureClient; | |
| 17 class ScreenPositionClient; | |
| 18 } | |
| 19 } | |
| 20 | |
| 21 namespace views { | |
| 22 class DesktopActivationClient; | |
| 23 class DesktopCursorClient; | |
| 24 class DesktopDispatcherClient; | |
| 25 class HWNDMessageHandler; | |
| 26 namespace corewm { | |
| 27 class CompoundEventFilter; | |
| 28 class InputMethodEventFilter; | |
| 29 } | |
| 30 | |
| 31 class VIEWS_EXPORT DesktopRootWindowHostWin | |
| 32 : public DesktopRootWindowHost, | |
| 33 public aura::RootWindowHost, | |
| 34 public HWNDMessageHandlerDelegate { | |
| 35 public: | |
| 36 DesktopRootWindowHostWin( | |
| 37 internal::NativeWidgetDelegate* native_widget_delegate, | |
| 38 DesktopNativeWidgetAura* desktop_native_widget_aura, | |
| 39 const gfx::Rect& initial_bounds); | |
| 40 virtual ~DesktopRootWindowHostWin(); | |
| 41 | |
| 42 // A way of converting an HWND into a content window. | |
| 43 static aura::Window* GetContentWindowForHWND(HWND hwnd); | |
| 44 | |
| 45 protected: | |
| 46 // Overridden from DesktopRootWindowHost: | |
| 47 virtual aura::RootWindow* Init(aura::Window* content_window, | |
| 48 const Widget::InitParams& params) OVERRIDE; | |
| 49 virtual void Close() OVERRIDE; | |
| 50 virtual void CloseNow() OVERRIDE; | |
| 51 virtual aura::RootWindowHost* AsRootWindowHost() OVERRIDE; | |
| 52 virtual void ShowWindowWithState(ui::WindowShowState show_state) OVERRIDE; | |
| 53 virtual void ShowMaximizedWithBounds( | |
| 54 const gfx::Rect& restored_bounds) OVERRIDE; | |
| 55 virtual bool IsVisible() const OVERRIDE; | |
| 56 virtual void SetSize(const gfx::Size& size) OVERRIDE; | |
| 57 virtual void CenterWindow(const gfx::Size& size) OVERRIDE; | |
| 58 virtual void GetWindowPlacement( | |
| 59 gfx::Rect* bounds, | |
| 60 ui::WindowShowState* show_state) const OVERRIDE; | |
| 61 virtual gfx::Rect GetWindowBoundsInScreen() const OVERRIDE; | |
| 62 virtual gfx::Rect GetClientAreaBoundsInScreen() const OVERRIDE; | |
| 63 virtual gfx::Rect GetRestoredBounds() const OVERRIDE; | |
| 64 virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE; | |
| 65 virtual void SetShape(gfx::NativeRegion native_region) OVERRIDE; | |
| 66 virtual void Activate() OVERRIDE; | |
| 67 virtual void Deactivate() OVERRIDE; | |
| 68 virtual bool IsActive() const OVERRIDE; | |
| 69 virtual void Maximize() OVERRIDE; | |
| 70 virtual void Minimize() OVERRIDE; | |
| 71 virtual void Restore() OVERRIDE; | |
| 72 virtual bool IsMaximized() const OVERRIDE; | |
| 73 virtual bool IsMinimized() const OVERRIDE; | |
| 74 virtual bool HasCapture() const OVERRIDE; | |
| 75 virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE; | |
| 76 virtual InputMethod* CreateInputMethod() OVERRIDE; | |
| 77 virtual internal::InputMethodDelegate* GetInputMethodDelegate() OVERRIDE; | |
| 78 virtual void SetWindowTitle(const string16& title) OVERRIDE; | |
| 79 virtual void ClearNativeFocus() OVERRIDE; | |
| 80 virtual Widget::MoveLoopResult RunMoveLoop( | |
| 81 const gfx::Vector2d& drag_offset) OVERRIDE; | |
| 82 virtual void EndMoveLoop() OVERRIDE; | |
| 83 virtual void SetVisibilityChangedAnimationsEnabled(bool value) OVERRIDE; | |
| 84 virtual bool ShouldUseNativeFrame() OVERRIDE; | |
| 85 virtual void FrameTypeChanged() OVERRIDE; | |
| 86 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; | |
| 87 virtual void SetFullscreen(bool fullscreen) OVERRIDE; | |
| 88 virtual bool IsFullscreen() const OVERRIDE; | |
| 89 virtual void SetOpacity(unsigned char opacity) OVERRIDE; | |
| 90 virtual void SetWindowIcons(const gfx::ImageSkia& window_icon, | |
| 91 const gfx::ImageSkia& app_icon) OVERRIDE; | |
| 92 virtual void SetAccessibleName(const string16& name) OVERRIDE; | |
| 93 virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; | |
| 94 virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; | |
| 95 virtual void InitModalType(ui::ModalType modal_type) OVERRIDE; | |
| 96 virtual void FlashFrame(bool flash_frame) OVERRIDE; | |
| 97 virtual void OnNativeWidgetFocus() OVERRIDE; | |
| 98 virtual void OnNativeWidgetBlur() OVERRIDE; | |
| 99 | |
| 100 // Overridden from aura::RootWindowHost: | |
| 101 virtual void SetDelegate(aura::RootWindowHostDelegate* delegate) OVERRIDE; | |
| 102 virtual aura::RootWindow* GetRootWindow() OVERRIDE; | |
| 103 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; | |
| 104 virtual void Show() OVERRIDE; | |
| 105 virtual void Hide() OVERRIDE; | |
| 106 virtual void ToggleFullScreen() OVERRIDE; | |
| 107 virtual gfx::Rect GetBounds() const OVERRIDE; | |
| 108 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | |
| 109 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; | |
| 110 virtual void SetCapture() OVERRIDE; | |
| 111 virtual void ReleaseCapture() OVERRIDE; | |
| 112 virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; | |
| 113 virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE; | |
| 114 virtual bool ConfineCursorToRootWindow() OVERRIDE; | |
| 115 virtual void UnConfineCursor() OVERRIDE; | |
| 116 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; | |
| 117 virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; | |
| 118 virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, | |
| 119 const gfx::Point& dest_offset, | |
| 120 SkCanvas* canvas) OVERRIDE; | |
| 121 virtual bool GrabSnapshot( | |
| 122 const gfx::Rect& snapshot_bounds, | |
| 123 std::vector<unsigned char>* png_representation) OVERRIDE; | |
| 124 virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; | |
| 125 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; | |
| 126 virtual void PrepareForShutdown() OVERRIDE; | |
| 127 | |
| 128 // Overridden from HWNDMessageHandlerDelegate: | |
| 129 virtual bool IsWidgetWindow() const OVERRIDE; | |
| 130 virtual bool IsUsingCustomFrame() const OVERRIDE; | |
| 131 virtual void SchedulePaint() OVERRIDE; | |
| 132 virtual void EnableInactiveRendering() OVERRIDE; | |
| 133 virtual bool IsInactiveRenderingDisabled() OVERRIDE; | |
| 134 virtual bool CanResize() const OVERRIDE; | |
| 135 virtual bool CanMaximize() const OVERRIDE; | |
| 136 virtual bool CanActivate() const OVERRIDE; | |
| 137 virtual bool WidgetSizeIsClientSize() const OVERRIDE; | |
| 138 virtual bool CanSaveFocus() const OVERRIDE; | |
| 139 virtual void SaveFocusOnDeactivate() OVERRIDE; | |
| 140 virtual void RestoreFocusOnActivate() OVERRIDE; | |
| 141 virtual void RestoreFocusOnEnable() OVERRIDE; | |
| 142 virtual bool IsModal() const OVERRIDE; | |
| 143 virtual int GetInitialShowState() const OVERRIDE; | |
| 144 virtual bool WillProcessWorkAreaChange() const OVERRIDE; | |
| 145 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; | |
| 146 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* path) OVERRIDE; | |
| 147 virtual bool GetClientAreaInsets(gfx::Insets* insets) const OVERRIDE; | |
| 148 virtual void GetMinMaxSize(gfx::Size* min_size, | |
| 149 gfx::Size* max_size) const OVERRIDE; | |
| 150 virtual gfx::Size GetRootViewSize() const OVERRIDE; | |
| 151 virtual void ResetWindowControls() OVERRIDE; | |
| 152 virtual void PaintLayeredWindow(gfx::Canvas* canvas) OVERRIDE; | |
| 153 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; | |
| 154 virtual InputMethod* GetInputMethod() OVERRIDE; | |
| 155 virtual void HandleAppDeactivated() OVERRIDE; | |
| 156 virtual void HandleActivationChanged(bool active) OVERRIDE; | |
| 157 virtual bool HandleAppCommand(short command) OVERRIDE; | |
| 158 virtual void HandleCaptureLost() OVERRIDE; | |
| 159 virtual void HandleClose() OVERRIDE; | |
| 160 virtual bool HandleCommand(int command) OVERRIDE; | |
| 161 virtual void HandleAccelerator(const ui::Accelerator& accelerator) OVERRIDE; | |
| 162 virtual void HandleCreate() OVERRIDE; | |
| 163 virtual void HandleDestroying() OVERRIDE; | |
| 164 virtual void HandleDestroyed() OVERRIDE; | |
| 165 virtual bool HandleInitialFocus() OVERRIDE; | |
| 166 virtual void HandleDisplayChange() OVERRIDE; | |
| 167 virtual void HandleBeginWMSizeMove() OVERRIDE; | |
| 168 virtual void HandleEndWMSizeMove() OVERRIDE; | |
| 169 virtual void HandleMove() OVERRIDE; | |
| 170 virtual void HandleWorkAreaChanged() OVERRIDE; | |
| 171 virtual void HandleVisibilityChanged(bool visible) OVERRIDE; | |
| 172 virtual void HandleClientSizeChanged(const gfx::Size& new_size) OVERRIDE; | |
| 173 virtual void HandleFrameChanged() OVERRIDE; | |
| 174 virtual void HandleNativeFocus(HWND last_focused_window) OVERRIDE; | |
| 175 virtual void HandleNativeBlur(HWND focused_window) OVERRIDE; | |
| 176 virtual bool HandleMouseEvent(const ui::MouseEvent& event) OVERRIDE; | |
| 177 virtual bool HandleKeyEvent(const ui::KeyEvent& event) OVERRIDE; | |
| 178 virtual bool HandleUntranslatedKeyEvent(const ui::KeyEvent& event) OVERRIDE; | |
| 179 virtual bool HandleIMEMessage(UINT message, | |
| 180 WPARAM w_param, | |
| 181 LPARAM l_param, | |
| 182 LRESULT* result) OVERRIDE; | |
| 183 virtual void HandleInputLanguageChange(DWORD character_set, | |
| 184 HKL input_language_id) OVERRIDE; | |
| 185 virtual bool HandlePaintAccelerated(const gfx::Rect& invalid_rect) OVERRIDE; | |
| 186 virtual void HandlePaint(gfx::Canvas* canvas) OVERRIDE; | |
| 187 virtual void HandleScreenReaderDetected() OVERRIDE; | |
| 188 virtual bool HandleTooltipNotify(int w_param, | |
| 189 NMHDR* l_param, | |
| 190 LRESULT* l_result) OVERRIDE; | |
| 191 virtual void HandleTooltipMouseMove(UINT message, | |
| 192 WPARAM w_param, | |
| 193 LPARAM l_param) OVERRIDE; | |
| 194 virtual bool PreHandleMSG(UINT message, | |
| 195 WPARAM w_param, | |
| 196 LPARAM l_param, | |
| 197 LRESULT* result) OVERRIDE; | |
| 198 virtual void PostHandleMSG(UINT message, | |
| 199 WPARAM w_param, | |
| 200 LPARAM l_param) OVERRIDE; | |
| 201 | |
| 202 Widget* GetWidget(); | |
| 203 const Widget* GetWidget() const; | |
| 204 HWND GetHWND() const; | |
| 205 | |
| 206 private: | |
| 207 // We are owned by the RootWindow, but we have to have a back pointer to it. | |
| 208 aura::RootWindow* root_window_; | |
| 209 | |
| 210 scoped_ptr<HWNDMessageHandler> message_handler_; | |
| 211 scoped_ptr<aura::client::DefaultCaptureClient> capture_client_; | |
| 212 scoped_ptr<DesktopDispatcherClient> dispatcher_client_; | |
| 213 scoped_ptr<aura::FocusManager> focus_manager_; | |
| 214 // Depends on focus_manager_. | |
| 215 scoped_ptr<DesktopActivationClient> activation_client_; | |
| 216 scoped_ptr<corewm::InputMethodEventFilter> input_method_filter_; | |
| 217 | |
| 218 // TODO(beng): Consider providing an interface to DesktopNativeWidgetAura | |
| 219 // instead of providing this route back to Widget. | |
| 220 internal::NativeWidgetDelegate* native_widget_delegate_; | |
| 221 | |
| 222 DesktopNativeWidgetAura* desktop_native_widget_aura_; | |
| 223 | |
| 224 aura::RootWindowHostDelegate* root_window_host_delegate_; | |
| 225 aura::Window* content_window_; | |
| 226 | |
| 227 // In some cases, we set a screen position client on |root_window_|. If we | |
| 228 // do, we're responsible for the lifetime. | |
| 229 scoped_ptr<aura::client::ScreenPositionClient> position_client_; | |
| 230 | |
| 231 // A simple cursor client which just forwards events to the RootWindow. | |
| 232 scoped_ptr<DesktopCursorClient> cursor_client_; | |
| 233 | |
| 234 // The RootWindow's CompoundEventFilter. | |
| 235 views::corewm::CompoundEventFilter* root_window_event_filter_; | |
| 236 | |
| 237 DISALLOW_COPY_AND_ASSIGN(DesktopRootWindowHostWin); | |
| 238 }; | |
| 239 | |
| 240 } // namespace views | |
| 241 | |
| 242 #endif // UI_VIEWS_WIDGET_DESKTOP_ROOT_WINDOW_HOST_WIN_H_ | |
| OLD | NEW |