From d70a003617e5be71fd95755095ac2baa92ae351b Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 7 Sep 2025 19:27:24 +0300 Subject: [PATCH] Improve tab-less dock window behavior in other platforms Add checks for #3215 to hide the tab bar only if it doesn't prevent window dragging in Wayland sessions with native decorations. --- Source/Editor/GUI/Docking/DockPanelProxy.cs | 6 +----- Source/Editor/Options/InterfaceOptions.cs | 2 +- Source/Editor/Utilities/Utils.cs | 14 ++++++++++++++ Source/Engine/Platform/Base/PlatformBase.cpp | 9 +++++++++ Source/Engine/Platform/Base/PlatformBase.h | 5 +++++ Source/Engine/Platform/SDL/SDLPlatform.cpp | 8 ++++++++ Source/Engine/Platform/SDL/SDLPlatform.h | 1 + 7 files changed, 39 insertions(+), 6 deletions(-) diff --git a/Source/Editor/GUI/Docking/DockPanelProxy.cs b/Source/Editor/GUI/Docking/DockPanelProxy.cs index bad8968b8..e6df56d1f 100644 --- a/Source/Editor/GUI/Docking/DockPanelProxy.cs +++ b/Source/Editor/GUI/Docking/DockPanelProxy.cs @@ -19,11 +19,7 @@ namespace FlaxEditor.GUI.Docking private float _tabHeight = Editor.Instance.Options.Options.Interface.TabHeight; private bool _useMinimumTabWidth = Editor.Instance.Options.Options.Interface.UseMinimumTabWidth; private float _minimumTabWidth = Editor.Instance.Options.Options.Interface.MinimumTabWidth; -#if PLATFORM_WINDOWS - private readonly bool _hideTabForSingleTab = Editor.Instance.Options.Options.Interface.HideSingleTabWindowTabBars; -#else - private readonly bool _hideTabForSingleTab = false; -#endif + private readonly bool _hideTabForSingleTab = Utilities.Utils.HideSingleTabWindowTabBars(); /// /// The is mouse down flag (left button). diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index 26e627bdc..172f63f36 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -312,7 +312,7 @@ namespace FlaxEditor.Options public bool UseNativeWindowSystem { get; set; } = false; #endif -#if PLATFORM_WINDOWS +#if PLATFORM_SDL || PLATFORM_WINDOWS /// /// Gets or sets a value indicating whether a window containing a single tabs hides the tab bar. Editor restart recommended. /// diff --git a/Source/Editor/Utilities/Utils.cs b/Source/Editor/Utilities/Utils.cs index 284a0b6c6..7594bcd22 100644 --- a/Source/Editor/Utilities/Utils.cs +++ b/Source/Editor/Utilities/Utils.cs @@ -1571,5 +1571,19 @@ namespace FlaxEditor.Utilities _ => throw new ArgumentOutOfRangeException() }; } + + internal static bool HideSingleTabWindowTabBars() + { +#if PLATFORM_SDL + // We should not hide the tab bars if tab handle is the only way to dock the window + bool clientSideDecorations = UseCustomWindowDecorations(false); + bool draggableDecorations = clientSideDecorations || Platform.SupportsNativeDecorationDragging; + return draggableDecorations && Editor.Instance.Options.Options.Interface.HideSingleTabWindowTabBars; +#elif PLATFORM_WINDOWS + return Editor.Instance.Options.Options.Interface.HideSingleTabWindowTabBars; +#else + return false; +#endif + } } } diff --git a/Source/Engine/Platform/Base/PlatformBase.cpp b/Source/Engine/Platform/Base/PlatformBase.cpp index 7a93c24ed..65e1dfdc5 100644 --- a/Source/Engine/Platform/Base/PlatformBase.cpp +++ b/Source/Engine/Platform/Base/PlatformBase.cpp @@ -274,6 +274,15 @@ bool PlatformBase::SupportsNativeDecorations() return true; } +bool PlatformBase::SupportsNativeDecorationDragging() +{ +#if PLATFORM_LINUX + return false; +#else + return true; +#endif +} + #endif bool PlatformBase::Is64BitApp() diff --git a/Source/Engine/Platform/Base/PlatformBase.h b/Source/Engine/Platform/Base/PlatformBase.h index 97928c376..50b430203 100644 --- a/Source/Engine/Platform/Base/PlatformBase.h +++ b/Source/Engine/Platform/Base/PlatformBase.h @@ -379,6 +379,11 @@ public: /// API_PROPERTY() static bool SupportsNativeDecorations(); + /// + /// Returns true if system provides support for native window dragging events. + /// + API_PROPERTY() static bool SupportsNativeDecorationDragging(); + /// /// 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 b673d9c17..5014119cb 100644 --- a/Source/Engine/Platform/SDL/SDLPlatform.cpp +++ b/Source/Engine/Platform/SDL/SDLPlatform.cpp @@ -32,6 +32,7 @@ namespace SDLImpl int32 SystemDpi = 96; String UserLocale("en"); bool WindowDecorationsSupported = true; + bool SupportsDecorationDragging = true; String WaylandDisplayEnv; String XDGCurrentDesktop; } @@ -63,6 +64,8 @@ bool SDLPlatform::Init() SDL_SetHint(SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR, "0"); SDLImpl::WindowDecorationsSupported = false; } + if (waylandSession) + SupportsDecorationDragging = false; #endif #if PLATFORM_LINUX @@ -204,6 +207,11 @@ bool SDLPlatform::SupportsNativeDecorations() return SDLImpl::WindowDecorationsSupported; } +bool SDLPlatform::SupportsNativeDecorationDragging() +{ + return SDLImpl::SupportsDecorationDragging; +} + BatteryInfo SDLPlatform::GetBatteryInfo() { BatteryInfo info; diff --git a/Source/Engine/Platform/SDL/SDLPlatform.h b/Source/Engine/Platform/SDL/SDLPlatform.h index 842082a37..daf81cb2a 100644 --- a/Source/Engine/Platform/SDL/SDLPlatform.h +++ b/Source/Engine/Platform/SDL/SDLPlatform.h @@ -75,6 +75,7 @@ public: static void Tick(); static String GetDisplayServer(); static bool SupportsNativeDecorations(); + static bool SupportsNativeDecorationDragging(); static void SetHighDpiAwarenessEnabled(bool enable); static BatteryInfo GetBatteryInfo(); static int32 GetDpi();