Update Windows app template (#65696)

This commit is contained in:
stuartmorgan 2020-09-14 21:07:04 -04:00 committed by GitHub
parent 9dd6738662
commit fa12f443df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 19 additions and 53 deletions

View file

@ -7,12 +7,12 @@ add_executable(${BINARY_NAME} WIN32
"run_loop.cpp"
"utils.cpp"
"win32_window.cpp"
"window_configuration.cpp"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
"Runner.rc"
"runner.exe.manifest"
)
apply_standard_settings(${BINARY_NAME})
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
add_dependencies(${BINARY_NAME} flutter_assemble)

View file

@ -1,5 +1,5 @@
#ifndef FLUTTER_WINDOW_H_
#define FLUTTER_WINDOW_H_
#ifndef RUNNER_FLUTTER_WINDOW_H_
#define RUNNER_FLUTTER_WINDOW_H_
#include <flutter/dart_project.h>
#include <flutter/flutter_view_controller.h>
@ -36,4 +36,4 @@ class FlutterWindow : public Win32Window {
std::unique_ptr<flutter::FlutterViewController> flutter_controller_;
};
#endif // FLUTTER_WINDOW_H_
#endif // RUNNER_FLUTTER_WINDOW_H_

View file

@ -5,7 +5,6 @@
#include "flutter_window.h"
#include "run_loop.h"
#include "utils.h"
#include "window_configuration.h"
int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
_In_ wchar_t *command_line, _In_ int show_command) {
@ -23,9 +22,9 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
flutter::DartProject project(L"data");
FlutterWindow window(&run_loop, project);
Win32Window::Point origin(kFlutterWindowOriginX, kFlutterWindowOriginY);
Win32Window::Size size(kFlutterWindowWidth, kFlutterWindowHeight);
if (!window.CreateAndShow(kFlutterWindowTitle, origin, size)) {
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.CreateAndShow(L"{{projectName}}", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);

View file

@ -1,9 +1,6 @@
#include "run_loop.h"
#include <Windows.h>
// Don't stomp std::min/std::max
#undef max
#undef min
#include <windows.h>
#include <algorithm>

View file

@ -1,5 +1,5 @@
#ifndef RUN_LOOP_H_
#define RUN_LOOP_H_
#ifndef RUNNER_RUN_LOOP_H_
#define RUNNER_RUN_LOOP_H_
#include <flutter/flutter_engine.h>
@ -37,4 +37,4 @@ class RunLoop {
std::set<flutter::FlutterEngine*> flutter_instances_;
};
#endif // RUN_LOOP_H_
#endif // RUNNER_RUN_LOOP_H_

View file

@ -1,8 +1,8 @@
#ifndef CONSOLE_UTILS_H_
#define CONSOLE_UTILS_H_
#ifndef RUNNER_UTILS_H_
#define RUNNER_UTILS_H_
// Creates a console for the process, and redirects stdout and stderr to
// it for both the runner and the Flutter library.
void CreateAndAttachConsole();
#endif // CONSOLE_UTILS_H_
#endif // RUNNER_UTILS_H_

View file

@ -1,8 +1,7 @@
#ifndef WIN32_WINDOW_H_
#define WIN32_WINDOW_H_
#ifndef RUNNER_WIN32_WINDOW_H_
#define RUNNER_WIN32_WINDOW_H_
#include <Windows.h>
#include <Windowsx.h>
#include <windows.h>
#include <functional>
#include <memory>
@ -96,4 +95,4 @@ class Win32Window {
HWND child_content_ = nullptr;
};
#endif // WIN32_WINDOW_H_
#endif // RUNNER_WIN32_WINDOW_H_

View file

@ -1,7 +0,0 @@
#include "window_configuration.h"
const wchar_t* kFlutterWindowTitle = L"{{projectName}}";
const unsigned int kFlutterWindowOriginX = 10;
const unsigned int kFlutterWindowOriginY = 10;
const unsigned int kFlutterWindowWidth = 1280;
const unsigned int kFlutterWindowHeight = 720;

View file

@ -1,18 +0,0 @@
#ifndef WINDOW_CONFIGURATION_
#define WINDOW_CONFIGURATION_
// This is a temporary approach to isolate changes that people are likely to
// make to main.cpp, where the APIs are still in flux. This will reduce the
// need to resolve conflicts or re-create changes slightly differently every
// time the Windows Flutter API surface changes.
//
// Longer term there should be simpler configuration options for common
// customizations like this, without requiring native code changes.
extern const wchar_t* kFlutterWindowTitle;
extern const unsigned int kFlutterWindowOriginX;
extern const unsigned int kFlutterWindowOriginY;
extern const unsigned int kFlutterWindowWidth;
extern const unsigned int kFlutterWindowHeight;
#endif // WINDOW_CONFIGURATION_

View file

@ -84,8 +84,6 @@
"templates/app/linux.tmpl/main.cc",
"templates/app/linux.tmpl/my_application.cc",
"templates/app/linux.tmpl/my_application.h",
"templates/app/linux.tmpl/window_configuration.cc.tmpl",
"templates/app/linux.tmpl/window_configuration.h",
"templates/app/macos.tmpl/.gitignore",
"templates/app/macos.tmpl/Flutter/Flutter-Debug.xcconfig",
"templates/app/macos.tmpl/Flutter/Flutter-Release.xcconfig",
@ -128,7 +126,7 @@
"templates/app/windows.tmpl/runner/CMakeLists.txt",
"templates/app/windows.tmpl/runner/flutter_window.cpp",
"templates/app/windows.tmpl/runner/flutter_window.h",
"templates/app/windows.tmpl/runner/main.cpp",
"templates/app/windows.tmpl/runner/main.cpp.tmpl",
"templates/app/windows.tmpl/runner/resource.h",
"templates/app/windows.tmpl/runner/resources/app_icon.ico.img.tmpl",
"templates/app/windows.tmpl/runner/runner.exe.manifest",
@ -139,8 +137,6 @@
"templates/app/windows.tmpl/runner/utils.h",
"templates/app/windows.tmpl/runner/win32_window.cpp",
"templates/app/windows.tmpl/runner/win32_window.h",
"templates/app/windows.tmpl/runner/window_configuration.cpp.tmpl",
"templates/app/windows.tmpl/runner/window_configuration.h",
"templates/cocoapods/Podfile-ios-objc",
"templates/cocoapods/Podfile-ios-swift",
"templates/cocoapods/Podfile-macos",