Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit f439be2

Browse files
committed
Refactor device ID
1 parent 8150b5a commit f439be2

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

shell/platform/windows/direct_manipulation.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525
namespace flutter {
2626

27+
int32_t DirectManipulationEventHandler::GetDeviceId() {
28+
return (int32_t) reinterpret_cast<int64_t>(this);
29+
}
30+
2731
STDMETHODIMP DirectManipulationEventHandler::QueryInterface(REFIID iid,
2832
void** ppv) {
2933
if ((iid == IID_IUnknown) ||
@@ -50,8 +54,7 @@ HRESULT DirectManipulationEventHandler::OnViewportStatusChanged(
5054
if (!during_synthesized_reset_) {
5155
// Not a false event.
5256
if (owner_->binding_handler_delegate) {
53-
owner_->binding_handler_delegate->OnPointerPanZoomStart(
54-
(int32_t) reinterpret_cast<int64_t>(this));
57+
owner_->binding_handler_delegate->OnPointerPanZoomStart(GetDeviceId());
5558
}
5659
}
5760
}
@@ -60,12 +63,11 @@ HRESULT DirectManipulationEventHandler::OnViewportStatusChanged(
6063
last_pan_delta_x_ = 0.0;
6164
last_pan_delta_y_ = 0.0;
6265
if (owner_->binding_handler_delegate) {
63-
owner_->binding_handler_delegate->OnPointerPanZoomEnd(
64-
(int32_t) reinterpret_cast<int64_t>(this));
66+
owner_->binding_handler_delegate->OnPointerPanZoomEnd(GetDeviceId());
6567
}
6668
} else if (previous == DIRECTMANIPULATION_INERTIA) {
6769
if (owner_->binding_handler_delegate && std::max(std::abs(last_pan_delta_x_), std::abs(last_pan_delta_y_)) > 0.01) {
68-
owner_->binding_handler_delegate->OnScrollInertiaCancel((int32_t) reinterpret_cast<int64_t>(this));
70+
owner_->binding_handler_delegate->OnScrollInertiaCancel(GetDeviceId());
6971
}
7072
// Need to reset the content transform to its original position
7173
// so that we are ready for the next gesture.
@@ -123,7 +125,7 @@ HRESULT DirectManipulationEventHandler::OnContentUpdated(
123125
last_pan_y_ = pan_y;
124126
if (owner_->binding_handler_delegate && !during_inertia_) {
125127
owner_->binding_handler_delegate->OnPointerPanZoomUpdate(
126-
(int32_t) reinterpret_cast<int64_t>(this), pan_x, pan_y, scale, 0);
128+
GetDeviceId(), pan_x, pan_y, scale, 0);
127129
}
128130
}
129131
return S_OK;

shell/platform/windows/direct_manipulation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ class DirectManipulationEventHandler
106106
DIRECTMANIPULATION_INTERACTION_TYPE interaction) override;
107107

108108
private:
109+
// Unique identifier to associate with all gesture event updates.
110+
int32_t GetDeviceId();
109111
// Parent object, used to store the target for gesture event updates.
110112
DirectManipulationOwner* owner_;
111113
// We need to reset some parts of DirectManipulation after each gesture

0 commit comments

Comments
 (0)