Skip to content

Conversation

lindexi
Copy link
Member

@lindexi lindexi commented Sep 17, 2025

Description

The RegisterHwndForInput only be called by HwndStylusInputProvider..ctor. And the HwndStylusInputProvider..ctor will pass the HwndSource source to RegisterHwndForInput method. So that it unnecessary to use the PresentationSource in RegisterHwndForInput.

/////////////////////////////////////////////////////////////////////
internal HwndStylusInputProvider(HwndSource source)
{
InputManager inputManager = InputManager.Current;
_stylusLogic = StylusLogic.GetCurrentStylusLogicAs<WispLogic>();
IntPtr sourceHandle;
// Register ourselves as an input provider with the input manager.
_site = inputManager.RegisterInputProvider(this);
sourceHandle = source.Handle;
_stylusLogic.RegisterHwndForInput(inputManager, source);
_source = source;
// Enables multi-touch input
UnsafeNativeMethods.SetProp(new HandleRef(this, sourceHandle), "MicrosoftTabletPenServiceProperty", new HandleRef(null, new IntPtr(MultiTouchEnabledFlag)));
}

Customer Impact

None.

Regression

Testing

Only CI

Risk

Low. I do not change any behavior.

Microsoft Reviewers: Open in CodeFlow

@Copilot Copilot AI review requested due to automatic review settings September 17, 2025 09:59
@lindexi lindexi requested a review from a team as a code owner September 17, 2025 09:59
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes the RegisterHwndForInput method by removing unnecessary casting from PresentationSource to HwndSource, since the caller already has an HwndSource instance.

  • Removes unnecessary type casting in the RegisterHwndForInput method
  • Changes the parameter type from PresentationSource to HwndSource to match actual usage

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Sep 17, 2025
The RegisterHwndForInput only be called by `HwndStylusInputProvider..ctor`. And the `HwndStylusInputProvider..ctor` will pass the `HwndSource source` to RegisterHwndForInput method. So that it unnecessary to use the PresentationSource in RegisterHwndForInput.
@lindexi lindexi force-pushed the t/lindexi/RegisterHwndForInput branch from 3d3c03e to 6e23ef8 Compare September 17, 2025 10:03
Copy link
Member

@h3xds1nz h3xds1nz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants