Home | History | Annotate | Download | only in win
      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.
      4 
      5 #ifndef UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_
      6 #define UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_
      7 
      8 #include <windows.h>
      9 #include <atlbase.h>
     10 #include <atlapp.h>
     11 #include <atlmisc.h>
     12 
     13 #include <set>
     14 #include <vector>
     15 
     16 #include "base/basictypes.h"
     17 #include "base/compiler_specific.h"
     18 #include "base/memory/scoped_ptr.h"
     19 #include "base/memory/weak_ptr.h"
     20 #include "base/message_loop/message_loop.h"
     21 #include "base/strings/string16.h"
     22 #include "base/win/scoped_gdi_object.h"
     23 #include "base/win/win_util.h"
     24 #include "ui/base/accessibility/accessibility_types.h"
     25 #include "ui/base/ui_base_types.h"
     26 #include "ui/events/event.h"
     27 #include "ui/gfx/rect.h"
     28 #include "ui/gfx/sequential_id_generator.h"
     29 #include "ui/gfx/win/window_impl.h"
     30 #include "ui/views/ime/input_method_delegate.h"
     31 #include "ui/views/views_export.h"
     32 
     33 namespace gfx {
     34 class Canvas;
     35 class ImageSkia;
     36 class Insets;
     37 }
     38 
     39 namespace views {
     40 
     41 class FullscreenHandler;
     42 class HWNDMessageHandlerDelegate;
     43 class InputMethod;
     44 
     45 // These two messages aren't defined in winuser.h, but they are sent to windows
     46 // with captions. They appear to paint the window caption and frame.
     47 // Unfortunately if you override the standard non-client rendering as we do
     48 // with CustomFrameWindow, sometimes Windows (not deterministically
     49 // reproducibly but definitely frequently) will send these messages to the
     50 // window and paint the standard caption/title over the top of the custom one.
     51 // So we need to handle these messages in CustomFrameWindow to prevent this
     52 // from happening.
     53 const int WM_NCUAHDRAWCAPTION = 0xAE;
     54 const int WM_NCUAHDRAWFRAME = 0xAF;
     55 
     56 // IsMsgHandled() and BEGIN_SAFE_MSG_MAP_EX are a modified version of
     57 // BEGIN_MSG_MAP_EX. The main difference is it adds a WeakPtrFactory member
     58 // (|weak_factory_|) that is used in _ProcessWindowMessage() and changing
     59 // IsMsgHandled() from a member function to a define that checks if the weak
     60 // factory is still valid in addition to the member. Together these allow for
     61 // |this| to be deleted during dispatch.
     62 #define IsMsgHandled() !ref.get() || msg_handled_
     63 
     64 #define BEGIN_SAFE_MSG_MAP_EX(the_class) \
     65  private: \
     66   base::WeakPtrFactory<the_class> weak_factory_; \
     67   BOOL msg_handled_; \
     68 \
     69  public: \
     70   /* "handled" management for cracked handlers */ \
     71   void SetMsgHandled(BOOL handled) { \
     72     msg_handled_ = handled; \
     73   } \
     74   BOOL ProcessWindowMessage(HWND hwnd, \
     75                             UINT msg, \
     76                             WPARAM w_param, \
     77                             LPARAM l_param, \
     78                             LRESULT& l_result, \
     79                             DWORD msg_map_id = 0) { \
     80     BOOL old_msg_handled = msg_handled_; \
     81     BOOL ret = _ProcessWindowMessage(hwnd, msg, w_param, l_param, l_result, \
     82                                      msg_map_id); \
     83     msg_handled_ = old_msg_handled; \
     84     return ret; \
     85   } \
     86   BOOL _ProcessWindowMessage(HWND hWnd, \
     87                              UINT uMsg, \
     88                              WPARAM wParam, \
     89                              LPARAM lParam, \
     90                              LRESULT& lResult, \
     91                              DWORD dwMsgMapID) { \
     92     base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); \
     93     BOOL bHandled = TRUE; \
     94     hWnd; \
     95     uMsg; \
     96     wParam; \
     97     lParam; \
     98     lResult; \
     99     bHandled; \
    100     switch(dwMsgMapID) { \
    101       case 0:
    102 
    103 // An object that handles messages for a HWND that implements the views
    104 // "Custom Frame" look. The purpose of this class is to isolate the windows-
    105 // specific message handling from the code that wraps it. It is intended to be
    106 // used by both a views::NativeWidget and an aura::RootWindowHost
    107 // implementation.
    108 // TODO(beng): This object should eventually *become* the WindowImpl.
    109 class VIEWS_EXPORT HWNDMessageHandler :
    110     public gfx::WindowImpl,
    111     public internal::InputMethodDelegate,
    112     public base::MessageLoopForUI::Observer {
    113  public:
    114   explicit HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate);
    115   ~HWNDMessageHandler();
    116 
    117   void Init(HWND parent, const gfx::Rect& bounds);
    118   void InitModalType(ui::ModalType modal_type);
    119 
    120   void Close();
    121   void CloseNow();
    122 
    123   gfx::Rect GetWindowBoundsInScreen() const;
    124   gfx::Rect GetClientAreaBoundsInScreen() const;
    125   gfx::Rect GetRestoredBounds() const;
    126   // This accounts for the case where the widget size is the client size.
    127   gfx::Rect GetClientAreaBounds() const;
    128 
    129   void GetWindowPlacement(gfx::Rect* bounds,
    130                           ui::WindowShowState* show_state) const;
    131 
    132   void SetBounds(const gfx::Rect& bounds_in_pixels);
    133   void SetSize(const gfx::Size& size);
    134   void CenterWindow(const gfx::Size& size);
    135 
    136   void SetRegion(HRGN rgn);
    137 
    138   void StackAbove(HWND other_hwnd);
    139   void StackAtTop();
    140 
    141   void Show();
    142   void ShowWindowWithState(ui::WindowShowState show_state);
    143   // TODO(beng): distinguish from ShowWindowWithState().
    144   void Show(int show_state);
    145   void ShowMaximizedWithBounds(const gfx::Rect& bounds);
    146   void Hide();
    147 
    148   void Maximize();
    149   void Minimize();
    150   void Restore();
    151 
    152   void Activate();
    153   void Deactivate();
    154 
    155   void SetAlwaysOnTop(bool on_top);
    156 
    157   bool IsVisible() const;
    158   bool IsActive() const;
    159   bool IsMinimized() const;
    160   bool IsMaximized() const;
    161   bool IsAlwaysOnTop() const;
    162 
    163   bool RunMoveLoop(const gfx::Vector2d& drag_offset, bool hide_on_escape);
    164   void EndMoveLoop();
    165 
    166   // Tells the HWND its client area has changed.
    167   void SendFrameChanged();
    168 
    169   void FlashFrame(bool flash);
    170 
    171   void ClearNativeFocus();
    172 
    173   void SetCapture();
    174   void ReleaseCapture();
    175   bool HasCapture() const;
    176 
    177   FullscreenHandler* fullscreen_handler() { return fullscreen_handler_.get(); }
    178 
    179   void SetVisibilityChangedAnimationsEnabled(bool enabled);
    180 
    181   // Returns true if the title changed.
    182   bool SetTitle(const string16& title);
    183 
    184   void SetCursor(HCURSOR cursor);
    185 
    186   void FrameTypeChanged();
    187 
    188   void SchedulePaintInRect(const gfx::Rect& rect);
    189   void SetOpacity(BYTE opacity);
    190 
    191   void SetWindowIcons(const gfx::ImageSkia& window_icon,
    192                       const gfx::ImageSkia& app_icon);
    193 
    194   void set_remove_standard_frame(bool remove_standard_frame) {
    195     remove_standard_frame_ = remove_standard_frame;
    196   }
    197 
    198   void set_use_system_default_icon(bool use_system_default_icon) {
    199     use_system_default_icon_ = use_system_default_icon;
    200   }
    201 
    202  private:
    203   typedef std::set<DWORD> TouchIDs;
    204 
    205   // Overridden from internal::InputMethodDelegate:
    206   virtual void DispatchKeyEventPostIME(const ui::KeyEvent& key) OVERRIDE;
    207 
    208   // Overridden from WindowImpl:
    209   virtual HICON GetDefaultWindowIcon() const OVERRIDE;
    210   virtual LRESULT OnWndProc(UINT message,
    211                             WPARAM w_param,
    212                             LPARAM l_param) OVERRIDE;
    213 
    214   // Overridden from MessageLoopForUI::Observer:
    215   virtual base::EventStatus WillProcessEvent(
    216       const base::NativeEvent& event) OVERRIDE;
    217   virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE;
    218 
    219   // Returns the auto-hide edges of the appbar. See Appbar::GetAutohideEdges()
    220   // for details. If the edges change OnAppbarAutohideEdgesChanged() is called.
    221   int GetAppbarAutohideEdges(HMONITOR monitor);
    222 
    223   // Callback if the autohide edges have changed. See Appbar for details.
    224   void OnAppbarAutohideEdgesChanged();
    225 
    226   // Can be called after the delegate has had the opportunity to set focus and
    227   // did not do so.
    228   void SetInitialFocus();
    229 
    230   // Called after the WM_ACTIVATE message has been processed by the default
    231   // windows procedure.
    232   void PostProcessActivateMessage(int activation_state, bool minimized);
    233 
    234   // Enables disabled owner windows that may have been disabled due to this
    235   // window's modality.
    236   void RestoreEnabledIfNecessary();
    237 
    238   // Executes the specified SC_command.
    239   void ExecuteSystemMenuCommand(int command);
    240 
    241   // Start tracking all mouse events so that this window gets sent mouse leave
    242   // messages too.
    243   void TrackMouseEvents(DWORD mouse_tracking_flags);
    244 
    245   // Responds to the client area changing size, either at window creation time
    246   // or subsequently.
    247   void ClientAreaSizeChanged();
    248 
    249   // Returns the insets of the client area relative to the non-client area of
    250   // the window.
    251   bool GetClientAreaInsets(gfx::Insets* insets) const;
    252 
    253   // Resets the window region for the current widget bounds if necessary.
    254   // If |force| is true, the window region is reset to NULL even for native
    255   // frame windows.
    256   void ResetWindowRegion(bool force, bool redraw);
    257 
    258   // Enables or disables rendering of the non-client (glass) area by DWM,
    259   // under Vista and above, depending on whether the caller has requested a
    260   // custom frame.
    261   void UpdateDwmNcRenderingPolicy();
    262 
    263   // Calls DefWindowProc, safely wrapping the call in a ScopedRedrawLock to
    264   // prevent frame flicker. DefWindowProc handling can otherwise render the
    265   // classic-look window title bar directly.
    266   LRESULT DefWindowProcWithRedrawLock(UINT message,
    267                                       WPARAM w_param,
    268                                       LPARAM l_param);
    269 
    270   // Notifies any owned windows that we're closing.
    271   void NotifyOwnedWindowsParentClosing();
    272 
    273   // Lock or unlock the window from being able to redraw itself in response to
    274   // updates to its invalid region.
    275   class ScopedRedrawLock;
    276   void LockUpdates(bool force);
    277   void UnlockUpdates(bool force);
    278 
    279   // Stops ignoring SetWindowPos() requests (see below).
    280   void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; }
    281 
    282   // Synchronously paints the invalid contents of the Widget.
    283   void RedrawInvalidRect();
    284 
    285   // Synchronously updates the invalid contents of the Widget. Valid for
    286   // layered windows only.
    287   void RedrawLayeredWindowContents();
    288 
    289   // Attempts to force the window to be redrawn, ensuring that it gets
    290   // onscreen.
    291   void ForceRedrawWindow(int attempts);
    292 
    293   // Message Handlers ----------------------------------------------------------
    294 
    295   BEGIN_SAFE_MSG_MAP_EX(HWNDMessageHandler)
    296     // Range handlers must go first!
    297     MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange)
    298     MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, WM_NCXBUTTONDBLCLK, OnMouseRange)
    299 
    300     // CustomFrameWindow hacks
    301     MESSAGE_HANDLER_EX(WM_NCUAHDRAWCAPTION, OnNCUAHDrawCaption)
    302     MESSAGE_HANDLER_EX(WM_NCUAHDRAWFRAME, OnNCUAHDrawFrame)
    303 
    304     // Vista and newer
    305     MESSAGE_HANDLER_EX(WM_DWMCOMPOSITIONCHANGED, OnDwmCompositionChanged)
    306 
    307     // Non-atlcrack.h handlers
    308     MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject)
    309 
    310     // Mouse events.
    311     MESSAGE_HANDLER_EX(WM_MOUSEACTIVATE, OnMouseActivate)
    312     MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseRange)
    313     MESSAGE_HANDLER_EX(WM_NCMOUSELEAVE, OnMouseRange)
    314     MESSAGE_HANDLER_EX(WM_SETCURSOR, OnSetCursor);
    315 
    316     // Key events.
    317     MESSAGE_HANDLER_EX(WM_KEYDOWN, OnKeyEvent)
    318     MESSAGE_HANDLER_EX(WM_KEYUP, OnKeyEvent)
    319     MESSAGE_HANDLER_EX(WM_SYSKEYDOWN, OnKeyEvent)
    320     MESSAGE_HANDLER_EX(WM_SYSKEYUP, OnKeyEvent)
    321 
    322     // IME Events.
    323     MESSAGE_HANDLER_EX(WM_IME_SETCONTEXT, OnImeMessages)
    324     MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeMessages)
    325     MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeMessages)
    326     MESSAGE_HANDLER_EX(WM_IME_ENDCOMPOSITION, OnImeMessages)
    327     MESSAGE_HANDLER_EX(WM_IME_REQUEST, OnImeMessages)
    328     MESSAGE_HANDLER_EX(WM_IME_NOTIFY, OnImeMessages)
    329     MESSAGE_HANDLER_EX(WM_CHAR, OnImeMessages)
    330     MESSAGE_HANDLER_EX(WM_SYSCHAR, OnImeMessages)
    331     MESSAGE_HANDLER_EX(WM_DEADCHAR, OnImeMessages)
    332     MESSAGE_HANDLER_EX(WM_SYSDEADCHAR, OnImeMessages)
    333 
    334     // Scroll events
    335     MESSAGE_HANDLER_EX(WM_VSCROLL, OnScrollMessage)
    336     MESSAGE_HANDLER_EX(WM_HSCROLL, OnScrollMessage)
    337 
    338     // Touch Events.
    339     MESSAGE_HANDLER_EX(WM_TOUCH, OnTouchEvent)
    340 
    341     // Uses the general handler macro since the specific handler macro
    342     // MSG_WM_NCACTIVATE would convert WPARAM type to BOOL type. The high
    343     // word of WPARAM could be set when the window is minimized or restored.
    344     MESSAGE_HANDLER_EX(WM_NCACTIVATE, OnNCActivate)
    345 
    346     // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU.
    347     MSG_WM_ACTIVATEAPP(OnActivateApp)
    348     MSG_WM_APPCOMMAND(OnAppCommand)
    349     MSG_WM_CANCELMODE(OnCancelMode)
    350     MSG_WM_CAPTURECHANGED(OnCaptureChanged)
    351     MSG_WM_CLOSE(OnClose)
    352     MSG_WM_COMMAND(OnCommand)
    353     MSG_WM_CREATE(OnCreate)
    354     MSG_WM_DESTROY(OnDestroy)
    355     MSG_WM_DISPLAYCHANGE(OnDisplayChange)
    356     MSG_WM_ENTERSIZEMOVE(OnEnterSizeMove)
    357     MSG_WM_ERASEBKGND(OnEraseBkgnd)
    358     MSG_WM_EXITSIZEMOVE(OnExitSizeMove)
    359     MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo)
    360     MSG_WM_INITMENU(OnInitMenu)
    361     MSG_WM_INPUTLANGCHANGE(OnInputLangChange)
    362     MSG_WM_KILLFOCUS(OnKillFocus)
    363     MSG_WM_MOVE(OnMove)
    364     MSG_WM_MOVING(OnMoving)
    365     MSG_WM_NCCALCSIZE(OnNCCalcSize)
    366     MSG_WM_NCHITTEST(OnNCHitTest)
    367     MSG_WM_NCPAINT(OnNCPaint)
    368     MSG_WM_NOTIFY(OnNotify)
    369     MSG_WM_PAINT(OnPaint)
    370     MSG_WM_SETFOCUS(OnSetFocus)
    371     MSG_WM_SETICON(OnSetIcon)
    372     MSG_WM_SETTEXT(OnSetText)
    373     MSG_WM_SETTINGCHANGE(OnSettingChange)
    374     MSG_WM_SIZE(OnSize)
    375     MSG_WM_SYSCOMMAND(OnSysCommand)
    376     MSG_WM_THEMECHANGED(OnThemeChanged)
    377     MSG_WM_WINDOWPOSCHANGED(OnWindowPosChanged)
    378     MSG_WM_WINDOWPOSCHANGING(OnWindowPosChanging)
    379     MSG_WM_WTSSESSION_CHANGE(OnSessionChange)
    380   END_MSG_MAP()
    381 
    382   // Message Handlers.
    383   // This list is in _ALPHABETICAL_ order!
    384   // TODO(beng): Once this object becomes the WindowImpl, these methods can
    385   //             be made private.
    386   void OnActivateApp(BOOL active, DWORD thread_id);
    387   // TODO(beng): return BOOL is temporary until this object becomes a
    388   //             WindowImpl.
    389   BOOL OnAppCommand(HWND window, short command, WORD device, int keystate);
    390   void OnCancelMode();
    391   void OnCaptureChanged(HWND window);
    392   void OnClose();
    393   void OnCommand(UINT notification_code, int command, HWND window);
    394   LRESULT OnCreate(CREATESTRUCT* create_struct);
    395   void OnDestroy();
    396   void OnDisplayChange(UINT bits_per_pixel, const CSize& screen_size);
    397   LRESULT OnDwmCompositionChanged(UINT msg, WPARAM w_param, LPARAM l_param);
    398   void OnEnterSizeMove();
    399   LRESULT OnEraseBkgnd(HDC dc);
    400   void OnExitSizeMove();
    401   void OnGetMinMaxInfo(MINMAXINFO* minmax_info);
    402   LRESULT OnGetObject(UINT message, WPARAM w_param, LPARAM l_param);
    403   LRESULT OnImeMessages(UINT message, WPARAM w_param, LPARAM l_param);
    404   void OnInitMenu(HMENU menu);
    405   void OnInputLangChange(DWORD character_set, HKL input_language_id);
    406   LRESULT OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param);
    407   void OnKillFocus(HWND focused_window);
    408   LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param);
    409   LRESULT OnMouseRange(UINT message, WPARAM w_param, LPARAM l_param);
    410   void OnMove(const CPoint& point);
    411   void OnMoving(UINT param, const RECT* new_bounds);
    412   LRESULT OnNCActivate(UINT message, WPARAM w_param, LPARAM l_param);
    413   LRESULT OnNCCalcSize(BOOL mode, LPARAM l_param);
    414   LRESULT OnNCHitTest(const CPoint& point);
    415   void OnNCPaint(HRGN rgn);
    416   LRESULT OnNCUAHDrawCaption(UINT message, WPARAM w_param, LPARAM l_param);
    417   LRESULT OnNCUAHDrawFrame(UINT message, WPARAM w_param, LPARAM l_param);
    418   LRESULT OnNotify(int w_param, NMHDR* l_param);
    419   void OnPaint(HDC dc);
    420   LRESULT OnReflectedMessage(UINT message, WPARAM w_param, LPARAM l_param);
    421   LRESULT OnScrollMessage(UINT message, WPARAM w_param, LPARAM l_param);
    422   void OnSessionChange(WPARAM status_code, PWTSSESSION_NOTIFICATION session_id);
    423   LRESULT OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param);
    424   void OnSetFocus(HWND last_focused_window);
    425   LRESULT OnSetIcon(UINT size_type, HICON new_icon);
    426   LRESULT OnSetText(const wchar_t* text);
    427   void OnSettingChange(UINT flags, const wchar_t* section);
    428   void OnSize(UINT param, const CSize& size);
    429   void OnSysCommand(UINT notification_code, const CPoint& point);
    430   void OnThemeChanged();
    431   LRESULT OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param);
    432   void OnWindowPosChanging(WINDOWPOS* window_pos);
    433   void OnWindowPosChanged(WINDOWPOS* window_pos);
    434 
    435   typedef std::vector<ui::TouchEvent> TouchEvents;
    436   // Helper to handle the list of touch events passed in. We need this because
    437   // touch events on windows don't fire if we enter a modal loop in the context
    438   // of a touch event.
    439   void HandleTouchEvents(const TouchEvents& touch_events);
    440 
    441   HWNDMessageHandlerDelegate* delegate_;
    442 
    443   scoped_ptr<FullscreenHandler> fullscreen_handler_;
    444 
    445   // Set to true in Close() and false is CloseNow().
    446   bool waiting_for_close_now_;
    447 
    448   bool remove_standard_frame_;
    449 
    450   bool use_system_default_icon_;
    451 
    452   // Whether the focus should be restored next time we get enabled.  Needed to
    453   // restore focus correctly when Windows modal dialogs are displayed.
    454   bool restore_focus_when_enabled_;
    455 
    456   // Whether all ancestors have been enabled. This is only used if is_modal_ is
    457   // true.
    458   bool restored_enabled_;
    459 
    460   // The current cursor.
    461   HCURSOR current_cursor_;
    462 
    463   // The last cursor that was active before the current one was selected. Saved
    464   // so that we can restore it.
    465   HCURSOR previous_cursor_;
    466 
    467   // Event handling ------------------------------------------------------------
    468 
    469   // The flags currently being used with TrackMouseEvent to track mouse
    470   // messages. 0 if there is no active tracking. The value of this member is
    471   // used when tracking is canceled.
    472   DWORD active_mouse_tracking_flags_;
    473 
    474   // Set to true when the user presses the right mouse button on the caption
    475   // area. We need this so we can correctly show the context menu on mouse-up.
    476   bool is_right_mouse_pressed_on_caption_;
    477 
    478   // The set of touch devices currently down.
    479   TouchIDs touch_ids_;
    480 
    481   // ScopedRedrawLock ----------------------------------------------------------
    482 
    483   // Represents the number of ScopedRedrawLocks active against this widget.
    484   // If this is greater than zero, the widget should be locked against updates.
    485   int lock_updates_count_;
    486 
    487   // Window resizing -----------------------------------------------------------
    488 
    489   // When true, this flag makes us discard incoming SetWindowPos() requests that
    490   // only change our position/size.  (We still allow changes to Z-order,
    491   // activation, etc.)
    492   bool ignore_window_pos_changes_;
    493 
    494   // The last-seen monitor containing us, and its rect and work area.  These are
    495   // used to catch updates to the rect and work area and react accordingly.
    496   HMONITOR last_monitor_;
    497   gfx::Rect last_monitor_rect_, last_work_area_;
    498 
    499   // Layered windows -----------------------------------------------------------
    500 
    501   // Should we keep an off-screen buffer? This is false by default, set to true
    502   // when WS_EX_LAYERED is specified before the native window is created.
    503   //
    504   // NOTE: this is intended to be used with a layered window (a window with an
    505   // extended window style of WS_EX_LAYERED). If you are using a layered window
    506   // and NOT changing the layered alpha or anything else, then leave this value
    507   // alone. OTOH if you are invoking SetLayeredWindowAttributes then you'll
    508   // most likely want to set this to false, or after changing the alpha toggle
    509   // the extended style bit to false than back to true. See MSDN for more
    510   // details.
    511   bool use_layered_buffer_;
    512 
    513   // The default alpha to be applied to the layered window.
    514   BYTE layered_alpha_;
    515 
    516   // A canvas that contains the window contents in the case of a layered
    517   // window.
    518   scoped_ptr<gfx::Canvas> layered_window_contents_;
    519 
    520   // We must track the invalid rect ourselves, for two reasons:
    521   // For layered windows, Windows will not do this properly with
    522   // InvalidateRect()/GetUpdateRect(). (In fact, it'll return misleading
    523   // information from GetUpdateRect()).
    524   // We also need to keep track of the invalid rectangle for the RootView should
    525   // we need to paint the non-client area. The data supplied to WM_NCPAINT seems
    526   // to be insufficient.
    527   gfx::Rect invalid_rect_;
    528 
    529   // Set to true when waiting for RedrawLayeredWindowContents().
    530   bool waiting_for_redraw_layered_window_contents_;
    531 
    532   // True the first time nccalc is called on a sizable widget
    533   bool is_first_nccalc_;
    534 
    535   // Copy of custom window region specified via SetRegion(), if any.
    536   base::win::ScopedRegion custom_window_region_;
    537 
    538   // A factory used to lookup appbar autohide edges.
    539   base::WeakPtrFactory<HWNDMessageHandler> autohide_factory_;
    540 
    541   // Generates touch-ids for touch-events.
    542   ui::SequentialIDGenerator id_generator_;
    543 
    544   // Indicates if the window needs the WS_VSCROLL and WS_HSCROLL styles.
    545   bool needs_scroll_styles_;
    546 
    547   // Set to true if we are in the context of a sizing operation.
    548   bool in_size_loop_;
    549 
    550   DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler);
    551 };
    552 
    553 // This window property if set on the window does not activate the window for a
    554 // touch based WM_MOUSEACTIVATE message.
    555 const wchar_t kIgnoreTouchMouseActivateForWindow[] =
    556     L"Chrome.IgnoreMouseActivate";
    557 
    558 }  // namespace views
    559 
    560 #endif  // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_
    561