Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 3295beb

Browse files
authored
Windows: Add UWP target stub [#14697] (#21754)
1 parent 1f1c6d2 commit 3295beb

31 files changed

+1049
-293
lines changed

BUILD.gn

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,15 @@ group("flutter") {
152152
}
153153

154154
if (is_win) {
155-
public_deps += [
156-
"//flutter/shell/platform/windows:flutter_windows_unittests",
157-
"//flutter/shell/platform/windows/client_wrapper:client_wrapper_windows_unittests",
158-
]
155+
if (target_os == "winuwp") {
156+
# TODO: Add winnup variant of the unit tests here; see
157+
# https://github.com/flutter/flutter/issues/70197
158+
} else {
159+
public_deps += [
160+
"//flutter/shell/platform/windows:flutter_windows_unittests",
161+
"//flutter/shell/platform/windows/client_wrapper:client_wrapper_windows_unittests",
162+
]
163+
}
159164
}
160165
}
161166
}

ci/licenses_golden/licenses_flutter

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,16 +1408,31 @@ FILE: ../../../flutter/shell/platform/windows/flutter_windows_engine.h
14081408
FILE: ../../../flutter/shell/platform/windows/flutter_windows_engine_unittests.cc
14091409
FILE: ../../../flutter/shell/platform/windows/flutter_windows_view.cc
14101410
FILE: ../../../flutter/shell/platform/windows/flutter_windows_view.h
1411+
FILE: ../../../flutter/shell/platform/windows/flutter_windows_win32.cc
1412+
FILE: ../../../flutter/shell/platform/windows/flutter_windows_winuwp.cc
14111413
FILE: ../../../flutter/shell/platform/windows/key_event_handler.cc
14121414
FILE: ../../../flutter/shell/platform/windows/key_event_handler.h
14131415
FILE: ../../../flutter/shell/platform/windows/keyboard_hook_handler.h
1416+
FILE: ../../../flutter/shell/platform/windows/platform_handler.cc
1417+
FILE: ../../../flutter/shell/platform/windows/platform_handler.h
1418+
FILE: ../../../flutter/shell/platform/windows/platform_handler_unittests.cc
1419+
FILE: ../../../flutter/shell/platform/windows/platform_handler_win32.cc
1420+
FILE: ../../../flutter/shell/platform/windows/platform_handler_win32.h
1421+
FILE: ../../../flutter/shell/platform/windows/platform_handler_winuwp.cc
1422+
FILE: ../../../flutter/shell/platform/windows/platform_handler_winuwp.h
14141423
FILE: ../../../flutter/shell/platform/windows/public/flutter_windows.h
14151424
FILE: ../../../flutter/shell/platform/windows/string_conversion.cc
14161425
FILE: ../../../flutter/shell/platform/windows/string_conversion.h
14171426
FILE: ../../../flutter/shell/platform/windows/string_conversion_unittests.cc
14181427
FILE: ../../../flutter/shell/platform/windows/system_utils.h
14191428
FILE: ../../../flutter/shell/platform/windows/system_utils_unittests.cc
14201429
FILE: ../../../flutter/shell/platform/windows/system_utils_win32.cc
1430+
FILE: ../../../flutter/shell/platform/windows/system_utils_winuwp.cc
1431+
FILE: ../../../flutter/shell/platform/windows/task_runner.h
1432+
FILE: ../../../flutter/shell/platform/windows/task_runner_win32.cc
1433+
FILE: ../../../flutter/shell/platform/windows/task_runner_win32.h
1434+
FILE: ../../../flutter/shell/platform/windows/task_runner_winuwp.cc
1435+
FILE: ../../../flutter/shell/platform/windows/task_runner_winuwp.h
14211436
FILE: ../../../flutter/shell/platform/windows/text_input_plugin.cc
14221437
FILE: ../../../flutter/shell/platform/windows/text_input_plugin.h
14231438
FILE: ../../../flutter/shell/platform/windows/win32_dpi_utils.cc
@@ -1426,10 +1441,6 @@ FILE: ../../../flutter/shell/platform/windows/win32_dpi_utils_unittests.cc
14261441
FILE: ../../../flutter/shell/platform/windows/win32_flutter_window.cc
14271442
FILE: ../../../flutter/shell/platform/windows/win32_flutter_window.h
14281443
FILE: ../../../flutter/shell/platform/windows/win32_flutter_window_unittests.cc
1429-
FILE: ../../../flutter/shell/platform/windows/win32_platform_handler.cc
1430-
FILE: ../../../flutter/shell/platform/windows/win32_platform_handler.h
1431-
FILE: ../../../flutter/shell/platform/windows/win32_task_runner.cc
1432-
FILE: ../../../flutter/shell/platform/windows/win32_task_runner.h
14331444
FILE: ../../../flutter/shell/platform/windows/win32_window.cc
14341445
FILE: ../../../flutter/shell/platform/windows/win32_window.h
14351446
FILE: ../../../flutter/shell/platform/windows/win32_window_proc_delegate_manager.cc

shell/platform/windows/BUILD.gn

Lines changed: 95 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,20 @@ source_set("flutter_windows_headers") {
2929
public_deps =
3030
[ "//flutter/shell/platform/common/cpp:common_cpp_library_headers" ]
3131

32-
configs +=
33-
[ "//flutter/shell/platform/common/cpp:desktop_library_implementation" ]
32+
if (target_os == "winuwp") {
33+
configs +=
34+
[ "//flutter/shell/platform/common/cpp:desktop_library_implementation" ]
35+
} else {
36+
configs +=
37+
[ "//flutter/shell/platform/common/cpp:desktop_library_implementation" ]
38+
}
3439

3540
public_configs =
3641
[ "//flutter/shell/platform/common/cpp:relative_flutter_library_headers" ]
3742
}
3843

3944
source_set("flutter_windows_source") {
45+
# Common Windows sources.
4046
sources = [
4147
"angle_surface_manager.cc",
4248
"angle_surface_manager.h",
@@ -52,29 +58,48 @@ source_set("flutter_windows_source") {
5258
"key_event_handler.cc",
5359
"key_event_handler.h",
5460
"keyboard_hook_handler.h",
61+
"platform_handler.cc",
62+
"platform_handler.h",
5563
"string_conversion.cc",
5664
"string_conversion.h",
5765
"system_utils.h",
58-
"system_utils_win32.cc",
66+
"task_runner.h",
5967
"text_input_plugin.cc",
6068
"text_input_plugin.h",
61-
"win32_dpi_utils.cc",
62-
"win32_dpi_utils.h",
63-
"win32_flutter_window.cc",
64-
"win32_flutter_window.h",
65-
"win32_platform_handler.cc",
66-
"win32_platform_handler.h",
67-
"win32_task_runner.cc",
68-
"win32_task_runner.h",
69-
"win32_window.cc",
70-
"win32_window.h",
71-
"win32_window_proc_delegate_manager.cc",
72-
"win32_window_proc_delegate_manager.h",
7369
"window_binding_handler.h",
7470
"window_binding_handler_delegate.h",
7571
"window_state.h",
7672
]
7773

74+
# Target-specific sources.
75+
if (target_os == "winuwp") {
76+
sources += [
77+
"flutter_windows_winuwp.cc",
78+
"platform_handler_winuwp.cc",
79+
"platform_handler_winuwp.h",
80+
"system_utils_winuwp.cc",
81+
"task_runner_winuwp.cc",
82+
"task_runner_winuwp.h",
83+
]
84+
} else {
85+
sources += [
86+
"flutter_windows_win32.cc",
87+
"platform_handler_win32.cc",
88+
"platform_handler_win32.h",
89+
"system_utils_win32.cc",
90+
"task_runner_win32.cc",
91+
"task_runner_win32.h",
92+
"win32_dpi_utils.cc",
93+
"win32_dpi_utils.h",
94+
"win32_flutter_window.cc",
95+
"win32_flutter_window.h",
96+
"win32_window.cc",
97+
"win32_window.h",
98+
"win32_window_proc_delegate_manager.cc",
99+
"win32_window_proc_delegate_manager.h",
100+
]
101+
}
102+
78103
configs += [
79104
"//flutter/shell/platform/common/cpp:desktop_library_implementation",
80105
"//third_party/angle:gl_prototypes",
@@ -116,40 +141,51 @@ shared_library("flutter_windows") {
116141
public_configs = [ "//flutter:config" ]
117142
}
118143

144+
shared_library("flutter_windows_winuwp") {
145+
deps = [ ":flutter_windows_source" ]
146+
libs = [ "windowsapp.lib" ]
147+
public_configs = [ "//flutter:config" ]
148+
}
149+
119150
test_fixtures("flutter_windows_fixtures") {
120151
fixtures = []
121152
}
122153

123-
executable("flutter_windows_unittests") {
124-
testonly = true
125-
126-
sources = [
127-
"flutter_project_bundle_unittests.cc",
128-
"flutter_windows_engine_unittests.cc",
129-
"string_conversion_unittests.cc",
130-
"system_utils_unittests.cc",
131-
"testing/engine_embedder_api_modifier.h",
132-
"testing/mock_win32_window.cc",
133-
"testing/mock_win32_window.h",
134-
"testing/win32_flutter_window_test.cc",
135-
"testing/win32_flutter_window_test.h",
136-
"win32_dpi_utils_unittests.cc",
137-
"win32_flutter_window_unittests.cc",
138-
"win32_window_proc_delegate_manager_unittests.cc",
139-
"win32_window_unittests.cc",
140-
]
141-
142-
public_configs = [ "//flutter:config" ]
143-
144-
deps = [
145-
":flutter_windows_fixtures",
146-
":flutter_windows_headers",
147-
":flutter_windows_source",
148-
"//flutter/shell/platform/embedder:embedder_as_internal_library",
149-
"//flutter/shell/platform/embedder:embedder_test_utils",
150-
"//flutter/testing",
151-
"//third_party/rapidjson",
152-
]
154+
if (target_os == "winuwp") {
155+
# disabled until the uwp implementation is present
156+
} else {
157+
executable("flutter_windows_unittests") {
158+
testonly = true
159+
160+
sources = [
161+
"flutter_project_bundle_unittests.cc",
162+
"flutter_windows_engine_unittests.cc",
163+
"string_conversion_unittests.cc",
164+
"system_utils_unittests.cc",
165+
"testing/engine_embedder_api_modifier.h",
166+
"testing/mock_win32_window.cc",
167+
"testing/mock_win32_window.h",
168+
"testing/win32_flutter_window_test.cc",
169+
"testing/win32_flutter_window_test.h",
170+
"win32_dpi_utils_unittests.cc",
171+
"win32_flutter_window_unittests.cc",
172+
"win32_window_proc_delegate_manager_unittests.cc",
173+
"win32_window_unittests.cc",
174+
]
175+
176+
public_configs = [ "//flutter:config" ]
177+
178+
deps = [
179+
":flutter_windows_fixtures",
180+
":flutter_windows_headers",
181+
":flutter_windows_source",
182+
"//flutter/shell/platform/common/cpp:common_cpp",
183+
"//flutter/shell/platform/embedder:embedder_as_internal_library",
184+
"//flutter/shell/platform/embedder:embedder_test_utils",
185+
"//flutter/testing",
186+
"//third_party/rapidjson",
187+
]
188+
}
153189
}
154190

155191
shared_library("flutter_windows_glfw") {
@@ -168,11 +204,20 @@ group("windows_glfw") {
168204
}
169205

170206
group("windows") {
171-
deps = [
172-
":flutter_windows",
173-
":publish_headers_windows",
174-
"//flutter/shell/platform/windows/client_wrapper:publish_wrapper_windows",
175-
]
207+
if (target_os == "winuwp") {
208+
deps = [
209+
":flutter_windows_winuwp",
210+
":publish_headers_windows",
211+
"//flutter/shell/platform/windows/client_wrapper:publish_wrapper_windows",
212+
]
213+
} else {
214+
deps = [
215+
":flutter_windows",
216+
":publish_headers_windows",
217+
"//flutter/shell/platform/windows/client_wrapper:publish_wrapper_windows",
218+
]
219+
}
220+
176221
if (build_glfw_shell) {
177222
deps += [ ":windows_glfw" ]
178223
}

shell/platform/windows/client_wrapper/flutter_engine.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ void FlutterEngine::ShutDown() {
6464
engine_ = nullptr;
6565
}
6666

67+
#ifndef WINUWP
6768
std::chrono::nanoseconds FlutterEngine::ProcessMessages() {
6869
return std::chrono::nanoseconds(FlutterDesktopEngineProcessMessages(engine_));
6970
}
71+
#endif
7072

7173
void FlutterEngine::ReloadSystemFonts() {
7274
FlutterDesktopEngineReloadSystemFonts(engine_);

shell/platform/windows/client_wrapper/flutter_view_controller.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ FlutterViewController::~FlutterViewController() {
2929
}
3030
}
3131

32+
#ifndef WINUWP
3233
std::optional<LRESULT> FlutterViewController::HandleTopLevelWindowProc(
3334
HWND hwnd,
3435
UINT message,
@@ -39,5 +40,6 @@ std::optional<LRESULT> FlutterViewController::HandleTopLevelWindowProc(
3940
controller_, hwnd, message, wparam, lparam, &result);
4041
return handled ? result : std::optional<LRESULT>(std::nullopt);
4142
}
43+
#endif
4244

4345
} // namespace flutter

shell/platform/windows/client_wrapper/include/flutter/flutter_view_controller.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class FlutterViewController {
4646
// Returns the view managed by this controller.
4747
FlutterView* view() { return view_.get(); }
4848

49+
#ifndef WINUWP
4950
// Allows the Flutter engine and any interested plugins an opportunity to
5051
// handle the given message.
5152
//
@@ -55,6 +56,7 @@ class FlutterViewController {
5556
UINT message,
5657
WPARAM wparam,
5758
LPARAM lparam);
59+
#endif
5860

5961
private:
6062
// Handle for interacting with the C API's view controller, if any.

shell/platform/windows/flutter_project_bundle.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <filesystem>
88
#include <iostream>
99

10-
#include "flutter/shell/platform/common/cpp/engine_switches.h"
10+
#include "flutter/shell/platform/common/cpp/engine_switches.h" // nogncheck
1111
#include "flutter/shell/platform/common/cpp/path_utils.h"
1212

1313
namespace flutter {

0 commit comments

Comments
 (0)