Skip to content

Commit

Permalink
Bug 1744687 - Part 3. Fix build error for newer Windows SDK. r=gsvelto
Browse files Browse the repository at this point in the history
Now hal uses AR_STATE for screen orientation, so we should move it from
WinUtils.cpp to WinUtils.h for newer Windows 11 SDK.

Also, newer Windows SDK has to set WINVER to WIN8 to use auto rotation API.

Differential Revision: https://phabricator.services.mozilla.com/D163099
  • Loading branch information
makotokato committed Nov 25, 2022
1 parent d377cc7 commit 2e9e0c4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
3 changes: 2 additions & 1 deletion hal/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ elif CONFIG["OS_TARGET"] == "WINNT":
REQUIRES_UNIFIED_BUILD = True
UNIFIED_SOURCES += [
"fallback/FallbackVibration.cpp",
"windows/WindowsScreenConfiguration.cpp",
"windows/WindowsSensor.cpp",
]
# WindowsBattery.cpp cannot be built in unified mode because it relies on HalImpl.h.
# WindowsProcessPriority.cpp needs to set _WIN32_WINNT to Windows 8
# WindowsScreenConfiguration.cpp needs to set WINVER to 0x0602.
SOURCES += [
"windows/WindowsBattery.cpp",
"windows/WindowsProcessPriority.cpp",
"windows/WindowsScreenConfiguration.cpp",
]
elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "cocoa":
UNIFIED_SOURCES += [
Expand Down
5 changes: 5 additions & 0 deletions hal/windows/WindowsScreenConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#if defined(WINVER)
# undef WINVER
# define WINVER 0x0602
#endif

#include "Hal.h"
#include "mozilla/WindowsVersion.h"
#include "mozilla/widget/ScreenManager.h"
Expand Down
20 changes: 0 additions & 20 deletions widget/windows/WinUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1488,26 +1488,6 @@ uint32_t WinUtils::GetMaxTouchPoints() {
return 0;
}

// Starting with version 10.0.22621.0 of the Windows SDK the AR_STATE enum and
// types are only defined when building for Windows 8 instead of Windows 7.
#if (WDK_NTDDI_VERSION >= 0x0A00000C) && (WINVER < 0x0602)

enum AR_STATE {
AR_ENABLED = 0x0,
AR_DISABLED = 0x1,
AR_SUPPRESSED = 0x2,
AR_REMOTESESSION = 0x4,
AR_MULTIMON = 0x8,
AR_NOSENSOR = 0x10,
AR_NOT_SUPPORTED = 0x20,
AR_DOCKED = 0x40,
AR_LAPTOP = 0x80
};

using PAR_STATE = enum AR_STATE*;

#endif // (WDK_NTDDI_VERSION >= 0x0A00000C) && (WINVER < 0x0602)

/* static */
POWER_PLATFORM_ROLE
WinUtils::GetPowerPlatformRole() {
Expand Down
22 changes: 22 additions & 0 deletions widget/windows/WinUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@
#include "mozilla/WindowsProcessMitigations.h"
#include "mozilla/gfx/2D.h"

// Starting with version 10.0.22621.0 of the Windows SDK the AR_STATE enum and
// types are only defined when building for Windows 8 instead of Windows 7.
#if (WDK_NTDDI_VERSION >= 0x0A00000C) && (WINVER < 0x0602)

enum tagAR_STATE {
AR_ENABLED = 0x0,
AR_DISABLED = 0x1,
AR_SUPPRESSED = 0x2,
AR_REMOTESESSION = 0x4,
AR_MULTIMON = 0x8,
AR_NOSENSOR = 0x10,
AR_NOT_SUPPORTED = 0x20,
AR_DOCKED = 0x40,
AR_LAPTOP = 0x80
};

typedef enum tagAR_STATE AR_STATE;

using PAR_STATE = enum tagAR_STATE*;

#endif // (WDK_NTDDI_VERSION >= 0x0A00000C) && (WINVER < 0x0602)

/**
* NS_INLINE_DECL_IUNKNOWN_REFCOUNTING should be used for defining and
* implementing AddRef() and Release() of IUnknown interface.
Expand Down

0 comments on commit 2e9e0c4

Please sign in to comment.