Bug 1767948: Make Windows cursor hiding dependent on if mouse is installed r=Jamie,cmartin

We don't need to track cursor hiding when typing if there shouldn't be a cursor anyway because there is no mouse.

Differential Revision: https://phabricator.services.mozilla.com/D146516
This commit is contained in:
David Parks 2022-05-17 20:05:08 +00:00
Родитель 0c67406f3b
Коммит 80bfc4acf7
1 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -678,6 +678,19 @@ static bool IsMouseVanishKey(WPARAM aVirtKey) {
* Hide/unhide the cursor if the correct Windows and Firefox settings are set.
*/
static void MaybeHideCursor(bool aShouldHide) {
static bool sMouseExists =
[]{
// Before the first call to ShowCursor, the visibility count is 0
// if there is a mouse installed and -1 if not.
int count = ::ShowCursor(FALSE);
::ShowCursor(TRUE);
return count == -1;
}();
if (!sMouseExists) {
return;
}
static bool sIsHidden = false;
bool shouldHide = aShouldHide &&
StaticPrefs::widget_windows_hide_cursor_when_typing() &&