[Windows] Fix tablet mode detection#11135
Conversation
|
Hey there @matt-goldman! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
Looking at this now. What device are you testing with? I am sure I tested this bad code before and it worked. I am just resetting my surface book 2 and will test again. |
|
Tested on a Dell 7620. I've got a Surface Pro 8 too but it doesn't turn on anymore, I'll see if I can get some more people to pull my sample and test it. |
|
Confirmed on my SB2 that it is indeed = when detached and in tablet mode. So... no idea what I was testing previously... Thanks so much for this PR! |
|
/backport to net7.0 |
|
Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/3489850541 |
|
This has broken all sorts of stuff in our app (just moved from .NET 6 to 8) which runs on POS devices and relies on OnIdiom in the XAML to differentiate sizes appropriately between these POS devices and iPads and Android tablets, which we intend to support eventually. These are desktop machines with touch screens, and usually no physical keyboard. We can't disable 'tablet mode' in Windows, tried forcing it in the registry but that didn't work. I would argue in this case that 'tablet mode' and 'tablet device' are two different things, this suggests that one of those huge great screens in McDonalds would be reported as a 'tablet'....try taking that on the train! Fortunately we are no longer planning to support phones so hopefully I can replace all my OnIdiom XAML customisations with OnPlatform but what a pain! |
Description of Change
DeviceInfoon Windows currently usesSM_CONVERTIBLESLATEMODEto detect tablet mode. However the logic is currently:var inTabletMode = GetSystemMetrics(SM_CONVERTIBLESLATEMODE) != 0;But according to the documentation:
So it appears 0 = slate mode, but the current logic is checking for anything other than 0.
Issues Fixed
Fixes #11126