diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index d2355b90c6a72..6216b49e29152 100755 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -1713,6 +1713,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 bcd3ce1e0a90e..845b629242297 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; - (void)applicationWillTerminate:(NSNotification*)notification; @@ -1019,7 +1019,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 8f8990ff96e8e..88fb14ba013b2 100644 --- a/shell/platform/fuchsia/flutter/platform_view.cc +++ b/shell/platform/fuchsia/flutter/platform_view.cc @@ -378,6 +378,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 b23efacefa87b..4c100dbb94865 100644 --- a/shell/platform/windows/BUILD.gn +++ b/shell/platform/windows/BUILD.gn @@ -350,6 +350,8 @@ source_set("uwptool_utils") { "uwptool_utils.h", ] + defines = [ "_SILENCE_CLANG_COROUTINE_MESSAGE" ] + deps = [ ":string_conversion" ] defines = [ "_SILENCE_CLANG_COROUTINE_MESSAGE" ] @@ -368,6 +370,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 4c3d0a398b259..d9dc70c0f03c4 100644 --- a/shell/platform/windows/flutter_window_win32.cc +++ b/shell/platform/windows/flutter_window_win32.cc @@ -263,4 +263,11 @@ gfx::NativeViewAccessible FlutterWindowWin32::GetNativeViewAccessible() { return binding_handler_delegate_->GetNativeViewAccessible(); } +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 584daa4a932dc..ce18ac4a43af4 100644 --- a/shell/platform/windows/flutter_window_win32.h +++ b/shell/platform/windows/flutter_window_win32.h @@ -133,6 +133,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 7274e1af1d4c9..ce85a92e6e955 100644 --- a/shell/platform/windows/flutter_window_winuwp.cc +++ b/shell/platform/windows/flutter_window_winuwp.cc @@ -392,4 +392,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 065841fc2a972..ce7589d431156 100644 --- a/shell/platform/windows/flutter_window_winuwp.h +++ b/shell/platform/windows/flutter_window_winuwp.h @@ -67,6 +67,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 c30d17ae6cafa..3b6295b65edde 100644 --- a/shell/platform/windows/flutter_windows_view.cc +++ b/shell/platform/windows/flutter_windows_view.cc @@ -205,7 +205,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); } @@ -214,13 +214,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); } @@ -641,11 +641,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 480ff1327876b..43c5a2c14fd9d 100644 --- a/shell/platform/windows/flutter_windows_view.h +++ b/shell/platform/windows/flutter_windows_view.h @@ -335,9 +335,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