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

Commit a7fed63

Browse files
committed
Keep pan/zoom origin constant for gesture
1 parent ebf828b commit a7fed63

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

shell/platform/windows/flutter_windows_view.cc

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,11 @@ void FlutterWindowsView::OnPointerPanZoomUpdate(int32_t device_id,
213213
double pan_y,
214214
double scale,
215215
double rotation) {
216-
PointerLocation point = binding_handler_->GetPrimaryPointerLocation();
217-
SendPointerPanZoomUpdate(device_id, point.x, point.y, pan_x, pan_y, scale,
218-
rotation);
216+
SendPointerPanZoomUpdate(device_id, pan_x, pan_y, scale, rotation);
219217
}
220218

221219
void FlutterWindowsView::OnPointerPanZoomEnd(int32_t device_id) {
222-
PointerLocation point = binding_handler_->GetPrimaryPointerLocation();
223-
SendPointerPanZoomEnd(device_id, point.x, point.y);
220+
SendPointerPanZoomEnd(device_id);
224221
}
225222

226223
void FlutterWindowsView::OnText(const std::u16string& text) {
@@ -396,6 +393,8 @@ void FlutterWindowsView::SendPointerPanZoomStart(int32_t device_id,
396393
double y) {
397394
auto state =
398395
GetOrCreatePointerState(kFlutterPointerDeviceKindTouch, device_id);
396+
state->pan_zoom_start_x = x;
397+
state->pan_zoom_start_y = y;
399398
FlutterPointerEvent event = {};
400399
event.x = x;
401400
event.y = y;
@@ -404,17 +403,15 @@ void FlutterWindowsView::SendPointerPanZoomStart(int32_t device_id,
404403
}
405404

406405
void FlutterWindowsView::SendPointerPanZoomUpdate(int32_t device_id,
407-
double x,
408-
double y,
409406
double pan_x,
410407
double pan_y,
411408
double scale,
412409
double rotation) {
413410
auto state =
414411
GetOrCreatePointerState(kFlutterPointerDeviceKindTouch, device_id);
415412
FlutterPointerEvent event = {};
416-
event.x = x;
417-
event.y = y;
413+
event.x = state->pan_zoom_start_x;
414+
event.y = state->pan_zoom_start_y;
418415
event.pan_x = pan_x;
419416
event.pan_y = pan_y;
420417
event.scale = scale;
@@ -423,14 +420,12 @@ void FlutterWindowsView::SendPointerPanZoomUpdate(int32_t device_id,
423420
SendPointerEventWithData(event, state);
424421
}
425422

426-
void FlutterWindowsView::SendPointerPanZoomEnd(int32_t device_id,
427-
double x,
428-
double y) {
423+
void FlutterWindowsView::SendPointerPanZoomEnd(int32_t device_id) {
429424
auto state =
430425
GetOrCreatePointerState(kFlutterPointerDeviceKindTouch, device_id);
431426
FlutterPointerEvent event = {};
432-
event.x = x;
433-
event.y = y;
427+
event.x = state->pan_zoom_start_x;
428+
event.y = state->pan_zoom_start_y;
434429
event.phase = FlutterPointerPhase::kPanZoomEnd;
435430
SendPointerEventWithData(event, state);
436431
}

shell/platform/windows/flutter_windows_view.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate,
214214

215215
// The currently pressed buttons, as represented in FlutterPointerEvent.
216216
uint64_t buttons = 0;
217+
218+
// The x position where the last pan/zoom started
219+
double pan_zoom_start_x = 0;
220+
221+
// The y position where the last pan/zoom started
222+
double pan_zoom_start_y = 0;
217223
};
218224

219225
// States a resize event can be in.
@@ -257,14 +263,12 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate,
257263
void SendPointerPanZoomStart(int32_t device_id, double x, double y);
258264

259265
void SendPointerPanZoomUpdate(int32_t device_id,
260-
double x,
261-
double y,
262266
double pan_x,
263267
double pan_y,
264268
double scale,
265269
double rotation);
266270

267-
void SendPointerPanZoomEnd(int32_t device_id, double x, double y);
271+
void SendPointerPanZoomEnd(int32_t device_id);
268272

269273
// Reports a keyboard character to Flutter engine.
270274
void SendText(const std::u16string&);

0 commit comments

Comments
 (0)