From 0a4cb9e9b107bdce067643b7f3c73090a70ef3de Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 2 Feb 2025 18:34:47 +0200 Subject: [PATCH] Show current display server in Editor window tooltip (cherry picked from commit 62968dd4376bb0a3c0aa09316174e0e00a9ea31b) --- Source/Editor/GUI/MainMenu.cs | 4 +++- Source/Engine/Platform/Base/PlatformBase.cpp | 9 +++++++++ Source/Engine/Platform/Base/PlatformBase.h | 5 +++++ Source/Engine/Platform/SDL/SDLPlatform.cpp | 12 ++++++++++++ Source/Engine/Platform/SDL/SDLPlatform.h | 1 + 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Source/Editor/GUI/MainMenu.cs b/Source/Editor/GUI/MainMenu.cs index 99439539f..e370e2dd3 100644 --- a/Source/Editor/GUI/MainMenu.cs +++ b/Source/Editor/GUI/MainMenu.cs @@ -84,13 +84,15 @@ namespace FlaxEditor.GUI ScriptsBuilder.GetBinariesConfiguration(out _, out _, out _, out var configuration); + var driver = Platform.DisplayServer; + _icon = new Image { Margin = new Margin(6, 6, 6, 6), Brush = new TextureBrush(windowIcon), Color = Style.Current.Foreground, KeepAspectRatio = false, - TooltipText = string.Format("{0}\nVersion {1}\nConfiguration {3}\nGraphics {2}", _window.Title, Globals.EngineVersion, GPUDevice.Instance.RendererType, configuration), + TooltipText = string.Format("{0}\nVersion {1}\nConfiguration {3}\nGraphics {2} {4}", _window.Title, Globals.EngineVersion, GPUDevice.Instance.RendererType, configuration, driver), Parent = this, }; diff --git a/Source/Engine/Platform/Base/PlatformBase.cpp b/Source/Engine/Platform/Base/PlatformBase.cpp index c9661709f..d16521c24 100644 --- a/Source/Engine/Platform/Base/PlatformBase.cpp +++ b/Source/Engine/Platform/Base/PlatformBase.cpp @@ -262,6 +262,15 @@ PlatformType PlatformBase::GetPlatformType() return PLATFORM_TYPE; } +#if !PLATFORM_SDL + +String PlatformBase::GetDisplayServer() +{ + return String::Empty; +} + +#endif + bool PlatformBase::Is64BitApp() { #if PLATFORM_64BITS diff --git a/Source/Engine/Platform/Base/PlatformBase.h b/Source/Engine/Platform/Base/PlatformBase.h index 0b5cab0bc..e7cc6e8e3 100644 --- a/Source/Engine/Platform/Base/PlatformBase.h +++ b/Source/Engine/Platform/Base/PlatformBase.h @@ -369,6 +369,11 @@ public: /// API_PROPERTY() static PlatformType GetPlatformType(); + /// + /// Returns the display server name on Linux. + /// + API_PROPERTY() static String GetDisplayServer() = delete; + /// /// Returns true if is running 64 bit application (otherwise 32 bit). It's compile-time constant. /// diff --git a/Source/Engine/Platform/SDL/SDLPlatform.cpp b/Source/Engine/Platform/SDL/SDLPlatform.cpp index 790d6498a..84861752d 100644 --- a/Source/Engine/Platform/SDL/SDLPlatform.cpp +++ b/Source/Engine/Platform/SDL/SDLPlatform.cpp @@ -166,6 +166,18 @@ bool SDLPlatform::HandleEvent(SDL_Event& event) return true; } +String SDLPlatform::GetDisplayServer() +{ +#if PLATFORM_LINUX + String driver(SDL_GetCurrentVideoDriver()); + if (driver.Length() > 0) + driver[0] = StringUtils::ToUpper(driver[0]); + return driver; +#else + return String::Empty; +#endif +} + BatteryInfo SDLPlatform::GetBatteryInfo() { BatteryInfo info; diff --git a/Source/Engine/Platform/SDL/SDLPlatform.h b/Source/Engine/Platform/SDL/SDLPlatform.h index 8f374e400..52f8b8bfe 100644 --- a/Source/Engine/Platform/SDL/SDLPlatform.h +++ b/Source/Engine/Platform/SDL/SDLPlatform.h @@ -63,6 +63,7 @@ public: static bool Init(); static void LogInfo(); static void Tick(); + static String GetDisplayServer(); static void SetHighDpiAwarenessEnabled(bool enable); static BatteryInfo GetBatteryInfo(); static int32 GetDpi();