diff --git a/shell/platform/embedder/BUILD.gn b/shell/platform/embedder/BUILD.gn index 7cbba62bbc5c5..f545de9691ef8 100644 --- a/shell/platform/embedder/BUILD.gn +++ b/shell/platform/embedder/BUILD.gn @@ -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", diff --git a/shell/platform/windows/BUILD.gn b/shell/platform/windows/BUILD.gn index 8881c7d13b170..0468c04fc2bdc 100644 --- a/shell/platform/windows/BUILD.gn +++ b/shell/platform/windows/BUILD.gn @@ -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. diff --git a/shell/platform/windows/key_event_handler.cc b/shell/platform/windows/key_event_handler.cc index 3d6b488bc4b82..de607b917d21e 100644 --- a/shell/platform/windows/key_event_handler.cc +++ b/shell/platform/windows/key_event_handler.cc @@ -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; @@ -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; @@ -199,6 +213,7 @@ void KeyEventHandler::HandleResponse(bool handled, "with scancode " << scancode << " (character " << character << ")" << std::endl; } +#endif } } @@ -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) { diff --git a/shell/platform/windows/key_event_handler.h b/shell/platform/windows/key_event_handler.h index 06ae709a91231..7c4df0f038fc6 100644 --- a/shell/platform/windows/key_event_handler.h +++ b/shell/platform/windows/key_event_handler.h @@ -27,8 +27,19 @@ class KeyEventHandler : public KeyboardHookHandler { using SendInputDelegate = std::function; +// 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(); diff --git a/shell/testing/BUILD.gn b/shell/testing/BUILD.gn index 459e7e9886db6..f82f481326fc7 100644 --- a/shell/testing/BUILD.gn +++ b/shell/testing/BUILD.gn @@ -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", diff --git a/tools/gn b/tools/gn index e6f8c218d779f..ea19ec069cc88 100755 --- a/tools/gn +++ b/tools/gn @@ -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