| 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)
bool | HasTopLevelWindows () const
FlutterViewId | CreateRegularWindow (const WindowCreationRequest *request)
std::optional< LRESULT > | HandleMessage (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
void | OnEngineShutdown ()

## Detailed Description

Definition at line 77 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

## ◆ CreateRegularWindow()

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

Definition at line 34 of file window_manager.cc.

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

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

Referenced by InternalFlutterWindows_WindowManager_CreateRegularWindow().

## ◆ HandleMessage()

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

Definition at line 64 of file window_manager.cc.

67 {
68 if (message == WM_NCDESTROY) {
69 active_windows_.erase(hwnd);
70 }
71
72 FlutterWindowsView* view = engine_->GetViewFromTopLevelWindow(hwnd);
73 if (!view) {
74 FML_LOG(WARNING) << "Received message for unknown view";
75 return std::nullopt;
76 }
77
78 WindowsMessage message_struct = {.view_id = view->view_id(),
79 .hwnd = hwnd,
80 .message = message,
81 .wParam = wparam,
82 .lParam = lparam,
83 .result = 0,
84 .handled = false};
85
86 // Not initialized yet.
87 if (!isolate_) {
88 return std::nullopt;
89 }
90
91 IsolateScope scope(*isolate_);
92 on_message_(&message_struct);
93 if (message_struct.handled) {
94 return message_struct.result;
95 } else {
96 return std::nullopt;
97 }
98 }
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.

## ◆ HasTopLevelWindows()

bool flutter::WindowManager::HasTopLevelWindows | ( |  | ) | const

Definition at line 30 of file window_manager.cc.

30 {
31 return !active_windows_.empty();
32 }

Referenced by InternalFlutterWindows_WindowManager_HasTopLevelWindows().

## ◆ 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 48 of file window_manager.cc.

48 {
49 // Don't send any more messages to isolate.
50 on_message_ = nullptr;
51 std::vector<HWND> active_handles;
52 active_handles.reserve(active_windows_.size());
53 for (auto& [hwnd, window] : active_windows_) {
54 active_handles.push_back(hwnd);
55 }
56 for (auto hwnd : active_handles) {
57 // This will destroy the window, which will in turn remove the
58 // HostWindow from map when handling WM_NCDESTROY inside
59 // HandleMessage.
60 DestroyWindow(hwnd);
61 }
62 }

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

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