Skip to content

Commit

Permalink
Attempt flutter#1 to fix CI failures
Browse files Browse the repository at this point in the history
  • Loading branch information
moffatman committed Nov 30, 2021
1 parent f107af5 commit 6e49bad
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 22 deletions.
3 changes: 3 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/web_ui/lib/src/engine/pointer_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<flutter::PointerDataPacket>()];
Expand Down
5 changes: 5 additions & 0 deletions shell/platform/fuchsia/flutter/platform_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<flutter::PointerDataPacket>(1);
Expand Down
4 changes: 4 additions & 0 deletions shell/platform/windows/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ source_set("uwptool_utils") {
"uwptool_utils.h",
]

defines = [ "_SILENCE_CLANG_COROUTINE_MESSAGE" ]

deps = [ ":string_conversion" ]

defines = [ "_SILENCE_CLANG_COROUTINE_MESSAGE" ]
Expand All @@ -368,6 +370,8 @@ executable("uwptool") {
]
}

defines = [ "_SILENCE_CLANG_COROUTINE_MESSAGE" ]

sources = [ "uwptool_main.cc" ]
deps = [
":string_conversion",
Expand Down
6 changes: 3 additions & 3 deletions shell/platform/windows/direct_manipulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions shell/platform/windows/direct_manipulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "flutter/fml/memory/ref_counted.h"

#include <winrt/base.h>
#include <wrl/client.h>
#include "directmanipulation.h"

namespace flutter {
Expand All @@ -32,9 +32,9 @@ class DirectManipulationOwner {
private:
WindowWin32* window_;
DWORD viewportHandlerCookie_;
winrt::com_ptr<IDirectManipulationManager> manager_;
winrt::com_ptr<IDirectManipulationUpdateManager> updateManager_;
winrt::com_ptr<IDirectManipulationViewport> viewport_;
Microsoft::WRL::ComPtr<IDirectManipulationManager> manager_;
Microsoft::WRL::ComPtr<IDirectManipulationUpdateManager> updateManager_;
Microsoft::WRL::ComPtr<IDirectManipulationViewport> viewport_;
fml::RefPtr<DirectManipulationEventHandler> handler_;
};

Expand Down
7 changes: 7 additions & 0 deletions shell/platform/windows/flutter_window_win32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions shell/platform/windows/flutter_window_win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions shell/platform/windows/flutter_window_winuwp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<size_t>(point.X - bounds.X), static_cast<size_t>(point.Y - bounds.Y)};
}

} // namespace flutter
2 changes: 2 additions & 0 deletions shell/platform/windows/flutter_window_winuwp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 3 additions & 10 deletions shell/platform/windows/flutter_windows_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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
3 changes: 0 additions & 3 deletions shell/platform/windows/flutter_windows_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions shell/platform/windows/window_binding_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6e49bad

Please sign in to comment.