Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: ui/views/win/hwnd_message_handler.h

Issue 10871077: Move more code from NWW to HWNDMessageHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/win/DEPS ('k') | ui/views/win/hwnd_message_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/base/accessibility/accessibility_types.h"
19 #include "ui/base/ui_base_types.h" 20 #include "ui/base/ui_base_types.h"
20 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
21 #include "ui/views/ime/input_method_delegate.h" 22 #include "ui/views/ime/input_method_delegate.h"
22 #include "ui/views/views_export.h" 23 #include "ui/views/views_export.h"
23 24
24 namespace gfx { 25 namespace gfx {
26 class Canvas;
25 class Insets; 27 class Insets;
26 } 28 }
27 29
28 namespace views { 30 namespace views {
29 31
30 class FullscreenHandler; 32 class FullscreenHandler;
31 class HWNDMessageHandlerDelegate; 33 class HWNDMessageHandlerDelegate;
32 class InputMethod; 34 class InputMethod;
33 35
34 VIEWS_EXPORT bool IsAeroGlassEnabled(); 36 VIEWS_EXPORT bool IsAeroGlassEnabled();
(...skipping 12 matching lines...) Expand all
47 void Init(const gfx::Rect& bounds); 49 void Init(const gfx::Rect& bounds);
48 void InitModalType(ui::ModalType modal_type); 50 void InitModalType(ui::ModalType modal_type);
49 51
50 void CloseNow(); 52 void CloseNow();
51 53
52 gfx::Rect GetWindowBoundsInScreen() const; 54 gfx::Rect GetWindowBoundsInScreen() const;
53 gfx::Rect GetClientAreaBoundsInScreen() const; 55 gfx::Rect GetClientAreaBoundsInScreen() const;
54 gfx::Rect GetRestoredBounds() const; 56 gfx::Rect GetRestoredBounds() const;
55 void GetWindowPlacement(gfx::Rect* bounds, 57 void GetWindowPlacement(gfx::Rect* bounds,
56 ui::WindowShowState* show_state) const; 58 ui::WindowShowState* show_state) const;
59 gfx::Rect GetWorkAreaBoundsInScreen() const;
57 60
58 void SetBounds(const gfx::Rect& bounds); 61 void SetBounds(const gfx::Rect& bounds);
59 void SetSize(const gfx::Size& size); 62 void SetSize(const gfx::Size& size);
63 void CenterWindow(const gfx::Size& size);
60 64
61 void SetRegion(HRGN rgn); 65 void SetRegion(HRGN rgn);
62 66
63 void StackAbove(HWND other_hwnd); 67 void StackAbove(HWND other_hwnd);
64 void StackAtTop(); 68 void StackAtTop();
65 69
66 void ShowMaximizedWithBounds(const gfx::Rect& bounds); 70 void ShowMaximizedWithBounds(const gfx::Rect& bounds);
67 void Hide(); 71 void Hide();
68 72
69 void Maximize(); 73 void Maximize();
70 void Minimize(); 74 void Minimize();
71 void Restore(); 75 void Restore();
72 76
73 void Activate(); 77 void Activate();
74 void Deactivate(); 78 void Deactivate();
75 79
76 void SetAlwaysOnTop(bool on_top); 80 void SetAlwaysOnTop(bool on_top);
77 81
78 bool IsVisible() const; 82 bool IsVisible() const;
79 bool IsActive() const; 83 bool IsActive() const;
80 bool IsMinimized() const; 84 bool IsMinimized() const;
81 bool IsMaximized() const; 85 bool IsMaximized() const;
82 86
87 bool RunMoveLoop(const gfx::Point& drag_offset);
88
83 // Tells the HWND its client area has changed. 89 // Tells the HWND its client area has changed.
84 void SendFrameChanged(); 90 void SendFrameChanged();
85 91
86 void FlashFrame(bool flash); 92 void FlashFrame(bool flash);
87 93
88 void ClearNativeFocus(); 94 void ClearNativeFocus();
89 void FocusHWND(HWND hwnd); 95 void FocusHWND(HWND hwnd);
90 96
91 void SetCapture(); 97 void SetCapture();
92 void ReleaseCapture(); 98 void ReleaseCapture();
93 bool HasCapture() const; 99 bool HasCapture() const;
94 100
95 FullscreenHandler* fullscreen_handler() { return fullscreen_handler_.get(); } 101 FullscreenHandler* fullscreen_handler() { return fullscreen_handler_.get(); }
96 102
97 void SetVisibilityChangedAnimationsEnabled(bool enabled); 103 void SetVisibilityChangedAnimationsEnabled(bool enabled);
98 104
99 InputMethod* CreateInputMethod(); 105 InputMethod* CreateInputMethod();
100 106
107 void SendNativeAccessibilityEvent(int id,
108 ui::AccessibilityTypes::Event event_type);
109
110 void SetCursor(HCURSOR cursor);
111
112 void FrameTypeChanged();
113
114 // Disable Layered Window updates by setting to false.
115 void set_can_update_layered_window(bool can_update_layered_window) {
116 can_update_layered_window_ = can_update_layered_window;
117 }
118 void SchedulePaintInRect(const gfx::Rect& rect);
119 void SetOpacity(BYTE opacity);
120
101 // Message Handlers. 121 // Message Handlers.
102 void OnActivate(UINT action, BOOL minimized, HWND window); 122 void OnActivate(UINT action, BOOL minimized, HWND window);
103 // TODO(beng): Once this object becomes the WindowImpl, these methods can 123 // TODO(beng): Once this object becomes the WindowImpl, these methods can
104 // be made private. 124 // be made private.
105 void OnActivateApp(BOOL active, DWORD thread_id); 125 void OnActivateApp(BOOL active, DWORD thread_id);
106 // TODO(beng): return BOOL is temporary until this object becomes a 126 // TODO(beng): return BOOL is temporary until this object becomes a
107 // WindowImpl. 127 // WindowImpl.
108 BOOL OnAppCommand(HWND window, short command, WORD device, int keystate); 128 BOOL OnAppCommand(HWND window, short command, WORD device, int keystate);
109 void OnCancelMode(); 129 void OnCancelMode();
110 void OnCaptureChanged(HWND window); 130 void OnCaptureChanged(HWND window);
(...skipping 17 matching lines...) Expand all
128 void OnInputLangChange(DWORD character_set, HKL input_language_id); 148 void OnInputLangChange(DWORD character_set, HKL input_language_id);
129 LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param); 149 LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param);
130 void OnKillFocus(HWND focused_window); 150 void OnKillFocus(HWND focused_window);
131 LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param); 151 LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param);
132 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param); 152 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param);
133 void OnMove(const CPoint& point); 153 void OnMove(const CPoint& point);
134 void OnMoving(UINT param, const RECT* new_bounds); 154 void OnMoving(UINT param, const RECT* new_bounds);
135 LRESULT OnNCActivate(BOOL active); 155 LRESULT OnNCActivate(BOOL active);
136 LRESULT OnNCCalcSize(BOOL mode, LPARAM l_param); 156 LRESULT OnNCCalcSize(BOOL mode, LPARAM l_param);
137 LRESULT OnNCHitTest(const CPoint& point); 157 LRESULT OnNCHitTest(const CPoint& point);
158 void OnNCPaint(HRGN rgn);
138 LRESULT OnNCUAHDrawCaption(UINT message, WPARAM w_param, LPARAM l_param); 159 LRESULT OnNCUAHDrawCaption(UINT message, WPARAM w_param, LPARAM l_param);
139 LRESULT OnNCUAHDrawFrame(UINT message, WPARAM w_param, LPARAM l_param); 160 LRESULT OnNCUAHDrawFrame(UINT message, WPARAM w_param, LPARAM l_param);
140 LRESULT OnNotify(int w_param, NMHDR* l_param); 161 LRESULT OnNotify(int w_param, NMHDR* l_param);
162 void OnPaint(HDC dc);
141 LRESULT OnPowerBroadcast(DWORD power_event, DWORD data); 163 LRESULT OnPowerBroadcast(DWORD power_event, DWORD data);
142 LRESULT OnReflectedMessage(UINT message, WPARAM w_param, LPARAM l_param); 164 LRESULT OnReflectedMessage(UINT message, WPARAM w_param, LPARAM l_param);
143 LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param); 165 LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param);
144 void OnSetFocus(HWND last_focused_window); 166 void OnSetFocus(HWND last_focused_window);
145 LRESULT OnSetIcon(UINT size_type, HICON new_icon); 167 LRESULT OnSetIcon(UINT size_type, HICON new_icon);
146 LRESULT OnSetText(const wchar_t* text); 168 LRESULT OnSetText(const wchar_t* text);
147 void OnSettingChange(UINT flags, const wchar_t* section); 169 void OnSettingChange(UINT flags, const wchar_t* section);
148 void OnSize(UINT param, const CSize& size); 170 void OnSize(UINT param, const CSize& size);
149 void OnSysCommand(UINT notification_code, const CPoint& point); 171 void OnSysCommand(UINT notification_code, const CPoint& point);
150 void OnThemeChanged(); 172 void OnThemeChanged();
151 LRESULT OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param); 173 LRESULT OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param);
152 void OnVScroll(int scroll_type, short position, HWND scrollbar); 174 void OnVScroll(int scroll_type, short position, HWND scrollbar);
153 void OnWindowPosChanging(WINDOWPOS* window_pos); 175 void OnWindowPosChanging(WINDOWPOS* window_pos);
154 void OnWindowPosChanged(WINDOWPOS* window_pos); 176 void OnWindowPosChanged(WINDOWPOS* window_pos);
155 177
156 // TODO(beng): Can be removed once this object becomes the WindowImpl. 178 // TODO(beng): Can be removed once this object becomes the WindowImpl.
157 bool remove_standard_frame() const { return remove_standard_frame_; } 179 bool remove_standard_frame() const { return remove_standard_frame_; }
158 void set_remove_standard_frame(bool remove_standard_frame) { 180 void set_remove_standard_frame(bool remove_standard_frame) {
159 remove_standard_frame_ = remove_standard_frame; 181 remove_standard_frame_ = remove_standard_frame;
160 } 182 }
161 183
162 // Resets the window region for the current widget bounds if necessary. 184 // Resets the window region for the current widget bounds if necessary.
163 // If |force| is true, the window region is reset to NULL even for native 185 // If |force| is true, the window region is reset to NULL even for native
164 // frame windows. 186 // frame windows.
165 void ResetWindowRegion(bool force); 187 void ResetWindowRegion(bool force);
166 188
189 // TODO(beng): This won't be a style violation once this object becomes the
190 // WindowImpl.
191 HWND hwnd();
192 HWND hwnd() const;
193
167 private: 194 private:
168 typedef std::set<DWORD> TouchIDs; 195 typedef std::set<DWORD> TouchIDs;
169 196
170 // TODO(beng): remove once this is the WindowImpl. 197 // TODO(beng): remove once this is the WindowImpl.
171 friend class NativeWidgetWin; 198 friend class NativeWidgetWin;
172 199
173 // Overridden from internal::InputMethodDelegate 200 // Overridden from internal::InputMethodDelegate
174 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE; 201 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE;
175 202
176 // Executes the specified SC_command. 203 // Executes the specified SC_command.
(...skipping 23 matching lines...) Expand all
200 227
201 // Lock or unlock the window from being able to redraw itself in response to 228 // Lock or unlock the window from being able to redraw itself in response to
202 // updates to its invalid region. 229 // updates to its invalid region.
203 class ScopedRedrawLock; 230 class ScopedRedrawLock;
204 void LockUpdates(bool force); 231 void LockUpdates(bool force);
205 void UnlockUpdates(bool force); 232 void UnlockUpdates(bool force);
206 233
207 // Stops ignoring SetWindowPos() requests (see below). 234 // Stops ignoring SetWindowPos() requests (see below).
208 void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; } 235 void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; }
209 236
210 // TODO(beng): This won't be a style violation once this object becomes the 237 // Synchronously paints the invalid contents of the Widget.
211 // WindowImpl. 238 void RedrawInvalidRect();
212 HWND hwnd(); 239
213 HWND hwnd() const; 240 // Synchronously updates the invalid contents of the Widget. Valid for
241 // layered windows only.
242 void RedrawLayeredWindowContents();
214 243
215 // TODO(beng): Remove once this class becomes the WindowImpl. 244 // TODO(beng): Remove once this class becomes the WindowImpl.
216 void SetMsgHandled(BOOL handled); 245 void SetMsgHandled(BOOL handled);
217 246
218 HWNDMessageHandlerDelegate* delegate_; 247 HWNDMessageHandlerDelegate* delegate_;
219 248
220 scoped_ptr<FullscreenHandler> fullscreen_handler_; 249 scoped_ptr<FullscreenHandler> fullscreen_handler_;
221 250
222 bool remove_standard_frame_; 251 bool remove_standard_frame_;
223 252
253 // The last cursor that was active before the current one was selected. Saved
254 // so that we can restore it.
255 HCURSOR previous_cursor_;
256
224 // Event handling ------------------------------------------------------------ 257 // Event handling ------------------------------------------------------------
225 258
226 // The flags currently being used with TrackMouseEvent to track mouse 259 // The flags currently being used with TrackMouseEvent to track mouse
227 // messages. 0 if there is no active tracking. The value of this member is 260 // messages. 0 if there is no active tracking. The value of this member is
228 // used when tracking is canceled. 261 // used when tracking is canceled.
229 DWORD active_mouse_tracking_flags_; 262 DWORD active_mouse_tracking_flags_;
230 263
231 // Set to true when the user presses the right mouse button on the caption 264 // Set to true when the user presses the right mouse button on the caption
232 // area. We need this so we can correctly show the context menu on mouse-up. 265 // area. We need this so we can correctly show the context menu on mouse-up.
233 bool is_right_mouse_pressed_on_caption_; 266 bool is_right_mouse_pressed_on_caption_;
(...skipping 21 matching lines...) Expand all
255 288
256 // The following factory is used to ignore SetWindowPos() calls for short time 289 // The following factory is used to ignore SetWindowPos() calls for short time
257 // periods. 290 // periods.
258 base::WeakPtrFactory<HWNDMessageHandler> ignore_pos_changes_factory_; 291 base::WeakPtrFactory<HWNDMessageHandler> ignore_pos_changes_factory_;
259 292
260 // The last-seen monitor containing us, and its rect and work area. These are 293 // The last-seen monitor containing us, and its rect and work area. These are
261 // used to catch updates to the rect and work area and react accordingly. 294 // used to catch updates to the rect and work area and react accordingly.
262 HMONITOR last_monitor_; 295 HMONITOR last_monitor_;
263 gfx::Rect last_monitor_rect_, last_work_area_; 296 gfx::Rect last_monitor_rect_, last_work_area_;
264 297
298 // Layered windows -----------------------------------------------------------
299
300 // Should we keep an off-screen buffer? This is false by default, set to true
301 // when WS_EX_LAYERED is specified before the native window is created.
302 //
303 // NOTE: this is intended to be used with a layered window (a window with an
304 // extended window style of WS_EX_LAYERED). If you are using a layered window
305 // and NOT changing the layered alpha or anything else, then leave this value
306 // alone. OTOH if you are invoking SetLayeredWindowAttributes then you'll
307 // most likely want to set this to false, or after changing the alpha toggle
308 // the extended style bit to false than back to true. See MSDN for more
309 // details.
310 bool use_layered_buffer_;
311
312 // The default alpha to be applied to the layered window.
313 BYTE layered_alpha_;
314
315 // A canvas that contains the window contents in the case of a layered
316 // window.
317 scoped_ptr<gfx::Canvas> layered_window_contents_;
318
319 // We must track the invalid rect ourselves, for two reasons:
320 // For layered windows, Windows will not do this properly with
321 // InvalidateRect()/GetUpdateRect(). (In fact, it'll return misleading
322 // information from GetUpdateRect()).
323 // We also need to keep track of the invalid rectangle for the RootView should
324 // we need to paint the non-client area. The data supplied to WM_NCPAINT seems
325 // to be insufficient.
326 gfx::Rect invalid_rect_;
327
328 // A factory that allows us to schedule a redraw for layered windows.
329 base::WeakPtrFactory<HWNDMessageHandler> paint_layered_window_factory_;
330
331 // True if we are allowed to update the layered window from the DIB backing
332 // store if necessary.
333 bool can_update_layered_window_;
334
265 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); 335 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler);
266 }; 336 };
267 337
268 } // namespace views 338 } // namespace views
269 339
270 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ 340 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_
OLDNEW
« no previous file with comments | « ui/views/win/DEPS ('k') | ui/views/win/hwnd_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698