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"
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 
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  uint64_t buttons,
41  uint32_t rotation,
42  uint32_t pressure,
43  int modifiers_state) = 0;
44 
45  // Notifies delegate that backing window mouse pointer button has been
46  // pressed. Typically called by currently configured WindowBindingHandler.
47  virtual void OnPointerDown(double x,
48  double y,
49  FlutterPointerDeviceKind device_kind,
50  int32_t device_id,
51  uint64_t buttons,
52  uint32_t rotation,
53  uint32_t pressure) = 0;
54 
55  // Notifies delegate that backing window mouse pointer button has been
56  // released. Typically called by currently configured WindowBindingHandler.
57  virtual void OnPointerUp(double x,
58  double y,
59  FlutterPointerDeviceKind device_kind,
60  int32_t device_id,
61  uint64_t buttons) = 0;
62 
63  // Notifies delegate that backing window mouse pointer has left the window.
64  // Typically called by currently configured WindowBindingHandler.
65  virtual void OnPointerLeave(double x,
66  double y,
67  FlutterPointerDeviceKind device_kind,
68  int32_t device_id) = 0;
69 
70  // Notifies delegate that a pan/zoom gesture has started.
71  // Typically called by DirectManipulationEventHandler.
72  virtual void OnPointerPanZoomStart(int32_t device_id) = 0;
73 
74  // Notifies delegate that a pan/zoom gesture has updated.
75  // Typically called by DirectManipulationEventHandler.
76  virtual void OnPointerPanZoomUpdate(int32_t device_id,
77  double pan_x,
78  double pan_y,
79  double scale,
80  double rotation) = 0;
81 
82  // Notifies delegate that a pan/zoom gesture has ended.
83  // Typically called by DirectManipulationEventHandler.
84  virtual void OnPointerPanZoomEnd(int32_t device_id) = 0;
85 
86  // Notifies delegate that backing window has received text.
87  // Typically called by currently configured WindowBindingHandler.
88  virtual void OnText(const std::u16string&) = 0;
89 
90  // Notifies delegate that backing window size has received key press. Should
91  // return true if the event was handled and should not be propagated.
92  // Typically called by currently configured WindowBindingHandler.
93  virtual void OnKey(int key,
94  int scancode,
95  int action,
96  char32_t character,
97  bool extended,
98  bool was_down,
100 
101  /// Notifies the delegate that the backing window has received or
102  /// lost focus.
103  ///
104  /// Typically called by currently configured WindowBindingHandler.
105  virtual void OnFocus(FlutterViewFocusState focus_state,
106  FlutterViewFocusDirection direction) = 0;
107 
108  // Notifies the delegate that IME composing mode has begun.
109  //
110  // Triggered when the user begins editing composing text using a multi-step
111  // input method such as in CJK text input.
112  virtual void OnComposeBegin() = 0;
113 
114  // Notifies the delegate that IME composing region have been committed.
115  //
116  // Triggered when the user triggers a commit of the current composing text
117  // while using a multi-step input method such as in CJK text input. Composing
118  // continues with the next keypress.
119  virtual void OnComposeCommit() = 0;
120 
121  // Notifies the delegate that IME composing mode has ended.
122  //
123  // Triggered when the composing ends, for example when the user presses
124  // ESC or when the user triggers a commit of the composing text while using a
125  // multi-step input method such as in CJK text input.
126  virtual void OnComposeEnd() = 0;
127 
128  // Notifies the delegate that IME composing region contents have changed.
129  //
130  // Triggered when the user edits the composing text while using a multi-step
131  // input method such as in CJK text input.
132  virtual void OnComposeChange(const std::u16string& text, int cursor_pos) = 0;
133 
134  // Notifies delegate that backing window size has recevied scroll.
135  // Typically called by currently configured WindowBindingHandler.
136  virtual void OnScroll(double x,
137  double y,
138  double delta_x,
139  double delta_y,
140  int scroll_offset_multiplier,
141  FlutterPointerDeviceKind device_kind,
142  int32_t device_id) = 0;
143 
144  // Notifies delegate that scroll inertia should be cancelled.
145  // Typically called by DirectManipulationEventHandler
146  virtual void OnScrollInertiaCancel(int32_t device_id) = 0;
147 
148  // Notifies delegate that the Flutter semantics tree should be enabled or
149  // disabled.
150  virtual void OnUpdateSemanticsEnabled(bool enabled) = 0;
151 
152  // Returns the root view accessibility node, or nullptr if none.
153  virtual gfx::NativeViewAccessible GetNativeViewAccessible() = 0;
154 
155  // Update the status of the high contrast feature.
156  virtual void OnHighContrastChanged() = 0;
157 
158  // Obtain a pointer to the fragment root delegate.
159  // This is required by UIA in order to obtain the fragment root that
160  // contains a fragment obtained by, for example, a hit test. Unlike
161  // MSAA, UIA elements do not explicitly store or enumerate their
162  // children and parents, so a method such as this is required.
163  virtual ui::AXFragmentRootDelegateWin* GetAxFragmentRootDelegate() = 0;
164 
165  // Called when a window receives an event that may alter application lifecycle
166  // state.
167  virtual void OnWindowStateEvent(HWND hwnd, WindowStateEvent event) = 0;
168 };
169 
170 } // namespace flutter
171 
172 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOW_BINDING_HANDLER_DELEGATE_H_
virtual void OnComposeChange(const std::u16string &text, int cursor_pos)=0
virtual void OnPointerPanZoomStart(int32_t device_id)=0
virtual void OnText(const std::u16string &)=0
virtual void OnPointerLeave(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id)=0
virtual void OnKey(int key, int scancode, int action, char32_t character, bool extended, bool was_down, KeyEventCallback callback)=0
virtual void OnUpdateSemanticsEnabled(bool enabled)=0
virtual void OnPointerPanZoomEnd(int32_t device_id)=0
virtual void OnWindowStateEvent(HWND hwnd, WindowStateEvent event)=0
virtual ui::AXFragmentRootDelegateWin * GetAxFragmentRootDelegate()=0
virtual void OnScrollInertiaCancel(int32_t device_id)=0
virtual gfx::NativeViewAccessible GetNativeViewAccessible()=0
virtual bool OnWindowSizeChanged(size_t width, size_t height)=0
virtual void OnPointerUp(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, uint64_t buttons)=0
virtual void OnFocus(FlutterViewFocusState focus_state, FlutterViewFocusDirection direction)=0
virtual void OnPointerDown(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, uint64_t buttons, uint32_t rotation, uint32_t pressure)=0
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
virtual void OnPointerPanZoomUpdate(int32_t device_id, double pan_x, double pan_y, double scale, double rotation)=0
virtual void OnPointerMove(double x, double y, FlutterPointerDeviceKind device_kind, int32_t device_id, uint64_t buttons, uint32_t rotation, uint32_t pressure, int modifiers_state)=0
FlutterDesktopBinaryReply callback
std::u16string text
WindowStateEvent
An event representing a change in window state that may update the.