Skip to content

Commit

Permalink
fix: application window is not visible on Windows (#6740)
Browse files Browse the repository at this point in the history
* fix: try to fix the windows not visible issue

* chore: update win32_window

* chore: adjust the new api
  • Loading branch information
LucasXu0 authored Nov 7, 2024
1 parent 97999ae commit 4e1532a
Show file tree
Hide file tree
Showing 4 changed files with 211 additions and 190 deletions.
12 changes: 11 additions & 1 deletion frontend/appflowy_flutter/windows/runner/flutter_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bool FlutterWindow::OnCreate() {
RECT frame = GetClientArea();

// The size here must match the window dimensions to avoid unnecessary surface
// creation / destruction in the startup path.
// creation / destruction in the startup path.
flutter_controller_ = std::make_unique<flutter::FlutterViewController>(
frame.right - frame.left, frame.bottom - frame.top, project_);
// Ensure that basic setup of the controller was successful.
Expand All @@ -26,6 +26,16 @@ bool FlutterWindow::OnCreate() {
}
RegisterPlugins(flutter_controller_->engine());
SetChildContent(flutter_controller_->view()->GetNativeWindow());

flutter_controller_->engine()->SetNextFrameCallback([&]() {
this->Show();
});

// Flutter can complete the first frame before the "show window" callback is
// registered. The following call ensures a frame is pending to ensure the
// window is shown. It is a no-op if the first frame hasn't completed yet.
flutter_controller_->ForceRedraw();

return true;
}

Expand Down
5 changes: 4 additions & 1 deletion frontend/appflowy_flutter/windows/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.CreateAndShow(L"AppFlowy", origin, size)) {

if (!window.Create(L"AppFlowy", origin, size)) {
return EXIT_FAILURE;
}

window.Show();
window.SetQuitOnClose(true);

::MSG msg;
Expand Down
Loading

0 comments on commit 4e1532a

Please sign in to comment.