microsoft / microsoft/WPF-Samples

TouchKeyboardNotifier - Does not work properly with Per Monitor V2 DPI Scaling

Open
#429 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
5.7k
Forks
3.3k
Avg merge
12d 8h
Merged PRs (30d)
2

Description

With Per Monitor V2 DPI Scaling, the showingHandler code in TouchKeyboardNotifier does not return the correct occludedRect when the window which raised the event is on a non-primary monitor and that monitor's DPI scaling is different to the primary monitor's. It seems that the returned value assumes that it is coming from the primary monitor when it may not be. This issue may be in the underlying InputPane class this sample uses as it seems like that might be returning the incorrect values based on my investigation.

Note that this was tested with Per Monitor V2 Scaling enabled in the app manifest of a WPF app using both .Net Framework 4.8 and .Net Core 3.1. The WPF window itself scales fine and doesn't use bitmap stretching, but the occludedRect value produced in the showingHandler from this sample returns values that are too small or too big when the window which raised the event is on a non-primary monitor and that monitor's DPI scaling is different to the primary monitor's. When the WPF window is on a primary monitor, it seems to work fine regardless of DPI scaling.

Here is the expected behaviour (When WPF window is on a primary monitor):
image

And here it is on a secondary monitor whose DPI scaling is different from the primary monitors. The occludedRect is far to tall, resulting in most of the window being cut off when the content within it is resized to fit within the top of the touch keyboard and the top of the screen:
image

This was using Windows 11 but the issue occurs in Windows 10 too.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TouchKeyboardNotifier sample's showingHandler and trace how the InputPane occludedRect is obtained and interpreted. Reproduce the report on primary and non-primary monitors with different Per Monitor V2 DPI settings, then compare the resulting rectangle with the expected touch-keyboard bounds; done means the values are correct on both Windows 10 and Windows 11 scenarios described.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.