Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ee4fa1b3
Unverified
Commit
ee4fa1b3
authored
Sep 10, 2020
by
stuartmorgan
Committed by
GitHub
Sep 10, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Windows app template (#65511)
parent
0ea0e9d0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
16 deletions
+16
-16
.template_version
...ools/templates/app/windows.tmpl/flutter/.template_version
+1
-1
flutter_window.cpp
...ools/templates/app/windows.tmpl/runner/flutter_window.cpp
+7
-6
run_loop.cpp
...tter_tools/templates/app/windows.tmpl/runner/run_loop.cpp
+4
-5
run_loop.h
...lutter_tools/templates/app/windows.tmpl/runner/run_loop.h
+4
-4
No files found.
packages/flutter_tools/templates/app/windows.tmpl/flutter/.template_version
View file @
ee4fa1b3
6
7
packages/flutter_tools/templates/app/windows.tmpl/runner/flutter_window.cpp
View file @
ee4fa1b3
...
...
@@ -17,22 +17,23 @@ bool FlutterWindow::OnCreate() {
RECT
frame
=
GetClientArea
();
// The size here must match the window dimensions to avoid unnecessary surface creation / destruction in the startup path.
flutter_controller_
=
std
::
make_unique
<
flutter
::
FlutterViewController
>
(
frame
.
right
-
frame
.
left
,
frame
.
bottom
-
frame
.
top
,
project_
);
// The size here must match the window dimensions to avoid unnecessary surface
// 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.
if
(
!
flutter_controller_
->
engine
()
||
!
flutter_controller_
->
view
())
{
return
false
;
}
RegisterPlugins
(
flutter_controller_
.
get
());
run_loop_
->
RegisterFlutterInstance
(
flutter_controller_
.
get
());
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_
.
get
());
run_loop_
->
UnregisterFlutterInstance
(
flutter_controller_
->
engine
());
flutter_controller_
=
nullptr
;
}
...
...
packages/flutter_tools/templates/app/windows.tmpl/runner/run_loop.cpp
View file @
ee4fa1b3
...
...
@@ -47,20 +47,19 @@ void RunLoop::Run() {
}
void
RunLoop
::
RegisterFlutterInstance
(
flutter
::
Flutter
ViewController
*
flutter_instance
)
{
flutter
::
Flutter
Engine
*
flutter_instance
)
{
flutter_instances_
.
insert
(
flutter_instance
);
}
void
RunLoop
::
UnregisterFlutterInstance
(
flutter
::
Flutter
ViewController
*
flutter_instance
)
{
flutter
::
Flutter
Engine
*
flutter_instance
)
{
flutter_instances_
.
erase
(
flutter_instance
);
}
RunLoop
::
TimePoint
RunLoop
::
ProcessFlutterMessages
()
{
TimePoint
next_event_time
=
TimePoint
::
max
();
for
(
auto
flutter_controller
:
flutter_instances_
)
{
std
::
chrono
::
nanoseconds
wait_duration
=
flutter_controller
->
ProcessMessages
();
for
(
auto
instance
:
flutter_instances_
)
{
std
::
chrono
::
nanoseconds
wait_duration
=
instance
->
ProcessMessages
();
if
(
wait_duration
!=
std
::
chrono
::
nanoseconds
::
max
())
{
next_event_time
=
std
::
min
(
next_event_time
,
TimePoint
::
clock
::
now
()
+
wait_duration
);
...
...
packages/flutter_tools/templates/app/windows.tmpl/runner/run_loop.h
View file @
ee4fa1b3
#ifndef RUN_LOOP_H_
#define RUN_LOOP_H_
#include <flutter/flutter_
view_controller
.h>
#include <flutter/flutter_
engine
.h>
#include <chrono>
#include <set>
...
...
@@ -22,11 +22,11 @@ class RunLoop {
// Registers the given Flutter instance for event servicing.
void
RegisterFlutterInstance
(
flutter
::
Flutter
ViewController
*
flutter_instance
);
flutter
::
Flutter
Engine
*
flutter_instance
);
// Unregisters the given Flutter instance from event servicing.
void
UnregisterFlutterInstance
(
flutter
::
Flutter
ViewController
*
flutter_instance
);
flutter
::
Flutter
Engine
*
flutter_instance
);
private
:
using
TimePoint
=
std
::
chrono
::
steady_clock
::
time_point
;
...
...
@@ -34,7 +34,7 @@ class RunLoop {
// Processes all currently pending messages for registered Flutter instances.
TimePoint
ProcessFlutterMessages
();
std
::
set
<
flutter
::
Flutter
ViewController
*>
flutter_instances_
;
std
::
set
<
flutter
::
Flutter
Engine
*>
flutter_instances_
;
};
#endif // RUN_LOOP_H_
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment