Flutter Engine
 
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)
 
bool HasTopLevelWindows () const
 
FlutterViewId CreateRegularWindow (const RegularWindowCreationRequest *request)
 
FlutterViewId CreateDialogWindow (const DialogWindowCreationRequest *request)
 
std::optional< LRESULTHandleMessage (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) {}
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 48 of file window_manager.cc.

49 {
51 this, engine_, request->preferred_size, request->preferred_constraints,
52 request->title, request->parent_or_null);
53 if (!window || !window->GetWindowHandle()) {
54 FML_LOG(ERROR) << "Failed to create host window";
55 return -1;
56 }
57 FlutterViewId const view_id = window->view_controller_->view()->view_id();
58 active_windows_[window->GetWindowHandle()] = std::move(window);
59 return view_id;
60}
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:386
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.

◆ CreateRegularWindow()

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

Definition at line 34 of file window_manager.cc.

35 {
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}
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.

◆ HandleMessage()

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

Definition at line 78 of file window_manager.cc.

81 {
82 if (message == WM_NCDESTROY) {
83 active_windows_.erase(hwnd);
84 }
85
86 FlutterWindowsView* view = engine_->GetViewFromTopLevelWindow(hwnd);
87 if (!view) {
88 FML_LOG(WARNING) << "Received message for unknown view";
89 return std::nullopt;
90 }
91
92 WindowsMessage message_struct = {.view_id = view->view_id(),
93 .hwnd = hwnd,
94 .message = message,
95 .wParam = wparam,
96 .lParam = lparam,
97 .result = 0,
98 .handled = false};
99
100 // Not initialized yet.
101 if (!isolate_) {
102 return std::nullopt;
103 }
104
105 IsolateScope scope(*isolate_);
106 on_message_(&message_struct);
107 if (message_struct.handled) {
108 return message_struct.result;
109 } else {
110 return std::nullopt;
111 }
112}
FlutterWindowsView * GetViewFromTopLevelWindow(HWND hwnd) const
FlView * view
G_BEGIN_DECLS GBytes * message

References FML_LOG, flutter::FlutterWindowsEngine::GetViewFromTopLevelWindow(), flutter::WindowsMessage::handled, message, flutter::WindowsMessage::result, view, 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}

◆ 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}
static Isolate Current()

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

◆ OnEngineShutdown()

void flutter::WindowManager::OnEngineShutdown ( )

Definition at line 62 of file window_manager.cc.

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

References window.


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