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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 224 |
221 private: | 225 private: |
222 typedef std::set<DWORD> TouchIDs; | 226 typedef std::set<DWORD> TouchIDs; |
223 enum class DwmFrameState { OFF, ON }; | 227 enum class DwmFrameState { OFF, ON }; |
224 | 228 |
225 // Overridden from WindowImpl: | 229 // Overridden from WindowImpl: |
226 HICON GetDefaultWindowIcon() const override; | 230 HICON GetDefaultWindowIcon() const override; |
227 HICON GetSmallWindowIcon() const override; | 231 HICON GetSmallWindowIcon() const override; |
228 LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) override; | 232 LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) override; |
229 | 233 |
| 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 |
230 // Overridden from WindowEventTarget | 243 // Overridden from WindowEventTarget |
231 LRESULT HandleMouseMessage(unsigned int message, | 244 LRESULT HandleMouseMessage(unsigned int message, |
232 WPARAM w_param, | 245 WPARAM w_param, |
233 LPARAM l_param, | 246 LPARAM l_param, |
234 bool* handled) override; | 247 bool* handled) override; |
235 LRESULT HandleKeyboardMessage(unsigned int message, | 248 LRESULT HandleKeyboardMessage(unsigned int message, |
236 WPARAM w_param, | 249 WPARAM w_param, |
237 LPARAM l_param, | 250 LPARAM l_param, |
238 bool* handled) override; | 251 bool* handled) override; |
239 LRESULT HandleTouchMessage(unsigned int message, | 252 LRESULT HandleTouchMessage(unsigned int message, |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 bool sent_window_size_changing_; | 696 bool sent_window_size_changing_; |
684 | 697 |
685 // This is used to keep track of whether a WM_WINDOWPOSCHANGED has | 698 // This is used to keep track of whether a WM_WINDOWPOSCHANGED has |
686 // been received after the WM_WINDOWPOSCHANGING. | 699 // been received after the WM_WINDOWPOSCHANGING. |
687 uint32_t current_window_size_message_ = 0; | 700 uint32_t current_window_size_message_ = 0; |
688 | 701 |
689 // Manages observation of Windows Session Change messages. | 702 // Manages observation of Windows Session Change messages. |
690 std::unique_ptr<WindowsSessionChangeObserver> | 703 std::unique_ptr<WindowsSessionChangeObserver> |
691 windows_session_change_observer_; | 704 windows_session_change_observer_; |
692 | 705 |
| 706 // Some assistive software need to track the location of the caret. |
| 707 std::unique_ptr<ui::AXFakeCaretWin> ax_fake_caret_; |
| 708 |
693 // This class provides functionality to register the legacy window as a | 709 // This class provides functionality to register the legacy window as a |
694 // Direct Manipulation consumer. This allows us to support smooth scroll | 710 // Direct Manipulation consumer. This allows us to support smooth scroll |
695 // in Chrome on Windows 10. | 711 // in Chrome on Windows 10. |
696 std::unique_ptr<gfx::win::DirectManipulationHelper> | 712 std::unique_ptr<gfx::win::DirectManipulationHelper> |
697 direct_manipulation_helper_; | 713 direct_manipulation_helper_; |
698 | 714 |
699 // The location where the user clicked on the caption. We cache this when we | 715 // The location where the user clicked on the caption. We cache this when we |
700 // receive the WM_NCLBUTTONDOWN message. We use this in the subsequent | 716 // receive the WM_NCLBUTTONDOWN message. We use this in the subsequent |
701 // WM_NCMOUSEMOVE message to see if the mouse actually moved. | 717 // WM_NCMOUSEMOVE message to see if the mouse actually moved. |
702 // Please refer to the HandleMouseEventInternal function for details on why | 718 // Please refer to the HandleMouseEventInternal function for details on why |
(...skipping 27 matching lines...) Expand all Loading... |
730 | 746 |
731 // The factory used with BEGIN_SAFE_MSG_MAP_EX. | 747 // The factory used with BEGIN_SAFE_MSG_MAP_EX. |
732 base::WeakPtrFactory<HWNDMessageHandler> weak_factory_; | 748 base::WeakPtrFactory<HWNDMessageHandler> weak_factory_; |
733 | 749 |
734 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); | 750 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); |
735 }; | 751 }; |
736 | 752 |
737 } // namespace views | 753 } // namespace views |
738 | 754 |
739 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ | 755 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ |
OLD | NEW |