| 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 // Abstract class for binding Windows platform windows to Flutter views.
40 class WindowBindingHandler {
41 public:
42 virtual ~WindowBindingHandler() = default;
43
44 // Sets the delegate used to communicate state changes from window to view
45 // such as key presses, mouse position updates etc.
46 virtual void SetView(WindowBindingHandlerDelegate* view) = 0;
47
48 // Returns the underlying HWND backing the window.
49 virtual HWND GetWindowHandle() = 0;
50
51 // Returns the scale factor for the backing window.
52 virtual float GetDpiScale() = 0;
53
54 // Returns whether the HWND is currently visible.
55 virtual bool IsVisible() = 0;
56
57 // Returns the bounds of the backing window in physical pixels.
58 virtual PhysicalWindowBounds GetPhysicalWindowBounds() = 0;
59
60 // Sets the cursor that should be used when the mouse is over the Flutter
61 // content. See mouse_cursor.dart for the values and meanings of cursor_name.
62 virtual void UpdateFlutterCursor(const std::string& cursor_name) = 0;
63
64 // Sets the cursor directly from a cursor handle.
65 virtual void SetFlutterCursor(HCURSOR cursor) = 0;
66
67 // Invoked when the cursor/composing rect has been updated in the framework.
68 virtual void OnCursorRectUpdated(const Rect& rect) = 0;
69
70 // Invoked when the Embedder provides us with new bitmap data for the contents
71 // of this Flutter view.
72 //
73 // Returns whether the surface was successfully updated or not.
74 virtual bool OnBitmapSurfaceUpdated(const void* allocation,
75 size_t row_bytes,
76 size_t height) = 0;
77
78 // Invoked when the app ends IME composing, such when the active text input
79 // client is cleared.
80 virtual void OnResetImeComposing() = 0;
81
82 // Returns the last known position of the primary pointer in window
83 // coordinates.
84 virtual PointerLocation GetPrimaryPointerLocation() = 0;
85
86 // Retrieve the delegate for the alert.
87 virtual AlertPlatformNodeDelegate* GetAlertDelegate() = 0;
88
89 // Retrieve the alert node.
90 virtual ui::AXPlatformNodeWin* GetAlert() = 0;
91 };
92
93 } // namespace flutter
94
95 #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::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::OnResetImeComposing
virtual void OnResetImeComposing()=0
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::~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
Definition: window_binding_handler.h:40
flutter::PointerLocation::x
size_t x
Definition: window_binding_handler.h:35
window_binding_handler_delegate.h
flutter::WindowBindingHandler::IsVisible
virtual bool IsVisible()=0
flutter::WindowBindingHandler::GetWindowHandle
virtual HWND GetWindowHandle()=0