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