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