Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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)
 
FlutterViewId CreatePopupWindow (const PopupWindowCreationRequest *request)
 
std::optional< LRESULTHandleMessage (HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
 
void OnEngineShutdown ()
 

Detailed Description

Definition at line 118 of file window_manager.h.

Constructor & Destructor Documentation

◆ WindowManager()

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

Definition at line 25 of file window_manager.cc.

25: engine_(engine) {}
FlutterEngine engine
Definition main.cc:84

◆ ~WindowManager()

virtual flutter::WindowManager::~WindowManager ( )
virtualdefault

Member Function Documentation

◆ CreateDialogWindow()

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

Definition at line 46 of file window_manager.cc.

47 {
49 this, engine_, request->preferred_size, request->preferred_constraints,
50 request->title, request->parent_or_null, request->sized_to_content,
51 request->resizable);
52 if (!window || !window->GetWindowHandle()) {
53 FML_LOG(ERROR) << "Failed to create host window";
54 return -1;
55 }
56 FlutterViewId const view_id = window->view_controller_->view()->view_id();
57 active_windows_[window->GetWindowHandle()] = std::move(window);
58 return view_id;
59}
static std::unique_ptr< HostWindow > CreateDialogWindow(WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowSizeRequest &preferred_size, const WindowConstraints &preferred_constraints, LPCWSTR title, HWND parent, bool sized_to_content, bool resizable)
int64_t FlutterViewId
Definition embedder.h:393
GLFWwindow * window
Definition main.cc:60
G_BEGIN_DECLS FlutterViewId view_id
#define FML_LOG(severity)
Definition logging.h:101

References flutter::HostWindow::CreateDialogWindow(), FML_LOG, flutter::DialogWindowCreationRequest::parent_or_null, flutter::DialogWindowCreationRequest::preferred_constraints, flutter::DialogWindowCreationRequest::preferred_size, flutter::DialogWindowCreationRequest::resizable, flutter::DialogWindowCreationRequest::sized_to_content, flutter::DialogWindowCreationRequest::title, view_id, and window.

◆ CreatePopupWindow()

FlutterViewId flutter::WindowManager::CreatePopupWindow ( const PopupWindowCreationRequest request)

Definition at line 75 of file window_manager.cc.

76 {
78 this, engine_, request->preferred_constraints,
79 request->get_position_callback, request->parent);
80 if (!window || !window->GetWindowHandle()) {
81 FML_LOG(ERROR) << "Failed to create host window";
82 return -1;
83 }
84 FlutterViewId const view_id = window->view_controller_->view()->view_id();
85 active_windows_[window->GetWindowHandle()] = std::move(window);
86 return view_id;
87}
static std::unique_ptr< HostWindow > CreatePopupWindow(WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowConstraints &preferred_constraints, GetWindowPositionCallback get_position_callback, HWND parent)

References flutter::HostWindow::CreatePopupWindow(), FML_LOG, flutter::PopupWindowCreationRequest::get_position_callback, flutter::PopupWindowCreationRequest::parent, flutter::PopupWindowCreationRequest::preferred_constraints, view_id, and window.

◆ CreateRegularWindow()

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

Definition at line 32 of file window_manager.cc.

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

References flutter::HostWindow::CreateRegularWindow(), FML_LOG, flutter::RegularWindowCreationRequest::preferred_constraints, flutter::RegularWindowCreationRequest::preferred_size, flutter::RegularWindowCreationRequest::resizable, flutter::RegularWindowCreationRequest::sized_to_content, flutter::RegularWindowCreationRequest::title, view_id, and window.

◆ CreateTooltipWindow()

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

Definition at line 61 of file window_manager.cc.

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

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

◆ HandleMessage()

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

Definition at line 105 of file window_manager.cc.

108 {
109 if (message == WM_NCDESTROY) {
110 active_windows_.erase(hwnd);
111 return std::nullopt;
112 }
113
114 HostWindow* host_window = HostWindow::GetThisFromHandle(hwnd);
115 FlutterWindowsView* view =
116 host_window ? host_window->view_controller_->view() : nullptr;
117
118 if (!view) {
119 FML_LOG(WARNING) << "Received message for unknown view";
120 return std::nullopt;
121 }
122
123 WindowsMessage message_struct = {.view_id = view->view_id(),
124 .hwnd = hwnd,
125 .message = message,
126 .wParam = wparam,
127 .lParam = lparam,
128 .result = 0,
129 .handled = false};
130
131 // Not initialized yet.
132 if (!isolate_) {
133 return std::nullopt;
134 }
135
136 IsolateScope scope(*isolate_);
137 on_message_(&message_struct);
138 if (message_struct.handled) {
139 return message_struct.result;
140 } else {
141 return std::nullopt;
142 }
143}
static HostWindow * GetThisFromHandle(HWND hwnd)
FlView * view
const char * message

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

◆ Initialize()

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

Definition at line 27 of file window_manager.cc.

27 {
28 on_message_ = request->on_message;
29 isolate_ = Isolate::Current();
30}
static Isolate Current()

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

◆ OnEngineShutdown()

void flutter::WindowManager::OnEngineShutdown ( )

Definition at line 89 of file window_manager.cc.

89 {
90 // Don't send any more messages to isolate.
91 on_message_ = nullptr;
92 std::vector<HWND> active_handles;
93 active_handles.reserve(active_windows_.size());
94 for (auto& [hwnd, window] : active_windows_) {
95 active_handles.push_back(hwnd);
96 }
97 for (auto hwnd : active_handles) {
98 // This will destroy the window, which will in turn remove the
99 // HostWindow from map when handling WM_NCDESTROY inside
100 // HandleMessage.
102 }
103}
void InternalFlutterWindows_WindowManager_OnDestroyWindow(HWND hwnd)

References InternalFlutterWindows_WindowManager_OnDestroyWindow(), and window.


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