From e6fd2c9cdb9011a19066f1f5f43cd2ece87be996 Mon Sep 17 00:00:00 2001 From: LibretroAdmin Date: Sat, 27 Aug 2022 16:16:24 +0200 Subject: [PATCH] (Win32) Do optimization for Windows where we only update the title when the previous title differs from the current title (X11) Have to roll back the previous title optimization/less calls to XChangeProperty, because the title is lost upon toggling between fullscreen/windowed and is no longer set --- gfx/common/win32_common.c | 15 +++++---------- gfx/common/x11_common.c | 6 +----- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 71db3aefd3..d17307f651 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -2339,22 +2339,17 @@ bool win32_set_video_mode(void *data, void win32_update_title(void) { const ui_window_t *window = ui_companion_driver_get_window_ptr(); - static unsigned update_title_wait = 0; - - if (update_title_wait) - { - update_title_wait--; - return; - } - if (window) { + static char prev_title[128]; char title[128]; title[0] = '\0'; video_driver_get_window_title(title, sizeof(title)); - update_title_wait = g_win32_refresh_rate; - if (title[0]) + if (title[0] && !string_is_equal(title, prev_title)) + { window->set_title(&main_window, title); + strlcpy(prev_title, title, sizeof(prev_title)); + } } } #endif diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 503259105e..4ff0541074 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -766,16 +766,12 @@ bool x11_connect(void) void x11_update_title(void *data) { size_t len; - static char prev_title[128]; char title[128]; title[0] = '\0'; len = video_driver_get_window_title(title, sizeof(title)); - if (title[0] && !string_is_equal(title, prev_title)) - { + if (title[0]) XChangeProperty(g_x11_dpy, g_x11_win, XA_WM_NAME, XA_STRING, 8, PropModeReplace, (const unsigned char*)title, len); - strlcpy(prev_title, title, sizeof(prev_title)); - } } bool x11_input_ctx_new(bool true_full)