| 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> |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
| 20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
| 21 #include "base/win/scoped_gdi_object.h" | 21 #include "base/win/scoped_gdi_object.h" |
| 22 #include "base/win/win_util.h" | 22 #include "base/win/win_util.h" |
| 23 #include "ui/accessibility/ax_enums.h" | 23 #include "ui/accessibility/ax_enums.h" |
| 24 #include "ui/base/ime/input_method_observer.h" | |
| 25 #include "ui/base/ui_base_types.h" | 24 #include "ui/base/ui_base_types.h" |
| 26 #include "ui/base/win/window_event_target.h" | 25 #include "ui/base/win/window_event_target.h" |
| 27 #include "ui/events/event.h" | 26 #include "ui/events/event.h" |
| 28 #include "ui/gfx/geometry/rect.h" | 27 #include "ui/gfx/geometry/rect.h" |
| 29 #include "ui/gfx/sequential_id_generator.h" | 28 #include "ui/gfx/sequential_id_generator.h" |
| 30 #include "ui/gfx/win/window_impl.h" | 29 #include "ui/gfx/win/window_impl.h" |
| 31 #include "ui/views/views_export.h" | 30 #include "ui/views/views_export.h" |
| 32 | 31 |
| 33 namespace gfx { | 32 namespace gfx { |
| 34 class ImageSkia; | 33 class ImageSkia; |
| 35 class Insets; | 34 class Insets; |
| 36 namespace win { | 35 namespace win { |
| 37 class DirectManipulationHelper; | 36 class DirectManipulationHelper; |
| 38 } // namespace win | 37 } // namespace win |
| 39 } // namespace gfx | 38 } // namespace gfx |
| 40 | 39 |
| 41 namespace ui { | 40 namespace ui { |
| 42 class AXSystemCaretWin; | |
| 43 class InputMethod; | |
| 44 class TextInputClient; | |
| 45 class ViewProp; | 41 class ViewProp; |
| 46 } | 42 } |
| 47 | 43 |
| 48 namespace views { | 44 namespace views { |
| 49 | 45 |
| 50 class FullscreenHandler; | 46 class FullscreenHandler; |
| 51 class HWNDMessageHandlerDelegate; | 47 class HWNDMessageHandlerDelegate; |
| 52 class WindowsSessionChangeObserver; | 48 class WindowsSessionChangeObserver; |
| 53 | 49 |
| 54 // These two messages aren't defined in winuser.h, but they are sent to windows | 50 // These two messages aren't defined in winuser.h, but they are sent to windows |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 bHandled; \ | 110 bHandled; \ |
| 115 switch(dwMsgMapID) { \ | 111 switch(dwMsgMapID) { \ |
| 116 case 0: | 112 case 0: |
| 117 | 113 |
| 118 // An object that handles messages for a HWND that implements the views | 114 // An object that handles messages for a HWND that implements the views |
| 119 // "Custom Frame" look. The purpose of this class is to isolate the windows- | 115 // "Custom Frame" look. The purpose of this class is to isolate the windows- |
| 120 // specific message handling from the code that wraps it. It is intended to be | 116 // specific message handling from the code that wraps it. It is intended to be |
| 121 // used by both a views::NativeWidget and an aura::WindowTreeHost | 117 // used by both a views::NativeWidget and an aura::WindowTreeHost |
| 122 // implementation. | 118 // implementation. |
| 123 // TODO(beng): This object should eventually *become* the WindowImpl. | 119 // TODO(beng): This object should eventually *become* the WindowImpl. |
| 124 class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl, | 120 class VIEWS_EXPORT HWNDMessageHandler : |
| 125 public ui::InputMethodObserver, | 121 public gfx::WindowImpl, |
| 126 public ui::WindowEventTarget { | 122 public ui::WindowEventTarget { |
| 127 public: | 123 public: |
| 128 explicit HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate); | 124 explicit HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate); |
| 129 ~HWNDMessageHandler() override; | 125 ~HWNDMessageHandler() override; |
| 130 | 126 |
| 131 void Init(HWND parent, const gfx::Rect& bounds); | 127 void Init(HWND parent, const gfx::Rect& bounds); |
| 132 void InitModalType(ui::ModalType modal_type); | 128 void InitModalType(ui::ModalType modal_type); |
| 133 | 129 |
| 134 void Close(); | 130 void Close(); |
| 135 void CloseNow(); | 131 void CloseNow(); |
| 136 | 132 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 220 |
| 225 private: | 221 private: |
| 226 typedef std::set<DWORD> TouchIDs; | 222 typedef std::set<DWORD> TouchIDs; |
| 227 enum class DwmFrameState { OFF, ON }; | 223 enum class DwmFrameState { OFF, ON }; |
| 228 | 224 |
| 229 // Overridden from WindowImpl: | 225 // Overridden from WindowImpl: |
| 230 HICON GetDefaultWindowIcon() const override; | 226 HICON GetDefaultWindowIcon() const override; |
| 231 HICON GetSmallWindowIcon() const override; | 227 HICON GetSmallWindowIcon() const override; |
| 232 LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) override; | 228 LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) override; |
| 233 | 229 |
| 234 // Overridden from InputMethodObserver | |
| 235 void OnTextInputTypeChanged(const ui::TextInputClient* client) override; | |
| 236 void OnFocus() override; | |
| 237 void OnBlur() override; | |
| 238 void OnCaretBoundsChanged(const ui::TextInputClient* client) override; | |
| 239 void OnTextInputStateChanged(const ui::TextInputClient* client) override; | |
| 240 void OnInputMethodDestroyed(const ui::InputMethod* input_method) override; | |
| 241 void OnShowImeIfNeeded() override; | |
| 242 | |
| 243 // Overridden from WindowEventTarget | 230 // Overridden from WindowEventTarget |
| 244 LRESULT HandleMouseMessage(unsigned int message, | 231 LRESULT HandleMouseMessage(unsigned int message, |
| 245 WPARAM w_param, | 232 WPARAM w_param, |
| 246 LPARAM l_param, | 233 LPARAM l_param, |
| 247 bool* handled) override; | 234 bool* handled) override; |
| 248 LRESULT HandleKeyboardMessage(unsigned int message, | 235 LRESULT HandleKeyboardMessage(unsigned int message, |
| 249 WPARAM w_param, | 236 WPARAM w_param, |
| 250 LPARAM l_param, | 237 LPARAM l_param, |
| 251 bool* handled) override; | 238 bool* handled) override; |
| 252 LRESULT HandleTouchMessage(unsigned int message, | 239 LRESULT HandleTouchMessage(unsigned int message, |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 // Checks if there is a full screen window on the same monitor as the | 567 // Checks if there is a full screen window on the same monitor as the |
| 581 // |window| which is becoming active. If yes then we reduce the size of the | 568 // |window| which is becoming active. If yes then we reduce the size of the |
| 582 // fullscreen window by 1 px to ensure that maximized windows on the same | 569 // fullscreen window by 1 px to ensure that maximized windows on the same |
| 583 // monitor don't draw over the taskbar. | 570 // monitor don't draw over the taskbar. |
| 584 void CheckAndHandleBackgroundFullscreenOnMonitor(HWND window); | 571 void CheckAndHandleBackgroundFullscreenOnMonitor(HWND window); |
| 585 | 572 |
| 586 // Provides functionality to reduce the bounds of the fullscreen window by 1 | 573 // Provides functionality to reduce the bounds of the fullscreen window by 1 |
| 587 // px on activation loss to a window on the same monitor. | 574 // px on activation loss to a window on the same monitor. |
| 588 void OnBackgroundFullscreen(); | 575 void OnBackgroundFullscreen(); |
| 589 | 576 |
| 590 // Deletes the system caret used for accessibility. This will result in any | |
| 591 // clients that are still holding onto its |IAccessible| to get a failure code | |
| 592 // if they request its location. | |
| 593 void DestroyAXSystemCaret(); | |
| 594 | |
| 595 HWNDMessageHandlerDelegate* delegate_; | 577 HWNDMessageHandlerDelegate* delegate_; |
| 596 | 578 |
| 597 std::unique_ptr<FullscreenHandler> fullscreen_handler_; | 579 std::unique_ptr<FullscreenHandler> fullscreen_handler_; |
| 598 | 580 |
| 599 // Set to true in Close() and false is CloseNow(). | 581 // Set to true in Close() and false is CloseNow(). |
| 600 bool waiting_for_close_now_; | 582 bool waiting_for_close_now_; |
| 601 | 583 |
| 602 bool use_system_default_icon_; | 584 bool use_system_default_icon_; |
| 603 | 585 |
| 604 // Whether all ancestors have been enabled. This is only used if is_modal_ is | 586 // Whether all ancestors have been enabled. This is only used if is_modal_ is |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 bool sent_window_size_changing_; | 691 bool sent_window_size_changing_; |
| 710 | 692 |
| 711 // This is used to keep track of whether a WM_WINDOWPOSCHANGED has | 693 // This is used to keep track of whether a WM_WINDOWPOSCHANGED has |
| 712 // been received after the WM_WINDOWPOSCHANGING. | 694 // been received after the WM_WINDOWPOSCHANGING. |
| 713 uint32_t current_window_size_message_ = 0; | 695 uint32_t current_window_size_message_ = 0; |
| 714 | 696 |
| 715 // Manages observation of Windows Session Change messages. | 697 // Manages observation of Windows Session Change messages. |
| 716 std::unique_ptr<WindowsSessionChangeObserver> | 698 std::unique_ptr<WindowsSessionChangeObserver> |
| 717 windows_session_change_observer_; | 699 windows_session_change_observer_; |
| 718 | 700 |
| 719 // Some assistive software need to track the location of the caret. | |
| 720 std::unique_ptr<ui::AXSystemCaretWin> ax_system_caret_; | |
| 721 | |
| 722 // This class provides functionality to register the legacy window as a | 701 // This class provides functionality to register the legacy window as a |
| 723 // Direct Manipulation consumer. This allows us to support smooth scroll | 702 // Direct Manipulation consumer. This allows us to support smooth scroll |
| 724 // in Chrome on Windows 10. | 703 // in Chrome on Windows 10. |
| 725 std::unique_ptr<gfx::win::DirectManipulationHelper> | 704 std::unique_ptr<gfx::win::DirectManipulationHelper> |
| 726 direct_manipulation_helper_; | 705 direct_manipulation_helper_; |
| 727 | 706 |
| 728 // The location where the user clicked on the caption. We cache this when we | 707 // The location where the user clicked on the caption. We cache this when we |
| 729 // receive the WM_NCLBUTTONDOWN message. We use this in the subsequent | 708 // receive the WM_NCLBUTTONDOWN message. We use this in the subsequent |
| 730 // WM_NCMOUSEMOVE message to see if the mouse actually moved. | 709 // WM_NCMOUSEMOVE message to see if the mouse actually moved. |
| 731 // Please refer to the HandleMouseEventInternal function for details on why | 710 // Please refer to the HandleMouseEventInternal function for details on why |
| (...skipping 27 matching lines...) Expand all Loading... |
| 759 | 738 |
| 760 // The factory used with BEGIN_SAFE_MSG_MAP_EX. | 739 // The factory used with BEGIN_SAFE_MSG_MAP_EX. |
| 761 base::WeakPtrFactory<HWNDMessageHandler> weak_factory_; | 740 base::WeakPtrFactory<HWNDMessageHandler> weak_factory_; |
| 762 | 741 |
| 763 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); | 742 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); |
| 764 }; | 743 }; |
| 765 | 744 |
| 766 } // namespace views | 745 } // namespace views |
| 767 | 746 |
| 768 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ | 747 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ |
| OLD | NEW |