Slate.SleepBufferPostInput

Slate.SleepBufferPostInput

#Overview

name: Slate.SleepBufferPostInput

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Slate.SleepBufferPostInput is to control the idle behavior of the Slate UI system in Unreal Engine 5. It defines the amount of time that must pass without any user action before Slate is put to sleep, provided there are no active timers.

This setting variable is primarily used by the Slate subsystem, which is part of Unreal Engine’s UI framework. Based on the callsites, it’s specifically utilized within the SlateApplication module.

The value of this variable is set as a console variable, which means it can be adjusted at runtime through the console or configuration files. It’s initialized with a default value of 0.0f, but can be modified as needed.

The variable interacts with other timing-related variables in the Slate system, such as LastTickTime, LastUserInteractionTime, and LastMouseMoveTime. These are used in conjunction with Slate.SleepBufferPostInput to determine if the user is idle.

Developers should be aware that this variable directly impacts the responsiveness and performance of the UI system. Setting it too low might cause Slate to sleep too frequently, potentially affecting UI responsiveness, while setting it too high might keep the UI system active unnecessarily, potentially impacting performance.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of your application or game.
  2. Testing different values to find the right balance between responsiveness and performance.
  3. Considering the target platform and typical user interaction patterns when setting this value.

Regarding the associated variable SleepBufferPostInput, it’s actually the same variable. The code shows that Slate.SleepBufferPostInput is the console variable name, while SleepBufferPostInput is the C++ variable name used in the code. They refer to the same setting and share the same value.

The SleepBufferPostInput variable is used in the TickAndDrawWidgets function of the SlateApplication to determine if the user is idle. It’s compared against the time since the last input and mouse move to decide whether to put Slate to sleep. This mechanism helps optimize performance by reducing UI updates when the user is not actively interacting with the application.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

/** The amount of time that must pass without any user action before Slate is put to sleep (provided that there are no active timers). */
TAutoConsoleVariable<float> SleepBufferPostInput(
	TEXT("Slate.SleepBufferPostInput"),
	0.0f,
	TEXT("The amount of time that must pass without any user action before Slate is put to sleep (provided that there are no active timers)."));

static bool bRequireFocusForGamepadInput = false;
FAutoConsoleVariableRef CVarRequireFocusForGamepadInput(
	TEXT("Slate.RequireFocusForGamepadInput"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:


/** The amount of time that must pass without any user action before Slate is put to sleep (provided that there are no active timers). */
TAutoConsoleVariable<float> SleepBufferPostInput(
	TEXT("Slate.SleepBufferPostInput"),
	0.0f,
	TEXT("The amount of time that must pass without any user action before Slate is put to sleep (provided that there are no active timers)."));

static bool bRequireFocusForGamepadInput = false;
FAutoConsoleVariableRef CVarRequireFocusForGamepadInput(

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

Scope (from outer to inner):

file
function     void FSlateApplication::TickAndDrawWidgets

Source code excerpt:

		TSharedPtr<SWindow> ActiveModalWindow = GetActiveModalWindow();

		const float SleepThreshold = SleepBufferPostInput.GetValueOnGameThread();
		const double TimeSinceInput = LastTickTime - LastUserInteractionTime;
		const double TimeSinceMouseMove = LastTickTime - LastMouseMoveTime;
	
		const bool bIsUserIdle = (TimeSinceInput > SleepThreshold) && (TimeSinceMouseMove > SleepThreshold);
		const bool bAnyActiveTimersPending = AnyActiveTimersArePending();