Skip to content

The first point in StylusPlugin is wrong when use the high DPI #6415

Closed

Description

@lindexi
  • .NET Core Version: (e.g. 3.0 Preview1, or daily build number, use dotnet --info)
  • Windows version: (winver)
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes/No
  • Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? If yes, please file the issue via the instructions here.
  • Security issues and bugs should be reported privately, learn more via our responsible disclosure guidelines.

Problem description:

After #2891 , we call calculate the point with stylusDevice.CriticalActiveSource. But the stylusDevice.CriticalActiveSource must be null when first touch down, because the wpf do not touch any element and do not get the AcitveSource before first touch down.

Actual behavior:

All of the StylusPlugin will reviece the wrong coordinate point.

Expected behavior:

These points can be calculated correctly.

Minimal repro:

Before you try repro this issues, please make sure you own a touch screen.

Preparation:

  1. Set the touch screen DPI to 150% (Not 100% is enough)

Step:

  1. Create an empty WPF project.
  2. Add the InkCanvas control to WPF project.
  3. Run the project in the device with the touch screen and then try write an ink.

Actual behavior: you will find the first point in ink will skew, just as the image shows.

The other repro step: Create an empty WPF project and add the StylusPlugin and then output the point received.

cc @rladuca @singhashish-wpf

Activity

  1. lindexi commented on Apr 13, 2022

    @lindexi
    MemberAuthor

    And I think the StylusLogic.GetAndCacheTransformToDeviceMatrix should return the first Matrix when the source is null.

    protected Matrix GetAndCacheTransformToDeviceMatrix(PresentationSource source)
    {
    var hwndSource = source as HwndSource;
    Matrix toDevice = Matrix.Identity;
    if (hwndSource?.CompositionTarget != null)
    {
    // If we have not yet seen this DPI, store the matrix for it.
    if (!_transformToDeviceMatrices.ContainsKey(hwndSource.CompositionTarget.CurrentDpiScale))
    {
    _transformToDeviceMatrices[hwndSource.CompositionTarget.CurrentDpiScale] = hwndSource.CompositionTarget.TransformToDevice;
    Debug.Assert(_transformToDeviceMatrices[hwndSource.CompositionTarget.CurrentDpiScale].HasInverse);
    }
    toDevice = _transformToDeviceMatrices[hwndSource.CompositionTarget.CurrentDpiScale];
    }
    return toDevice;
    }

  2. added
    Bug
    and removed on Apr 14, 2022
  3. lindexi commented on Apr 14, 2022

    @lindexi
    MemberAuthor

    When the wpf will set the stylusDevice.CriticalActiveSource ? The WispLogic.PreNotifyInput will call the stylusDevice.UpdateState method to calculate the ActiveSource in the Main UI Thread.

    But the StylusPlugin is running in the Stylus Input thread and fast than the UI thread.

  4. changed the title [-]The first point in StylusPlugin is wrong when use the hight DPI[/-] [+]The first point in StylusPlugin is wrong when use the high DPI[/+] on Apr 14, 2022
  5. lindexi commented on Apr 25, 2022

    @lindexi
    MemberAuthor

    I tested the my app for a week. This issue has been fixed and no new issues have been introduced.

  6. added this to the Future milestone on Sep 15, 2023
  7. lindexi commented on Nov 13, 2023

    @lindexi
    MemberAuthor

    @karelz Can I ask any plan about this issues? It will affect all touch applications.

    I have cherry-picked my two PRs, #6428 and #6829, to build my private version of WPF. My application, which utilizes this private WPF version, has been running for almost two years now. Moreover, it has been performing well on millions of touch devices. This stands as a testament to the reliability of my PRs.

  8. singhashish-wpf commented on Nov 14, 2023

    @singhashish-wpf
    Contributor

    @lindexi Thanks a lot for your contributions. These PRs are currently not prioritized as the touch area isn't prioritized as of now from the team. We can prioritize it if the area receives more hits in terms of issues or more people running into this. Thanks again for the reliability data, I will try to get these 2 PRs in the next community test pass.

  9. lindexi commented on Nov 14, 2023

    @lindexi
    MemberAuthor
  10. ghost removed this from the Future milestone on Dec 11, 2023
  11. locked and limited conversation to collaborators on Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🚧 work in progressBug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions