EnableHighDPIAwareness

EnableHighDPIAwareness

#Overview

name: EnableHighDPIAwareness

This variable is created as a Console Variable (cvar).

It is referenced in 8 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of EnableHighDPIAwareness is to enable or disable high DPI mode in the Unreal Engine application. This setting is primarily used for managing the user interface scaling and display quality on high-resolution screens.

This setting variable is primarily used by the Unreal Engine’s application core and user interface subsystems. Specifically, it is referenced in the ApplicationCore and Slate modules, as well as in the UnrealEd editor settings.

The value of this variable is set in multiple places:

  1. It can be set through a console variable (CVar) named “EnableHighDPIAwareness”.
  2. In the editor, it can be modified through the EditorStyleSettings (bEnableHighDPIAwareness property).
  3. For game mode, it’s read from the engine configuration file (GEngineIni) under the UserInterfaceSettings section.

The associated variable bEnableHighDPIAwareness interacts closely with EnableHighDPIAwareness. They share the same value and are used interchangeably in different parts of the codebase.

Developers should be aware of the following when using this variable:

  1. Changing this setting may require a restart of the application to take full effect.
  2. It affects the entire application’s UI scaling, so it should be used carefully to ensure a consistent user experience across different display resolutions.
  3. The setting behaves differently in editor mode versus game mode.

Best practices for using this variable include:

  1. Consider the target platforms and typical display resolutions when deciding whether to enable high DPI awareness.
  2. Test the application thoroughly on various display configurations when modifying this setting.
  3. Coordinate changes to this variable with adjustments to other UI scaling settings, such as ApplicationScale.

Regarding the associated variable bEnableHighDPIAwareness:

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/GenericPlatform/GenericPlatformApplicationMisc.cpp:21

Scope: file

Source code excerpt:


FAutoConsoleVariableRef FGenericPlatformApplicationMisc::CVarEnableHighDPIAwareness(
	TEXT("EnableHighDPIAwareness"),
	bEnableHighDPIAwareness,
	TEXT("Enables or disables high dpi mode"),
	ECVF_ReadOnly
);

static bool bAllowVirtualKeyboard  = false;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorStyleClasses.cpp:98

Scope (from outer to inner):

file
function     void UEditorStyleSettings::PostEditChangeProperty

Source code excerpt:

	if (PropertyName == GET_MEMBER_NAME_CHECKED(UEditorStyleSettings, bEnableHighDPIAwareness))
	{
		GConfig->SetBool(TEXT("HDPI"), TEXT("EnableHighDPIAwareness"), bEnableHighDPIAwareness, GEditorSettingsIni);
	}
	else if (PropertyName.IsNone() || PropertyName == GET_MEMBER_NAME_CHECKED(UEditorStyleSettings, ApplicationScale))
	{
		if (FSlateApplication::IsInitialized())
		{
			FSlateApplication::Get().SetApplicationScale(ApplicationScale);

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:922

Scope (from outer to inner):

file
function     void FSlateApplication::InitHighDPI

Source code excerpt:

		if (GIsEditor)
		{
			GConfig->GetBool(TEXT("HDPI"), TEXT("EnableHighDPIAwareness"), bRequestEnableHighDPI, GEditorSettingsIni);
		}
		else
		{
			GConfig->GetBool(TEXT("/Script/Engine.UserInterfaceSettings"), TEXT("bAllowHighDPIInGameMode"), bRequestEnableHighDPI, GEngineIni);
		}

#Associated Variable and Callsites

This variable is associated with another variable named bEnableHighDPIAwareness. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/EditorStyleSettings.h:46

Scope (from outer to inner):

file
class        class UEditorStyleSettings : public UObject

Source code excerpt:

	 */
	UPROPERTY(EditAnywhere, Category=UserInterface, meta = (ConfigRestartRequired = true, DisplayName="Enable High DPI Support"))
	bool bEnableHighDPIAwareness;
	
	/** 
	 * Scales the entire editor interface up or down. 
	 */
	UPROPERTY(EditAnywhere, Config, Category=UserInterface, meta=(ClampMin=0.5, ClampMax=3.0))
	float ApplicationScale = 1.0f;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorStyleClasses.cpp:76

Scope (from outer to inner):

file
function     void UEditorStyleSettings::Init

Source code excerpt:

	// Set from CVar 
	IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(TEXT("EnableHighDPIAwareness"));
	bEnableHighDPIAwareness = CVar->GetInt() != 0;
}

FLinearColor UEditorStyleSettings::GetSubduedSelectionColor() const
{
	FLinearColor SubduedSelectionColor = SelectionColor.LinearRGBToHSV();
	SubduedSelectionColor.G *= 0.55f;		// take the saturation 

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorStyleClasses.cpp:96

Scope (from outer to inner):

file
function     void UEditorStyleSettings::PostEditChangeProperty

Source code excerpt:


	// This property is intentionally not per project so it must be manually written to the correct config file
	if (PropertyName == GET_MEMBER_NAME_CHECKED(UEditorStyleSettings, bEnableHighDPIAwareness))
	{
		GConfig->SetBool(TEXT("HDPI"), TEXT("EnableHighDPIAwareness"), bEnableHighDPIAwareness, GEditorSettingsIni);
	}
	else if (PropertyName.IsNone() || PropertyName == GET_MEMBER_NAME_CHECKED(UEditorStyleSettings, ApplicationScale))
	{
		if (FSlateApplication::IsInitialized())
		{
			FSlateApplication::Get().SetApplicationScale(ApplicationScale);

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/GenericPlatform/GenericPlatformApplicationMisc.cpp:18

Scope: file

Source code excerpt:

int32 FGenericPlatformApplicationMisc::CachedPhysicalScreenDensity = 0;

static int32 bEnableHighDPIAwareness = 1;

FAutoConsoleVariableRef FGenericPlatformApplicationMisc::CVarEnableHighDPIAwareness(
	TEXT("EnableHighDPIAwareness"),
	bEnableHighDPIAwareness,
	TEXT("Enables or disables high dpi mode"),
	ECVF_ReadOnly
);

static bool bAllowVirtualKeyboard  = false;

#Loc: <Workspace>/Engine/Source/Runtime/ApplicationCore/Private/GenericPlatform/GenericPlatformApplicationMisc.cpp:103

Scope (from outer to inner):

file
function     bool FGenericPlatformApplicationMisc::IsHighDPIAwarenessEnabled

Source code excerpt:

bool FGenericPlatformApplicationMisc::IsHighDPIAwarenessEnabled()
{
	return bEnableHighDPIAwareness != 0;
}

void FGenericPlatformApplicationMisc::ClipboardCopy(const TCHAR* Str)
{

}