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_AURA_WINDOW_TREE_HOST_WIN_H_ | 5 #ifndef UI_AURA_WINDOW_TREE_HOST_WIN_H_ |
6 #define UI_AURA_WINDOW_TREE_HOST_WIN_H_ | 6 #define UI_AURA_WINDOW_TREE_HOST_WIN_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" |
9 #include "ui/aura/aura_export.h" | 10 #include "ui/aura/aura_export.h" |
10 #include "ui/aura/window_tree_host.h" | 11 #include "ui/aura/window_tree_host.h" |
11 #include "ui/events/event_source.h" | 12 #include "ui/events/event_source.h" |
12 #include "ui/gfx/win/window_impl.h" | 13 #include "ui/platform_window/platform_window.h" |
| 14 #include "ui/platform_window/platform_window_delegate.h" |
13 | 15 |
14 namespace aura { | 16 namespace aura { |
15 | 17 |
16 class AURA_EXPORT WindowTreeHostWin : public WindowTreeHost, | 18 class AURA_EXPORT WindowTreeHostWin |
17 public ui::EventSource, | 19 : public WindowTreeHost, |
18 public gfx::WindowImpl { | 20 public ui::EventSource, |
| 21 public NON_EXPORTED_BASE(ui::PlatformWindowDelegate) { |
19 public: | 22 public: |
20 explicit WindowTreeHostWin(const gfx::Rect& bounds); | 23 explicit WindowTreeHostWin(const gfx::Rect& bounds); |
21 virtual ~WindowTreeHostWin(); | 24 virtual ~WindowTreeHostWin(); |
| 25 |
22 // WindowTreeHost: | 26 // WindowTreeHost: |
23 virtual ui::EventSource* GetEventSource() OVERRIDE; | 27 virtual ui::EventSource* GetEventSource() OVERRIDE; |
24 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; | 28 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; |
25 virtual void Show() OVERRIDE; | 29 virtual void Show() OVERRIDE; |
26 virtual void Hide() OVERRIDE; | 30 virtual void Hide() OVERRIDE; |
27 virtual gfx::Rect GetBounds() const OVERRIDE; | 31 virtual gfx::Rect GetBounds() const OVERRIDE; |
28 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; | 32 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; |
29 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; | 33 virtual gfx::Point GetLocationOnNativeScreen() const OVERRIDE; |
30 virtual void SetCapture() OVERRIDE; | 34 virtual void SetCapture() OVERRIDE; |
31 virtual void ReleaseCapture() OVERRIDE; | 35 virtual void ReleaseCapture() OVERRIDE; |
32 virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE; | 36 virtual void SetCursorNative(gfx::NativeCursor cursor) OVERRIDE; |
33 virtual void MoveCursorToNative(const gfx::Point& location) OVERRIDE; | 37 virtual void MoveCursorToNative(const gfx::Point& location) OVERRIDE; |
34 virtual void OnCursorVisibilityChangedNative(bool show) OVERRIDE; | 38 virtual void OnCursorVisibilityChangedNative(bool show) OVERRIDE; |
35 virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; | 39 virtual void PostNativeEvent(const base::NativeEvent& native_event) OVERRIDE; |
36 | 40 |
37 // ui::EventSource: | 41 // ui::EventSource: |
38 virtual ui::EventProcessor* GetEventProcessor() OVERRIDE; | 42 virtual ui::EventProcessor* GetEventProcessor() OVERRIDE; |
39 | 43 |
| 44 protected: |
| 45 gfx::AcceleratedWidget hwnd() const { return widget_; } |
| 46 |
40 private: | 47 private: |
41 CR_BEGIN_MSG_MAP_EX(WindowTreeHostWin) | 48 // ui::PlatformWindowDelegate: |
42 // Range handlers must go first! | 49 virtual void OnBoundsChanged(const gfx::Rect& new_bounds) OVERRIDE; |
43 CR_MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) | 50 virtual void OnDamageRect(const gfx::Rect& damaged_region) OVERRIDE; |
44 CR_MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, | 51 virtual void DispatchEvent(ui::Event* event) OVERRIDE; |
45 WM_NCXBUTTONDBLCLK, | 52 virtual void OnCloseRequest() OVERRIDE; |
46 OnMouseRange) | 53 virtual void OnClosed() OVERRIDE; |
47 | 54 virtual void OnWindowStateChanged(ui::PlatformWindowState new_state) OVERRIDE; |
48 // Mouse capture events. | 55 virtual void OnLostCapture() OVERRIDE; |
49 CR_MESSAGE_HANDLER_EX(WM_CAPTURECHANGED, OnCaptureChanged) | 56 virtual void OnAcceleratedWidgetAvailable( |
50 | 57 gfx::AcceleratedWidget widget) OVERRIDE; |
51 // Key events. | 58 virtual void OnActivationChanged(bool active) OVERRIDE; |
52 CR_MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyEvent) | |
53 CR_MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyEvent) | |
54 CR_MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyEvent) | |
55 CR_MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyEvent) | |
56 CR_MESSAGE_HANDLER_EX(WM_CHAR, OnKeyEvent) | |
57 CR_MESSAGE_HANDLER_EX(WM_SYSCHAR, OnKeyEvent) | |
58 CR_MESSAGE_HANDLER_EX(WM_IME_CHAR, OnKeyEvent) | |
59 CR_MESSAGE_HANDLER_EX(WM_NCACTIVATE, OnNCActivate) | |
60 | |
61 CR_MSG_WM_CLOSE(OnClose) | |
62 CR_MSG_WM_MOVE(OnMove) | |
63 CR_MSG_WM_PAINT(OnPaint) | |
64 CR_MSG_WM_SIZE(OnSize) | |
65 CR_END_MSG_MAP() | |
66 | |
67 void OnClose(); | |
68 LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param); | |
69 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param); | |
70 LRESULT OnCaptureChanged(UINT message, WPARAM w_param, LPARAM l_param); | |
71 LRESULT OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param); | |
72 void OnMove(const gfx::Point& point); | |
73 void OnPaint(HDC dc); | |
74 void OnSize(UINT param, const gfx::Size& size); | |
75 | 59 |
76 bool has_capture_; | 60 bool has_capture_; |
| 61 gfx::Rect bounds_; |
| 62 gfx::AcceleratedWidget widget_; |
| 63 scoped_ptr<ui::PlatformWindow> window_; |
77 | 64 |
78 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostWin); | 65 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostWin); |
79 }; | 66 }; |
80 | 67 |
81 namespace test { | |
82 | |
83 // Set true to let WindowTreeHostWin use a popup window | |
84 // with no frame/title so that the window size and test's | |
85 // expectations matches. | |
86 AURA_EXPORT void SetUsePopupAsRootWindowForTest(bool use); | |
87 | |
88 } // namespace | |
89 | |
90 } // namespace aura | 68 } // namespace aura |
91 | 69 |
92 #endif // UI_AURA_WINDOW_TREE_HOST_WIN_H_ | 70 #endif // UI_AURA_WINDOW_TREE_HOST_WIN_H_ |
OLD | NEW |