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 {} | |
sky
2017/06/19 15:00:14
Don't inline virtual functions like this in the he
| |
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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 // Checks if there is a full screen window on the same monitor as the | 572 // Checks if there is a full screen window on the same monitor as the |
560 // |window| which is becoming active. If yes then we reduce the size of the | 573 // |window| which is becoming active. If yes then we reduce the size of the |
561 // fullscreen window by 1 px to ensure that maximized windows on the same | 574 // fullscreen window by 1 px to ensure that maximized windows on the same |
562 // monitor don't draw over the taskbar. | 575 // monitor don't draw over the taskbar. |
563 void CheckAndHandleBackgroundFullscreenOnMonitor(HWND window); | 576 void CheckAndHandleBackgroundFullscreenOnMonitor(HWND window); |
564 | 577 |
565 // Provides functionality to reduce the bounds of the fullscreen window by 1 | 578 // Provides functionality to reduce the bounds of the fullscreen window by 1 |
566 // px on activation loss to a window on the same monitor. | 579 // px on activation loss to a window on the same monitor. |
567 void OnBackgroundFullscreen(); | 580 void OnBackgroundFullscreen(); |
568 | 581 |
582 // Destructs the fake caret used for accessibility. This will result in any | |
sky
2017/06/19 15:00:14
Destructs -> Deletes
| |
583 // clients that are still holding onto its |IAccessible| to get a failure code | |
584 // if they request its location. | |
585 void DestroyFakeCaret(); | |
586 | |
569 HWNDMessageHandlerDelegate* delegate_; | 587 HWNDMessageHandlerDelegate* delegate_; |
570 | 588 |
571 std::unique_ptr<FullscreenHandler> fullscreen_handler_; | 589 std::unique_ptr<FullscreenHandler> fullscreen_handler_; |
572 | 590 |
573 // Set to true in Close() and false is CloseNow(). | 591 // Set to true in Close() and false is CloseNow(). |
574 bool waiting_for_close_now_; | 592 bool waiting_for_close_now_; |
575 | 593 |
576 bool use_system_default_icon_; | 594 bool use_system_default_icon_; |
577 | 595 |
578 // Whether all ancestors have been enabled. This is only used if is_modal_ is | 596 // 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... | |
683 bool sent_window_size_changing_; | 701 bool sent_window_size_changing_; |
684 | 702 |
685 // This is used to keep track of whether a WM_WINDOWPOSCHANGED has | 703 // This is used to keep track of whether a WM_WINDOWPOSCHANGED has |
686 // been received after the WM_WINDOWPOSCHANGING. | 704 // been received after the WM_WINDOWPOSCHANGING. |
687 uint32_t current_window_size_message_ = 0; | 705 uint32_t current_window_size_message_ = 0; |
688 | 706 |
689 // Manages observation of Windows Session Change messages. | 707 // Manages observation of Windows Session Change messages. |
690 std::unique_ptr<WindowsSessionChangeObserver> | 708 std::unique_ptr<WindowsSessionChangeObserver> |
691 windows_session_change_observer_; | 709 windows_session_change_observer_; |
692 | 710 |
711 // Some assistive software need to track the location of the caret. | |
712 std::unique_ptr<ui::AXFakeCaretWin> ax_fake_caret_; | |
713 | |
693 // This class provides functionality to register the legacy window as a | 714 // This class provides functionality to register the legacy window as a |
694 // Direct Manipulation consumer. This allows us to support smooth scroll | 715 // Direct Manipulation consumer. This allows us to support smooth scroll |
695 // in Chrome on Windows 10. | 716 // in Chrome on Windows 10. |
696 std::unique_ptr<gfx::win::DirectManipulationHelper> | 717 std::unique_ptr<gfx::win::DirectManipulationHelper> |
697 direct_manipulation_helper_; | 718 direct_manipulation_helper_; |
698 | 719 |
699 // The location where the user clicked on the caption. We cache this when we | 720 // 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 | 721 // receive the WM_NCLBUTTONDOWN message. We use this in the subsequent |
701 // WM_NCMOUSEMOVE message to see if the mouse actually moved. | 722 // WM_NCMOUSEMOVE message to see if the mouse actually moved. |
702 // Please refer to the HandleMouseEventInternal function for details on why | 723 // Please refer to the HandleMouseEventInternal function for details on why |
(...skipping 27 matching lines...) Expand all Loading... | |
730 | 751 |
731 // The factory used with BEGIN_SAFE_MSG_MAP_EX. | 752 // The factory used with BEGIN_SAFE_MSG_MAP_EX. |
732 base::WeakPtrFactory<HWNDMessageHandler> weak_factory_; | 753 base::WeakPtrFactory<HWNDMessageHandler> weak_factory_; |
733 | 754 |
734 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); | 755 DISALLOW_COPY_AND_ASSIGN(HWNDMessageHandler); |
735 }; | 756 }; |
736 | 757 |
737 } // namespace views | 758 } // namespace views |
738 | 759 |
739 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ | 760 #endif // UI_VIEWS_WIN_HWND_MESSAGE_HANDLER_H_ |
OLD | NEW |