Skip to content

Comments

[Windows] Fix tablet mode detection#11135

Merged
mattleibow merged 1 commit intodotnet:mainfrom
matt-goldman:fix-windows-slatemode
Nov 11, 2022
Merged

[Windows] Fix tablet mode detection#11135
mattleibow merged 1 commit intodotnet:mainfrom
matt-goldman:fix-windows-slatemode

Conversation

@matt-goldman
Copy link
Contributor

Description of Change

DeviceInfo on Windows currently uses SM_CONVERTIBLESLATEMODE to detect tablet mode. However the logic is currently:
var inTabletMode = GetSystemMetrics(SM_CONVERTIBLESLATEMODE) != 0;
But according to the documentation:

SM_CONVERTIBLESLATEMODE
0x2003
Reflects the state of the laptop or slate mode, 0 for Slate Mode and non-zero otherwise. When this system metric changes, the system sends a broadcast message via WM_SETTINGCHANGE with "ConvertibleSlateMode" in the LPARAM. Note that this system metric doesn't apply to desktop PCs. In that case, use GetAutoRotationState.

So it appears 0 = slate mode, but the current logic is checking for anything other than 0.

Issues Fixed

Fixes #11126

@ghost ghost added the community ✨ Community Contribution label Nov 6, 2022
@ghost
Copy link

ghost commented Nov 6, 2022

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.

@jfversluis jfversluis requested a review from mattleibow November 7, 2022 08:26
@jfversluis
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@jfversluis jfversluis added the area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info label Nov 7, 2022
@mattleibow
Copy link
Member

mattleibow commented Nov 10, 2022

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.

@matt-goldman
Copy link
Contributor Author

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.

@mattleibow
Copy link
Member

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!

@mattleibow mattleibow merged commit b9cd0f7 into dotnet:main Nov 11, 2022
@mattleibow mattleibow added the backport/suggested The PR author or issue review has suggested that the change should be backported. label Nov 11, 2022
@hartez
Copy link
Contributor

hartez commented Nov 17, 2022

/backport to net7.0

@github-actions
Copy link
Contributor

@matt-goldman matt-goldman deleted the fix-windows-slatemode branch November 20, 2022 04:37
@hartez hartez added the backport/approved After some discussion or review, this PR or change was approved to be backported. label Feb 16, 2023
@1888games
Copy link

1888games commented Dec 6, 2023

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!

@github-actions github-actions bot locked and limited conversation to collaborators Jan 6, 2024
@samhouts samhouts added the fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info backport/approved After some discussion or review, this PR or change was approved to be backported. backport/suggested The PR author or issue review has suggested that the change should be backported. community ✨ Community Contribution fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! platform/windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Device Idiom detects Windows as tablet

6 participants