Skip to content

Commit

Permalink
update windows files
Browse files Browse the repository at this point in the history
  • Loading branch information
zmtzawqlp committed Jan 7, 2022
1 parent 9b5d643 commit a207af0
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 135 deletions.
2 changes: 1 addition & 1 deletion Flutter/json_to_dart/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.14)
project(json_to_dart LANGUAGES CXX)

set(BINARY_NAME "json_to_dart")
Expand Down
2 changes: 1 addition & 1 deletion Flutter/json_to_dart/windows/flutter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.14)

set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Generated file. Do not edit.
//

// clang-format off

#include "generated_plugin_registrant.h"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Generated file. Do not edit.
//

// clang-format off

#ifndef GENERATED_PLUGIN_REGISTRANT_
#define GENERATED_PLUGIN_REGISTRANT_

Expand Down
3 changes: 1 addition & 2 deletions Flutter/json_to_dart/windows/runner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.14)
project(runner LANGUAGES CXX)

add_executable(${BINARY_NAME} WIN32
"flutter_window.cpp"
"main.cpp"
"run_loop.cpp"
"utils.cpp"
"win32_window.cpp"
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
Expand Down
10 changes: 5 additions & 5 deletions Flutter/json_to_dart/windows/runner/Runner.rc
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "com.example" "\0"
VALUE "FileDescription", "The tool to convert json to dart code." "\0"
VALUE "FileDescription", "A new Flutter project." "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "JsonToDart" "\0"
VALUE "LegalCopyright", "Copyright (C) 2021 com.example. All rights reserved." "\0"
VALUE "OriginalFilename", "JsonToDart.exe" "\0"
VALUE "ProductName", "JsonToDart" "\0"
VALUE "InternalName", "json_to_dart" "\0"
VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0"
VALUE "OriginalFilename", "json_to_dart.exe" "\0"
VALUE "ProductName", "json_to_dart" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"
END
END
Expand Down
9 changes: 3 additions & 6 deletions Flutter/json_to_dart/windows/runner/flutter_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

#include "flutter/generated_plugin_registrant.h"

FlutterWindow::FlutterWindow(RunLoop* run_loop,
const flutter::DartProject& project)
: run_loop_(run_loop), project_(project) {}
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
: project_(project) {}

FlutterWindow::~FlutterWindow() {}

Expand All @@ -26,14 +25,12 @@ bool FlutterWindow::OnCreate() {
return false;
}
RegisterPlugins(flutter_controller_->engine());
run_loop_->RegisterFlutterInstance(flutter_controller_->engine());
SetChildContent(flutter_controller_->view()->GetNativeWindow());
return true;
}

void FlutterWindow::OnDestroy() {
if (flutter_controller_) {
run_loop_->UnregisterFlutterInstance(flutter_controller_->engine());
flutter_controller_ = nullptr;
}

Expand All @@ -44,7 +41,7 @@ LRESULT
FlutterWindow::MessageHandler(HWND hwnd, UINT const message,
WPARAM const wparam,
LPARAM const lparam) noexcept {
// Give Flutter, including plugins, an opporutunity to handle window messages.
// Give Flutter, including plugins, an opportunity to handle window messages.
if (flutter_controller_) {
std::optional<LRESULT> result =
flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam,
Expand Down
10 changes: 2 additions & 8 deletions Flutter/json_to_dart/windows/runner/flutter_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@

#include <memory>

#include "run_loop.h"
#include "win32_window.h"

// A window that does nothing but host a Flutter view.
class FlutterWindow : public Win32Window {
public:
// Creates a new FlutterWindow driven by the |run_loop|, hosting a
// Flutter view running |project|.
explicit FlutterWindow(RunLoop* run_loop,
const flutter::DartProject& project);
// Creates a new FlutterWindow hosting a Flutter view running |project|.
explicit FlutterWindow(const flutter::DartProject& project);
virtual ~FlutterWindow();

protected:
Expand All @@ -26,9 +23,6 @@ class FlutterWindow : public Win32Window {
LPARAM const lparam) noexcept override;

private:
// The run loop driving events for this window.
RunLoop* run_loop_;

// The project to run.
flutter::DartProject project_;

Expand Down
13 changes: 7 additions & 6 deletions Flutter/json_to_dart/windows/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <windows.h>

#include "flutter_window.h"
#include "run_loop.h"
#include "utils.h"

int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
Expand All @@ -18,24 +17,26 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
// plugins.
::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);

RunLoop run_loop;

flutter::DartProject project(L"data");

std::vector<std::string> command_line_arguments =
GetCommandLineArguments();

project.set_dart_entrypoint_arguments(std::move(command_line_arguments));

FlutterWindow window(&run_loop, project);
FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.CreateAndShow(L"JsonToDart", origin, size)) {
if (!window.CreateAndShow(L"json_to_dart", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);

run_loop.Run();
::MSG msg;
while (::GetMessage(&msg, nullptr, 0, 0)) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}

::CoUninitialize();
return EXIT_SUCCESS;
Expand Down
66 changes: 0 additions & 66 deletions Flutter/json_to_dart/windows/runner/run_loop.cpp

This file was deleted.

40 changes: 0 additions & 40 deletions Flutter/json_to_dart/windows/runner/run_loop.h

This file was deleted.

0 comments on commit a207af0

Please sign in to comment.