Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions engine/src/flutter/shell/platform/common/isolate_scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace flutter {
/// as argument to IsolateScope constructor to enter and exit the isolate.
class Isolate {
public:
/// Retrieve the current Dart Isolate. If no isolate is current, this
/// results in a crash.
static Isolate Current();

~Isolate() = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class FlutterWindowsEngine {
WindowManager* window_manager() { return window_manager_.get(); }

// Returns the root view associated with the top-level window with |hwnd| as
// the window handle.
// the window handle or nullptr if no such view could be found.
FlutterWindowsView* GetViewFromTopLevelWindow(HWND hwnd) const;

protected:
Expand Down
16 changes: 0 additions & 16 deletions engine/src/flutter/shell/platform/windows/host_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,6 @@ bool IsClassRegistered(LPCWSTR class_name) {
0;
}

// Converts std::string to std::wstring.
std::wstring StringToWstring(std::string_view str) {
if (str.empty()) {
return {};
}
if (int buffer_size =
MultiByteToWideChar(CP_UTF8, 0, str.data(), str.size(), nullptr, 0)) {
std::wstring wide_str(buffer_size, L'\0');
if (MultiByteToWideChar(CP_UTF8, 0, str.data(), str.size(), &wide_str[0],
buffer_size)) {
return wide_str;
}
}
return {};
}

// Window attribute that enables dark mode window decorations.
//
// Redefined in case the developer's machine has a Windows SDK older than
Expand Down
16 changes: 1 addition & 15 deletions engine/src/flutter/shell/platform/windows/window_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ WindowManager::WindowManager(FlutterWindowsEngine* engine) : engine_(engine) {}
void WindowManager::Initialize(const WindowingInitRequest* request) {
on_message_ = request->on_message;
isolate_ = Isolate::Current();

// Send messages accumulated before isolate called this method.
for (WindowsMessage& message : pending_messages_) {
IsolateScope scope(*isolate_);
on_message_(&message);
}
pending_messages_.clear();
}

bool WindowManager::HasTopLevelWindows() const {
Expand All @@ -44,7 +37,7 @@ FlutterViewId WindowManager::CreateRegularWindow(
HostWindow::CreateRegularWindow(this, engine_, request->content_size);
if (!window || !window->GetWindowHandle()) {
FML_LOG(ERROR) << "Failed to create host window";
return 0;
return -1;
}
FlutterViewId const view_id = window->view_controller_->view()->view_id();
active_windows_[window->GetWindowHandle()] = std::move(window);
Expand Down Expand Up @@ -91,13 +84,6 @@ std::optional<LRESULT> WindowManager::HandleMessage(HWND hwnd,

// Not initialized yet.
if (!isolate_) {
if (pending_messages_.size() > 1024) {
FML_LOG(ERROR) << "The pending message cache has been maxed out, "
"something must be going wrong.";
return std::nullopt;
}

pending_messages_.push_back(message_struct);
return std::nullopt;
}

Expand Down
11 changes: 4 additions & 7 deletions engine/src/flutter/shell/platform/windows/window_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define FLUTTER_SHELL_PLATFORM_WINDOWS_WINDOW_MANAGER_H_

#include <windows.h>
#include <functional>
#include <optional>
#include <unordered_map>
#include <vector>
Expand Down Expand Up @@ -66,7 +67,7 @@ class WindowManager {

// Message handler called by |HostWindow::WndProc| to process window
// messages before delegating them to the host window. This allows the
// controller to process messages that affect the state of other host windows.
// manager to process messages that affect the state of other host windows.
std::optional<LRESULT> HandleMessage(HWND hwnd,
UINT message,
WPARAM wparam,
Expand All @@ -75,20 +76,16 @@ class WindowManager {
void OnEngineShutdown();

private:
// The Flutter engine that owns this controller.
// The Flutter engine that owns this manager.
FlutterWindowsEngine* const engine_;

// Callback that relays windows messages to the isolate. Set
// during Initialize().
void (*on_message_)(WindowsMessage*) = nullptr;
std::function<void(WindowsMessage*)> on_message_;

// Isolate that runs the Dart code. Set during Initialize().
std::optional<Isolate> isolate_;

// Messages received before the controller is initialized from dart
// code. Buffered until Initialize() is called.
std::vector<WindowsMessage> pending_messages_;

// A map of active windows. Used to destroy remaining windows on engine
// shutdown.
std::unordered_map<HWND, std::unique_ptr<HostWindow>> active_windows_;
Expand Down
Loading