Sort unlaunched apps on app list start page by apps grid order.
[chromium-blink-merge.git] / ui / views / win / hwnd_message_handler.h
blobb7db7f228faec4cc248f66fb874684ba3506ccf8
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/geometry/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 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); \
82 BOOL old_msg_handled = msg_handled_; \
83 BOOL ret = _ProcessWindowMessage(hwnd, msg, w_param, l_param, l_result, \
84 msg_map_id); \
85 if (ref.get()) \
86 msg_handled_ = old_msg_handled; \
87 return ret; \
88 } \
89 BOOL _ProcessWindowMessage(HWND hWnd, \
90 UINT uMsg, \
91 WPARAM wParam, \
92 LPARAM lParam, \
93 LRESULT& lResult, \
94 DWORD dwMsgMapID) { \
95 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); \
96 BOOL bHandled = TRUE; \
97 hWnd; \
98 uMsg; \
99 wParam; \
100 lParam; \
101 lResult; \
102 bHandled; \
103 switch(dwMsgMapID) { \
104 case 0:
106 // An object that handles messages for a HWND that implements the views
107 // "Custom Frame" look. The purpose of this class is to isolate the windows-
108 // specific message handling from the code that wraps it. It is intended to be
109 // used by both a views::NativeWidget and an aura::WindowTreeHost
110 // implementation.
111 // TODO(beng): This object should eventually *become* the WindowImpl.
112 class VIEWS_EXPORT HWNDMessageHandler :
113 public gfx::WindowImpl,
114 public internal::InputMethodDelegate,
115 public ui::WindowEventTarget {
116 public:
117 explicit HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate);
118 ~HWNDMessageHandler();
120 void Init(HWND parent, const gfx::Rect& bounds);
121 void InitModalType(ui::ModalType modal_type);
123 void Close();
124 void CloseNow();
126 gfx::Rect GetWindowBoundsInScreen() const;
127 gfx::Rect GetClientAreaBoundsInScreen() const;
128 gfx::Rect GetRestoredBounds() const;
129 // This accounts for the case where the widget size is the client size.
130 gfx::Rect GetClientAreaBounds() const;
132 void GetWindowPlacement(gfx::Rect* bounds,
133 ui::WindowShowState* show_state) const;
135 // Sets the bounds of the HWND to |bounds_in_pixels|. If the HWND size is not
136 // changed, |force_size_changed| determines if we should pretend it is.
137 void SetBounds(const gfx::Rect& bounds_in_pixels, bool force_size_changed);
139 void SetSize(const gfx::Size& size);
140 void CenterWindow(const gfx::Size& size);
142 void SetRegion(HRGN rgn);
144 void StackAbove(HWND other_hwnd);
145 void StackAtTop();
147 void Show();
148 void ShowWindowWithState(ui::WindowShowState show_state);
149 void ShowMaximizedWithBounds(const gfx::Rect& bounds);
150 void Hide();
152 void Maximize();
153 void Minimize();
154 void Restore();
156 void Activate();
157 void Deactivate();
159 void SetAlwaysOnTop(bool on_top);
161 bool IsVisible() const;
162 bool IsActive() const;
163 bool IsMinimized() const;
164 bool IsMaximized() const;
165 bool IsAlwaysOnTop() const;
167 bool RunMoveLoop(const gfx::Vector2d& drag_offset, bool hide_on_escape);
168 void EndMoveLoop();
170 // Tells the HWND its client area has changed.
171 void SendFrameChanged();
173 void FlashFrame(bool flash);
175 void ClearNativeFocus();
177 void SetCapture();
178 void ReleaseCapture();
179 bool HasCapture() const;
181 FullscreenHandler* fullscreen_handler() { return fullscreen_handler_.get(); }
183 void SetVisibilityChangedAnimationsEnabled(bool enabled);
185 // Returns true if the title changed.
186 bool SetTitle(const base::string16& title);
188 void SetCursor(HCURSOR cursor);
190 void FrameTypeChanged();
192 void SchedulePaintInRect(const gfx::Rect& rect);
193 void SetOpacity(BYTE opacity);
195 void SetWindowIcons(const gfx::ImageSkia& window_icon,
196 const gfx::ImageSkia& app_icon);
198 void set_remove_standard_frame(bool remove_standard_frame) {
199 remove_standard_frame_ = remove_standard_frame;
202 void set_use_system_default_icon(bool use_system_default_icon) {
203 use_system_default_icon_ = use_system_default_icon;
206 void SetFullscreen(bool fullscreen);
208 // Updates the window style to reflect whether it can be resized or maximized.
209 void SizeConstraintsChanged();
211 private:
212 typedef std::set<DWORD> TouchIDs;
214 // Overridden from internal::InputMethodDelegate:
215 virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) override;
217 // Overridden from WindowImpl:
218 virtual HICON GetDefaultWindowIcon() const override;
219 virtual HICON GetSmallWindowIcon() const override;
220 virtual LRESULT OnWndProc(UINT message,
221 WPARAM w_param,
222 LPARAM l_param) override;
224 // Overridden from WindowEventTarget
225 virtual LRESULT HandleMouseMessage(unsigned int message,
226 WPARAM w_param,
227 LPARAM l_param,
228 bool* handled) override;
229 virtual LRESULT HandleKeyboardMessage(unsigned int message,
230 WPARAM w_param,
231 LPARAM l_param,
232 bool* handled) override;
233 virtual LRESULT HandleTouchMessage(unsigned int message,
234 WPARAM w_param,
235 LPARAM l_param,
236 bool* handled) override;
238 virtual LRESULT HandleScrollMessage(unsigned int message,
239 WPARAM w_param,
240 LPARAM l_param,
241 bool* handled) override;
243 virtual LRESULT HandleNcHitTestMessage(unsigned int message,
244 WPARAM w_param,
245 LPARAM l_param,
246 bool* handled) override;
248 // Returns the auto-hide edges of the appbar. See
249 // ViewsDelegate::GetAppbarAutohideEdges() for details. If the edges change,
250 // OnAppbarAutohideEdgesChanged() is called.
251 int GetAppbarAutohideEdges(HMONITOR monitor);
253 // Callback if the autohide edges have changed. See
254 // ViewsDelegate::GetAppbarAutohideEdges() for details.
255 void OnAppbarAutohideEdgesChanged();
257 // Can be called after the delegate has had the opportunity to set focus and
258 // did not do so.
259 void SetInitialFocus();
261 // Called after the WM_ACTIVATE message has been processed by the default
262 // windows procedure.
263 void PostProcessActivateMessage(int activation_state, bool minimized);
265 // Enables disabled owner windows that may have been disabled due to this
266 // window's modality.
267 void RestoreEnabledIfNecessary();
269 // Executes the specified SC_command.
270 void ExecuteSystemMenuCommand(int command);
272 // Start tracking all mouse events so that this window gets sent mouse leave
273 // messages too.
274 void TrackMouseEvents(DWORD mouse_tracking_flags);
276 // Responds to the client area changing size, either at window creation time
277 // or subsequently.
278 void ClientAreaSizeChanged();
280 // Returns the insets of the client area relative to the non-client area of
281 // the window.
282 bool GetClientAreaInsets(gfx::Insets* insets) const;
284 // Resets the window region for the current widget bounds if necessary.
285 // If |force| is true, the window region is reset to NULL even for native
286 // frame windows.
287 void ResetWindowRegion(bool force, bool redraw);
289 // Enables or disables rendering of the non-client (glass) area by DWM,
290 // under Vista and above, depending on whether the caller has requested a
291 // custom frame.
292 void UpdateDwmNcRenderingPolicy();
294 // Calls DefWindowProc, safely wrapping the call in a ScopedRedrawLock to
295 // prevent frame flicker. DefWindowProc handling can otherwise render the
296 // classic-look window title bar directly.
297 LRESULT DefWindowProcWithRedrawLock(UINT message,
298 WPARAM w_param,
299 LPARAM l_param);
301 // Lock or unlock the window from being able to redraw itself in response to
302 // updates to its invalid region.
303 class ScopedRedrawLock;
304 void LockUpdates(bool force);
305 void UnlockUpdates(bool force);
307 // Stops ignoring SetWindowPos() requests (see below).
308 void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; }
310 // Synchronously updates the invalid contents of the Widget. Valid for
311 // layered windows only.
312 void RedrawLayeredWindowContents();
314 // Attempts to force the window to be redrawn, ensuring that it gets
315 // onscreen.
316 void ForceRedrawWindow(int attempts);
318 // Message Handlers ----------------------------------------------------------
320 BEGIN_SAFE_MSG_MAP_EX(HWNDMessageHandler)
321 // Range handlers must go first!
322 CR_MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
323 CR_MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE,
324 WM_NCXBUTTONDBLCLK,
325 OnMouseRange)
327 // CustomFrameWindow hacks
328 CR_MESSAGE_HANDLER_EX(WM_NCUAHDRAWCAPTION, OnNCUAHDrawCaption)
329 CR_MESSAGE_HANDLER_EX(WM_NCUAHDRAWFRAME, OnNCUAHDrawFrame)
331 // Vista and newer
332 CR_MESSAGE_HANDLER_EX(WM_DWMCOMPOSITIONCHANGED, OnDwmCompositionChanged)
334 // Non-atlcrack.h handlers
335 CR_MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject)
337 // Mouse events.
338 CR_MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate)
339 CR_MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseRange)
340 CR_MESSAGE_HANDLER_EX(WM_NCMOUSELEAVE, OnMouseRange)
341 CR_MESSAGE_HANDLER_EX(WM_SETCURSOR, OnSetCursor);
343 // Key events.
344 CR_MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyEvent)
345 CR_MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyEvent)
346 CR_MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyEvent)
347 CR_MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyEvent)
349 // IME Events.
350 CR_MESSAGE_HANDLER_EX(WM_IME_SETCONTEXT, OnImeMessages)
351 CR_MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeMessages)
352 CR_MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeMessages)
353 CR_MESSAGE_HANDLER_EX(WM_IME_ENDCOMPOSITION, OnImeMessages)
354 CR_MESSAGE_HANDLER_EX(WM_IME_REQUEST, OnImeMessages)
355 CR_MESSAGE_HANDLER_EX(WM_IME_NOTIFY, OnImeMessages)
356 CR_MESSAGE_HANDLER_EX(WM_CHAR, OnImeMessages)
357 CR_MESSAGE_HANDLER_EX(WM_SYSCHAR, OnImeMessages)
359 // Scroll events
360 CR_MESSAGE_HANDLER_EX(WM_VSCROLL, OnScrollMessage)
361 CR_MESSAGE_HANDLER_EX(WM_HSCROLL, OnScrollMessage)
363 // Touch Events.
364 CR_MESSAGE_HANDLER_EX(WM_TOUCH, OnTouchEvent)
366 // Uses the general handler macro since the specific handler macro
367 // MSG_WM_NCACTIVATE would convert WPARAM type to BOOL type. The high
368 // word of WPARAM could be set when the window is minimized or restored.
369 CR_MESSAGE_HANDLER_EX(WM_NCACTIVATE, OnNCActivate)
371 // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU.
372 CR_MSG_WM_ACTIVATEAPP(OnActivateApp)
373 CR_MSG_WM_APPCOMMAND(OnAppCommand)
374 CR_MSG_WM_CANCELMODE(OnCancelMode)
375 CR_MSG_WM_CAPTURECHANGED(OnCaptureChanged)
376 CR_MSG_WM_CLOSE(OnClose)
377 CR_MSG_WM_COMMAND(OnCommand)
378 CR_MSG_WM_CREATE(OnCreate)
379 CR_MSG_WM_DESTROY(OnDestroy)
380 CR_MSG_WM_DISPLAYCHANGE(OnDisplayChange)
381 CR_MSG_WM_ENTERMENULOOP(OnEnterMenuLoop)
382 CR_MSG_WM_EXITMENULOOP(OnExitMenuLoop)
383 CR_MSG_WM_ENTERSIZEMOVE(OnEnterSizeMove)
384 CR_MSG_WM_ERASEBKGND(OnEraseBkgnd)
385 CR_MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
386 CR_MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo)
387 CR_MSG_WM_INITMENU(OnInitMenu)
388 CR_MSG_WM_INPUTLANGCHANGE(OnInputLangChange)
389 CR_MSG_WM_KILLFOCUS(OnKillFocus)
390 CR_MSG_WM_MOVE(OnMove)
391 CR_MSG_WM_MOVING(OnMoving)
392 CR_MSG_WM_NCCALCSIZE(OnNCCalcSize)
393 CR_MSG_WM_NCHITTEST(OnNCHitTest)
394 CR_MSG_WM_NCPAINT(OnNCPaint)
395 CR_MSG_WM_NOTIFY(OnNotify)
396 CR_MSG_WM_PAINT(OnPaint)
397 CR_MSG_WM_SETFOCUS(OnSetFocus)
398 CR_MSG_WM_SETICON(OnSetIcon)
399 CR_MSG_WM_SETTEXT(OnSetText)
400 CR_MSG_WM_SETTINGCHANGE(OnSettingChange)
401 CR_MSG_WM_SIZE(OnSize)
402 CR_MSG_WM_SYSCOMMAND(OnSysCommand)
403 CR_MSG_WM_THEMECHANGED(OnThemeChanged)
404 CR_MSG_WM_WINDOWPOSCHANGED(OnWindowPosChanged)
405 CR_MSG_WM_WINDOWPOSCHANGING(OnWindowPosChanging)
406 CR_MSG_WM_WTSSESSION_CHANGE(OnSessionChange)
407 CR_END_MSG_MAP()
409 // Message Handlers.
410 // This list is in _ALPHABETICAL_ order!
411 // TODO(beng): Once this object becomes the WindowImpl, these methods can
412 // be made private.
413 void OnActivateApp(BOOL active, DWORD thread_id);
414 // TODO(beng): return BOOL is temporary until this object becomes a
415 // WindowImpl.
416 BOOL OnAppCommand(HWND window, short command, WORD device, int keystate);
417 void OnCancelMode();
418 void OnCaptureChanged(HWND window);
419 void OnClose();
420 void OnCommand(UINT notification_code, int command, HWND window);
421 LRESULT OnCreate(CREATESTRUCT* create_struct);
422 void OnDestroy();
423 void OnDisplayChange(UINT bits_per_pixel, const gfx::Size& screen_size);
424 LRESULT OnDwmCompositionChanged(UINT msg, WPARAM w_param, LPARAM l_param);
425 void OnEnterMenuLoop(BOOL from_track_popup_menu);
426 void OnEnterSizeMove();
427 LRESULT OnEraseBkgnd(HDC dc);
428 void OnExitMenuLoop(BOOL is_shortcut_menu);
429 void OnExitSizeMove();
430 void OnGetMinMaxInfo(MINMAXINFO* minmax_info);
431 LRESULT OnGetObject(UINT message, WPARAM w_param, LPARAM l_param);
432 LRESULT OnImeMessages(UINT message, WPARAM w_param, LPARAM l_param);
433 void OnInitMenu(HMENU menu);
434 void OnInputLangChange(DWORD character_set, HKL input_language_id);
435 LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param);
436 void OnKillFocus(HWND focused_window);
437 LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param);
438 LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param);
439 void OnMove(const gfx::Point& point);
440 void OnMoving(UINT param, const RECT* new_bounds);
441 LRESULT OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param);
442 LRESULT OnNCCalcSize(BOOL mode, LPARAM l_param);
443 LRESULT OnNCHitTest(const gfx::Point& point);
444 void OnNCPaint(HRGN rgn);
445 LRESULT OnNCUAHDrawCaption(UINT message, WPARAM w_param, LPARAM l_param);
446 LRESULT OnNCUAHDrawFrame(UINT message, WPARAM w_param, LPARAM l_param);
447 LRESULT OnNotify(int w_param, NMHDR* l_param);
448 void OnPaint(HDC dc);
449 LRESULT OnReflectedMessage(UINT message, WPARAM w_param, LPARAM l_param);
450 LRESULT OnScrollMessage(UINT message, WPARAM w_param, LPARAM l_param);
451 void OnSessionChange(WPARAM status_code, PWTSSESSION_NOTIFICATION session_id);
452 LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param);
453 void OnSetFocus(HWND last_focused_window);
454 LRESULT OnSetIcon(UINT size_type, HICON new_icon);
455 LRESULT OnSetText(const wchar_t* text);
456 void OnSettingChange(UINT flags, const wchar_t* section);
457 void OnSize(UINT param, const gfx::Size& size);
458 void OnSysCommand(UINT notification_code, const gfx::Point& point);
459 void OnThemeChanged();
460 LRESULT OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param);
461 void OnWindowPosChanging(WINDOWPOS* window_pos);
462 void OnWindowPosChanged(WINDOWPOS* window_pos);
464 typedef std::vector<ui::TouchEvent> TouchEvents;
465 // Helper to handle the list of touch events passed in. We need this because
466 // touch events on windows don't fire if we enter a modal loop in the context
467 // of a touch event.
468 void HandleTouchEvents(const TouchEvents& touch_events);
470 // Resets the flag which indicates that we are in the context of a touch down
471 // event.
472 void ResetTouchDownContext();
474 // Helper to handle mouse events.
475 // The |message|, |w_param|, |l_param| parameters identify the Windows mouse
476 // message and its parameters respectively.
477 // The |track_mouse| parameter indicates if we should track the mouse.
478 LRESULT HandleMouseEventInternal(UINT message,
479 WPARAM w_param,
480 LPARAM l_param,
481 bool track_mouse);
483 // Returns true if the mouse message passed in is an OS synthesized mouse
484 // message.
485 // |message| identifies the mouse message.
486 // |message_time| is the time when the message occurred.
487 // |l_param| indicates the location of the mouse message.
488 bool IsSynthesizedMouseMessage(unsigned int message,
489 int message_time,
490 LPARAM l_param);
492 // Provides functionality to transition a frame to DWM.
493 void PerformDwmTransition();
495 HWNDMessageHandlerDelegate* delegate_;
497 scoped_ptr<FullscreenHandler> fullscreen_handler_;
499 // Set to true in Close() and false is CloseNow().
500 bool waiting_for_close_now_;
502 bool remove_standard_frame_;
504 bool use_system_default_icon_;
506 // Whether all ancestors have been enabled. This is only used if is_modal_ is
507 // true.
508 bool restored_enabled_;
510 // The current cursor.
511 HCURSOR current_cursor_;
513 // The last cursor that was active before the current one was selected. Saved
514 // so that we can restore it.
515 HCURSOR previous_cursor_;
517 // Event handling ------------------------------------------------------------
519 // The flags currently being used with TrackMouseEvent to track mouse
520 // messages. 0 if there is no active tracking. The value of this member is
521 // used when tracking is canceled.
522 DWORD active_mouse_tracking_flags_;
524 // Set to true when the user presses the right mouse button on the caption
525 // area. We need this so we can correctly show the context menu on mouse-up.
526 bool is_right_mouse_pressed_on_caption_;
528 // The set of touch devices currently down.
529 TouchIDs touch_ids_;
531 // ScopedRedrawLock ----------------------------------------------------------
533 // Represents the number of ScopedRedrawLocks active against this widget.
534 // If this is greater than zero, the widget should be locked against updates.
535 int lock_updates_count_;
537 // Window resizing -----------------------------------------------------------
539 // When true, this flag makes us discard incoming SetWindowPos() requests that
540 // only change our position/size. (We still allow changes to Z-order,
541 // activation, etc.)
542 bool ignore_window_pos_changes_;
544 // The last-seen monitor containing us, and its rect and work area. These are
545 // used to catch updates to the rect and work area and react accordingly.
546 HMONITOR last_monitor_;
547 gfx::Rect last_monitor_rect_, last_work_area_;
549 // Layered windows -----------------------------------------------------------
551 // Should we keep an off-screen buffer? This is false by default, set to true
552 // when WS_EX_LAYERED is specified before the native window is created.
554 // NOTE: this is intended to be used with a layered window (a window with an
555 // extended window style of WS_EX_LAYERED). If you are using a layered window
556 // and NOT changing the layered alpha or anything else, then leave this value
557 // alone. OTOH if you are invoking SetLayeredWindowAttributes then you'll
558 // most likely want to set this to false, or after changing the alpha toggle
559 // the extended style bit to false than back to true. See MSDN for more
560 // details.
561 bool use_layered_buffer_;
563 // The default alpha to be applied to the layered window.
564 BYTE layered_alpha_;
566 // A canvas that contains the window contents in the case of a layered
567 // window.
568 scoped_ptr<gfx::Canvas> layered_window_contents_;
570 // We must track the invalid rect ourselves, for two reasons:
571 // For layered windows, Windows will not do this properly with
572 // InvalidateRect()/GetUpdateRect(). (In fact, it'll return misleading
573 // information from GetUpdateRect()).
574 // We also need to keep track of the invalid rectangle for the RootView should
575 // we need to paint the non-client area. The data supplied to WM_NCPAINT seems
576 // to be insufficient.
577 gfx::Rect invalid_rect_;
579 // Set to true when waiting for RedrawLayeredWindowContents().
580 bool waiting_for_redraw_layered_window_contents_;
582 // True the first time nccalc is called on a sizable widget
583 bool is_first_nccalc_;
585 // Copy of custom window region specified via SetRegion(), if any.
586 base::win::ScopedRegion custom_window_region_;
588 // If > 0 indicates a menu is running (we're showing a native menu).
589 int menu_depth_;
591 // A factory used to lookup appbar autohide edges.
592 base::WeakPtrFactory<HWNDMessageHandler> autohide_factory_;
594 // Generates touch-ids for touch-events.
595 ui::SequentialIDGenerator id_generator_;
597 // Indicates if the window needs the WS_VSCROLL and WS_HSCROLL styles.
598 bool needs_scroll_styles_;
600 // Set to true if we are in the context of a sizing operation.
601 bool in_size_loop_;
603 // Stores a pointer to the WindowEventTarget interface implemented by this
604 // class. Allows callers to retrieve the interface pointer.
605 scoped_ptr<ui::ViewProp> prop_window_target_;
607 // Number of active touch down contexts. This is incremented on touch down
608 // events and decremented later using a delayed task.
609 // We need this to ignore WM_MOUSEACTIVATE messages generated in response to
610 // touch input. This is fine because activation still works correctly via
611 // native SetFocus calls invoked in the views code.
612 int touch_down_contexts_;
614 // Time the last touch message was received. Used to flag mouse messages
615 // synthesized by Windows for touch which are not flagged by the OS as
616 // synthesized mouse messages. For more information please refer to
617 // the IsMouseEventFromTouch function.
618 static long last_touch_message_time_;
620 // Time the last WM_MOUSEHWHEEL message is received. Please refer to the
621 // HandleMouseEventInternal function as to why this is needed.
622 long last_mouse_hwheel_time_;
624 // On Windows Vista and beyond, if we are transitioning from custom frame
625 // to Aero(glass) we delay setting the DWM related properties in full
626 // screen mode as DWM is not supported in full screen windows. We perform
627 // the DWM related operations when the window comes out of fullscreen mode.
628 // This member variable is set to true if the window is transitioning to
629 // glass. Defaults to false.
630 bool dwm_transition_desired_;
632 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler);
635 } // namespace views
637 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_