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 114 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);
51 if (!window || !window->GetWindowHandle()) {
52 FML_LOG(ERROR) << "Failed to create host window";
53 return -1;
54 }
55 FlutterViewId const view_id = window->view_controller_->view()->view_id();
56 active_windows_[window->GetWindowHandle()] = std::move(window);
57 return view_id;
58}
static std::unique_ptr< HostWindow > CreateDialogWindow(WindowManager *window_manager, FlutterWindowsEngine *engine, const WindowSizeRequest &preferred_size, const WindowConstraints &preferred_constraints, LPCWSTR title, HWND parent)
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::title, view_id, and window.

◆ CreatePopupWindow()

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

Definition at line 74 of file window_manager.cc.

75 {
77 this, engine_, request->preferred_constraints,
78 request->get_position_callback, request->parent);
79 if (!window || !window->GetWindowHandle()) {
80 FML_LOG(ERROR) << "Failed to create host window";
81 return -1;
82 }
83 FlutterViewId const view_id = window->view_controller_->view()->view_id();
84 active_windows_[window->GetWindowHandle()] = std::move(window);
85 return view_id;
86}
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);
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)

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

◆ CreateTooltipWindow()

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

Definition at line 60 of file window_manager.cc.

61 {
63 this, engine_, request->preferred_constraints,
64 request->get_position_callback, 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}
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 104 of file window_manager.cc.

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

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

References InternalFlutterWindows_WindowManager_OnDestroyWindow(), and window.


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