diff --git a/src/sdlwindow.cpp b/src/sdlwindow.cpp index 8986e02..cb0f7c3 100644 --- a/src/sdlwindow.cpp +++ b/src/sdlwindow.cpp @@ -13,6 +13,8 @@ #include "sdlscancodetable.hpp" +#define DEFAULT_TITLE "gamescope" + static bool g_bSDLInitOK = false; static std::mutex g_SDLInitLock; @@ -25,6 +27,10 @@ SDL_Window *g_SDLWindow; static uint32_t g_unSDLUserEventID; static SDL_Event g_SDLUserEvent; +static std::mutex g_SDLWindowTitleLock; +static std::string g_SDLWindowTitle; +static bool g_bUpdateSDLWindowTitle = false; + //----------------------------------------------------------------------------- // Purpose: Convert from the remote scancode to a Linux event keycode //----------------------------------------------------------------------------- @@ -84,7 +90,7 @@ void inputSDLThreadRun( void ) nSDLWindowFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP; } - g_SDLWindow = SDL_CreateWindow( "gamescope", + g_SDLWindow = SDL_CreateWindow( DEFAULT_TITLE, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, g_nOutputWidth, @@ -242,6 +248,27 @@ void sdlwindow_update( void ) SDL_HideWindow( g_SDLWindow ); } } + + g_SDLWindowTitleLock.lock(); + if ( g_bUpdateSDLWindowTitle ) + { + g_bUpdateSDLWindowTitle = false; + SDL_SetWindowTitle( g_SDLWindow, g_SDLWindowTitle.c_str() ); + } + g_SDLWindowTitleLock.unlock(); +} + +void sdlwindow_title( const char* title ) +{ + title = title ? title : DEFAULT_TITLE; + g_SDLWindowTitleLock.lock(); + if ( g_SDLWindowTitle != title ) + { + g_SDLWindowTitle = title ? title : DEFAULT_TITLE; + g_bUpdateSDLWindowTitle = true; + sdlwindow_pushupdate(); + } + g_SDLWindowTitleLock.unlock(); } void sdlwindow_pushupdate( void ) diff --git a/src/sdlwindow.hpp b/src/sdlwindow.hpp index b572d29..fa9e07e 100644 --- a/src/sdlwindow.hpp +++ b/src/sdlwindow.hpp @@ -8,6 +8,7 @@ bool sdlwindow_init( void ); void sdlwindow_update( void ); +void sdlwindow_title( const char* title ); // called from other threads with interesting things have happened with clients that might warrant updating the nested window void sdlwindow_pushupdate( void ); diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index 36774b0..f128501 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -2218,6 +2218,8 @@ found: } XFree(children); + + sdlwindow_title( w->title ); } static void @@ -3199,6 +3201,10 @@ handle_property_notify(Display *dpy, XPropertyEvent *ev) win *w = find_win(dpy, ev->window); if (w) { get_win_title(dpy, w, ev->atom); + if (w == currentFocusWin) + { + sdlwindow_title( w->title ); + } } } }