| 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)
std::optional< LRESULT > | HandleMessage (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
void | OnEngineShutdown ()

## Detailed Description

Definition at line 84 of file window_manager.h.

## Constructor & Destructor Documentation

## ◆ WindowManager()

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

Definition at line 23 of file window_manager.cc.

23 : engine_(engine) {}

## ◆ ~WindowManager()

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

## Member Function Documentation

## ◆ CreateDialogWindow()

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

Definition at line 44 of file window_manager.cc.

45 {
46 auto window = HostWindow::CreateDialogWindow(
47 this, engine_, request->preferred_size, request->preferred_constraints,
48 request->title, request->parent_or_null);
49 if (!window || !window->GetWindowHandle()) {
50 FML_LOG(ERROR) << "Failed to create host window";
51 return -1;
52 }
53 FlutterViewId const view_id = window->view_controller_->view()->view_id();
54 active_windows_[window->GetWindowHandle()] = std::move(window);
55 return view_id;
56 }
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:215
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 30 of file window_manager.cc.

31 {
32 auto window = HostWindow::CreateRegularWindow(
33 this, engine_, request->preferred_size, request->preferred_constraints,
34 request->title);
35 if (!window || !window->GetWindowHandle()) {
36 FML_LOG(ERROR) << "Failed to create host window";
37 return -1;
38 }
39 FlutterViewId const view_id = window->view_controller_->view()->view_id();
40 active_windows_[window->GetWindowHandle()] = std::move(window);
41 return view_id;
42 }
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:204

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

Referenced by InternalFlutterWindows_WindowManager_CreateRegularWindow().

## ◆ HandleMessage()

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

Definition at line 74 of file window_manager.cc.

77 {
78 if (message == WM_NCDESTROY) {
79 active_windows_.erase(hwnd);
80 }
81
82 FlutterWindowsView* view = engine_->GetViewFromTopLevelWindow(hwnd);
83 if (!view) {
84 FML_LOG(WARNING) << "Received message for unknown view";
85 return std::nullopt;
86 }
87
88 WindowsMessage message_struct = {.view_id = view->view_id(),
89 .hwnd = hwnd,
90 .message = message,
91 .wParam = wparam,
92 .lParam = lparam,
93 .result = 0,
94 .handled = false};
95
96 // Not initialized yet.
97 if (!isolate_) {
98 return std::nullopt;
99 }
100
101 IsolateScope scope(*isolate_);
102 on_message_(&message_struct);
103 if (message_struct.handled) {
104 return message_struct.result;
105 } else {
106 return std::nullopt;
107 }
108 }
flutter::FlutterWindowsEngine::GetViewFromTopLevelWindow
FlutterWindowsView * GetViewFromTopLevelWindow(HWND hwnd) const
Definition: flutter_windows_engine.cc:864
flutter::FlutterWindowsView::view_id
FlutterViewId view_id() const
Definition: flutter_windows_view.cc:711
message
Win32Message message
Definition: keyboard_unittests.cc:137

References flutter::FlutterWindowsEngine::GetViewFromTopLevelWindow(), flutter::WindowsMessage::handled, message, flutter::WindowsMessage::result, flutter::FlutterWindowsView::view_id(), and flutter::WindowsMessage::view_id.

## ◆ Initialize()

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

Definition at line 25 of file window_manager.cc.

25 {
26 on_message_ = request->on_message;
27 isolate_ = Isolate::Current();
28 }
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 58 of file window_manager.cc.

58 {
59 // Don't send any more messages to isolate.
60 on_message_ = nullptr;
61 std::vector<HWND> active_handles;
62 active_handles.reserve(active_windows_.size());
63 for (auto& [hwnd, window] : active_windows_) {
64 active_handles.push_back(hwnd);
65 }
66 for (auto hwnd : active_handles) {
67 // This will destroy the window, which will in turn remove the
68 // HostWindow from map when handling WM_NCDESTROY inside
69 // HandleMessage.
70 DestroyWindow(hwnd);
71 }
72 }

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

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