שאלה BUG of TouchDevice or InputManager of WPF

  • יום שלישי 24 יולי 2012 11:19
     
     

    I write a "TouchDeviceAutoCheck" to test whether the TouchDevice can be used without some "physical" touch screens.

    the source code can be found:

    https://docs.google.com/open?id=0B3LUAlOctdpzZWJ4N0k5c0tRMkE

    But the test of TouchDevice always failed:

    because the "TouchDevice.Target" is set to "null" sometimes;

    And i found that:

    there is a "HitTestInvalidatedAsyncCallback" in InputManager and it's invoked every 125 ms in a timer.

    while the "TouchDevice.ReportDown/Move/Up" are invoked in another thread.

    They are different in "CriticalHitTest":

    InputManager will cause "GlobalHitTest" to work while TouchDevice.ReportDown/Move/Up will cause "LocalHitTest" to work.

    In the "GlobalHitTest", it doing things as below:

                        // Find the HWND under the point.
                        hwndHit = UnsafeNativeMethods.WindowFromPoint((int)ptScreen.X, (int)ptScreen.Y);

                        // Make sure the window is enabled!
                        if (!SafeNativeMethods.IsWindowEnabled(new HandleRef(null, hwndHit)))
                        {
                            hwndHit = IntPtr.Zero;
                        }

    while the "LocalHitTest" will hittest the VisualTree of UIElement,

    they are DIFFERENT:

    1. i found the size of maxized WPF UIElement can larger than the resolution while the local window can NOT; for example, if the resolultion is "1280*800", the WPF UIElement can be "-3,-3" - "1283, 803", while every local maxized window can only be "0,0"-"1280,800";

    so when a touchpoint ("0, 800") "ReportDown" and later WindowFromPoint in "HitTestInvalidatedAsyncCallback", the WindowFromPoint((0,800)) will return NULL;

    2. if the IsWindowEnabled  return true, the BUG come out too.

    I want to know,

    1. can the "TouchDevice" be used without "Physical TouchScreens" ? and how?

    2. and whether the TouchEvents of WPF can work well for the "GlobalHitTest" being different from "LocalHitTest" in multi-thread?

כל התגובות

  • יום חמישי 26 יולי 2012 05:22
    מנחה דיון
     
     

    Hi zdragon2002,

    This is a quick note to let you know that we are performing research on this issue.

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • יום חמישי 26 יולי 2012 12:14
     
     
  • יום שישי 27 יולי 2012 05:23
     
     

    Hi zdragon2002,

    TouchDevice  can not be used without "Physical TouchScreens", you can fake manipulation (or touch) events using a mouse / keyboard by creating a Custom Touch Device though extending the Touch Device class with appropriate mouse inputs.

    As for the second question ,could you please share you whole sample project(zip all) for debugging?

    Best Regards

    Jenny

  • יום שני 30 יולי 2012 07:16
     
     

    Hi Jenny,

    thanks for the reply.

    1. the whole sample project is shared through google doc:

    https://docs.google.com/open?id=0B3LUAlOctdpzZWJ4N0k5c0tRMk

    you can download it by steps below:

    open the link -> click the "File" left upper under "Test.zip" -> select "Download";

    2. can i fake a "manipulation (or touch)" by another thread (Physical Touchscreen is unnecessary),

    for example, i create a simple timer to dispatch and report the

    touch events, you can see the source code in the link up.

    3. i also found another bug:

    some touch up events is not received/handled by the UIElement, while the "InputManger" exactly received it and call the "PostProcessInput", and the "UIElement" (here is a canvas) is fullscreen and there is no mouse action there;

    and i'm sure the "_isSynchronizedInput" of InputManager is "false",

    so i'm not sure what happened, i'm still try to found the actual reason.

  • יום שני 30 יולי 2012 09:26
     
     

    Hi zdragon2002,

    I cannot find "Download" tab so I cannot get them downloaded, If you want to email it directly to me you can email me at jenli@microsoft.com.  Be sure to delete the bin and obj directories and the code may zip up very compactly to attach to email...

  • יום שלישי 31 יולי 2012 03:56
     
     

    Hi Jenny,

    I've sent the two source code to your email;

    source code "Test.zip" for the bug "LocalHitTest with GlobalHitTeset";

    source code "TouchDeviceAutoCheck(UIElement no touch).zip" for the bug "UIElement not receive touch events";

    in the "TouchDeviceAutoCheck(UIElement no touch).zip", i removed some code may leads to the first bug,

    and add some code to receive the "PostProcessInput" of InputManager;

    any questions, please don't hesitate to contact me.

    thanks in advance.

  • יום חמישי 02 אוגוסט 2012 05:59
     
     

    Not very clearly about your  "LocalHitTest with GlobalHitTeset" meaning....

    and as for TouchDeviceAutoCheck(UIElement no touch), it does not respond.

  • יום שני 06 אוגוסט 2012 06:36
     
     
    • Q1.  LocalHitTest with GlobalHitTest (see my first report, floor 1):

    I write a "TouchDeviceAutoCheck" to test whether the TouchDevice can be used without some "physical" touch screens.

    the source code can be found:

    https://docs.google.com/open?id=0B3LUAlOctdpzZWJ4N0k5c0tRMkE

    But the test of TouchDevice always failed:

    because the "TouchDevice.Target" is set to "null" sometimes;

    And i found that:

    there is a "HitTestInvalidatedAsyncCallback" in InputManager and it's invoked every 125 ms in a timer.

    while the "TouchDevice.ReportDown/Move/Up" are invoked in another thread.

    They are different in "CriticalHitTest":

    InputManager will cause "GlobalHitTest" to work while TouchDevice.ReportDown/Move/Up will cause "LocalHitTest" to work.

    In the "GlobalHitTest", it doing things as below:

                        // Find the HWND under the point.
                        hwndHit = UnsafeNativeMethods.WindowFromPoint((int)ptScreen.X, (int)ptScreen.Y);

                        // Make sure the window is enabled!
                        if (!SafeNativeMethods.IsWindowEnabled(new HandleRef(null, hwndHit)))
                        {
                            hwndHit = IntPtr.Zero;
                        }

    while the "LocalHitTest" will hittest the VisualTree of UIElement,

    they are DIFFERENT:

    1. i found the size of maxized WPF UIElement can larger than the resolution while the local window can NOT; for example, if the resolultion is "1280*800", the WPF UIElement can be "-3,-3" - "1283, 803", while every local maxized window can only be "0,0"-"1280,800";

    so when a touchpoint ("0, 800") "ReportDown" and later WindowFromPoint in "HitTestInvalidatedAsyncCallback", the WindowFromPoint((0,800)) will return NULL;

    2. if the IsWindowEnabled  return true, the BUG come out too.

    -----------------------------

    • Q2. TouchDeviceAutoCheck(UIElement no touch), it does not respond.

    sorry, i'm not quite clear about "not respond" here, did you mean the bug not reproduce?

    if it's possible, i can communicate with you in msn,

    i'll send you my msn account through the email;

  • יום שני 06 אוגוסט 2012 07:55
     
     

    If you can't get answer here, you can open a case to Microsoft? With a support case, a support engineer will request to check Inspect source code, and assist you to find the solution. I believe you can do what Inspect has implemented after having someone check the source code.

    Please visit the below link to see the various paid support options that are available to better meet your needs.

    http://support.microsoft.com/default.aspx?id=fh%3ben-us%3bofferprophone


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Regards,
    Jacky Wu
    Microsoft Online Community Support