Slate.ThrottleWhenMouseIsMoving

Slate.ThrottleWhenMouseIsMoving

#Overview

name: Slate.ThrottleWhenMouseIsMoving

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.ThrottleWhenMouseIsMoving is to control whether the Slate UI system should attempt to increase UI responsiveness based on mouse cursor movement. This setting is part of the Slate framework, which is Unreal Engine’s UI system.

This setting variable is primarily used in the Slate subsystem, specifically within the SlateApplication module. Based on the callsites, it’s clear that this variable is used to manage performance and responsiveness of the UI.

The value of this variable is set as a console variable, which means it can be changed at runtime. It’s initialized to false by default, as seen in the source code:

TAutoConsoleVariable<int32> ThrottleWhenMouseIsMoving( 
	TEXT( "Slate.ThrottleWhenMouseIsMoving" ),
	false,
	TEXT( "Whether to attempt to increase UI responsiveness based on mouse cursor movement." ) );

This variable interacts with the ThrottleApplicationBasedOnMouseMovement function in the FSlateApplication class. When enabled, it allows the application to adjust its performance based on mouse movement.

Developers should be aware that this variable is stored as an int32 but is interpreted as a boolean value. This is done to accommodate the console variable system, as mentioned in the comment:

/** True if we should allow throttling based on mouse movement activity.  int32 instead of bool only for console variable system. */

Best practices when using this variable include:

  1. Consider enabling it in scenarios where UI responsiveness is crucial, especially in editor environments.
  2. Be aware that enabling this might affect overall performance, as it may prioritize UI responsiveness over other processes.
  3. Test thoroughly with this setting both enabled and disabled to ensure it doesn’t negatively impact your specific use case.

Regarding the associated variable ThrottleWhenMouseIsMoving, it appears to be the same variable. The code snippets show that it’s declared and used in the same way. This is likely not a separate variable, but rather the same console variable being referenced in different parts of the code. The usage remains consistent with what was described above.

#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:544

Scope: file

Source code excerpt:

/** True if we should allow throttling based on mouse movement activity.  int32 instead of bool only for console variable system. */
TAutoConsoleVariable<int32> ThrottleWhenMouseIsMoving( 
	TEXT( "Slate.ThrottleWhenMouseIsMoving" ),
	false,
	TEXT( "Whether to attempt to increase UI responsiveness based on mouse cursor movement." ) );

/** Minimum sustained average frame rate required before we consider the editor to be "responsive" for a smooth UI experience */
TAutoConsoleVariable<int32> TargetFrameRateForResponsiveness(
	TEXT( "Slate.TargetFrameRateForResponsiveness" ),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:


/** True if we should allow throttling based on mouse movement activity.  int32 instead of bool only for console variable system. */
TAutoConsoleVariable<int32> ThrottleWhenMouseIsMoving( 
	TEXT( "Slate.ThrottleWhenMouseIsMoving" ),
	false,
	TEXT( "Whether to attempt to increase UI responsiveness based on mouse cursor movement." ) );

/** Minimum sustained average frame rate required before we consider the editor to be "responsive" for a smooth UI experience */
TAutoConsoleVariable<int32> TargetFrameRateForResponsiveness(

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

Scope (from outer to inner):

file
function     void FSlateApplication::ThrottleApplicationBasedOnMouseMovement

Source code excerpt:

{
	bool bShouldThrottle = false;
	if( ThrottleWhenMouseIsMoving.GetValueOnGameThread() )	// Interpreted as bool here
	{
		// We only want to engage the throttle for a short amount of time after the mouse stops moving
		const float TimeToThrottleAfterMouseStops = 0.1f;

		// After a key or mouse button is pressed, we'll leave the throttle disengaged for awhile so the
		// user can use the keys to navigate in a viewport, for example.