summaryrefslogtreecommitdiffstats
path: root/mozglue/misc/WindowsDpiInitialization.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /mozglue/misc/WindowsDpiInitialization.h
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--mozglue/misc/WindowsDpiInitialization.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/mozglue/misc/WindowsDpiInitialization.h b/mozglue/misc/WindowsDpiInitialization.h
new file mode 100644
index 0000000000..5943d50526
--- /dev/null
+++ b/mozglue/misc/WindowsDpiInitialization.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+#ifndef MOZILLA_MOZGLUE_MISC_WINDOWSDPIINITIALIZATION_H_
+#define MOZILLA_MOZGLUE_MISC_WINDOWSDPIINITIALIZATION_H_
+#include "mozilla/Types.h"
+
+namespace mozilla {
+
+// The result codes that may be returned from WindowsDpiInitialization()
+enum class WindowsDpiInitializationResult : uint32_t {
+ Success,
+ FindSetProcessDpiAwarenessContextFailed,
+ SetProcessDpiAwarenessContextFailed,
+ FindSetProcessDpiAwarenessFailed,
+ SetProcessDpiAwarenessFailed,
+ SetProcessDPIAwareFailed,
+};
+
+// Get a string representation of any WindowsDpiInitializationResult value
+inline const char* WindowsDpiInitializationResultString(
+ WindowsDpiInitializationResult result) {
+ switch (result) {
+ case WindowsDpiInitializationResult::Success:
+ return "Success";
+ case WindowsDpiInitializationResult::
+ FindSetProcessDpiAwarenessContextFailed:
+ return "Failed to find SetProcessDpiAwarenessContext";
+ case WindowsDpiInitializationResult::SetProcessDpiAwarenessContextFailed:
+ return "SetProcessDpiAwarenessContext failed";
+ case WindowsDpiInitializationResult::FindSetProcessDpiAwarenessFailed:
+ return "Failed to find SetProcessDpiAwareness";
+ case WindowsDpiInitializationResult::SetProcessDpiAwarenessFailed:
+ return "SetProcessDpiAwareness failed";
+ case WindowsDpiInitializationResult::SetProcessDPIAwareFailed:
+ return "SetProcessDPIAware failed";
+ default:
+ return "Unknown result";
+ }
+}
+
+// Initialize DPI awareness to the best available for the current OS
+// According to MSDN, this will be:
+// Per-Monitor V2 for Windows 10 Creators Update (1703) and later
+// Per-Monitor V1 for Windows 8.1 and later
+// System DPI for Vista and later (we don't support anything older)
+// https://docs.microsoft.com/en-us/windows/win32/hidpi/high-dpi-desktop-application-development-on-windows
+MFBT_API WindowsDpiInitializationResult WindowsDpiInitialization();
+
+} // namespace mozilla
+
+#endif // MOZILLA_MOZGLUE_MISC_WINDOWSDPIINITIALIZATION_H_