Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

double Microsoft.UI.Input.PointerPoint.Position should be int #7323

Closed
1 of 2 tasks
Padanian opened this issue Jul 6, 2022 · 2 comments
Closed
1 of 2 tasks

double Microsoft.UI.Input.PointerPoint.Position should be int #7323

Padanian opened this issue Jul 6, 2022 · 2 comments
Labels

Comments

@Padanian
Copy link

Padanian commented Jul 6, 2022

Describe the bug

Consider the following

` 
        Microsoft.UI.Input.PointerPoint ptrPt;
        IntPtr hWnd;
        WindowId windowId;
        AppWindow appWindow;

        private void Grid_PointerMoved(object sender, PointerRoutedEventArgs e)
        {
             hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
             windowId = Microsoft.UI.Win32Interop.GetWindowIdFromWindow(hWnd);
             appWindow = Microsoft.UI.Windowing.AppWindow.GetFromWindowId(windowId);
             ptrPt = e.GetCurrentPoint(null);

             eDiff.X =  appWindow.Position.X + (int)ptrPt.Position.X;
             eDiff.Y =  appWindow.Position.Y + (int)ptrPt.Position.Y;

             // Set the new point
             appWindow.Move(eDiff);

        }

`

Is there any good reason why appWindow.Position.X is int while the pointer position is double?

Steps to reproduce the bug

See example above

Expected behavior

Pointer should be int.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.1.1

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 11 (21H2): Build 22000

Additional context

No response

@Padanian Padanian added the bug Something isn't working label Jul 6, 2022
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jul 6, 2022
@krschau krschau added question and removed bug Something isn't working labels Jul 7, 2022
@krschau
Copy link
Contributor

krschau commented Jul 7, 2022

@jlnordin, is this something you can speak to?

@jlnordin
Copy link

jlnordin commented Jul 7, 2022

There are a few reasons:

  • AppWindow uses integers to better integrate with Win32 HWND concepts. A Win32 window can only be positioned on integer boundaries, so we use Ints in that API.
  • Windows App SDK's PointerPoint (Microsoft.UI.Input.PointerPoint) is based on the Windows Platform SDK's PointerPoint (Windows.UI.Input.PointerPoint) and we wanted to make porting between these two easier.
  • PointerPoint can also be arbitrarily modified by scales, rotations, or other transformations depending on how it is used, such as when delivered in relation to a Xaml element with custom scaling. To support these scenarios we use doubles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants