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/geometry/geometry.h"
15 #include "flutter/shell/platform/embedder/embedder.h"
18 
19 namespace ui {
20 class AXPlatformNodeWin;
21 }
22 
23 namespace flutter {
24 
25 class FlutterWindowsView;
26 
27 // Structure containing physical bounds of a Window
29  size_t width;
30  size_t height;
31 };
32 
33 // Structure containing the position of a mouse pointer in the coordinate system
34 // specified by the function where it's used.
36  size_t x;
37  size_t y;
38 };
39 
40 // Abstract class for binding Windows platform windows to Flutter views.
42  public:
43  virtual ~WindowBindingHandler() = default;
44 
45  // Sets the delegate used to communicate state changes from window to view
46  // such as key presses, mouse position updates etc.
47  virtual void SetView(WindowBindingHandlerDelegate* view) = 0;
48 
49  // Returns the underlying HWND backing the window.
50  virtual HWND GetWindowHandle() = 0;
51 
52  // Returns the scale factor for the backing window.
53  virtual float GetDpiScale() = 0;
54 
55  // Returns the bounds of the backing window in physical pixels.
57 
58  // Invoked when the cursor/composing rect has been updated in the framework.
59  virtual void OnCursorRectUpdated(const Rect& rect) = 0;
60 
61  // Invoked when the embedder clears the contents of this Flutter view.
62  //
63  // Returns whether the surface was successfully updated or not.
64  virtual bool OnBitmapSurfaceCleared() = 0;
65 
66  // Invoked when the embedder provides us with new bitmap data for the contents
67  // of this Flutter view.
68  //
69  // Returns whether the surface was successfully updated or not.
70  virtual bool OnBitmapSurfaceUpdated(const void* allocation,
71  size_t row_bytes,
72  size_t height) = 0;
73 
74  // Invoked when the app ends IME composing, such when the active text input
75  // client is cleared.
76  virtual void OnResetImeComposing() = 0;
77 
78  // Returns the last known position of the primary pointer in window
79  // coordinates.
81 
82  // Retrieve the delegate for the alert.
84 
85  // Retrieve the alert node.
86  virtual ui::AXPlatformNodeWin* GetAlert() = 0;
87 
88  // Focuses the current window.
89  // Returns true if the window was successfully focused.
90  virtual bool Focus() = 0;
91 
92  // Retrieve the display ID of the display that this window has the largest
93  // area of intersection with.
94  virtual FlutterEngineDisplayId GetDisplayId() = 0;
95 };
96 
97 } // namespace flutter
98 
99 #endif // FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOW_BINDING_HANDLER_H_
virtual void OnResetImeComposing()=0
virtual ui::AXPlatformNodeWin * GetAlert()=0
virtual PointerLocation GetPrimaryPointerLocation()=0
virtual HWND GetWindowHandle()=0
virtual AlertPlatformNodeDelegate * GetAlertDelegate()=0
virtual bool OnBitmapSurfaceUpdated(const void *allocation, size_t row_bytes, size_t height)=0
virtual FlutterEngineDisplayId GetDisplayId()=0
virtual bool OnBitmapSurfaceCleared()=0
virtual PhysicalWindowBounds GetPhysicalWindowBounds()=0
virtual float GetDpiScale()=0
virtual void SetView(WindowBindingHandlerDelegate *view)=0
virtual void OnCursorRectUpdated(const Rect &rect)=0
virtual ~WindowBindingHandler()=default