Revert 268405 "Make sure that ScratchBuffer::Allocate() always r..."
[chromium-blink-merge.git] / ui / views / win / hwnd_message_handler.h
blobbfa1710358d6c84fa2b065a702d3ce0b0c3a4185
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_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_
6 #define UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_
8 #include <windows.h>
10 #include <set>
11 #include <vector>
13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/strings/string16.h"
18 #include "base/win/scoped_gdi_object.h"
19 #include "base/win/win_util.h"
20 #include "ui/accessibility/ax_enums.h"
21 #include "ui/base/ui_base_types.h"
22 #include "ui/base/win/window_event_target.h"
23 #include "ui/events/event.h"
24 #include "ui/gfx/rect.h"
25 #include "ui/gfx/sequential_id_generator.h"
26 #include "ui/gfx/win/window_impl.h"
27 #include "ui/views/ime/input_method_delegate.h"
28 #include "ui/views/views_export.h"
30 namespace gfx {
31 class Canvas;
32 class ImageSkia;
33 class Insets;
36 namespace ui {
37 class ViewProp;
40 namespace views {
42 class FullscreenHandler;
43 class HWNDMessageHandlerDelegate;
44 class InputMethod;
46 // These two messages aren't defined in winuser.h, but they are sent to windows
47 // with captions. They appear to paint the window caption and frame.
48 // Unfortunately if you override the standard non-client rendering as we do
49 // with CustomFrameWindow, sometimes Windows (not deterministically
50 // reproducibly but definitely frequently) will send these messages to the
51 // window and paint the standard caption/title over the top of the custom one.
52 // So we need to handle these messages in CustomFrameWindow to prevent this
53 // from happening.
54 const int WM_NCUAHDRAWCAPTION = 0xAE;
55 const int WM_NCUAHDRAWFRAME = 0xAF;
57 // IsMsgHandled() and BEGIN_SAFE_MSG_MAP_EX are a modified version of
58 // BEGIN_MSG_MAP_EX. The main difference is it adds a WeakPtrFactory member
59 // (|weak_factory_|) that is used in _ProcessWindowMessage() and changing
60 // IsMsgHandled() from a member function to a define that checks if the weak
61 // factory is still valid in addition to the member. Together these allow for
62 // |this| to be deleted during dispatch.
63 #define IsMsgHandled() !ref.get() || msg_handled_
65 #define BEGIN_SAFE_MSG_MAP_EX(the_class) \
66 private: \
67 base::WeakPtrFactory<the_class> weak_factory_; \
68 BOOL msg_handled_; \
70 public: \
71 /* "handled" management for cracked handlers */ \
72 void SetMsgHandled(BOOL handled) { \
73 msg_handled_ = handled; \
74 } \
75 BOOL ProcessWindowMessage(HWND hwnd, \
76 UINT msg, \
77 WPARAM w_param, \
78 LPARAM l_param, \
79 LRESULT& l_result, \
80 DWORD msg_map_id = 0) { \
81 BOOL old_msg_handled = msg_handled_; \
82 BOOL ret = _ProcessWindowMessage(hwnd, msg, w_param, l_param, l_result, \
83 msg_map_id); \
84 msg_handled_ = old_msg_handled; \
85 return ret; \
86 } \
87 BOOL _ProcessWindowMessage(HWND hWnd, \
88 UINT uMsg, \
89 WPARAM wParam, \
90 LPARAM lParam, \
91 LRESULT& lResult, \
92 DWORD dwMsgMapID) { \
93 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); \
94 BOOL bHandled = TRUE; \
95 hWnd; \
96 uMsg; \
97 wParam; \
98 lParam; \
99 lResult; \
100 bHandled; \
101 switch(dwMsgMapID) { \
102 case 0:
104 // An object that handles messages for a HWND that implements the views
105 // "Custom Frame" look. The purpose of this class is to isolate the windows-
106 // specific message handling from the code that wraps it. It is intended to be
107 // used by both a views::NativeWidget and an aura::WindowTreeHost
108 // implementation.
109 // TODO(beng): This object should eventually *become* the WindowImpl.
110 class VIEWS_EXPORT HWNDMessageHandler :
111 public gfx::WindowImpl,
112 public internal::InputMethodDelegate,
113 public ui::WindowEventTarget {
114 public:
115 explicit HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate);
116 ~HWNDMessageHandler();
118 void Init(HWND parent, const gfx::Rect& bounds);
119 void InitModalType(ui::ModalType modal_type);
121 void Close();
122 void CloseNow();
124 gfx::Rect GetWindowBoundsInScreen() const;
125 gfx::Rect GetClientAreaBoundsInScreen() const;
126 gfx::Rect GetRestoredBounds() const;
127 // This accounts for the case where the widget size is the client size.
128 gfx::Rect GetClientAreaBounds() const;
130 void GetWindowPlacement(gfx::Rect* bounds,
131 ui::WindowShowState* show_state) const;
133 void SetBounds(const gfx::Rect& bounds_in_pixels);
134 void SetSize(const gfx::Size& size);
135 void CenterWindow(const gfx::Size& size);
137 void SetRegion(HRGN rgn);
139 void StackAbove(HWND other_hwnd);
140 void StackAtTop();
142 void Show();
143 void ShowWindowWithState(ui::WindowShowState show_state);
144 void ShowMaximizedWithBounds(const gfx::Rect& bounds);
145 void Hide();
147 void Maximize();
148 void Minimize();
149 void Restore();
151 void Activate();
152 void Deactivate();
154 void SetAlwaysOnTop(bool on_top);
156 bool IsVisible() const;
157 bool IsActive() const;
158 bool IsMinimized() const;
159 bool IsMaximized() const;
160 bool IsAlwaysOnTop() const;
162 bool RunMoveLoop(const gfx::Vector2d& drag_offset, bool hide_on_escape);
163 void EndMoveLoop();
165 // Tells the HWND its client area has changed.
166 void SendFrameChanged();
168 void FlashFrame(bool flash);
170 void ClearNativeFocus();
172 void SetCapture();
173 void ReleaseCapture();
174 bool HasCapture() const;
176 FullscreenHandler* fullscreen_handler() { return fullscreen_handler_.get(); }
178 void SetVisibilityChangedAnimationsEnabled(bool enabled);
180 // Returns true if the title changed.
181 bool SetTitle(const base::string16& title);
183 void SetCursor(HCURSOR cursor);
185 void FrameTypeChanged();
187 void SchedulePaintInRect(const gfx::Rect& rect);
188 void SetOpacity(BYTE opacity);
190 void SetWindowIcons(const gfx::ImageSkia& window_icon,
191 const gfx::ImageSkia& app_icon);
193 void set_remove_standard_frame(bool remove_standard_frame) {
194 remove_standard_frame_ = remove_standard_frame;
197 void set_use_system_default_icon(bool use_system_default_icon) {
198 use_system_default_icon_ = use_system_default_icon;
201 private:
202 typedef std::set<DWORD> TouchIDs;
204 // Overridden from internal::InputMethodDelegate:
205 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE;
207 // Overridden from WindowImpl:
208 virtual HICON GetDefaultWindowIcon() const OVERRIDE;
209 virtual LRESULT OnWndProc(UINT message,
210 WPARAM w_param,
211 LPARAM l_param) OVERRIDE;
213 // Overridden from WindowEventTarget
214 virtual LRESULT HandleMouseMessage(unsigned int message,
215 WPARAM w_param,
216 LPARAM l_param) OVERRIDE;
217 virtual LRESULT HandleKeyboardMessage(unsigned int message,
218 WPARAM w_param,
219 LPARAM l_param) OVERRIDE;
220 virtual LRESULT HandleTouchMessage(unsigned int message,
221 WPARAM w_param,
222 LPARAM l_param) OVERRIDE;
224 virtual LRESULT HandleScrollMessage(unsigned int message,
225 WPARAM w_param,
226 LPARAM l_param) OVERRIDE;
228 virtual LRESULT HandleNcHitTestMessage(unsigned int message,
229 WPARAM w_param,
230 LPARAM l_param) OVERRIDE;
232 // Returns the auto-hide edges of the appbar. See
233 // ViewsDelegate::GetAppbarAutohideEdges() for details. If the edges change,
234 // OnAppbarAutohideEdgesChanged() is called.
235 int GetAppbarAutohideEdges(HMONITOR monitor);
237 // Callback if the autohide edges have changed. See
238 // ViewsDelegate::GetAppbarAutohideEdges() for details.
239 void OnAppbarAutohideEdgesChanged();
241 // Can be called after the delegate has had the opportunity to set focus and
242 // did not do so.
243 void SetInitialFocus();
245 // Called after the WM_ACTIVATE message has been processed by the default
246 // windows procedure.
247 void PostProcessActivateMessage(int activation_state, bool minimized);
249 // Enables disabled owner windows that may have been disabled due to this
250 // window's modality.
251 void RestoreEnabledIfNecessary();
253 // Executes the specified SC_command.
254 void ExecuteSystemMenuCommand(int command);
256 // Start tracking all mouse events so that this window gets sent mouse leave
257 // messages too.
258 void TrackMouseEvents(DWORD mouse_tracking_flags);
260 // Responds to the client area changing size, either at window creation time
261 // or subsequently.
262 void ClientAreaSizeChanged();
264 // Returns the insets of the client area relative to the non-client area of
265 // the window.
266 bool GetClientAreaInsets(gfx::Insets* insets) const;
268 // Resets the window region for the current widget bounds if necessary.
269 // If |force| is true, the window region is reset to NULL even for native
270 // frame windows.
271 void ResetWindowRegion(bool force, bool redraw);
273 // Enables or disables rendering of the non-client (glass) area by DWM,
274 // under Vista and above, depending on whether the caller has requested a
275 // custom frame.
276 void UpdateDwmNcRenderingPolicy();
278 // Calls DefWindowProc, safely wrapping the call in a ScopedRedrawLock to
279 // prevent frame flicker. DefWindowProc handling can otherwise render the
280 // classic-look window title bar directly.
281 LRESULT DefWindowProcWithRedrawLock(UINT message,
282 WPARAM w_param,
283 LPARAM l_param);
285 // Lock or unlock the window from being able to redraw itself in response to
286 // updates to its invalid region.
287 class ScopedRedrawLock;
288 void LockUpdates(bool force);
289 void UnlockUpdates(bool force);
291 // Stops ignoring SetWindowPos() requests (see below).
292 void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; }
294 // Synchronously updates the invalid contents of the Widget. Valid for
295 // layered windows only.
296 void RedrawLayeredWindowContents();
298 // Attempts to force the window to be redrawn, ensuring that it gets
299 // onscreen.
300 void ForceRedrawWindow(int attempts);
302 // Message Handlers ----------------------------------------------------------
304 BEGIN_SAFE_MSG_MAP_EX(HWNDMessageHandler)
305 // Range handlers must go first!
306 CR_MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
307 CR_MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE,
308 WM_NCXBUTTONDBLCLK,
309 OnMouseRange)
311 // CustomFrameWindow hacks
312 CR_MESSAGE_HANDLER_EX(WM_NCUAHDRAWCAPTION, OnNCUAHDrawCaption)
313 CR_MESSAGE_HANDLER_EX(WM_NCUAHDRAWFRAME, OnNCUAHDrawFrame)
315 // Vista and newer
316 CR_MESSAGE_HANDLER_EX(WM_DWMCOMPOSITIONCHANGED, OnDwmCompositionChanged)
318 // Non-atlcrack.h handlers
319 CR_MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject)
321 // Mouse events.
322 CR_MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate)
323 CR_MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseRange)
324 CR_MESSAGE_HANDLER_EX(WM_NCMOUSELEAVE, OnMouseRange)
325 CR_MESSAGE_HANDLER_EX(WM_SETCURSOR, OnSetCursor);
327 // Key events.
328 CR_MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyEvent)
329 CR_MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyEvent)
330 CR_MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyEvent)
331 CR_MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyEvent)
333 // IME Events.
334 CR_MESSAGE_HANDLER_EX(WM_IME_SETCONTEXT, OnImeMessages)
335 CR_MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeMessages)
336 CR_MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeMessages)
337 CR_MESSAGE_HANDLER_EX(WM_IME_ENDCOMPOSITION, OnImeMessages)
338 CR_MESSAGE_HANDLER_EX(WM_IME_REQUEST, OnImeMessages)
339 CR_MESSAGE_HANDLER_EX(WM_IME_NOTIFY, OnImeMessages)
340 CR_MESSAGE_HANDLER_EX(WM_CHAR, OnImeMessages)
341 CR_MESSAGE_HANDLER_EX(WM_SYSCHAR, OnImeMessages)
343 // Scroll events
344 CR_MESSAGE_HANDLER_EX(WM_VSCROLL, OnScrollMessage)
345 CR_MESSAGE_HANDLER_EX(WM_HSCROLL, OnScrollMessage)
347 // Touch Events.
348 CR_MESSAGE_HANDLER_EX(WM_TOUCH, OnTouchEvent)
350 // Uses the general handler macro since the specific handler macro
351 // MSG_WM_NCACTIVATE would convert WPARAM type to BOOL type. The high
352 // word of WPARAM could be set when the window is minimized or restored.
353 CR_MESSAGE_HANDLER_EX(WM_NCACTIVATE, OnNCActivate)
355 // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU.
356 CR_MSG_WM_ACTIVATEAPP(OnActivateApp)
357 CR_MSG_WM_APPCOMMAND(OnAppCommand)
358 CR_MSG_WM_CANCELMODE(OnCancelMode)
359 CR_MSG_WM_CAPTURECHANGED(OnCaptureChanged)
360 CR_MSG_WM_CLOSE(OnClose)
361 CR_MSG_WM_COMMAND(OnCommand)
362 CR_MSG_WM_CREATE(OnCreate)
363 CR_MSG_WM_DESTROY(OnDestroy)
364 CR_MSG_WM_DISPLAYCHANGE(OnDisplayChange)
365 CR_MSG_WM_ENTERMENULOOP(OnEnterMenuLoop)
366 CR_MSG_WM_EXITMENULOOP(OnExitMenuLoop)
367 CR_MSG_WM_ENTERSIZEMOVE(OnEnterSizeMove)
368 CR_MSG_WM_ERASEBKGND(OnEraseBkgnd)
369 CR_MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
370 CR_MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo)
371 CR_MSG_WM_INITMENU(OnInitMenu)
372 CR_MSG_WM_INPUTLANGCHANGE(OnInputLangChange)
373 CR_MSG_WM_KILLFOCUS(OnKillFocus)
374 CR_MSG_WM_MOVE(OnMove)
375 CR_MSG_WM_MOVING(OnMoving)
376 CR_MSG_WM_NCCALCSIZE(OnNCCalcSize)
377 CR_MSG_WM_NCHITTEST(OnNCHitTest)
378 CR_MSG_WM_NCPAINT(OnNCPaint)
379 CR_MSG_WM_NOTIFY(OnNotify)
380 CR_MSG_WM_PAINT(OnPaint)
381 CR_MSG_WM_SETFOCUS(OnSetFocus)
382 CR_MSG_WM_SETICON(OnSetIcon)
383 CR_MSG_WM_SETTEXT(OnSetText)
384 CR_MSG_WM_SETTINGCHANGE(OnSettingChange)
385 CR_MSG_WM_SIZE(OnSize)
386 CR_MSG_WM_SYSCOMMAND(OnSysCommand)
387 CR_MSG_WM_THEMECHANGED(OnThemeChanged)
388 CR_MSG_WM_WINDOWPOSCHANGED(OnWindowPosChanged)
389 CR_MSG_WM_WINDOWPOSCHANGING(OnWindowPosChanging)
390 CR_MSG_WM_WTSSESSION_CHANGE(OnSessionChange)
391 CR_END_MSG_MAP()
393 // Message Handlers.
394 // This list is in _ALPHABETICAL_ order!
395 // TODO(beng): Once this object becomes the WindowImpl, these methods can
396 // be made private.
397 void OnActivateApp(BOOL active, DWORD thread_id);
398 // TODO(beng): return BOOL is temporary until this object becomes a
399 // WindowImpl.
400 BOOL OnAppCommand(HWND window, short command, WORD device, int keystate);
401 void OnCancelMode();
402 void OnCaptureChanged(HWND window);
403 void OnClose();
404 void OnCommand(UINT notification_code, int command, HWND window);
405 LRESULT OnCreate(CREATESTRUCT* create_struct);
406 void OnDestroy();
407 void OnDisplayChange(UINT bits_per_pixel, const gfx::Size& screen_size);
408 LRESULT OnDwmCompositionChanged(UINT msg, WPARAM w_param, LPARAM l_param);
409 void OnEnterMenuLoop(BOOL from_track_popup_menu);
410 void OnEnterSizeMove();
411 LRESULT OnEraseBkgnd(HDC dc);
412 void OnExitMenuLoop(BOOL is_shortcut_menu);
413 void OnExitSizeMove();
414 void OnGetMinMaxInfo(MINMAXINFO* minmax_info);
415 LRESULT OnGetObject(UINT message, WPARAM w_param, LPARAM l_param);
416 LRESULT OnImeMessages(UINT message, WPARAM w_param, LPARAM l_param);
417 void OnInitMenu(HMENU menu);
418 void OnInputLangChange(DWORD character_set, HKL input_language_id);
419 LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param);
420 void OnKillFocus(HWND focused_window);
421 LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param);
422 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param);
423 void OnMove(const gfx::Point& point);
424 void OnMoving(UINT param, const RECT* new_bounds);
425 LRESULT OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param);
426 LRESULT OnNCCalcSize(BOOL mode, LPARAM l_param);
427 LRESULT OnNCHitTest(const gfx::Point& point);
428 void OnNCPaint(HRGN rgn);
429 LRESULT OnNCUAHDrawCaption(UINT message, WPARAM w_param, LPARAM l_param);
430 LRESULT OnNCUAHDrawFrame(UINT message, WPARAM w_param, LPARAM l_param);
431 LRESULT OnNotify(int w_param, NMHDR* l_param);
432 void OnPaint(HDC dc);
433 LRESULT OnReflectedMessage(UINT message, WPARAM w_param, LPARAM l_param);
434 LRESULT OnScrollMessage(UINT message, WPARAM w_param, LPARAM l_param);
435 void OnSessionChange(WPARAM status_code, PWTSSESSION_NOTIFICATION session_id);
436 LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param);
437 void OnSetFocus(HWND last_focused_window);
438 LRESULT OnSetIcon(UINT size_type, HICON new_icon);
439 LRESULT OnSetText(const wchar_t* text);
440 void OnSettingChange(UINT flags, const wchar_t* section);
441 void OnSize(UINT param, const gfx::Size& size);
442 void OnSysCommand(UINT notification_code, const gfx::Point& point);
443 void OnThemeChanged();
444 LRESULT OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param);
445 void OnWindowPosChanging(WINDOWPOS* window_pos);
446 void OnWindowPosChanged(WINDOWPOS* window_pos);
448 typedef std::vector<ui::TouchEvent> TouchEvents;
449 // Helper to handle the list of touch events passed in. We need this because
450 // touch events on windows don't fire if we enter a modal loop in the context
451 // of a touch event.
452 void HandleTouchEvents(const TouchEvents& touch_events);
454 // Resets the flag which indicates that we are in the context of a touch down
455 // event.
456 void ResetTouchDownContext();
458 // Helper to handle mouse events.
459 // The |message|, |w_param|, |l_param| parameters identify the Windows mouse
460 // message and its parameters respectively.
461 // The |track_mouse| parameter indicates if we should track the mouse.
462 LRESULT HandleMouseEventInternal(UINT message,
463 WPARAM w_param,
464 LPARAM l_param,
465 bool track_mouse);
467 // Returns true if the mouse message passed in is an OS synthesized mouse
468 // message.
469 // |message| identifies the mouse message.
470 // |message_time| is the time when the message occurred.
471 // |l_param| indicates the location of the mouse message.
472 bool IsSynthesizedMouseMessage(unsigned int message,
473 int message_time,
474 LPARAM l_param);
476 HWNDMessageHandlerDelegate* delegate_;
478 scoped_ptr<FullscreenHandler> fullscreen_handler_;
480 // Set to true in Close() and false is CloseNow().
481 bool waiting_for_close_now_;
483 bool remove_standard_frame_;
485 bool use_system_default_icon_;
487 // Whether all ancestors have been enabled. This is only used if is_modal_ is
488 // true.
489 bool restored_enabled_;
491 // The current cursor.
492 HCURSOR current_cursor_;
494 // The last cursor that was active before the current one was selected. Saved
495 // so that we can restore it.
496 HCURSOR previous_cursor_;
498 // Event handling ------------------------------------------------------------
500 // The flags currently being used with TrackMouseEvent to track mouse
501 // messages. 0 if there is no active tracking. The value of this member is
502 // used when tracking is canceled.
503 DWORD active_mouse_tracking_flags_;
505 // Set to true when the user presses the right mouse button on the caption
506 // area. We need this so we can correctly show the context menu on mouse-up.
507 bool is_right_mouse_pressed_on_caption_;
509 // The set of touch devices currently down.
510 TouchIDs touch_ids_;
512 // ScopedRedrawLock ----------------------------------------------------------
514 // Represents the number of ScopedRedrawLocks active against this widget.
515 // If this is greater than zero, the widget should be locked against updates.
516 int lock_updates_count_;
518 // Window resizing -----------------------------------------------------------
520 // When true, this flag makes us discard incoming SetWindowPos() requests that
521 // only change our position/size. (We still allow changes to Z-order,
522 // activation, etc.)
523 bool ignore_window_pos_changes_;
525 // The last-seen monitor containing us, and its rect and work area. These are
526 // used to catch updates to the rect and work area and react accordingly.
527 HMONITOR last_monitor_;
528 gfx::Rect last_monitor_rect_, last_work_area_;
530 // Layered windows -----------------------------------------------------------
532 // Should we keep an off-screen buffer? This is false by default, set to true
533 // when WS_EX_LAYERED is specified before the native window is created.
535 // NOTE: this is intended to be used with a layered window (a window with an
536 // extended window style of WS_EX_LAYERED). If you are using a layered window
537 // and NOT changing the layered alpha or anything else, then leave this value
538 // alone. OTOH if you are invoking SetLayeredWindowAttributes then you'll
539 // most likely want to set this to false, or after changing the alpha toggle
540 // the extended style bit to false than back to true. See MSDN for more
541 // details.
542 bool use_layered_buffer_;
544 // The default alpha to be applied to the layered window.
545 BYTE layered_alpha_;
547 // A canvas that contains the window contents in the case of a layered
548 // window.
549 scoped_ptr<gfx::Canvas> layered_window_contents_;
551 // We must track the invalid rect ourselves, for two reasons:
552 // For layered windows, Windows will not do this properly with
553 // InvalidateRect()/GetUpdateRect(). (In fact, it'll return misleading
554 // information from GetUpdateRect()).
555 // We also need to keep track of the invalid rectangle for the RootView should
556 // we need to paint the non-client area. The data supplied to WM_NCPAINT seems
557 // to be insufficient.
558 gfx::Rect invalid_rect_;
560 // Set to true when waiting for RedrawLayeredWindowContents().
561 bool waiting_for_redraw_layered_window_contents_;
563 // True the first time nccalc is called on a sizable widget
564 bool is_first_nccalc_;
566 // Copy of custom window region specified via SetRegion(), if any.
567 base::win::ScopedRegion custom_window_region_;
569 // If > 0 indicates a menu is running (we're showing a native menu).
570 int menu_depth_;
572 // A factory used to lookup appbar autohide edges.
573 base::WeakPtrFactory<HWNDMessageHandler> autohide_factory_;
575 // Generates touch-ids for touch-events.
576 ui::SequentialIDGenerator id_generator_;
578 // Indicates if the window needs the WS_VSCROLL and WS_HSCROLL styles.
579 bool needs_scroll_styles_;
581 // Set to true if we are in the context of a sizing operation.
582 bool in_size_loop_;
584 // Stores a pointer to the WindowEventTarget interface implemented by this
585 // class. Allows callers to retrieve the interface pointer.
586 scoped_ptr<ui::ViewProp> prop_window_target_;
588 // Set to true if we are in the context of a touch down event. This is reset
589 // to false in a delayed task. Defaults to false.
590 // We need this to ignore WM_MOUSEACTIVATE messages generated in response to
591 // touch input. This is fine because activation still works correctly via
592 // native SetFocus calls invoked in the views code.
593 bool touch_down_context_;
595 // Time the last touch message was received. Used to flag mouse messages
596 // synthesized by Windows for touch which are not flagged by the OS as
597 // synthesized mouse messages. For more information please refer to
598 // the IsMouseEventFromTouch function.
599 static long last_touch_message_time_;
601 // Time the last WM_MOUSEHWHEEL message is received. Please refer to the
602 // HandleMouseEventInternal function as to why this is needed.
603 long last_mouse_hwheel_time_;
605 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler);
608 } // namespace views
610 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_