diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 97f2e2fa5c669..bb01ff4f56c14 100755 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -1692,6 +1692,9 @@ FILE: ../../../flutter/shell/platform/windows/client_wrapper/include/flutter/plu FILE: ../../../flutter/shell/platform/windows/client_wrapper/plugin_registrar_windows_unittests.cc FILE: ../../../flutter/shell/platform/windows/cursor_handler.cc FILE: ../../../flutter/shell/platform/windows/cursor_handler.h +FILE: ../../../flutter/shell/platform/windows/direct_manipulation.cc +FILE: ../../../flutter/shell/platform/windows/direct_manipulation.h +FILE: ../../../flutter/shell/platform/windows/direct_manipulation_unittests.cc FILE: ../../../flutter/shell/platform/windows/display_helper_winuwp.cc FILE: ../../../flutter/shell/platform/windows/display_helper_winuwp.h FILE: ../../../flutter/shell/platform/windows/dpi_utils_win32.cc diff --git a/lib/web_ui/lib/src/engine/pointer_converter.dart b/lib/web_ui/lib/src/engine/pointer_converter.dart index 5b944f0767652..598b446ceef6f 100644 --- a/lib/web_ui/lib/src/engine/pointer_converter.dart +++ b/lib/web_ui/lib/src/engine/pointer_converter.dart @@ -613,6 +613,11 @@ class PointerDataConverter { ); _pointers.remove(device); break; + case ui.PointerChange.flowStart: + case ui.PointerChange.flowUpdate: + case ui.PointerChange.flowEnd: + // Pointer flow events are not gemerated on web + break; } } else { switch (signalKind) { diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm index a06d19bbcfaf0..28ced0de43596 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm @@ -121,7 +121,7 @@ - (void)surfaceUpdated:(BOOL)appeared; - (void)performOrientationUpdate:(UIInterfaceOrientationMask)new_preferences; - (void)handlePressEvent:(FlutterUIPressProxy*)press nextAction:(void (^)())next API_AVAILABLE(ios(13.4)); -- (void)scrollEvent:(UIPanGestureRecognizer*)recognizer; +- (void)panEvent:(UIPanGestureRecognizer*)recognizer; - (void)updateViewportMetrics; - (void)onUserSettingsChanged:(NSNotification*)notification; @end @@ -922,7 +922,7 @@ - (void)testMouseSupport API_AVAILABLE(ios(13.4)) { id mockPanGestureRecognizer = OCMClassMock([UIPanGestureRecognizer class]); XCTAssertNotNil(mockPanGestureRecognizer); - [vc scrollEvent:mockPanGestureRecognizer]; + [vc panEvent:mockPanGestureRecognizer]; [[[self.mockEngine verify] ignoringNonObjectArgs] dispatchPointerDataPacket:std::make_unique()]; diff --git a/shell/platform/fuchsia/flutter/platform_view.cc b/shell/platform/fuchsia/flutter/platform_view.cc index 1871ecc284226..db1e34a080228 100644 --- a/shell/platform/fuchsia/flutter/platform_view.cc +++ b/shell/platform/fuchsia/flutter/platform_view.cc @@ -376,6 +376,11 @@ bool PlatformView::OnHandlePointerEvent( FML_DLOG(ERROR) << "Received hover event for down pointer."; } break; + case flutter::PointerData::Change::kFlowStart: + case flutter::PointerData::Change::kFlowUpdate: + case flutter::PointerData::Change::kFlowEnd: + FML_DLOG(ERROR) << "Unexpectedly received pointer flow event"; + break; } auto packet = std::make_unique(1); diff --git a/shell/platform/windows/BUILD.gn b/shell/platform/windows/BUILD.gn index 3d5bf7ffd5ef8..8fd0edcdcdce9 100644 --- a/shell/platform/windows/BUILD.gn +++ b/shell/platform/windows/BUILD.gn @@ -336,6 +336,8 @@ source_set("uwptool_utils") { "uwptool_utils.h", ] + defines = [ "_SILENCE_CLANG_COROUTINE_MESSAGE" ] + deps = [ ":string_conversion" ] defines = [ "_SILENCE_CLANG_COROUTINE_MESSAGE" ] @@ -354,6 +356,8 @@ executable("uwptool") { ] } + defines = [ "_SILENCE_CLANG_COROUTINE_MESSAGE" ] + sources = [ "uwptool_main.cc" ] deps = [ ":string_conversion", diff --git a/shell/platform/windows/direct_manipulation.cc b/shell/platform/windows/direct_manipulation.cc index 0d4e93a5dafe7..9e3b935839a23 100644 --- a/shell/platform/windows/direct_manipulation.cc +++ b/shell/platform/windows/direct_manipulation.cc @@ -119,7 +119,7 @@ DirectManipulationOwner::DirectManipulationOwner(WindowWin32* window) int DirectManipulationOwner::Init(unsigned int width, unsigned int height) { HRESULT hr = CoCreateInstance( CLSID_DirectManipulationManager, nullptr, CLSCTX_INPROC_SERVER, - IID_IDirectManipulationManager, manager_.put_void()); + IID_IDirectManipulationManager, &manager_); if (FAILED(hr)) { FML_LOG(ERROR) << "CoCreateInstance(CLSID_DirectManipulationManager) failed"; @@ -128,7 +128,7 @@ int DirectManipulationOwner::Init(unsigned int width, unsigned int height) { } hr = manager_->GetUpdateManager(IID_IDirectManipulationUpdateManager, - updateManager_.put_void()); + &updateManager_); if (FAILED(hr)) { FML_LOG(ERROR) << "GetUpdateManager failed"; manager_ = nullptr; @@ -138,7 +138,7 @@ int DirectManipulationOwner::Init(unsigned int width, unsigned int height) { hr = manager_->CreateViewport(nullptr, window_->GetWindowHandle(), IID_IDirectManipulationViewport, - viewport_.put_void()); + &viewport_); if (FAILED(hr)) { FML_LOG(ERROR) << "CreateViewport failed"; manager_ = nullptr; diff --git a/shell/platform/windows/direct_manipulation.h b/shell/platform/windows/direct_manipulation.h index 4bd58d1377a0a..1f68d0d088df6 100644 --- a/shell/platform/windows/direct_manipulation.h +++ b/shell/platform/windows/direct_manipulation.h @@ -7,7 +7,7 @@ #include "flutter/fml/memory/ref_counted.h" -#include +#include #include "directmanipulation.h" namespace flutter { @@ -32,9 +32,9 @@ class DirectManipulationOwner { private: WindowWin32* window_; DWORD viewportHandlerCookie_; - winrt::com_ptr manager_; - winrt::com_ptr updateManager_; - winrt::com_ptr viewport_; + Microsoft::WRL::ComPtr manager_; + Microsoft::WRL::ComPtr updateManager_; + Microsoft::WRL::ComPtr viewport_; fml::RefPtr handler_; }; diff --git a/shell/platform/windows/flutter_window_win32.cc b/shell/platform/windows/flutter_window_win32.cc index 2919c3af37c44..0c2406e10cd04 100644 --- a/shell/platform/windows/flutter_window_win32.cc +++ b/shell/platform/windows/flutter_window_win32.cc @@ -255,4 +255,11 @@ bool FlutterWindowWin32::OnBitmapSurfaceUpdated(const void* allocation, return ret != 0; } +PointerLocation FlutterWindowWin32::GetPrimaryPointerLocation() { + POINT point; + GetCursorPos(&point); + ScreenToClient(GetWindowHandle(), &point); + return {(size_t)point.x, (size_t)point.y}; +} + } // namespace flutter diff --git a/shell/platform/windows/flutter_window_win32.h b/shell/platform/windows/flutter_window_win32.h index f1f13f37d8e41..11a96750c738e 100644 --- a/shell/platform/windows/flutter_window_win32.h +++ b/shell/platform/windows/flutter_window_win32.h @@ -127,6 +127,8 @@ class FlutterWindowWin32 : public WindowWin32, public WindowBindingHandler { size_t row_bytes, size_t height) override; + PointerLocation GetPrimaryPointerLocation() override; + private: // A pointer to a FlutterWindowsView that can be used to update engine // windowing and input state. diff --git a/shell/platform/windows/flutter_window_winuwp.cc b/shell/platform/windows/flutter_window_winuwp.cc index d8f7b55fb67e0..9b0204da44f79 100644 --- a/shell/platform/windows/flutter_window_winuwp.cc +++ b/shell/platform/windows/flutter_window_winuwp.cc @@ -376,4 +376,10 @@ bool FlutterWindowWinUWP::OnBitmapSurfaceUpdated(const void* allocation, return false; } +PointerLocation FlutterWindowWinUWP::GetPrimaryPointerLocation() { + auto point = window_.PointerPosition(); + auto bounds = window_.Bounds(); + return {static_cast(point.X - bounds.X), static_cast(point.Y - bounds.Y)}; +} + } // namespace flutter diff --git a/shell/platform/windows/flutter_window_winuwp.h b/shell/platform/windows/flutter_window_winuwp.h index 39a3eaa29fd19..08fc627dca1b0 100644 --- a/shell/platform/windows/flutter_window_winuwp.h +++ b/shell/platform/windows/flutter_window_winuwp.h @@ -66,6 +66,8 @@ class FlutterWindowWinUWP : public WindowBindingHandler { size_t row_bytes, size_t height) override; + PointerLocation GetPrimaryPointerLocation() override; + private: // Undoes the scale transform applied by the Windows compositor in order to // render at native scale and produce smooth results on high DPI screens. diff --git a/shell/platform/windows/flutter_windows_view.cc b/shell/platform/windows/flutter_windows_view.cc index f4426fa3108aa..87e753cbd3756 100644 --- a/shell/platform/windows/flutter_windows_view.cc +++ b/shell/platform/windows/flutter_windows_view.cc @@ -204,7 +204,7 @@ void FlutterWindowsView::OnPointerLeave(FlutterPointerDeviceKind device_kind, } void FlutterWindowsView::OnPointerFlowStart(int32_t device_id) { - POINT point = GetCursorPosition(); + PointerLocation point = binding_handler_->GetPrimaryPointerLocation(); SendPointerFlowStart(device_id, point.x, point.y); } @@ -213,13 +213,13 @@ void FlutterWindowsView::OnPointerFlowUpdate(int32_t device_id, double pan_y, double scale, double angle) { - POINT point = GetCursorPosition(); + PointerLocation point = binding_handler_->GetPrimaryPointerLocation(); SendPointerFlowUpdate(device_id, point.x, point.y, pan_x, pan_y, scale, angle); } void FlutterWindowsView::OnPointerFlowEnd(int32_t device_id) { - POINT point = GetCursorPosition(); + PointerLocation point = binding_handler_->GetPrimaryPointerLocation(); SendPointerFlowEnd(device_id, point.x, point.y); } @@ -632,11 +632,4 @@ FlutterWindowsEngine* FlutterWindowsView::GetEngine() { return engine_.get(); } -POINT FlutterWindowsView::GetCursorPosition() { - POINT point; - GetCursorPos(&point); - ScreenToClient(std::get<0>(*GetRenderTarget()), &point); - return point; -} - } // namespace flutter diff --git a/shell/platform/windows/flutter_windows_view.h b/shell/platform/windows/flutter_windows_view.h index 7bea3c2e5f6a9..95dec54ba4902 100644 --- a/shell/platform/windows/flutter_windows_view.h +++ b/shell/platform/windows/flutter_windows_view.h @@ -329,9 +329,6 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate, // Reports platform brightness change to Flutter engine. void SendPlatformBrightnessChanged(); - // Gets the current cursor position to set on trackpad gesture events - POINT GetCursorPosition(); - // Currently configured WindowsRenderTarget for this view used by // surface_manager for creation of render surfaces and bound to the physical // os window. diff --git a/shell/platform/windows/testing/mock_window_binding_handler.h b/shell/platform/windows/testing/mock_window_binding_handler.h index a5395c96cca02..a9eac85ba4320 100644 --- a/shell/platform/windows/testing/mock_window_binding_handler.h +++ b/shell/platform/windows/testing/mock_window_binding_handler.h @@ -35,6 +35,7 @@ class MockWindowBindingHandler : public WindowBindingHandler { MOCK_METHOD0(OnResetImeComposing, void()); MOCK_METHOD3(OnBitmapSurfaceUpdated, bool(const void* allocation, size_t row_bytes, size_t height)); + MOCK_METHOD0(GetPrimaryPointerLocation, PointerLocation()); }; } // namespace testing diff --git a/shell/platform/windows/window_binding_handler.h b/shell/platform/windows/window_binding_handler.h index 6f310217aa890..4ed1e54ad5d22 100644 --- a/shell/platform/windows/window_binding_handler.h +++ b/shell/platform/windows/window_binding_handler.h @@ -29,6 +29,12 @@ struct PhysicalWindowBounds { size_t height; }; +// Structure containing the position of a mouse pointer +struct PointerLocation { + size_t x; + size_t y; +}; + // Type representing an underlying platform window. #ifdef WINUWP using PlatformWindow = @@ -95,6 +101,9 @@ class WindowBindingHandler { // Invoked when the app ends IME composing, such when the active text input // client is cleared. virtual void OnResetImeComposing() = 0; + + // Returns the last known position of the primary pointer + virtual PointerLocation GetPrimaryPointerLocation() = 0; }; } // namespace flutter