| Flutter Windows Embedder |

window_binding_handler_delegate.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOW_BINDING_HANDLER_DELEGATE_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOW_BINDING_HANDLER_DELEGATE_H_
7
8 #include <functional>
9
10 #include "flutter/shell/geometry/geometry.h"
11 #include "flutter/shell/platform/embedder/embedder.h"
12 #include "flutter/shell/platform/windows/windows_lifecycle_manager.h"
13 #include "flutter/third_party/accessibility/ax/platform/ax_fragment_root_delegate_win.h"
14 #include "flutter/third_party/accessibility/gfx/native_widget_types.h"
15
16 namespace flutter {
17
18 class WindowBindingHandlerDelegate {
19 public:
20 using KeyEventCallback = std::function<void(bool)>;
21
22 // Notifies delegate that backing window size has changed.
23 //
24 // Called by |FlutterWindow| on the platform thread.
25 //
26 // Returns true if the delegate completed the window resize synchronously.
27 // The return value is exposed for unit testing.
28 virtual bool OnWindowSizeChanged(size_t width, size_t height) = 0;
29
30 // Notifies delegate that backing window needs to be repainted.
31 // Typically called by currently configured WindowBindingHandler.
32 virtual void OnWindowRepaint() = 0;
33
34 // Notifies delegate that backing window mouse has moved.
35 // Typically called by currently configured WindowBindingHandler.
36 virtual void OnPointerMove(double x,
37 double y,
38 FlutterPointerDeviceKind device_kind,
39 int32_t device_id,
40 int modifiers_state) = 0;
41
42 // Notifies delegate that backing window mouse pointer button has been
43 // pressed. Typically called by currently configured WindowBindingHandler.
44 virtual void OnPointerDown(double x,
45 double y,
46 FlutterPointerDeviceKind device_kind,
47 int32_t device_id,
48 FlutterPointerMouseButtons button) = 0;
49
50 // Notifies delegate that backing window mouse pointer button has been
51 // released. Typically called by currently configured WindowBindingHandler.
52 virtual void OnPointerUp(double x,
53 double y,
54 FlutterPointerDeviceKind device_kind,
55 int32_t device_id,
56 FlutterPointerMouseButtons button) = 0;
57
58 // Notifies delegate that backing window mouse pointer has left the window.
59 // Typically called by currently configured WindowBindingHandler.
60 virtual void OnPointerLeave(double x,
61 double y,
62 FlutterPointerDeviceKind device_kind,
63 int32_t device_id) = 0;
64
65 // Notifies delegate that a pan/zoom gesture has started.
66 // Typically called by DirectManipulationEventHandler.
67 virtual void OnPointerPanZoomStart(int32_t device_id) = 0;
68
69 // Notifies delegate that a pan/zoom gesture has updated.
70 // Typically called by DirectManipulationEventHandler.
71 virtual void OnPointerPanZoomUpdate(int32_t device_id,
72 double pan_x,
73 double pan_y,
74 double scale,
75 double rotation) = 0;
76
77 // Notifies delegate that a pan/zoom gesture has ended.
78 // Typically called by DirectManipulationEventHandler.
79 virtual void OnPointerPanZoomEnd(int32_t device_id) = 0;
80
81 // Notifies delegate that backing window has received text.
82 // Typically called by currently configured WindowBindingHandler.
83 virtual void OnText(const std::u16string&) = 0;
84
85 // Notifies delegate that backing window size has received key press. Should
86 // return true if the event was handled and should not be propagated.
87 // Typically called by currently configured WindowBindingHandler.
88 virtual void OnKey(int key,
89 int scancode,
90 int action,
91 char32_t character,
92 bool extended,
93 bool was_down,
94 KeyEventCallback callback) = 0;
95
96 /// Notifies the delegate that the backing window has received or
97 /// lost focus.
98 ///
99 /// Typically called by currently configured WindowBindingHandler.
100 virtual void OnFocus(FlutterViewFocusState focus_state,
101 FlutterViewFocusDirection direction) = 0;
102
103 // Notifies the delegate that IME composing mode has begun.
104 //
105 // Triggered when the user begins editing composing text using a multi-step
106 // input method such as in CJK text input.
107 virtual void OnComposeBegin() = 0;
108
109 // Notifies the delegate that IME composing region have been committed.
110 //
111 // Triggered when the user triggers a commit of the current composing text
112 // while using a multi-step input method such as in CJK text input. Composing
113 // continues with the next keypress.
114 virtual void OnComposeCommit() = 0;
115
116 // Notifies the delegate that IME composing mode has ended.
117 //
118 // Triggered when the composing ends, for example when the user presses
119 // ESC or when the user triggers a commit of the composing text while using a
120 // multi-step input method such as in CJK text input.
121 virtual void OnComposeEnd() = 0;
122
123 // Notifies the delegate that IME composing region contents have changed.
124 //
125 // Triggered when the user edits the composing text while using a multi-step
126 // input method such as in CJK text input.
127 virtual void OnComposeChange(const std::u16string& text, int cursor_pos) = 0;
128
129 // Notifies delegate that backing window size has recevied scroll.
130 // Typically called by currently configured WindowBindingHandler.
131 virtual void OnScroll(double x,
132 double y,
133 double delta_x,
134 double delta_y,
135 int scroll_offset_multiplier,
136 FlutterPointerDeviceKind device_kind,
137 int32_t device_id) = 0;
138
139 // Notifies delegate that scroll inertia should be cancelled.
140 // Typically called by DirectManipulationEventHandler
141 virtual void OnScrollInertiaCancel(int32_t device_id) = 0;
142
143 // Notifies delegate that the Flutter semantics tree should be enabled or
144 // disabled.
145 virtual void OnUpdateSemanticsEnabled(bool enabled) = 0;
146
147 // Returns the root view accessibility node, or nullptr if none.
148 virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0;
149
150 // Update the status of the high contrast feature.
151 virtual void OnHighContrastChanged() = 0;
152
153 // Obtain a pointer to the fragment root delegate.
154 // This is required by UIA in order to obtain the fragment root that
155 // contains a fragment obtained by, for example, a hit test. Unlike
156 // MSAA, UIA elements do not explicitly store or enumerate their
157 // children and parents, so a method such as this is required.
158 virtual ui::AXFragmentRootDelegateWin* GetAxFragmentRootDelegate() = 0;
159
160 // Called when a window receives an event that may alter application lifecycle
161 // state.
162 virtual void OnWindowStateEvent(HWND hwnd, WindowStateEvent event) = 0;
163 };
164
165 } // namespace flutter
166
167 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOW_BINDING_HANDLER_DELEGATE_H_
flutter::WindowBindingHandlerDelegate
Definition: window_binding_handler_delegate.h:18
flutter::WindowBindingHandlerDelegate::OnPointerDown
virtual void OnPointerDown(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, FlutterPointerMouseButtons button)=0
flutter::WindowBindingHandlerDelegate::OnPointerMove
virtual void OnPointerMove(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, int modifiers_state)=0
flutter::WindowBindingHandlerDelegate::OnComposeChange
virtual void OnComposeChange(const std::u16string &text, int cursor_pos)=0
flutter::WindowBindingHandlerDelegate::OnPointerPanZoomStart
virtual void OnPointerPanZoomStart(int32_t device_id)=0
flutter::WindowBindingHandlerDelegate::OnHighContrastChanged
virtual void OnHighContrastChanged()=0
flutter::WindowBindingHandlerDelegate::OnText
virtual void OnText(const std::u16string &)=0
flutter::WindowBindingHandlerDelegate::OnPointerLeave
virtual void OnPointerLeave(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id)=0
flutter::WindowBindingHandlerDelegate::OnKey
virtual void OnKey(int key, int scancode, int action, char32_t character, bool extended, bool was_down, KeyEventCallback callback)=0
flutter::WindowBindingHandlerDelegate::OnUpdateSemanticsEnabled
virtual void OnUpdateSemanticsEnabled(bool enabled)=0
flutter::WindowBindingHandlerDelegate::OnPointerUp
virtual void OnPointerUp(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, FlutterPointerMouseButtons button)=0
flutter::WindowBindingHandlerDelegate::OnPointerPanZoomEnd
virtual void OnPointerPanZoomEnd(int32_t device_id)=0
flutter::WindowBindingHandlerDelegate::OnWindowStateEvent
virtual void OnWindowStateEvent(HWND hwnd, WindowStateEvent event)=0
flutter::WindowBindingHandlerDelegate::GetAxFragmentRootDelegate
virtual ui::AXFragmentRootDelegateWin * GetAxFragmentRootDelegate()=0
flutter::WindowBindingHandlerDelegate::OnScrollInertiaCancel
virtual void OnScrollInertiaCancel(int32_t device_id)=0
flutter::WindowBindingHandlerDelegate::OnComposeEnd
virtual void OnComposeEnd()=0
flutter::WindowBindingHandlerDelegate::OnWindowRepaint
virtual void OnWindowRepaint()=0
flutter::WindowBindingHandlerDelegate::KeyEventCallback
std::function< void(bool)> KeyEventCallback
Definition: window_binding_handler_delegate.h:20
flutter::WindowBindingHandlerDelegate::GetNativeViewAccessible
virtual gfx::NativeViewAccessible GetNativeViewAccessible()=0
flutter::WindowBindingHandlerDelegate::OnWindowSizeChanged
virtual bool OnWindowSizeChanged(size_t width, size_t height)=0
flutter::WindowBindingHandlerDelegate::OnComposeBegin
virtual void OnComposeBegin()=0
flutter::WindowBindingHandlerDelegate::OnFocus
virtual void OnFocus(FlutterViewFocusState focus_state, FlutterViewFocusDirection direction)=0
flutter::WindowBindingHandlerDelegate::OnScroll
virtual void OnScroll(double x, double y, double delta_x, double delta_y, int scroll_offset_multiplier, FlutterPointerDeviceKind device_kind, int32_t device_id)=0
flutter::WindowBindingHandlerDelegate::OnComposeCommit
virtual void OnComposeCommit()=0
flutter::WindowBindingHandlerDelegate::OnPointerPanZoomUpdate
virtual void OnPointerPanZoomUpdate(int32_t device_id, double pan_x, double pan_y, double scale, double rotation)=0
callback
FlutterDesktopBinaryReply callback
Definition: flutter_windows_view_unittests.cc:52
extended
bool extended
Definition: keyboard_key_handler_unittests.cc:118
key
int key
Definition: keyboard_key_handler_unittests.cc:114
character
char32_t character
Definition: keyboard_key_handler_unittests.cc:117
action
int action
Definition: keyboard_key_handler_unittests.cc:116
scancode
int scancode
Definition: keyboard_key_handler_unittests.cc:115
was_down
bool was_down
Definition: keyboard_key_handler_unittests.cc:119
text
std::u16string text
Definition: keyboard_unittests.cc:332
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::WindowStateEvent
WindowStateEvent
An event representing a change in window state that may update the.
Definition: windows_lifecycle_manager.h:24
windows_lifecycle_manager.h