| 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" |
| 24 #include "ui/base/ui_base_types.h" | 25 #include "ui/base/ui_base_types.h" |
| 25 #include "ui/base/win/window_event_target.h" | 26 #include "ui/base/win/window_event_target.h" |
| 26 #include "ui/events/event.h" | 27 #include "ui/events/event.h" |
| 27 #include "ui/gfx/geometry/rect.h" | 28 #include "ui/gfx/geometry/rect.h" |
| 28 #include "ui/gfx/sequential_id_generator.h" | 29 #include "ui/gfx/sequential_id_generator.h" |
| 29 #include "ui/gfx/win/window_impl.h" | 30 #include "ui/gfx/win/window_impl.h" |
| 30 #include "ui/views/views_export.h" | 31 #include "ui/views/views_export.h" |
| 31 | 32 |
| 32 namespace gfx { | 33 namespace gfx { |
| 33 class ImageSkia; | 34 class ImageSkia; |
| 34 class Insets; | 35 class Insets; |
| 35 namespace win { | 36 namespace win { |
| 36 class DirectManipulationHelper; | 37 class DirectManipulationHelper; |
| 37 } // namespace win | 38 } // namespace win |
| 38 } // namespace gfx | 39 } // namespace gfx |
| 39 | 40 |
| 40 namespace ui { | 41 namespace ui { |
| 42 class AXFakeCaretWin; |
| 43 class InputMethod; |
| 44 class TextInputClient; |
| 41 class ViewProp; | 45 class ViewProp; |
| 42 } | 46 } |
| 43 | 47 |
| 44 namespace views { | 48 namespace views { |
| 45 | 49 |
| 46 class FullscreenHandler; | 50 class FullscreenHandler; |
| 47 class HWNDMessageHandlerDelegate; | 51 class HWNDMessageHandlerDelegate; |
| 48 class WindowsSessionChangeObserver; | 52 class WindowsSessionChangeObserver; |
| 49 | 53 |
| 50 // These two messages aren't defined in winuser.h, but they are sent to windows | 54 // 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... |
| 110 bHandled; \ | 114 bHandled; \ |
| 111 switch(dwMsgMapID) { \ | 115 switch(dwMsgMapID) { \ |
| 112 case 0: | 116 case 0: |
| 113 | 117 |
| 114 // An object that handles messages for a HWND that implements the views | 118 // An object that handles messages for a HWND that implements the views |
| 115 // "Custom Frame" look. The purpose of this class is to isolate the windows- | 119 // "Custom Frame" look. The purpose of this class is to isolate the windows- |
| 116 // specific message handling from the code that wraps it. It is intended to be | 120 // specific message handling from the code that wraps it. It is intended to be |
| 117 // used by both a views::NativeWidget and an aura::WindowTreeHost | 121 // used by both a views::NativeWidget and an aura::WindowTreeHost |
| 118 // implementation. | 122 // implementation. |
| 119 // TODO(beng): This object should eventually *become* the WindowImpl. | 123 // TODO(beng): This object should eventually *become* the WindowImpl. |
| 120 class VIEWS_EXPORT HWNDMessageHandler : | 124 class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl, |
| 121 public gfx::WindowImpl, | 125 public ui::InputMethodObserver, |
| 122 public ui::WindowEventTarget { | 126 public ui::WindowEventTarget { |
| 123 public: | 127 public: |
| 124 explicit HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate); | 128 explicit HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate); |
| 125 ~HWNDMessageHandler() override; | 129 ~HWNDMessageHandler() override; |
| 126 | 130 |
| 127 void Init(HWND parent, const gfx::Rect& bounds); | 131 void Init(HWND parent, const gfx::Rect& bounds); |
| 128 void InitModalType(ui::ModalType modal_type); | 132 void InitModalType(ui::ModalType modal_type); |
| 129 | 133 |
| 130 void Close(); | 134 void Close(); |
| 131 void CloseNow(); | 135 void CloseNow(); |
| 132 | 136 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 219 |
| 216 private: | 220 private: |
| 217 typedef std::set<DWORD> TouchIDs; | 221 typedef std::set<DWORD> TouchIDs; |
| 218 enum class DwmFrameState { OFF, ON }; | 222 enum class DwmFrameState { OFF, ON }; |
| 219 | 223 |
| 220 // Overridden from WindowImpl: | 224 // Overridden from WindowImpl: |
| 221 HICON GetDefaultWindowIcon() const override; | 225 HICON GetDefaultWindowIcon() const override; |
| 222 HICON GetSmallWindowIcon() const override; | 226 HICON GetSmallWindowIcon() const override; |
| 223 LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) override; | 227 LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) override; |
| 224 | 228 |
| 229 // Overridden from InputMethodObserver |
| 230 void OnTextInputTypeChanged(const ui::TextInputClient* client) override {} |
| 231 void OnFocus() override {} |
| 232 void OnBlur() override {} |
| 233 void OnCaretBoundsChanged(const ui::TextInputClient* client) override; |
| 234 void OnTextInputStateChanged(const ui::TextInputClient* client) override; |
| 235 void OnInputMethodDestroyed(const ui::InputMethod* input_method) override; |
| 236 void OnShowImeIfNeeded() override {} |
| 237 |
| 225 // Overridden from WindowEventTarget | 238 // Overridden from WindowEventTarget |
| 226 LRESULT HandleMouseMessage(unsigned int message, | 239 LRESULT HandleMouseMessage(unsigned int message, |
| 227 WPARAM w_param, | 240 WPARAM w_param, |
| 228 LPARAM l_param, | 241 LPARAM l_param, |
| 229 bool* handled) override; | 242 bool* handled) override; |
| 230 LRESULT HandleKeyboardMessage(unsigned int message, | 243 LRESULT HandleKeyboardMessage(unsigned int message, |
| 231 WPARAM w_param, | 244 WPARAM w_param, |
| 232 LPARAM l_param, | 245 LPARAM l_param, |
| 233 bool* handled) override; | 246 bool* handled) override; |
| 234 LRESULT HandleTouchMessage(unsigned int message, | 247 LRESULT HandleTouchMessage(unsigned int message, |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 bool sent_window_size_changing_; | 691 bool sent_window_size_changing_; |
| 679 | 692 |
| 680 // 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 |
| 681 // been received after the WM_WINDOWPOSCHANGING. | 694 // been received after the WM_WINDOWPOSCHANGING. |
| 682 uint32_t current_window_size_message_ = 0; | 695 uint32_t current_window_size_message_ = 0; |
| 683 | 696 |
| 684 // Manages observation of Windows Session Change messages. | 697 // Manages observation of Windows Session Change messages. |
| 685 std::unique_ptr<WindowsSessionChangeObserver> | 698 std::unique_ptr<WindowsSessionChangeObserver> |
| 686 windows_session_change_observer_; | 699 windows_session_change_observer_; |
| 687 | 700 |
| 701 // Some assistive software need to track the location of the caret. |
| 702 std::unique_ptr<ui::AXFakeCaretWin> ax_fake_caret_; |
| 703 |
| 688 // This class provides functionality to register the legacy window as a | 704 // This class provides functionality to register the legacy window as a |
| 689 // Direct Manipulation consumer. This allows us to support smooth scroll | 705 // Direct Manipulation consumer. This allows us to support smooth scroll |
| 690 // in Chrome on Windows 10. | 706 // in Chrome on Windows 10. |
| 691 std::unique_ptr<gfx::win::DirectManipulationHelper> | 707 std::unique_ptr<gfx::win::DirectManipulationHelper> |
| 692 direct_manipulation_helper_; | 708 direct_manipulation_helper_; |
| 693 | 709 |
| 694 // The location where the user clicked on the caption. We cache this when we | 710 // The location where the user clicked on the caption. We cache this when we |
| 695 // receive the WM_NCLBUTTONDOWN message. We use this in the subsequent | 711 // receive the WM_NCLBUTTONDOWN message. We use this in the subsequent |
| 696 // WM_NCMOUSEMOVE message to see if the mouse actually moved. | 712 // WM_NCMOUSEMOVE message to see if the mouse actually moved. |
| 697 // Please refer to the HandleMouseEventInternal function for details on why | 713 // Please refer to the HandleMouseEventInternal function for details on why |
| (...skipping 23 matching lines...) Expand all Loading... |
| 721 | 737 |
| 722 // The factory used with BEGIN_SAFE_MSG_MAP_EX. | 738 // The factory used with BEGIN_SAFE_MSG_MAP_EX. |
| 723 base::WeakPtrFactory<HWNDMessageHandler> weak_factory_; | 739 base::WeakPtrFactory<HWNDMessageHandler> weak_factory_; |
| 724 | 740 |
| 725 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); | 741 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); |
| 726 }; | 742 }; |
| 727 | 743 |
| 728 } // namespace views | 744 } // namespace views |
| 729 | 745 |
| 730 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ | 746 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ |
| OLD | NEW |