1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef MOZILLA_MOZGLUE_MISC_WINDOWSDPIINITIALIZATION_H_
7 #define MOZILLA_MOZGLUE_MISC_WINDOWSDPIINITIALIZATION_H_
8 #include "mozilla/Types.h"
12 // The result codes that may be returned from WindowsDpiInitialization()
13 enum class WindowsDpiInitializationResult
: uint32_t {
15 FindSetProcessDpiAwarenessContextFailed
,
16 SetProcessDpiAwarenessContextFailed
,
17 FindSetProcessDpiAwarenessFailed
,
18 SetProcessDpiAwarenessFailed
,
21 // Get a string representation of any WindowsDpiInitializationResult value
22 inline const char* WindowsDpiInitializationResultString(
23 WindowsDpiInitializationResult result
) {
25 case WindowsDpiInitializationResult::Success
:
27 case WindowsDpiInitializationResult::
28 FindSetProcessDpiAwarenessContextFailed
:
29 return "Failed to find SetProcessDpiAwarenessContext";
30 case WindowsDpiInitializationResult::SetProcessDpiAwarenessContextFailed
:
31 return "SetProcessDpiAwarenessContext failed";
32 case WindowsDpiInitializationResult::FindSetProcessDpiAwarenessFailed
:
33 return "Failed to find SetProcessDpiAwareness";
34 case WindowsDpiInitializationResult::SetProcessDpiAwarenessFailed
:
35 return "SetProcessDpiAwareness failed";
37 return "Unknown result";
41 // Initialize DPI awareness to the best available for the current OS
42 // According to MSDN, this will be:
43 // Per-Monitor V2 for Windows 10 Creators Update (1703) and later
44 // Per-Monitor V1 for Windows 8.1 and later
45 // System DPI for Vista and later (we don't support anything older)
46 // https://docs.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows
47 MFBT_API WindowsDpiInitializationResult
WindowsDpiInitialization();
49 } // namespace mozilla
51 #endif // MOZILLA_MOZGLUE_MISC_WINDOWSDPIINITIALIZATION_H_