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_AURA_ROOT_WINDOW_HOST_WIN_H_ 6 #define UI_AURA_ROOT_WINDOW_HOST_WIN_H_ 7 8 #include "base/compiler_specific.h" 9 #include "ui/aura/root_window_host.h" 10 #include "ui/base/ui_export.h" 11 #include "ui/base/win/window_impl.h" 12 13 namespace aura { 14 15 class RootWindowHostWin : public RootWindowHost, public ui::WindowImpl { 16 public: 17 RootWindowHostWin(const gfx::Rect& bounds); 18 virtual ~RootWindowHostWin(); 19 // RootWindowHost: 20 virtual void SetDelegate(RootWindowHostDelegate* delegate) OVERRIDE; 21 virtual RootWindow* GetRootWindow() OVERRIDE; 22 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; 23 virtual void Show() OVERRIDE; 24 virtual void Hide() OVERRIDE; 25 virtual void ToggleFullScreen() OVERRIDE; 26 virtual gfx::Rect GetBounds() const OVERRIDE; 27 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; 28 virtual gfx::Insets GetInsets() const OVERRIDE; 29 virtual void SetInsets(const gfx::Insets& insets) OVERRIDE; 30 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; 31 virtual void SetCapture() OVERRIDE; 32 virtual void ReleaseCapture() OVERRIDE; 33 virtual void SetCursor(gfx::NativeCursor cursor) OVERRIDE; 34 virtual bool QueryMouseLocation(gfx::Point* location_return) OVERRIDE; 35 virtual bool ConfineCursorToRootWindow() OVERRIDE; 36 virtual void UnConfineCursor() OVERRIDE; 37 virtual void OnCursorVisibilityChanged(bool show) OVERRIDE; 38 virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; 39 virtual void SetFocusWhenShown(bool focus_when_shown) OVERRIDE; 40 virtual bool CopyAreaToSkCanvas(const gfx::Rect& source_bounds, 41 const gfx::Point& dest_offset, 42 SkCanvas* canvas) OVERRIDE; 43 virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; 44 virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE; 45 virtual void PrepareForShutdown() OVERRIDE; 46 47 private: 48 BEGIN_MSG_MAP_EX(RootWindowHostWin) 49 // Range handlers must go first! 50 MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) 51 MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, WM_NCXBUTTONDBLCLK, OnMouseRange) 52 53 // Mouse capture events. 54 MESSAGE_HANDLER_EX(WM_CAPTURECHANGED, OnCaptureChanged) 55 56 // Key events. 57 MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyEvent) 58 MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyEvent) 59 MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyEvent) 60 MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyEvent) 61 MESSAGE_HANDLER_EX(WM_CHAR, OnKeyEvent) 62 MESSAGE_HANDLER_EX(WM_SYSCHAR, OnKeyEvent) 63 MESSAGE_HANDLER_EX(WM_IME_CHAR, OnKeyEvent) 64 MESSAGE_HANDLER_EX(WM_NCACTIVATE, OnNCActivate) 65 66 MSG_WM_CLOSE(OnClose) 67 MSG_WM_MOVE(OnMove) 68 MSG_WM_PAINT(OnPaint) 69 MSG_WM_SIZE(OnSize) 70 END_MSG_MAP() 71 72 void OnClose(); 73 LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param); 74 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param); 75 LRESULT OnCaptureChanged(UINT message, WPARAM w_param, LPARAM l_param); 76 LRESULT OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param); 77 void OnMove(const CPoint& point); 78 void OnPaint(HDC dc); 79 void OnSize(UINT param, const CSize& size); 80 81 RootWindowHostDelegate* delegate_; 82 83 bool fullscreen_; 84 bool has_capture_; 85 RECT saved_window_rect_; 86 DWORD saved_window_style_; 87 DWORD saved_window_ex_style_; 88 89 DISALLOW_COPY_AND_ASSIGN(RootWindowHostWin); 90 }; 91 92 namespace test { 93 94 // Set true to let RootWindowHostWin use a popup window 95 // with no frame/title so that the window size and test's 96 // expectations matches. 97 AURA_EXPORT void SetUsePopupAsRootWindowForTest(bool use); 98 99 } // namespace 100 101 } // namespace aura 102 103 #endif // UI_AURA_ROOT_WINDOW_HOST_WIN_H_ 104