diff --git a/NEWS b/NEWS index c639f461..556a0252 100644 --- a/NEWS +++ b/NEWS @@ -40,6 +40,7 @@ v0.x.x (xxxx-xx-xx) a kind. - Fixed compatibility problems with FreeBSD. - Added support for dynamically loaded Vulkan symbols. +- Trace description or filename is now displayed on the window title bar. v0.9.1 (2023-02-26) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index b19b0694..31b55320 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -671,7 +671,7 @@ bool View::DrawImpl() if( !m_titleSet && m_stcb ) { m_titleSet = true; - m_stcb( m_worker.GetCaptureName().c_str() ); + UpdateTitle(); } ImGuiViewport* viewport = ImGui::GetMainViewport(); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 3a78367b..6f2c6292 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -363,6 +363,7 @@ private: bool Save( const char* fn, FileWrite::Compression comp, int zlevel, bool buildDict ); void Attention( bool& alreadyDone ); + void UpdateTitle(); unordered_flat_map m_visibleMsgThread; unordered_flat_map m_waitStackThread; diff --git a/server/TracyView_TraceInfo.cpp b/server/TracyView_TraceInfo.cpp index 1d39dc5f..f01ff769 100644 --- a/server/TracyView_TraceInfo.cpp +++ b/server/TracyView_TraceInfo.cpp @@ -61,6 +61,7 @@ void View::DrawInfo() if( ImGui::InputTextWithHint( "##traceDesc", "Enter description of the trace", buf, 256 ) ) { m_userData.SetDescription( buf ); + if( m_stcb ) UpdateTitle(); } } diff --git a/server/TracyView_Utility.cpp b/server/TracyView_Utility.cpp index d6fbfb14..e341de59 100644 --- a/server/TracyView_Utility.cpp +++ b/server/TracyView_Utility.cpp @@ -870,4 +870,30 @@ void View::Attention( bool& alreadyDone ) } } +void View::UpdateTitle() +{ + auto captureName = m_worker.GetCaptureName().c_str(); + const auto& desc = m_userData.GetDescription(); + if( !desc.empty() ) + { + char buf[1024]; + snprintf( buf, 1024, "%s (%s)", captureName, desc.c_str() ); + m_stcb( buf ); + } + else if( !m_filename.empty() ) + { + auto fptr = m_filename.c_str() + m_filename.size() - 1; + while( fptr > m_filename.c_str() && *fptr != '/' && *fptr != '\\' ) fptr--; + if( *fptr == '/' || *fptr == '\\' ) fptr++; + + char buf[1024]; + snprintf( buf, 1024, "%s (%s)", captureName, fptr ); + m_stcb( buf ); + } + else + { + m_stcb( captureName ); + } +} + }