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.
5 #ifndef UI_AURA_WINDOW_TREE_HOST_WIN_H_
6 #define UI_AURA_WINDOW_TREE_HOST_WIN_H_
8 #include "base/compiler_specific.h"
9 #include "ui/aura/aura_export.h"
10 #include "ui/aura/window_tree_host.h"
11 #include "ui/events/event_source.h"
12 #include "ui/gfx/win/window_impl.h"
16 class WindowTreeHostWin
: public WindowTreeHost
,
17 public ui::EventSource
,
18 public gfx::WindowImpl
{
20 WindowTreeHostWin(const gfx::Rect
& bounds
);
21 virtual ~WindowTreeHostWin();
23 virtual gfx::AcceleratedWidget
GetAcceleratedWidget() OVERRIDE
;
24 virtual void Show() OVERRIDE
;
25 virtual void Hide() OVERRIDE
;
26 virtual void ToggleFullScreen() OVERRIDE
;
27 virtual gfx::Rect
GetBounds() const OVERRIDE
;
28 virtual void SetBounds(const gfx::Rect
& bounds
) OVERRIDE
;
29 virtual gfx::Insets
GetInsets() const OVERRIDE
;
30 virtual void SetInsets(const gfx::Insets
& insets
) OVERRIDE
;
31 virtual gfx::Point
GetLocationOnNativeScreen() const OVERRIDE
;
32 virtual void SetCapture() OVERRIDE
;
33 virtual void ReleaseCapture() OVERRIDE
;
34 virtual bool QueryMouseLocation(gfx::Point
* location_return
) OVERRIDE
;
35 virtual bool ConfineCursorToRootWindow() OVERRIDE
;
36 virtual void UnConfineCursor() OVERRIDE
;
37 virtual void SetCursorNative(gfx::NativeCursor cursor
) OVERRIDE
;
38 virtual void MoveCursorToNative(const gfx::Point
& location
) OVERRIDE
;
39 virtual void OnCursorVisibilityChangedNative(bool show
) OVERRIDE
;
40 virtual void PostNativeEvent(const base::NativeEvent
& native_event
) OVERRIDE
;
41 virtual void OnDeviceScaleFactorChanged(float device_scale_factor
) OVERRIDE
;
44 virtual ui::EventProcessor
* GetEventProcessor() OVERRIDE
;
47 CR_BEGIN_MSG_MAP_EX(WindowTreeHostWin
)
48 // Range handlers must go first!
49 CR_MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST
, WM_MOUSELAST
, OnMouseRange
)
50 CR_MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE
,
54 // Mouse capture events.
55 CR_MESSAGE_HANDLER_EX(WM_CAPTURECHANGED
, OnCaptureChanged
)
58 CR_MESSAGE_HANDLER_EX(WM_KEYDOWN
, OnKeyEvent
)
59 CR_MESSAGE_HANDLER_EX(WM_KEYUP
, OnKeyEvent
)
60 CR_MESSAGE_HANDLER_EX(WM_SYSKEYDOWN
, OnKeyEvent
)
61 CR_MESSAGE_HANDLER_EX(WM_SYSKEYUP
, OnKeyEvent
)
62 CR_MESSAGE_HANDLER_EX(WM_CHAR
, OnKeyEvent
)
63 CR_MESSAGE_HANDLER_EX(WM_SYSCHAR
, OnKeyEvent
)
64 CR_MESSAGE_HANDLER_EX(WM_IME_CHAR
, OnKeyEvent
)
65 CR_MESSAGE_HANDLER_EX(WM_NCACTIVATE
, OnNCActivate
)
67 CR_MSG_WM_CLOSE(OnClose
)
68 CR_MSG_WM_MOVE(OnMove
)
69 CR_MSG_WM_PAINT(OnPaint
)
70 CR_MSG_WM_SIZE(OnSize
)
74 LRESULT
OnKeyEvent(UINT message
, WPARAM w_param
, LPARAM l_param
);
75 LRESULT
OnMouseRange(UINT message
, WPARAM w_param
, LPARAM l_param
);
76 LRESULT
OnCaptureChanged(UINT message
, WPARAM w_param
, LPARAM l_param
);
77 LRESULT
OnNCActivate(UINT message
, WPARAM w_param
, LPARAM l_param
);
78 void OnMove(const gfx::Point
& point
);
80 void OnSize(UINT param
, const gfx::Size
& size
);
84 RECT saved_window_rect_
;
85 DWORD saved_window_style_
;
86 DWORD saved_window_ex_style_
;
88 DISALLOW_COPY_AND_ASSIGN(WindowTreeHostWin
);
93 // Set true to let WindowTreeHostWin use a popup window
94 // with no frame/title so that the window size and test's
95 // expectations matches.
96 AURA_EXPORT
void SetUsePopupAsRootWindowForTest(bool use
);
102 #endif // UI_AURA_WINDOW_TREE_HOST_WIN_H_