| 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 <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // with captions. They appear to paint the window caption and frame. | 52 // with captions. They appear to paint the window caption and frame. |
| 53 // Unfortunately if you override the standard non-client rendering as we do | 53 // Unfortunately if you override the standard non-client rendering as we do |
| 54 // with CustomFrameWindow, sometimes Windows (not deterministically | 54 // with CustomFrameWindow, sometimes Windows (not deterministically |
| 55 // reproducibly but definitely frequently) will send these messages to the | 55 // reproducibly but definitely frequently) will send these messages to the |
| 56 // window and paint the standard caption/title over the top of the custom one. | 56 // window and paint the standard caption/title over the top of the custom one. |
| 57 // So we need to handle these messages in CustomFrameWindow to prevent this | 57 // So we need to handle these messages in CustomFrameWindow to prevent this |
| 58 // from happening. | 58 // from happening. |
| 59 const int WM_NCUAHDRAWCAPTION = 0xAE; | 59 const int WM_NCUAHDRAWCAPTION = 0xAE; |
| 60 const int WM_NCUAHDRAWFRAME = 0xAF; | 60 const int WM_NCUAHDRAWFRAME = 0xAF; |
| 61 | 61 |
| 62 // The HWNDMessageHandler sends this message to itself on |
| 63 // WM_WINDOWPOSCHANGING. It's used to inform the client if a |
| 64 // WM_WINDOWPOSCHANGED won't be received. |
| 65 const int WM_WINDOWSIZINGFINISHED = WM_USER; |
| 66 |
| 62 // IsMsgHandled() and BEGIN_SAFE_MSG_MAP_EX are a modified version of | 67 // IsMsgHandled() and BEGIN_SAFE_MSG_MAP_EX are a modified version of |
| 63 // BEGIN_MSG_MAP_EX. The main difference is it uses a WeakPtrFactory member | 68 // BEGIN_MSG_MAP_EX. The main difference is it uses a WeakPtrFactory member |
| 64 // (|weak_factory|) that is used in _ProcessWindowMessage() and changing | 69 // (|weak_factory|) that is used in _ProcessWindowMessage() and changing |
| 65 // IsMsgHandled() from a member function to a define that checks if the weak | 70 // IsMsgHandled() from a member function to a define that checks if the weak |
| 66 // factory is still valid in addition to the member. Together these allow for | 71 // factory is still valid in addition to the member. Together these allow for |
| 67 // |this| to be deleted during dispatch. | 72 // |this| to be deleted during dispatch. |
| 68 #define IsMsgHandled() !ref.get() || msg_handled_ | 73 #define IsMsgHandled() !ref.get() || msg_handled_ |
| 69 | 74 |
| 70 #define BEGIN_SAFE_MSG_MAP_EX(weak_factory) \ | 75 #define BEGIN_SAFE_MSG_MAP_EX(weak_factory) \ |
| 71 private: \ | 76 private: \ |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 CR_MESSAGE_HANDLER_EX(WM_CHAR, OnImeMessages) | 371 CR_MESSAGE_HANDLER_EX(WM_CHAR, OnImeMessages) |
| 367 CR_MESSAGE_HANDLER_EX(WM_SYSCHAR, OnImeMessages) | 372 CR_MESSAGE_HANDLER_EX(WM_SYSCHAR, OnImeMessages) |
| 368 | 373 |
| 369 // Scroll events | 374 // Scroll events |
| 370 CR_MESSAGE_HANDLER_EX(WM_VSCROLL, OnScrollMessage) | 375 CR_MESSAGE_HANDLER_EX(WM_VSCROLL, OnScrollMessage) |
| 371 CR_MESSAGE_HANDLER_EX(WM_HSCROLL, OnScrollMessage) | 376 CR_MESSAGE_HANDLER_EX(WM_HSCROLL, OnScrollMessage) |
| 372 | 377 |
| 373 // Touch Events. | 378 // Touch Events. |
| 374 CR_MESSAGE_HANDLER_EX(WM_TOUCH, OnTouchEvent) | 379 CR_MESSAGE_HANDLER_EX(WM_TOUCH, OnTouchEvent) |
| 375 | 380 |
| 381 CR_MESSAGE_HANDLER_EX(WM_WINDOWSIZINGFINISHED, OnWindowSizingFinished) |
| 382 |
| 376 // Uses the general handler macro since the specific handler macro | 383 // Uses the general handler macro since the specific handler macro |
| 377 // MSG_WM_NCACTIVATE would convert WPARAM type to BOOL type. The high | 384 // MSG_WM_NCACTIVATE would convert WPARAM type to BOOL type. The high |
| 378 // word of WPARAM could be set when the window is minimized or restored. | 385 // word of WPARAM could be set when the window is minimized or restored. |
| 379 CR_MESSAGE_HANDLER_EX(WM_NCACTIVATE, OnNCActivate) | 386 CR_MESSAGE_HANDLER_EX(WM_NCACTIVATE, OnNCActivate) |
| 380 | 387 |
| 381 // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU. | 388 // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU. |
| 382 CR_MSG_WM_ACTIVATEAPP(OnActivateApp) | 389 CR_MSG_WM_ACTIVATEAPP(OnActivateApp) |
| 383 CR_MSG_WM_APPCOMMAND(OnAppCommand) | 390 CR_MSG_WM_APPCOMMAND(OnAppCommand) |
| 384 CR_MSG_WM_CANCELMODE(OnCancelMode) | 391 CR_MSG_WM_CANCELMODE(OnCancelMode) |
| 385 CR_MSG_WM_CAPTURECHANGED(OnCaptureChanged) | 392 CR_MSG_WM_CAPTURECHANGED(OnCaptureChanged) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 void OnSetFocus(HWND last_focused_window); | 470 void OnSetFocus(HWND last_focused_window); |
| 464 LRESULT OnSetIcon(UINT size_type, HICON new_icon); | 471 LRESULT OnSetIcon(UINT size_type, HICON new_icon); |
| 465 LRESULT OnSetText(const wchar_t* text); | 472 LRESULT OnSetText(const wchar_t* text); |
| 466 void OnSettingChange(UINT flags, const wchar_t* section); | 473 void OnSettingChange(UINT flags, const wchar_t* section); |
| 467 void OnSize(UINT param, const gfx::Size& size); | 474 void OnSize(UINT param, const gfx::Size& size); |
| 468 void OnSysCommand(UINT notification_code, const gfx::Point& point); | 475 void OnSysCommand(UINT notification_code, const gfx::Point& point); |
| 469 void OnThemeChanged(); | 476 void OnThemeChanged(); |
| 470 LRESULT OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param); | 477 LRESULT OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param); |
| 471 void OnWindowPosChanging(WINDOWPOS* window_pos); | 478 void OnWindowPosChanging(WINDOWPOS* window_pos); |
| 472 void OnWindowPosChanged(WINDOWPOS* window_pos); | 479 void OnWindowPosChanged(WINDOWPOS* window_pos); |
| 480 LRESULT OnWindowSizingFinished(UINT message, WPARAM w_param, LPARAM l_param); |
| 473 | 481 |
| 474 // Receives Windows Session Change notifications. | 482 // Receives Windows Session Change notifications. |
| 475 void OnSessionChange(WPARAM status_code); | 483 void OnSessionChange(WPARAM status_code); |
| 476 | 484 |
| 477 typedef std::vector<ui::TouchEvent> TouchEvents; | 485 typedef std::vector<ui::TouchEvent> TouchEvents; |
| 478 // Helper to handle the list of touch events passed in. We need this because | 486 // Helper to handle the list of touch events passed in. We need this because |
| 479 // touch events on windows don't fire if we enter a modal loop in the context | 487 // touch events on windows don't fire if we enter a modal loop in the context |
| 480 // of a touch event. | 488 // of a touch event. |
| 481 void HandleTouchEvents(const TouchEvents& touch_events); | 489 void HandleTouchEvents(const TouchEvents& touch_events); |
| 482 | 490 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 | 643 |
| 636 // On Windows Vista and beyond, if we are transitioning from custom frame | 644 // On Windows Vista and beyond, if we are transitioning from custom frame |
| 637 // to Aero(glass) we delay setting the DWM related properties in full | 645 // to Aero(glass) we delay setting the DWM related properties in full |
| 638 // screen mode as DWM is not supported in full screen windows. We perform | 646 // screen mode as DWM is not supported in full screen windows. We perform |
| 639 // the DWM related operations when the window comes out of fullscreen mode. | 647 // the DWM related operations when the window comes out of fullscreen mode. |
| 640 // This member variable is set to true if the window is transitioning to | 648 // This member variable is set to true if the window is transitioning to |
| 641 // glass. Defaults to false. | 649 // glass. Defaults to false. |
| 642 bool dwm_transition_desired_; | 650 bool dwm_transition_desired_; |
| 643 | 651 |
| 644 // True if HandleWindowSizeChanging has been called in the delegate, but not | 652 // True if HandleWindowSizeChanging has been called in the delegate, but not |
| 645 // HandleWindowSizeChanged. | 653 // HandleClientSizeChanged. |
| 646 bool sent_window_size_changing_; | 654 bool sent_window_size_changing_; |
| 647 | 655 |
| 656 // This is used to keep track of whether a WM_WINDOWPOSCHANGED has |
| 657 // been received after the WM_WINDOWPOSCHANGING. |
| 658 uint32_t current_window_size_message_ = 0; |
| 659 |
| 648 // Manages observation of Windows Session Change messages. | 660 // Manages observation of Windows Session Change messages. |
| 649 std::unique_ptr<WindowsSessionChangeObserver> | 661 std::unique_ptr<WindowsSessionChangeObserver> |
| 650 windows_session_change_observer_; | 662 windows_session_change_observer_; |
| 651 | 663 |
| 652 // This class provides functionality to register the legacy window as a | 664 // This class provides functionality to register the legacy window as a |
| 653 // Direct Manipulation consumer. This allows us to support smooth scroll | 665 // Direct Manipulation consumer. This allows us to support smooth scroll |
| 654 // in Chrome on Windows 10. | 666 // in Chrome on Windows 10. |
| 655 std::unique_ptr<gfx::win::DirectManipulationHelper> | 667 std::unique_ptr<gfx::win::DirectManipulationHelper> |
| 656 direct_manipulation_helper_; | 668 direct_manipulation_helper_; |
| 657 | 669 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 684 | 696 |
| 685 // The factory used with BEGIN_SAFE_MSG_MAP_EX. | 697 // The factory used with BEGIN_SAFE_MSG_MAP_EX. |
| 686 base::WeakPtrFactory<HWNDMessageHandler> weak_factory_; | 698 base::WeakPtrFactory<HWNDMessageHandler> weak_factory_; |
| 687 | 699 |
| 688 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); | 700 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); |
| 689 }; | 701 }; |
| 690 | 702 |
| 691 } // namespace views | 703 } // namespace views |
| 692 | 704 |
| 693 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ | 705 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ |
| OLD | NEW |