| Flutter Windows Embedder |

window_binding_handler.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_H_
6 #define FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOW_BINDING_HANDLER_H_
7
8 #include <windows.h>
9
10 #include <string>
11 #include <variant>
12
13 #include "flutter/shell/platform/common/alert_platform_node_delegate.h"
14 #include "flutter/shell/platform/common/geometry.h"
15 #include "flutter/shell/platform/windows/public/flutter_windows.h"
16 #include "flutter/shell/platform/windows/window_binding_handler_delegate.h"
17
18 namespace ui {
19 class AXPlatformNodeWin;
20 }
21
22 namespace flutter {
23
24 class FlutterWindowsView;
25
26 // Structure containing physical bounds of a Window
27 struct PhysicalWindowBounds {
28 size_t width;
29 size_t height;
30 };
31
32 // Structure containing the position of a mouse pointer in the coordinate system
33 // specified by the function where it's used.
34 struct PointerLocation {
35 size_t x;
36 size_t y;
37 };
38
39 // Type representing an underlying platform window.
40 using PlatformWindow = HWND;
41
42 // Type representing a platform object that can be accepted by the Angle
43 // rendering layer to bind to and render pixels into.
44 using WindowsRenderTarget = std::variant<HWND>;
45
46 // Abstract class for binding Windows platform windows to Flutter views.
47 class WindowBindingHandler {
48 public:
49 virtual ~WindowBindingHandler() = default;
50
51 // Sets the delegate used to communicate state changes from window to view
52 // such as key presses, mouse position updates etc.
53 virtual void SetView(WindowBindingHandlerDelegate* view) = 0;
54
55 // Returns a valid WindowsRenderTarget representing the platform object that
56 // rendering can be bound to by ANGLE rendering backend.
57 virtual WindowsRenderTarget GetRenderTarget() = 0;
58
59 // Returns a valid PlatformWindow representing the backing
60 // window.
61 virtual PlatformWindow GetPlatformWindow() = 0;
62
63 // Returns the scale factor for the backing window.
64 virtual float GetDpiScale() = 0;
65
66 // Returns whether the PlatformWindow is currently visible.
67 virtual bool IsVisible() = 0;
68
69 // Returns the bounds of the backing window in physical pixels.
70 virtual PhysicalWindowBounds GetPhysicalWindowBounds() = 0;
71
72 // Invoked after the window has been resized.
73 virtual void OnWindowResized() = 0;
74
75 // Sets the cursor that should be used when the mouse is over the Flutter
76 // content. See mouse_cursor.dart for the values and meanings of cursor_name.
77 virtual void UpdateFlutterCursor(const std::string& cursor_name) = 0;
78
79 // Sets the cursor directly from a cursor handle.
80 virtual void SetFlutterCursor(HCURSOR cursor) = 0;
81
82 // Invoked when the cursor/composing rect has been updated in the framework.
83 virtual void OnCursorRectUpdated(const Rect& rect) = 0;
84
85 // Invoked when the Embedder provides us with new bitmap data for the contents
86 // of this Flutter view.
87 //
88 // Returns whether the surface was successfully updated or not.
89 virtual bool OnBitmapSurfaceUpdated(const void* allocation,
90 size_t row_bytes,
91 size_t height) = 0;
92
93 // Invoked when the app ends IME composing, such when the active text input
94 // client is cleared.
95 virtual void OnResetImeComposing() = 0;
96
97 // Returns the last known position of the primary pointer in window
98 // coordinates.
99 virtual PointerLocation GetPrimaryPointerLocation() = 0;
100
101 // Called to set the initial state of accessibility features
102 virtual void SendInitialAccessibilityFeatures() = 0;
103
104 // Retrieve the delegate for the alert.
105 virtual AlertPlatformNodeDelegate* GetAlertDelegate() = 0;
106
107 // Retrieve the alert node.
108 virtual ui::AXPlatformNodeWin* GetAlert() = 0;
109
110 // If true, rendering to the window should synchronize with the vsync
111 // to prevent screen tearing.
112 virtual bool NeedsVSync() = 0;
113 };
114
115 } // namespace flutter
116
117 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOW_BINDING_HANDLER_H_
flutter::AlertPlatformNodeDelegate
Definition: alert_platform_node_delegate.h:18
flutter::WindowBindingHandler::GetPrimaryPointerLocation
virtual PointerLocation GetPrimaryPointerLocation()=0
alert_platform_node_delegate.h
geometry.h
flutter::WindowsRenderTarget
std::variant< HWND > WindowsRenderTarget
Definition: window_binding_handler.h:44
flutter::WindowBindingHandlerDelegate
Definition: window_binding_handler_delegate.h:18
flutter::Rect
Definition: geometry.h:56
flutter::PhysicalWindowBounds::width
size_t width
Definition: window_binding_handler.h:28
flutter::PhysicalWindowBounds
Definition: window_binding_handler.h:27
flutter::PointerLocation
Definition: window_binding_handler.h:34
flutter::WindowBindingHandler::OnBitmapSurfaceUpdated
virtual bool OnBitmapSurfaceUpdated(const void *allocation, size_t row_bytes, size_t height)=0
flutter::WindowBindingHandler::OnCursorRectUpdated
virtual void OnCursorRectUpdated(const Rect &rect)=0
flutter::WindowBindingHandler::GetPlatformWindow
virtual PlatformWindow GetPlatformWindow()=0
flutter::WindowBindingHandler::OnWindowResized
virtual void OnWindowResized()=0
flutter::WindowBindingHandler::NeedsVSync
virtual bool NeedsVSync()=0
flutter::WindowBindingHandler::OnResetImeComposing
virtual void OnResetImeComposing()=0
flutter::PlatformWindow
HWND PlatformWindow
Definition: window_binding_handler.h:40
flutter::PointerLocation::y
size_t y
Definition: window_binding_handler.h:36
ui
Definition: window_binding_handler.h:18
flutter::WindowBindingHandler::SetView
virtual void SetView(WindowBindingHandlerDelegate *view)=0
flutter::WindowBindingHandler::GetAlertDelegate
virtual AlertPlatformNodeDelegate * GetAlertDelegate()=0
flutter::WindowBindingHandler::GetPhysicalWindowBounds
virtual PhysicalWindowBounds GetPhysicalWindowBounds()=0
flutter
Definition: accessibility_bridge_windows.cc:11
flutter::WindowBindingHandler::GetAlert
virtual ui::AXPlatformNodeWin * GetAlert()=0
flutter::WindowBindingHandler::GetDpiScale
virtual float GetDpiScale()=0
flutter::WindowBindingHandler::SendInitialAccessibilityFeatures
virtual void SendInitialAccessibilityFeatures()=0
flutter::WindowBindingHandler::~WindowBindingHandler
virtual ~WindowBindingHandler()=default
flutter::WindowBindingHandler::SetFlutterCursor
virtual void SetFlutterCursor(HCURSOR cursor)=0
flutter::PhysicalWindowBounds::height
size_t height
Definition: window_binding_handler.h:29
flutter::WindowBindingHandler::UpdateFlutterCursor
virtual void UpdateFlutterCursor(const std::string &cursor_name)=0
flutter_windows.h
flutter::WindowBindingHandler::GetRenderTarget
virtual WindowsRenderTarget GetRenderTarget()=0
flutter::WindowBindingHandler
Definition: window_binding_handler.h:47
flutter::PointerLocation::x
size_t x
Definition: window_binding_handler.h:35
window_binding_handler_delegate.h
flutter::WindowBindingHandler::IsVisible
virtual bool IsVisible()=0