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

References flutter::HostWindow::CreateTooltipWindow(), flutter::TooltipWindowCreationRequest::get_position_callback, flutter::TooltipWindowCreationRequest::is_sized_to_content, 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 90 of file window_manager.cc.

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

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

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