5#ifndef FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_WINDOWS_ENGINE_H_
6#define FLUTTER_SHELL_PLATFORM_WINDOWS_FLUTTER_WINDOWS_ENGINE_H_
12#include <shared_mutex>
15#include <unordered_map>
48#include "third_party/rapidjson/include/rapidjson/document.h"
68 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL);
72 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
76 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
122 bool Run(std::string_view entrypoint);
125 virtual bool running()
const {
return engine_ !=
nullptr; }
135 std::unique_ptr<FlutterWindowsView>
CreateView(
136 std::unique_ptr<WindowBindingHandler>
window,
137 bool is_sized_to_content,
158 void SetSwitches(
const std::vector<std::string>& switches);
163 return message_dispatcher_.get();
167 return display_manager_;
178 return texture_registrar_.get();
186 return window_proc_delegate_manager_.get();
204 return keyboard_key_handler_.get();
212 const size_t message_size,
282 root_isolate_create_callback_ =
callback;
289 void OnQuit(std::optional<HWND> hwnd,
290 std::optional<WPARAM> wparam,
291 std::optional<LPARAM> lparam,
316 return lifecycle_manager_.get();
320 return windows_proc_table_;
376 HCURSOR GetCursorByName(
const std::string& cursor_name)
const;
382 void SendSystemLocales();
388 void InitializeKeyboard();
391 void SendAccessibilityFeatures();
403 std::unique_ptr<FlutterProjectBundle> project_;
421 std::unordered_map<FlutterViewId, FlutterWindowsView*> views_;
430 mutable std::shared_mutex views_mutex_;
433 std::shared_ptr<DisplayManagerWin32> display_manager_;
436 std::unique_ptr<TaskRunner> task_runner_;
442 std::unique_ptr<BinaryMessengerImpl> messenger_wrapper_;
445 std::unique_ptr<IncomingMessageDispatcher> message_dispatcher_;
448 std::unique_ptr<FlutterDesktopPluginRegistrar> plugin_registrar_;
451 std::unique_ptr<FlutterWindowsTextureRegistrar> texture_registrar_;
456 std::unique_ptr<egl::Manager> egl_manager_;
460 std::unique_ptr<Compositor> compositor_;
463 std::unique_ptr<PluginRegistrar> internal_plugin_registrar_;
466 std::unique_ptr<AccessibilityPlugin> accessibility_plugin_;
469 std::unique_ptr<CursorHandler> cursor_handler_;
472 std::unique_ptr<PlatformHandler> platform_handler_;
475 std::unique_ptr<KeyboardHandlerBase> keyboard_key_handler_;
479 std::unique_ptr<WindowManager> window_manager_;
482 std::unique_ptr<TextInputPlugin> text_input_plugin_;
485 std::unique_ptr<SettingsPlugin> settings_plugin_;
491 plugin_registrar_destruction_callbacks_;
494 std::chrono::nanoseconds FrameInterval();
497 std::chrono::nanoseconds start_time_ = std::chrono::nanoseconds::zero();
500 std::optional<std::chrono::nanoseconds> frame_interval_override_ =
503 bool semantics_enabled_ =
false;
505 bool high_contrast_enabled_ =
false;
507 bool enable_impeller_ =
false;
510 std::unique_ptr<WindowProcDelegateManager> window_proc_delegate_manager_;
519 std::unique_ptr<WindowsLifecycleManager> lifecycle_manager_;
521 std::shared_ptr<WindowsProcTable> windows_proc_table_;
523 std::shared_ptr<egl::ProcTable> gl_;
525 std::unique_ptr<PlatformViewPlugin> platform_view_plugin_;
528 bool HandleDisplayMonitorMessage(HWND hwnd,
FlutterDesktopMessengerRef ToRef()
Convert to FlutterDesktopMessengerRef.
void UpdateHighContrastMode()
void UpdateAccessibilityFeatures()
FlutterDesktopMessengerRef messenger()
void OnWindowStateEvent(HWND hwnd, WindowStateEvent event)
void OnDwmCompositionChanged()
void RequestApplicationQuit(HWND hwnd, WPARAM wparam, LPARAM lparam, AppExitType exit_type)
void OnPreEngineRestart()
void SendViewFocusEvent(const FlutterViewFocusEvent &event)
bool SendPlatformMessage(const char *channel, const uint8_t *message, const size_t message_size, const FlutterDesktopBinaryReply reply, void *user_data)
virtual void OnViewFocusChangeRequest(const FlutterViewFocusChangeRequest *request)
std::optional< LRESULT > ProcessExternalWindowMessage(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
void AddPluginRegistrarDestructionCallback(FlutterDesktopOnPluginRegistrarDestroyed callback, FlutterDesktopPluginRegistrarRef registrar)
std::shared_ptr< WindowsProcTable > windows_proc_table()
bool RegisterExternalTexture(int64_t texture_id)
void UpdateDisplay(const std::vector< FlutterEngineDisplay > &displays)
IncomingMessageDispatcher * message_dispatcher()
void SendPlatformMessageResponse(const FlutterDesktopMessageResponseHandle *handle, const uint8_t *data, size_t data_length)
void SetRootIsolateCreateCallback(const fml::closure &callback)
static FlutterWindowsEngine * GetEngineForId(int64_t engine_id)
void UpdateSemanticsEnabled(bool enabled)
std::unique_ptr< FlutterWindowsView > CreateView(std::unique_ptr< WindowBindingHandler > window, bool is_sized_to_content, const BoxConstraints &box_constraints, FlutterWindowsViewSizingDelegate *sizing_delegate=nullptr)
TaskRunner * task_runner()
WindowManager * window_manager()
std::string GetExecutableName() const
virtual void OnChannelUpdate(std::string name, bool listening)
virtual std::unique_ptr< KeyboardHandlerBase > CreateKeyboardKeyHandler(BinaryMessenger *messenger, KeyboardKeyEmbedderHandler::GetKeyStateHandler get_key_state, KeyboardKeyEmbedderHandler::MapVirtualKeyToScanCode map_vk_to_scan)
bool DispatchSemanticsAction(FlutterViewId view_id, uint64_t node_id, FlutterSemanticsAction action, fml::MallocMapping data)
std::shared_ptr< DisplayManagerWin32 > display_manager()
egl::Manager * egl_manager() const
bool MarkExternalTextureFrameAvailable(int64_t texture_id)
FlutterWindowsView * GetViewFromTopLevelWindow(HWND hwnd) const
bool high_contrast_enabled() const
virtual bool running() const
WindowProcDelegateManager * window_proc_delegate_manager()
bool semantics_enabled() const
virtual bool PostRasterThreadTask(fml::closure callback) const
FlutterWindowsTextureRegistrar * texture_registrar()
bool UnregisterExternalTexture(int64_t texture_id)
void SetNextFrameCallback(fml::closure callback)
void HandlePlatformMessage(const FlutterPlatformMessage *)
virtual void RemoveView(FlutterViewId view_id)
FlutterDesktopPluginRegistrarRef GetRegistrar()
virtual std::unique_ptr< TextInputPlugin > CreateTextInputPlugin(BinaryMessenger *messenger)
void UpdateFlutterCursor(const std::string &cursor_name) const
void SetFlutterCursor(HCURSOR cursor) const
void OnVsync(intptr_t baton)
TextInputPlugin * text_input_plugin()
WindowsLifecycleManager * lifecycle_manager()
void SendPointerEvent(const FlutterPointerEvent &event)
BinaryMessenger * messenger_wrapper()
void SendWindowMetricsEvent(const FlutterWindowMetricsEvent &event)
KeyboardHandlerBase * keyboard_key_handler()
void SetSwitches(const std::vector< std::string > &switches)
void SendKeyEvent(const FlutterKeyEvent &event, FlutterKeyEventCallback callback, void *user_data)
void OnQuit(std::optional< HWND > hwnd, std::optional< WPARAM > wparam, std::optional< LPARAM > lparam, UINT exit_code)
virtual ~FlutterWindowsEngine()
std::function< SHORT(UINT, bool)> MapVirtualKeyToScanCode
std::function< SHORT(int)> GetKeyStateHandler
A Mapping like NonOwnedMapping, but uses Free as its release proc.
#define FLUTTER_API_SYMBOL(symbol)
FlutterThreadPriority
Valid values for priority of Thread.
@ kBackground
Suitable for threads that shouldn't disrupt high priority work.
@ kDisplay
Suitable for threads which generate data for the display.
@ kNormal
Default priority level.
@ kRaster
Suitable for thread which raster data.
void(* FlutterKeyEventCallback)(bool, void *)
G_BEGIN_DECLS FlutterViewId view_id
void(* FlutterDesktopBinaryReply)(const uint8_t *data, size_t data_size, void *user_data)
void(* FlutterDesktopOnPluginRegistrarDestroyed)(FlutterDesktopPluginRegistrarRef)
FlutterDesktopBinaryReply callback
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
WindowStateEvent
An event representing a change in window state that may update the.
DEF_SWITCHES_START aot vmservice shared library name
constexpr FlutterViewId kImplicitViewId
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
static void WindowsPlatformThreadPrioritySetter(FlutterThreadPriority priority)
std::unique_ptr< _FlutterEngineAOTData, FlutterEngineCollectAOTDataFnPtr > UniqueAotDataPtr
std::function< void()> closure
Function-pointer-based versions of the APIs above.