Skip to content

Commit

Permalink
Use UIView.Window instead of the global window
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow committed Jul 18, 2024
1 parent bb2819e commit 660752e
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,11 @@ static void ProcessRecognizerHandlerTap(
if (weakRecognizer.Target is IPinchGestureController pinchGestureRecognizer &&
weakEventTracker.Target is GesturePlatformManager eventTracker &&
eventTracker._handler?.VirtualView is View view &&
UIApplication.SharedApplication.GetKeyWindow() is UIWindow window)
eventTracker.PlatformView is {} platformView)
{
var oldScale = eventTracker._previousScale;
var originPoint = r.LocationInView(null);
originPoint = window.ConvertPointToView(originPoint, eventTracker.PlatformView);
originPoint = platformView.Window.ConvertPointToView(originPoint, platformView);

var scaledPoint = new Point(originPoint.X / view.Width, originPoint.Y / view.Height);

Expand Down Expand Up @@ -412,8 +412,7 @@ UISwipeGestureRecognizer CreateSwipeRecognizer(SwipeDirection direction, Action<
{
if (weakRecognizer.Target is PointerGestureRecognizer pointerGestureRecognizer &&
weakEventTracker.Target is GesturePlatformManager eventTracker &&
eventTracker._handler?.VirtualView is View view &&
eventTracker._handler?.MauiContext?.GetPlatformWindow() is UIWindow window)
eventTracker._handler?.VirtualView is View view)
{
var originPoint = pointerGesture.LocationInView(eventTracker?.PlatformView);
var platformPointerArgs = new PlatformPointerEventArgs(pointerGesture.View, pointerGesture);
Expand Down

0 comments on commit 660752e

Please sign in to comment.