| 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 the bounds of the backing window in physical pixels.
55 virtual PhysicalWindowBounds GetPhysicalWindowBounds() = 0;
56
57 // Invoked when the cursor/composing rect has been updated in the framework.
58 virtual void OnCursorRectUpdated(const Rect& rect) = 0;
59
60 // Invoked when the embedder clears the contents of this Flutter view.
61 //
62 // Returns whether the surface was successfully updated or not.
63 virtual bool OnBitmapSurfaceCleared() = 0;
64
65 // Invoked when the embedder provides us with new bitmap data for the contents
66 // of this Flutter view.
67 //
68 // Returns whether the surface was successfully updated or not.
69 virtual bool OnBitmapSurfaceUpdated(const void* allocation,
70 size_t row_bytes,
71 size_t height) = 0;
72
73 // Invoked when the app ends IME composing, such when the active text input
74 // client is cleared.
75 virtual void OnResetImeComposing() = 0;
76
77 // Returns the last known position of the primary pointer in window
78 // coordinates.
79 virtual PointerLocation GetPrimaryPointerLocation() = 0;
80
81 // Retrieve the delegate for the alert.
82 virtual AlertPlatformNodeDelegate* GetAlertDelegate() = 0;
83
84 // Retrieve the alert node.
85 virtual ui::AXPlatformNodeWin* GetAlert() = 0;
86
87 // Focuses the current window.
88 // Returns true if the window was successfully focused.
89 virtual bool Focus() = 0;
90 };
91
92 } // namespace flutter
93
94 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOW_BINDING_HANDLER_H_
alert_platform_node_delegate.h
flutter::AlertPlatformNodeDelegate
Definition: alert_platform_node_delegate.h:18
flutter::Rect
Definition: geometry.h:56
flutter::WindowBindingHandlerDelegate
Definition: window_binding_handler_delegate.h:18
flutter::WindowBindingHandler
Definition: window_binding_handler.h:40
flutter::WindowBindingHandler::OnResetImeComposing
virtual void OnResetImeComposing()=0
flutter::WindowBindingHandler::GetAlert
virtual ui::AXPlatformNodeWin * GetAlert()=0
flutter::WindowBindingHandler::GetPrimaryPointerLocation
virtual PointerLocation GetPrimaryPointerLocation()=0
flutter::WindowBindingHandler::GetWindowHandle
virtual HWND GetWindowHandle()=0
flutter::WindowBindingHandler::Focus
virtual bool Focus()=0
flutter::WindowBindingHandler::GetAlertDelegate
virtual AlertPlatformNodeDelegate * GetAlertDelegate()=0
flutter::WindowBindingHandler::OnBitmapSurfaceUpdated
virtual bool OnBitmapSurfaceUpdated(const void *allocation, size_t row_bytes, size_t height)=0
flutter::WindowBindingHandler::OnBitmapSurfaceCleared
virtual bool OnBitmapSurfaceCleared()=0
flutter::WindowBindingHandler::GetPhysicalWindowBounds
virtual PhysicalWindowBounds GetPhysicalWindowBounds()=0
flutter::WindowBindingHandler::GetDpiScale
virtual float GetDpiScale()=0
flutter::WindowBindingHandler::SetView
virtual void SetView(WindowBindingHandlerDelegate *view)=0
flutter::WindowBindingHandler::OnCursorRectUpdated
virtual void OnCursorRectUpdated(const Rect &rect)=0
flutter::WindowBindingHandler::~WindowBindingHandler
virtual ~WindowBindingHandler()=default
flutter_windows.h
geometry.h
flutter
Definition: accessibility_bridge_windows.cc:11
ui
Definition: window_binding_handler.h:18
flutter::PhysicalWindowBounds
Definition: window_binding_handler.h:27
flutter::PhysicalWindowBounds::height
size_t height
Definition: window_binding_handler.h:29
flutter::PhysicalWindowBounds::width
size_t width
Definition: window_binding_handler.h:28
flutter::PointerLocation
Definition: window_binding_handler.h:34
flutter::PointerLocation::x
size_t x
Definition: window_binding_handler.h:35
flutter::PointerLocation::y
size_t y
Definition: window_binding_handler.h:36
window_binding_handler_delegate.h