Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions shell/platform/embedder/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,9 @@ if (enable_unittests) {
sources = [ "tests/embedder_unittests_proctable.cc" ]

defines = [ "FLUTTER_ENGINE_NO_PROTOTYPES" ]
if (is_win) {
libs = [ "psapi.lib" ]
}

deps = [
":embedder",
Expand Down
5 changes: 4 additions & 1 deletion shell/platform/windows/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ executable("flutter_windows_unittests") {
testonly = true

if (target_os == "winuwp") {
libs = [ "windowsapp.lib" ]
libs = [
"windowsapp.lib",
"user32.lib",
]
}

# Common Windows test sources.
Expand Down
19 changes: 19 additions & 0 deletions shell/platform/windows/key_event_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ KeyEventHandler::KeyEventHandler(flutter::BinaryMessenger* messenger,
kChannelName,
&flutter::JsonMessageCodec::GetInstance())),
send_input_(send_input) {
// As described in the header, UWP doesn't support the SendInput API hence we
// only need to assert that the delegate is null in the non-UWP case since it is
// expected to be null in the UWP case.
#ifndef WINUWP
assert(send_input != nullptr);
#endif
}

KeyEventHandler::~KeyEventHandler() = default;
Expand Down Expand Up @@ -190,6 +195,15 @@ void KeyEventHandler::HandleResponse(bool handled,
std::cerr << "Unable to find event " << id << " in pending events queue.";
return;
}

// As described in the header, the user32 SendInput function is not supported in
// UWP appcontainer and there is no WinRT equivalent hence we pass null for
// SendInputDelegate param. Since this handler is one of last resort, it is
// only applicable for platformview scenarios where the host view can handle
// input events in the event the Flutter view does not choose to handle them.
// Since platformview is currently not support for desktop, there is no
// functional gap caused by this currently.
#ifndef WINUWP
INPUT input_event;
input_event.type = INPUT_KEYBOARD;
input_event.ki = *key_event;
Expand All @@ -199,6 +213,7 @@ void KeyEventHandler::HandleResponse(bool handled,
"with scancode "
<< scancode << " (character " << character << ")" << std::endl;
}
#endif
}
}

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

switch (action) {
Expand Down
11 changes: 11 additions & 0 deletions shell/platform/windows/key_event_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,19 @@ class KeyEventHandler : public KeyboardHookHandler {
using SendInputDelegate =
std::function<UINT(UINT cInputs, LPINPUT pInputs, int cbSize)>;

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

virtual ~KeyEventHandler();

Expand Down
8 changes: 8 additions & 0 deletions shell/testing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ executable("testing") {
]

sources = [ "tester_main.cc" ]
if (is_win) {
libs = [
"psapi.lib",
"user32.lib",
"FontSub.lib",
"shlwapi.lib",
]
}

deps = [
"//flutter/assets",
Expand Down
2 changes: 2 additions & 0 deletions tools/gn
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ def to_gn_args(args):
gn_args['skia_use_fontconfig'] = args.enable_fontconfig
gn_args['flutter_use_fontconfig'] = args.enable_fontconfig
gn_args['flutter_enable_skshaper'] = args.enable_skshaper
if args.target_os == 'winuwp':
gn_args['skia_enable_winuwp'] = True
if args.enable_skshaper:
gn_args['skia_use_icu'] = True
gn_args['skia_enable_icu_ubrk_safeclone'] = True
Expand Down