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

Commit 623d9ce

Browse files
authored
Windows: linker compatibility with AppContainer for winuwp target (#24318)
* Update Windows linker settings to be compatible with AppContainer when target==winuwp
1 parent 6b33d4e commit 623d9ce

File tree

6 files changed

+47
-1
lines changed

6 files changed

+47
-1
lines changed

shell/platform/embedder/BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ if (enable_unittests) {
245245
sources = [ "tests/embedder_unittests_proctable.cc" ]
246246

247247
defines = [ "FLUTTER_ENGINE_NO_PROTOTYPES" ]
248+
if (is_win) {
249+
libs = [ "psapi.lib" ]
250+
}
248251

249252
deps = [
250253
":embedder",

shell/platform/windows/BUILD.gn

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ executable("flutter_windows_unittests") {
170170
testonly = true
171171

172172
if (target_os == "winuwp") {
173-
libs = [ "windowsapp.lib" ]
173+
libs = [
174+
"windowsapp.lib",
175+
"user32.lib",
176+
]
174177
}
175178

176179
# Common Windows test sources.

shell/platform/windows/key_event_handler.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ KeyEventHandler::KeyEventHandler(flutter::BinaryMessenger* messenger,
122122
kChannelName,
123123
&flutter::JsonMessageCodec::GetInstance())),
124124
send_input_(send_input) {
125+
// As described in the header, UWP doesn't support the SendInput API hence we
126+
// only need to assert that the delegate is null in the non-UWP case since it is
127+
// expected to be null in the UWP case.
128+
#ifndef WINUWP
125129
assert(send_input != nullptr);
130+
#endif
126131
}
127132

128133
KeyEventHandler::~KeyEventHandler() = default;
@@ -190,6 +195,15 @@ void KeyEventHandler::HandleResponse(bool handled,
190195
std::cerr << "Unable to find event " << id << " in pending events queue.";
191196
return;
192197
}
198+
199+
// As described in the header, the user32 SendInput function is not supported in
200+
// UWP appcontainer and there is no WinRT equivalent hence we pass null for
201+
// SendInputDelegate param. Since this handler is one of last resort, it is
202+
// only applicable for platformview scenarios where the host view can handle
203+
// input events in the event the Flutter view does not choose to handle them.
204+
// Since platformview is currently not support for desktop, there is no
205+
// functional gap caused by this currently.
206+
#ifndef WINUWP
193207
INPUT input_event;
194208
input_event.type = INPUT_KEYBOARD;
195209
input_event.ki = *key_event;
@@ -199,6 +213,7 @@ void KeyEventHandler::HandleResponse(bool handled,
199213
"with scancode "
200214
<< scancode << " (character " << character << ")" << std::endl;
201215
}
216+
#endif
202217
}
203218
}
204219

@@ -225,6 +240,10 @@ bool KeyEventHandler::KeyboardHook(FlutterWindowsView* view,
225240
event.AddMember(kKeyMapKey, kWindowsKeyMap, allocator);
226241
#ifndef WINUWP
227242
event.AddMember(kModifiersKey, GetModsForKeyState(), allocator);
243+
#else
244+
// TODO: Implement modifiers in UWP codepath
245+
// TODO: https://github.com/flutter/flutter/issues/70202
246+
event.AddMember(kModifiersKey, 0, allocator);
228247
#endif
229248

230249
switch (action) {

shell/platform/windows/key_event_handler.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,19 @@ class KeyEventHandler : public KeyboardHookHandler {
2727
using SendInputDelegate =
2828
std::function<UINT(UINT cInputs, LPINPUT pInputs, int cbSize)>;
2929

30+
// the user32 SendInput function is not supported in UWP appcontainer and there
31+
// is no WinRT equivalent hence we pass null for SendInputDelegate param. Since
32+
// this handler is one of last resort, it is only applicable for platformview
33+
// scenarios where the host view can handle input events in the event the
34+
// Flutter view does not choose to handle them. Since platformview is currently
35+
// not support for desktop, there is no functional gap caused by this currently.
36+
#ifdef WINUWP
37+
explicit KeyEventHandler(flutter::BinaryMessenger* messenger,
38+
SendInputDelegate delegate = nullptr);
39+
#else
3040
explicit KeyEventHandler(flutter::BinaryMessenger* messenger,
3141
SendInputDelegate delegate = SendInput);
42+
#endif
3243

3344
virtual ~KeyEventHandler();
3445

shell/testing/BUILD.gn

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ executable("testing") {
1313
]
1414

1515
sources = [ "tester_main.cc" ]
16+
if (is_win) {
17+
libs = [
18+
"psapi.lib",
19+
"user32.lib",
20+
"FontSub.lib",
21+
"shlwapi.lib",
22+
]
23+
}
1624

1725
deps = [
1826
"//flutter/assets",

tools/gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ def to_gn_args(args):
105105
gn_args['skia_use_fontconfig'] = args.enable_fontconfig
106106
gn_args['flutter_use_fontconfig'] = args.enable_fontconfig
107107
gn_args['flutter_enable_skshaper'] = args.enable_skshaper
108+
if args.target_os == 'winuwp':
109+
gn_args['skia_enable_winuwp'] = True
108110
if args.enable_skshaper:
109111
gn_args['skia_use_icu'] = True
110112
gn_args['skia_enable_icu_ubrk_safeclone'] = True

0 commit comments

Comments
 (0)