| Flutter Windows Embedder |

Public Member Functions | List of all members
flutter::WindowManager Class Reference

`#include <window_manager.h>`

## Public Member Functions
| WindowManager (FlutterWindowsEngine *engine)
virtual | ~WindowManager ()=default
void | Initialize (const WindowingInitRequest *request)
FlutterViewId | CreateRegularWindow (const RegularWindowCreationRequest *request)
FlutterViewId | CreateDialogWindow (const DialogWindowCreationRequest *request)
FlutterViewId | CreateTooltipWindow (const TooltipWindowCreationRequest *request)
std::optional< LRESULT > | HandleMessage (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
void | OnEngineShutdown ()

## Detailed Description

Definition at line 108 of file window_manager.h.

## Constructor & Destructor Documentation

## ◆ WindowManager()

flutter::WindowManager::WindowManager | ( | FlutterWindowsEngine * | engine | ) |
| explicit

Definition at line 24 of file window_manager.cc.

24 : engine_(engine) {}

## ◆ ~WindowManager()

virtual flutter::WindowManager::~WindowManager | ( |  | ) |
| virtual default

## Member Function Documentation

## ◆ CreateDialogWindow()

FlutterViewId flutter::WindowManager::CreateDialogWindow | ( | const DialogWindowCreationRequest * | request | ) |

Definition at line 45 of file window_manager.cc.

46 {
47 auto window = HostWindow::CreateDialogWindow(
48 this, engine_, request->preferred_size, request->preferred_constraints,
49 request->title, request->parent_or_null);
50 if (!window || !window->GetWindowHandle()) {
51 FML_LOG(ERROR) << "Failed to create host window";
52 return -1;
53 }
54 FlutterViewId const view_id = window->view_controller_->view()->view_id();
55 active_windows_[window->GetWindowHandle()] = std::move(window);
56 return view_id;
57 }
flutter::HostWindow::CreateDialogWindow
static std::unique_ptr< HostWindow > CreateDialogWindow(WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowSizeRequest &preferred_size, const WindowConstraints &preferred_constraints, LPCWSTR title, HWND parent)
Definition: host_window.cc:216
flutter::FlutterViewId
int64_t FlutterViewId
Definition: accessibility_plugin.h:15

References flutter::HostWindow::CreateDialogWindow(), flutter::DialogWindowCreationRequest::parent_or_null, flutter::DialogWindowCreationRequest::preferred_constraints, flutter::DialogWindowCreationRequest::preferred_size, and flutter::DialogWindowCreationRequest::title.

Referenced by InternalFlutterWindows_WindowManager_CreateDialogWindow().

## ◆ CreateRegularWindow()

FlutterViewId flutter::WindowManager::CreateRegularWindow | ( | const RegularWindowCreationRequest * | request | ) |

Definition at line 31 of file window_manager.cc.

32 {
33 auto window = HostWindow::CreateRegularWindow(
34 this, engine_, request->preferred_size, request->preferred_constraints,
35 request->title);
36 if (!window || !window->GetWindowHandle()) {
37 FML_LOG(ERROR) << "Failed to create host window";
38 return -1;
39 }
40 FlutterViewId const view_id = window->view_controller_->view()->view_id();
41 active_windows_[window->GetWindowHandle()] = std::move(window);
42 return view_id;
43 }
flutter::HostWindow::CreateRegularWindow
static std::unique_ptr< HostWindow > CreateRegularWindow(WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowSizeRequest &preferred_size, const WindowConstraints &preferred_constraints, LPCWSTR title)
Definition: host_window.cc:205

References flutter::HostWindow::CreateRegularWindow(), flutter::RegularWindowCreationRequest::preferred_constraints, flutter::RegularWindowCreationRequest::preferred_size, and flutter::RegularWindowCreationRequest::title.

Referenced by InternalFlutterWindows_WindowManager_CreateRegularWindow().

## ◆ CreateTooltipWindow()

FlutterViewId flutter::WindowManager::CreateTooltipWindow | ( | const TooltipWindowCreationRequest * | request | ) |

Definition at line 59 of file window_manager.cc.

60 {
61 auto window = HostWindow::CreateTooltipWindow(
62 this, engine_, request->preferred_constraints,
63 request->get_position_callback, request->parent);
64 if (!window || !window->GetWindowHandle()) {
65 FML_LOG(ERROR) << "Failed to create host window";
66 return -1;
67 }
68 FlutterViewId const view_id = window->view_controller_->view()->view_id();
69 active_windows_[window->GetWindowHandle()] = std::move(window);
70 return view_id;
71 }
flutter::HostWindow::CreateTooltipWindow
static std::unique_ptr< HostWindow > CreateTooltipWindow(WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowConstraints &preferred_constraints, GetWindowPositionCallback get_position_callback, HWND parent)
Definition: host_window.cc:229

References flutter::HostWindow::CreateTooltipWindow(), flutter::TooltipWindowCreationRequest::get_position_callback, flutter::TooltipWindowCreationRequest::parent, and flutter::TooltipWindowCreationRequest::preferred_constraints.

Referenced by InternalFlutterWindows_WindowManager_CreateTooltipWindow().

## ◆ HandleMessage()

std::optional< LRESULT > flutter::WindowManager::HandleMessage | ( | HWND | hwnd,
|  | UINT | message,
|  | WPARAM | wparam,
|  | LPARAM | lparam
| ) |  |

Definition at line 89 of file window_manager.cc.

92 {
93 if (message == WM_NCDESTROY) {
94 active_windows_.erase(hwnd);
95 return std::nullopt;
96 }
97
98 HostWindow* host_window = HostWindow::GetThisFromHandle(hwnd);
99 FlutterWindowsView* view =
100 host_window ? host_window->view_controller_->view() : nullptr;
101
102 if (!view) {
103 FML_LOG(WARNING) << "Received message for unknown view";
104 return std::nullopt;
105 }
106
107 WindowsMessage message_struct = {.view_id = view->view_id(),
108 .hwnd = hwnd,
109 .message = message,
110 .wParam = wparam,
111 .lParam = lparam,
112 .result = 0,
113 .handled = false};
114
115 // Not initialized yet.
116 if (!isolate_) {
117 return std::nullopt;
118 }
119
120 IsolateScope scope(*isolate_);
121 on_message_(&message_struct);
122 if (message_struct.handled) {
123 return message_struct.result;
124 } else {
125 return std::nullopt;
126 }
127 }
flutter::HostWindow::GetThisFromHandle
static HostWindow * GetThisFromHandle(HWND hwnd)
Definition: host_window.cc:337
message
Win32Message message
Definition: keyboard_unittests.cc:137

References flutter::HostWindow::GetThisFromHandle(), flutter::WindowsMessage::handled, message, flutter::WindowsMessage::result, flutter::HostWindow::view_controller_, flutter::FlutterWindowsView::view_id(), and flutter::WindowsMessage::view_id.

## ◆ Initialize()

void flutter::WindowManager::Initialize | ( | const WindowingInitRequest * | request | ) |

Definition at line 26 of file window_manager.cc.

26 {
27 on_message_ = request->on_message;
28 isolate_ = Isolate::Current();
29 }
flutter::Isolate::Current
static Isolate Current()
Definition: isolate_scope.cc:9

References flutter::Isolate::Current(), and flutter::WindowingInitRequest::on_message.

Referenced by InternalFlutterWindows_WindowManager_Initialize().

## ◆ OnEngineShutdown()

void flutter::WindowManager::OnEngineShutdown | ( |  | ) |

Definition at line 73 of file window_manager.cc.

73 {
74 // Don't send any more messages to isolate.
75 on_message_ = nullptr;
76 std::vector<HWND> active_handles;
77 active_handles.reserve(active_windows_.size());
78 for (auto& [hwnd, window] : active_windows_) {
79 active_handles.push_back(hwnd);
80 }
81 for (auto hwnd : active_handles) {
82 // This will destroy the window, which will in turn remove the
83 // HostWindow from map when handling WM_NCDESTROY inside
84 // HandleMessage.
85 InternalFlutterWindows_WindowManager_OnDestroyWindow(hwnd);
86 }
87 }
InternalFlutterWindows_WindowManager_OnDestroyWindow
void InternalFlutterWindows_WindowManager_OnDestroyWindow(HWND hwnd)
Definition: window_manager.cc:192

References InternalFlutterWindows_WindowManager_OnDestroyWindow().

The documentation for this class was generated from the following files:

- shell/platform/windows/window_manager.h
- shell/platform/windows/window_manager.cc