Skip to content

Commit b3bde1d

Browse files
Update the Windows runner for Gallery (flutter#84020)
1 parent 190a1a4 commit b3bde1d

File tree

13 files changed

+90
-133
lines changed

13 files changed

+90
-133
lines changed

dev/integration_tests/flutter_gallery/windows/flutter/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ list(APPEND FLUTTER_LIBRARY_HEADERS
2323
"flutter_windows.h"
2424
"flutter_messenger.h"
2525
"flutter_plugin_registrar.h"
26+
"flutter_texture_registrar.h"
2627
)
2728
list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
2829
add_library(flutter INTERFACE)
@@ -91,6 +92,7 @@ add_custom_command(
9192
${FLUTTER_TOOL_ENVIRONMENT}
9293
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
9394
windows-x64 $<CONFIG>
95+
VERBATIM
9496
)
9597
add_custom_target(flutter_assemble DEPENDS
9698
"${FLUTTER_LIBRARY}"

dev/integration_tests/flutter_gallery/windows/flutter/generated_plugin_registrant.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Generated file. Do not edit.
33
//
44

5+
// clang-format off
6+
57
#include "generated_plugin_registrant.h"
68

79
#include <url_launcher_windows/url_launcher_plugin.h>

dev/integration_tests/flutter_gallery/windows/flutter/generated_plugin_registrant.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Generated file. Do not edit.
33
//
44

5+
// clang-format off
6+
57
#ifndef GENERATED_PLUGIN_REGISTRANT_
68
#define GENERATED_PLUGIN_REGISTRANT_
79

dev/integration_tests/flutter_gallery/windows/runner/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ project(runner LANGUAGES CXX)
44
add_executable(${BINARY_NAME} WIN32
55
"flutter_window.cpp"
66
"main.cpp"
7-
"run_loop.cpp"
87
"utils.cpp"
98
"win32_window.cpp"
109
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"

dev/integration_tests/flutter_gallery/windows/runner/Runner.rc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ END
4545
#endif // APSTUDIO_INVOKED
4646

4747

48+
/////////////////////////////////////////////////////////////////////////////
49+
//
50+
// Icon
51+
//
52+
53+
// Icon with lowest ID value placed first to ensure application icon
54+
// remains consistent on all systems.
55+
// IDI_APP_ICON ICON "resources\\app_icon.ico"
56+
57+
4858
/////////////////////////////////////////////////////////////////////////////
4959
//
5060
// Version
@@ -79,11 +89,11 @@ BEGIN
7989
BEGIN
8090
BLOCK "040904e4"
8191
BEGIN
82-
VALUE "CompanyName", "io.flutter.demo" "\0"
92+
VALUE "CompanyName", "com.example" "\0"
8393
VALUE "FileDescription", "A new Flutter project." "\0"
8494
VALUE "FileVersion", VERSION_AS_STRING "\0"
8595
VALUE "InternalName", "flutter_gallery" "\0"
86-
VALUE "LegalCopyright", "Copyright (C) 2020 io.flutter.demo. All rights reserved." "\0"
96+
VALUE "LegalCopyright", "Copyright (C) 2021 com.example. All rights reserved." "\0"
8797
VALUE "OriginalFilename", "flutter_gallery.exe" "\0"
8898
VALUE "ProductName", "flutter_gallery" "\0"
8999
VALUE "ProductVersion", VERSION_AS_STRING "\0"

dev/integration_tests/flutter_gallery/windows/runner/flutter_window.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
#include "flutter/generated_plugin_registrant.h"
66

7-
FlutterWindow::FlutterWindow(RunLoop* run_loop,
8-
const flutter::DartProject& project)
9-
: run_loop_(run_loop), project_(project) {}
7+
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
8+
: project_(project) {}
109

1110
FlutterWindow::~FlutterWindow() {}
1211

@@ -26,14 +25,12 @@ bool FlutterWindow::OnCreate() {
2625
return false;
2726
}
2827
RegisterPlugins(flutter_controller_->engine());
29-
run_loop_->RegisterFlutterInstance(flutter_controller_->engine());
3028
SetChildContent(flutter_controller_->view()->GetNativeWindow());
3129
return true;
3230
}
3331

3432
void FlutterWindow::OnDestroy() {
3533
if (flutter_controller_) {
36-
run_loop_->UnregisterFlutterInstance(flutter_controller_->engine());
3734
flutter_controller_ = nullptr;
3835
}
3936

@@ -44,7 +41,7 @@ LRESULT
4441
FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
4542
WPARAM const wparam,
4643
LPARAM const lparam) noexcept {
47-
// Give Flutter, including plugins, an opporutunity to handle window messages.
44+
// Give Flutter, including plugins, an opportunity to handle window messages.
4845
if (flutter_controller_) {
4946
std::optional<LRESULT> result =
5047
flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,

dev/integration_tests/flutter_gallery/windows/runner/flutter_window.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010

1111
#include <memory>
1212

13-
#include "run_loop.h"
1413
#include "win32_window.h"
1514

1615
// A window that does nothing but host a Flutter view.
1716
class FlutterWindow : public Win32Window {
1817
public:
19-
// Creates a new FlutterWindow driven by the |run_loop|, hosting a
20-
// Flutter view running |project|.
21-
explicit FlutterWindow(RunLoop* run_loop,
22-
const flutter::DartProject& project);
18+
// Creates a new FlutterWindow hosting a Flutter view running |project|.
19+
explicit FlutterWindow(const flutter::DartProject& project);
2320
virtual ~FlutterWindow();
2421

2522
protected:
@@ -30,9 +27,6 @@ class FlutterWindow : public Win32Window {
3027
LPARAM const lparam) noexcept override;
3128

3229
private:
33-
// The run loop driving events for this window.
34-
RunLoop* run_loop_;
35-
3630
// The project to run.
3731
flutter::DartProject project_;
3832

dev/integration_tests/flutter_gallery/windows/runner/main.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <windows.h>
44

55
#include "flutter_window.h"
6-
#include "run_loop.h"
76
#include "utils.h"
87

98
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
@@ -18,18 +17,26 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
1817
// plugins.
1918
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
2019

21-
RunLoop run_loop;
22-
2320
flutter::DartProject project(L"data");
24-
FlutterWindow window(&run_loop, project);
21+
22+
std::vector<std::string> command_line_arguments =
23+
GetCommandLineArguments();
24+
25+
project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
26+
27+
FlutterWindow window(project);
2528
Win32Window::Point origin(10, 10);
2629
Win32Window::Size size(1280, 720);
2730
if (!window.CreateAndShow(L"flutter_gallery", origin, size)) {
2831
return EXIT_FAILURE;
2932
}
3033
window.SetQuitOnClose(true);
3134

32-
run_loop.Run();
35+
::MSG msg;
36+
while (::GetMessage(&msg, nullptr, 0, 0)) {
37+
::TranslateMessage(&msg);
38+
::DispatchMessage(&msg);
39+
}
3340

3441
::CoUninitialize();
3542
return EXIT_SUCCESS;

dev/integration_tests/flutter_gallery/windows/runner/run_loop.cpp

Lines changed: 0 additions & 66 deletions
This file was deleted.

dev/integration_tests/flutter_gallery/windows/runner/run_loop.h

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)