Flutter Engine
 
Loading...
Searching...
No Matches
flutter_glfw.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_GLFW_PUBLIC_FLUTTER_GLFW_H_
6#define FLUTTER_SHELL_PLATFORM_GLFW_PUBLIC_FLUTTER_GLFW_H_
7
8#include <stddef.h>
9#include <stdint.h>
10
11#include "flutter_export.h"
12#include "flutter_messenger.h"
14
15#if defined(__cplusplus)
16extern "C" {
17#endif
18
19// Indicates that any value is acceptable for an otherwise required property.
20extern const int32_t kFlutterDesktopDontCare;
21
22// Opaque reference to a Flutter window controller.
25
26// Opaque reference to a Flutter window.
28
29// Opaque reference to a Flutter engine instance.
31
32// Properties representing a generic rectangular size.
33typedef struct {
34 int32_t width;
35 int32_t height;
37
38// Properties for configuring a Flutter engine instance.
39typedef struct {
40 // The path to the flutter_assets folder for the application to be run.
41 // This can either be an absolute path, or on Windows or Linux, a path
42 // relative to the directory containing the executable.
43 const char* assets_path;
44 // The path to the icudtl.dat file for the version of Flutter you are using.
45 // This can either be an absolute path, or on Windows or Linux, a path
46 // relative to the directory containing the executable.
47 const char* icu_data_path;
48 // The path to the libapp.so file for the application to be run.
49 // This can either be an absolute path or a path relative to the directory
50 // containing the executable.
51 const char* aot_library_path;
52 // The switches to pass to the Flutter engine.
53 //
54 // See:
55 // https://github.com/flutter/flutter/blob/main/engine/src/flutter/shell/common/switches.h
56 // for details. Not all arguments will apply to desktop.
57 const char** switches;
58 // The number of elements in |switches|.
61
62// Properties for configuring the initial settings of a Flutter window.
63typedef struct {
64 // The display title.
65 const char* title;
66 // Width in screen coordinates.
67 int32_t width;
68 // Height in screen coordinates.
69 int32_t height;
70 // Whether or not the user is prevented from resizing the window.
71 // Reversed so that the default for a cleared struct is to allow resizing.
74
75// Sets up the library's graphic context. Must be called before any other
76// methods.
77//
78// Note: Internally, this library uses GLFW, which does not support multiple
79// copies within the same process. Internally this calls glfwInit, which will
80// fail if you have called glfwInit elsewhere in the process.
82
83// Tears down library state. Must be called before the process terminates.
85
86// Creates a Window running a Flutter Application.
87//
88// FlutterDesktopInit() must be called prior to this function.
89//
90// This will set up and run an associated Flutter engine using the settings in
91// |engine_properties|.
92//
93// Returns a null pointer in the event of an error. Otherwise, the pointer is
94// valid until FlutterDesktopDestroyWindow is called.
95// Note that calling FlutterDesktopCreateWindow without later calling
96// FlutterDesktopDestroyWindow on the returned reference is a memory leak.
98 const FlutterDesktopWindowProperties& window_properties,
99 const FlutterDesktopEngineProperties& engine_properties);
100
101// Shuts down the engine instance associated with |controller|, and cleans up
102// associated state.
103//
104// |controller| is no longer valid after this call.
107
108// Waits for and processes the next event before |timeout_milliseconds|.
109//
110// If |timeout_milliseconds| is zero, it will wait for the next event
111// indefinitely. A non-zero timeout is needed only if processing unrelated to
112// the event loop is necessary (e.g., to handle events from another source).
113//
114// Returns false if the window should be closed as a result of the last event
115// processed.
118 uint32_t timeout_milliseconds);
119
120// Returns the window handle for the window associated with
121// FlutterDesktopWindowControllerRef.
122//
123// Its lifetime is the same as the |controller|'s.
126
127// Returns the handle for the engine running in
128// FlutterDesktopWindowControllerRef.
129//
130// Its lifetime is the same as the |controller|'s.
133
134// Returns the plugin registrar handle for the plugin with the given name.
135//
136// The name must be unique across the application.
139 const char* plugin_name);
140
141// Enables or disables hover tracking.
142//
143// If hover is enabled, mouse movement will send hover events to the Flutter
144// engine, rather than only tracking the mouse while the button is pressed.
145// Defaults to on.
147 FlutterDesktopWindowRef flutter_window,
148 bool enabled);
149
150// Sets the displayed title for |flutter_window|.
152 FlutterDesktopWindowRef flutter_window,
153 const char* title);
154
155// Sets the displayed icon for |flutter_window|.
156//
157// The pixel format is 32-bit RGBA. The provided image data only needs to be
158// valid for the duration of the call to this method. Pass a nullptr to revert
159// to the default icon.
161 FlutterDesktopWindowRef flutter_window,
162 uint8_t* pixel_data,
163 int width,
164 int height);
165
166// Gets the position and size of |flutter_window| in screen coordinates.
168 FlutterDesktopWindowRef flutter_window,
169 int* x,
170 int* y,
171 int* width,
172 int* height);
173
174// Sets the position and size of |flutter_window| in screen coordinates.
176 FlutterDesktopWindowRef flutter_window,
177 int x,
178 int y,
179 int width,
180 int height);
181
182// Returns the scale factor--the number of pixels per screen coordinate--for
183// |flutter_window|.
185 FlutterDesktopWindowRef flutter_window);
186
187// Forces a specific pixel ratio for Flutter rendering in |flutter_window|,
188// rather than one computed automatically from screen information.
189//
190// To clear a previously set override, pass an override value of zero.
192 FlutterDesktopWindowRef flutter_window,
193 double pixel_ratio);
194
195// Sets the min/max size of |flutter_window| in screen coordinates. Use
196// kFlutterDesktopDontCare for any dimension you wish to leave unconstrained.
198 FlutterDesktopWindowRef flutter_window,
199 FlutterDesktopSize minimum_size,
200 FlutterDesktopSize maximum_size);
201
202// Runs an instance of a headless Flutter engine.
203//
204// Returns a null pointer in the event of an error.
207
208// Waits for and processes the next event before |timeout_milliseconds|.
209//
210// If |timeout_milliseconds| is zero, it will wait for the next event
211// indefinitely. A non-zero timeout is needed only if processing unrelated to
212// the event loop is necessary (e.g., to handle events from another source).
215 uint32_t timeout_milliseconds);
216
217// Shuts down the given engine instance. Returns true if the shutdown was
218// successful. |engine_ref| is no longer valid after this call.
221
222// Returns the window associated with this registrar's engine instance.
223//
224// This is a GLFW shell-specific extension to flutter_plugin_registrar.h
227
228// Enables input blocking on the given channel.
229//
230// If set, then the Flutter window will disable input callbacks
231// while waiting for the handler for messages on that channel to run. This is
232// useful if handling the message involves showing a modal window, for instance.
233//
234// This must be called after FlutterDesktopSetMessageHandler, as setting a
235// handler on a channel will reset the input blocking state back to the
236// default of disabled.
237//
238// This is a GLFW shell-specific extension to flutter_plugin_registrar.h
241 const char* channel);
242
243#if defined(__cplusplus)
244} // extern "C"
245#endif
246
247#endif // FLUTTER_SHELL_PLATFORM_GLFW_PUBLIC_FLUTTER_GLFW_H_
int32_t x
FlutterEngine engine
Definition main.cc:84
const gchar * channel
#define FLUTTER_EXPORT
FLUTTER_EXPORT void FlutterDesktopWindowSetPixelRatioOverride(FlutterDesktopWindowRef flutter_window, double pixel_ratio)
FLUTTER_EXPORT void FlutterDesktopTerminate()
FLUTTER_EXPORT bool FlutterDesktopShutDownEngine(FlutterDesktopEngineRef engine)
FLUTTER_EXPORT void FlutterDesktopWindowSetTitle(FlutterDesktopWindowRef flutter_window, const char *title)
FLUTTER_EXPORT FlutterDesktopWindowRef FlutterDesktopPluginRegistrarGetWindow(FlutterDesktopPluginRegistrarRef registrar)
FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopRunEngine(const FlutterDesktopEngineProperties &properties)
FLUTTER_EXPORT double FlutterDesktopWindowGetScaleFactor(FlutterDesktopWindowRef flutter_window)
FLUTTER_EXPORT void FlutterDesktopWindowSetFrame(FlutterDesktopWindowRef flutter_window, int x, int y, int width, int height)
FLUTTER_EXPORT bool FlutterDesktopInit()
FLUTTER_EXPORT void FlutterDesktopDestroyWindow(FlutterDesktopWindowControllerRef controller)
FLUTTER_EXPORT void FlutterDesktopWindowGetFrame(FlutterDesktopWindowRef flutter_window, int *x, int *y, int *width, int *height)
FLUTTER_EXPORT FlutterDesktopWindowRef FlutterDesktopGetWindow(FlutterDesktopWindowControllerRef controller)
struct FlutterDesktopEngineState * FlutterDesktopEngineRef
FLUTTER_EXPORT FlutterDesktopWindowControllerRef FlutterDesktopCreateWindow(const FlutterDesktopWindowProperties &window_properties, const FlutterDesktopEngineProperties &engine_properties)
FLUTTER_EXPORT bool FlutterDesktopRunWindowEventLoopWithTimeout(FlutterDesktopWindowControllerRef controller, uint32_t timeout_milliseconds)
struct FlutterDesktopWindowControllerState * FlutterDesktopWindowControllerRef
const int32_t kFlutterDesktopDontCare
FLUTTER_EXPORT void FlutterDesktopWindowSetIcon(FlutterDesktopWindowRef flutter_window, uint8_t *pixel_data, int width, int height)
FLUTTER_EXPORT void FlutterDesktopWindowSetHoverEnabled(FlutterDesktopWindowRef flutter_window, bool enabled)
struct FlutterDesktopWindow * FlutterDesktopWindowRef
FLUTTER_EXPORT void FlutterDesktopWindowSetSizeLimits(FlutterDesktopWindowRef flutter_window, FlutterDesktopSize minimum_size, FlutterDesktopSize maximum_size)
FLUTTER_EXPORT void FlutterDesktopPluginRegistrarEnableInputBlocking(FlutterDesktopPluginRegistrarRef registrar, const char *channel)
FLUTTER_EXPORT void FlutterDesktopRunEngineEventLoopWithTimeout(FlutterDesktopEngineRef engine, uint32_t timeout_milliseconds)
FLUTTER_EXPORT FlutterDesktopEngineRef FlutterDesktopGetEngine(FlutterDesktopWindowControllerRef controller)
FLUTTER_EXPORT FlutterDesktopPluginRegistrarRef FlutterDesktopGetPluginRegistrar(FlutterDesktopEngineRef engine, const char *plugin_name)
double y
int32_t height
int32_t width