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_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ | 5 #ifndef UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ |
6 #define UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ | 6 #define UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ |
7 | 7 |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 #include <atlapp.h> | 9 #include <atlapp.h> |
10 #include <atlmisc.h> | 10 #include <atlmisc.h> |
11 #include <windows.h> | 11 #include <windows.h> |
12 | 12 |
13 #include <set> | 13 #include <set> |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
| 19 #include "base/string16.h" |
19 #include "ui/base/accessibility/accessibility_types.h" | 20 #include "ui/base/accessibility/accessibility_types.h" |
20 #include "ui/base/ui_base_types.h" | 21 #include "ui/base/ui_base_types.h" |
21 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
22 #include "ui/views/ime/input_method_delegate.h" | 23 #include "ui/views/ime/input_method_delegate.h" |
23 #include "ui/views/views_export.h" | 24 #include "ui/views/views_export.h" |
24 | 25 |
25 namespace gfx { | 26 namespace gfx { |
26 class Canvas; | 27 class Canvas; |
| 28 class ImageSkia; |
27 class Insets; | 29 class Insets; |
28 } | 30 } |
29 | 31 |
30 namespace views { | 32 namespace views { |
31 | 33 |
32 class FullscreenHandler; | 34 class FullscreenHandler; |
33 class HWNDMessageHandlerDelegate; | 35 class HWNDMessageHandlerDelegate; |
34 class InputMethod; | 36 class InputMethod; |
35 | 37 |
36 VIEWS_EXPORT bool IsAeroGlassEnabled(); | 38 VIEWS_EXPORT bool IsAeroGlassEnabled(); |
37 | 39 |
38 // An object that handles messages for a HWND that implements the views | 40 // An object that handles messages for a HWND that implements the views |
39 // "Custom Frame" look. The purpose of this class is to isolate the windows- | 41 // "Custom Frame" look. The purpose of this class is to isolate the windows- |
40 // specific message handling from the code that wraps it. It is intended to be | 42 // specific message handling from the code that wraps it. It is intended to be |
41 // used by both a views::NativeWidget and an aura::RootWindowHost | 43 // used by both a views::NativeWidget and an aura::RootWindowHost |
42 // implementation. | 44 // implementation. |
43 // TODO(beng): This object should eventually *become* the WindowImpl. | 45 // TODO(beng): This object should eventually *become* the WindowImpl. |
44 class VIEWS_EXPORT HWNDMessageHandler : public internal::InputMethodDelegate { | 46 class VIEWS_EXPORT HWNDMessageHandler : public internal::InputMethodDelegate { |
45 public: | 47 public: |
46 explicit HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate); | 48 explicit HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate); |
47 ~HWNDMessageHandler(); | 49 ~HWNDMessageHandler(); |
48 | 50 |
49 void Init(const gfx::Rect& bounds); | 51 void Init(const gfx::Rect& bounds); |
50 void InitModalType(ui::ModalType modal_type); | 52 void InitModalType(ui::ModalType modal_type); |
51 | 53 |
| 54 void Close(); |
52 void CloseNow(); | 55 void CloseNow(); |
53 | 56 |
54 gfx::Rect GetWindowBoundsInScreen() const; | 57 gfx::Rect GetWindowBoundsInScreen() const; |
55 gfx::Rect GetClientAreaBoundsInScreen() const; | 58 gfx::Rect GetClientAreaBoundsInScreen() const; |
56 gfx::Rect GetRestoredBounds() const; | 59 gfx::Rect GetRestoredBounds() const; |
57 void GetWindowPlacement(gfx::Rect* bounds, | 60 void GetWindowPlacement(gfx::Rect* bounds, |
58 ui::WindowShowState* show_state) const; | 61 ui::WindowShowState* show_state) const; |
59 gfx::Rect GetWorkAreaBoundsInScreen() const; | 62 gfx::Rect GetWorkAreaBoundsInScreen() const; |
60 | 63 |
61 void SetBounds(const gfx::Rect& bounds); | 64 void SetBounds(const gfx::Rect& bounds); |
62 void SetSize(const gfx::Size& size); | 65 void SetSize(const gfx::Size& size); |
63 void CenterWindow(const gfx::Size& size); | 66 void CenterWindow(const gfx::Size& size); |
64 | 67 |
65 void SetRegion(HRGN rgn); | 68 void SetRegion(HRGN rgn); |
66 | 69 |
67 void StackAbove(HWND other_hwnd); | 70 void StackAbove(HWND other_hwnd); |
68 void StackAtTop(); | 71 void StackAtTop(); |
69 | 72 |
| 73 void Show(); |
| 74 void ShowWindowWithState(ui::WindowShowState show_state); |
| 75 // TODO(beng): distinguish from ShowWindowWithState(). |
| 76 void Show(int show_state); |
70 void ShowMaximizedWithBounds(const gfx::Rect& bounds); | 77 void ShowMaximizedWithBounds(const gfx::Rect& bounds); |
71 void Hide(); | 78 void Hide(); |
72 | 79 |
73 void Maximize(); | 80 void Maximize(); |
74 void Minimize(); | 81 void Minimize(); |
75 void Restore(); | 82 void Restore(); |
76 | 83 |
77 void Activate(); | 84 void Activate(); |
78 void Deactivate(); | 85 void Deactivate(); |
79 | 86 |
80 void SetAlwaysOnTop(bool on_top); | 87 void SetAlwaysOnTop(bool on_top); |
81 | 88 |
82 bool IsVisible() const; | 89 bool IsVisible() const; |
83 bool IsActive() const; | 90 bool IsActive() const; |
84 bool IsMinimized() const; | 91 bool IsMinimized() const; |
85 bool IsMaximized() const; | 92 bool IsMaximized() const; |
86 | 93 |
87 bool RunMoveLoop(const gfx::Point& drag_offset); | 94 bool RunMoveLoop(const gfx::Point& drag_offset); |
| 95 void EndMoveLoop(); |
88 | 96 |
89 // Tells the HWND its client area has changed. | 97 // Tells the HWND its client area has changed. |
90 void SendFrameChanged(); | 98 void SendFrameChanged(); |
91 | 99 |
92 void FlashFrame(bool flash); | 100 void FlashFrame(bool flash); |
93 | 101 |
94 void ClearNativeFocus(); | 102 void ClearNativeFocus(); |
95 void FocusHWND(HWND hwnd); | 103 void FocusHWND(HWND hwnd); |
96 | 104 |
97 void SetCapture(); | 105 void SetCapture(); |
98 void ReleaseCapture(); | 106 void ReleaseCapture(); |
99 bool HasCapture() const; | 107 bool HasCapture() const; |
100 | 108 |
101 FullscreenHandler* fullscreen_handler() { return fullscreen_handler_.get(); } | 109 FullscreenHandler* fullscreen_handler() { return fullscreen_handler_.get(); } |
102 | 110 |
103 void SetVisibilityChangedAnimationsEnabled(bool enabled); | 111 void SetVisibilityChangedAnimationsEnabled(bool enabled); |
104 | 112 |
105 InputMethod* CreateInputMethod(); | 113 InputMethod* CreateInputMethod(); |
106 | 114 |
| 115 void SetTitle(const string16& title); |
| 116 |
| 117 void SetAccessibleName(const string16& name); |
| 118 void SetAccessibleRole(ui::AccessibilityTypes::Role role); |
| 119 void SetAccessibleState(ui::AccessibilityTypes::State state); |
107 void SendNativeAccessibilityEvent(int id, | 120 void SendNativeAccessibilityEvent(int id, |
108 ui::AccessibilityTypes::Event event_type); | 121 ui::AccessibilityTypes::Event event_type); |
109 | 122 |
110 void SetCursor(HCURSOR cursor); | 123 void SetCursor(HCURSOR cursor); |
111 | 124 |
112 void FrameTypeChanged(); | 125 void FrameTypeChanged(); |
113 | 126 |
114 // Disable Layered Window updates by setting to false. | 127 // Disable Layered Window updates by setting to false. |
115 void set_can_update_layered_window(bool can_update_layered_window) { | 128 void set_can_update_layered_window(bool can_update_layered_window) { |
116 can_update_layered_window_ = can_update_layered_window; | 129 can_update_layered_window_ = can_update_layered_window; |
117 } | 130 } |
118 void SchedulePaintInRect(const gfx::Rect& rect); | 131 void SchedulePaintInRect(const gfx::Rect& rect); |
119 void SetOpacity(BYTE opacity); | 132 void SetOpacity(BYTE opacity); |
120 | 133 |
| 134 void SetWindowIcons(const gfx::ImageSkia& window_icon, |
| 135 const gfx::ImageSkia& app_icon); |
| 136 |
121 // Message Handlers. | 137 // Message Handlers. |
122 void OnActivate(UINT action, BOOL minimized, HWND window); | 138 void OnActivate(UINT action, BOOL minimized, HWND window); |
123 // TODO(beng): Once this object becomes the WindowImpl, these methods can | 139 // TODO(beng): Once this object becomes the WindowImpl, these methods can |
124 // be made private. | 140 // be made private. |
125 void OnActivateApp(BOOL active, DWORD thread_id); | 141 void OnActivateApp(BOOL active, DWORD thread_id); |
126 // TODO(beng): return BOOL is temporary until this object becomes a | 142 // TODO(beng): return BOOL is temporary until this object becomes a |
127 // WindowImpl. | 143 // WindowImpl. |
128 BOOL OnAppCommand(HWND window, short command, WORD device, int keystate); | 144 BOOL OnAppCommand(HWND window, short command, WORD device, int keystate); |
129 void OnCancelMode(); | 145 void OnCancelMode(); |
130 void OnCaptureChanged(HWND window); | 146 void OnCaptureChanged(HWND window); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // WindowImpl. | 206 // WindowImpl. |
191 HWND hwnd(); | 207 HWND hwnd(); |
192 HWND hwnd() const; | 208 HWND hwnd() const; |
193 | 209 |
194 private: | 210 private: |
195 typedef std::set<DWORD> TouchIDs; | 211 typedef std::set<DWORD> TouchIDs; |
196 | 212 |
197 // TODO(beng): remove once this is the WindowImpl. | 213 // TODO(beng): remove once this is the WindowImpl. |
198 friend class NativeWidgetWin; | 214 friend class NativeWidgetWin; |
199 | 215 |
200 // Overridden from internal::InputMethodDelegate | 216 // Overridden from internal::InputMethodDelegate: |
201 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE; | 217 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE; |
202 | 218 |
| 219 // Overridden from WindowImpl: |
| 220 virtual HICON GetDefaultWindowIcon() const; |
| 221 virtual LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param); |
| 222 |
| 223 // Can be called after the delegate has had the opportunity to set focus and |
| 224 // did not do so. |
| 225 void SetInitialFocus(); |
| 226 |
| 227 // Called after the WM_ACTIVATE message has been processed by the default |
| 228 // windows procedure. |
| 229 void PostProcessActivateMessage(int activation_state); |
| 230 |
| 231 // Enables disabled owner windows that may have been disabled due to this |
| 232 // window's modality. |
| 233 void RestoreEnabledIfNecessary(); |
| 234 |
203 // Executes the specified SC_command. | 235 // Executes the specified SC_command. |
204 void ExecuteSystemMenuCommand(int command); | 236 void ExecuteSystemMenuCommand(int command); |
205 | 237 |
206 // Start tracking all mouse events so that this window gets sent mouse leave | 238 // Start tracking all mouse events so that this window gets sent mouse leave |
207 // messages too. | 239 // messages too. |
208 void TrackMouseEvents(DWORD mouse_tracking_flags); | 240 void TrackMouseEvents(DWORD mouse_tracking_flags); |
209 | 241 |
210 // Responds to the client area changing size, either at window creation time | 242 // Responds to the client area changing size, either at window creation time |
211 // or subsequently. | 243 // or subsequently. |
212 void ClientAreaSizeChanged(); | 244 void ClientAreaSizeChanged(); |
(...skipping 28 matching lines...) Expand all Loading... |
241 // layered windows only. | 273 // layered windows only. |
242 void RedrawLayeredWindowContents(); | 274 void RedrawLayeredWindowContents(); |
243 | 275 |
244 // TODO(beng): Remove once this class becomes the WindowImpl. | 276 // TODO(beng): Remove once this class becomes the WindowImpl. |
245 void SetMsgHandled(BOOL handled); | 277 void SetMsgHandled(BOOL handled); |
246 | 278 |
247 HWNDMessageHandlerDelegate* delegate_; | 279 HWNDMessageHandlerDelegate* delegate_; |
248 | 280 |
249 scoped_ptr<FullscreenHandler> fullscreen_handler_; | 281 scoped_ptr<FullscreenHandler> fullscreen_handler_; |
250 | 282 |
| 283 // The following factory is used for calls to close the NativeWidgetWin |
| 284 // instance. |
| 285 base::WeakPtrFactory<HWNDMessageHandler> close_widget_factory_; |
| 286 |
251 bool remove_standard_frame_; | 287 bool remove_standard_frame_; |
252 | 288 |
| 289 // Whether the focus should be restored next time we get enabled. Needed to |
| 290 // restore focus correctly when Windows modal dialogs are displayed. |
| 291 bool restore_focus_when_enabled_; |
| 292 |
| 293 // Whether all ancestors have been enabled. This is only used if is_modal_ is |
| 294 // true. |
| 295 bool restored_enabled_; |
| 296 |
253 // The last cursor that was active before the current one was selected. Saved | 297 // The last cursor that was active before the current one was selected. Saved |
254 // so that we can restore it. | 298 // so that we can restore it. |
255 HCURSOR previous_cursor_; | 299 HCURSOR previous_cursor_; |
256 | 300 |
257 // Event handling ------------------------------------------------------------ | 301 // Event handling ------------------------------------------------------------ |
258 | 302 |
259 // The flags currently being used with TrackMouseEvent to track mouse | 303 // The flags currently being used with TrackMouseEvent to track mouse |
260 // messages. 0 if there is no active tracking. The value of this member is | 304 // messages. 0 if there is no active tracking. The value of this member is |
261 // used when tracking is canceled. | 305 // used when tracking is canceled. |
262 DWORD active_mouse_tracking_flags_; | 306 DWORD active_mouse_tracking_flags_; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 // True if we are allowed to update the layered window from the DIB backing | 375 // True if we are allowed to update the layered window from the DIB backing |
332 // store if necessary. | 376 // store if necessary. |
333 bool can_update_layered_window_; | 377 bool can_update_layered_window_; |
334 | 378 |
335 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); | 379 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); |
336 }; | 380 }; |
337 | 381 |
338 } // namespace views | 382 } // namespace views |
339 | 383 |
340 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ | 384 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ |
OLD | NEW |