Skip to content

Commit

Permalink
XMB: Trigger bg-image load on theme change (#17599)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonninnos authored Feb 19, 2025
1 parent 8bf7e76 commit b5e0142
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
64 changes: 28 additions & 36 deletions menu/drivers/xmb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,13 +1164,13 @@ static void xmb_render_messagebox_internal(
string_list_deinitialize(&list);
}

static char *xmb_path_dynamic_wallpaper(xmb_handle_t *xmb,
bool menu_dynamic_wallpaper_enable,
unsigned xmb_color_theme,
const char *path_menu_wallpaper,
const char *dir_dynamic_wallpapers
)
static char *xmb_path_dynamic_wallpaper(xmb_handle_t *xmb)
{
settings_t *settings = config_get_ptr();
bool menu_dynamic_wallpaper_enable = settings->bools.menu_dynamic_wallpaper_enable;
unsigned xmb_color_theme = settings->uints.menu_xmb_color_theme;
const char *path_menu_wallpaper = settings->paths.path_menu_wallpaper;
const char *dir_dynamic_wallpapers = settings->paths.directory_dynamic_wallpapers;
char path[PATH_MAX_LENGTH];
unsigned depth = (unsigned)xmb_list_get_size(xmb, MENU_LIST_PLAIN);

Expand Down Expand Up @@ -1208,18 +1208,9 @@ static char *xmb_path_dynamic_wallpaper(xmb_handle_t *xmb,
return strdup(path);
}

static void xmb_update_dynamic_wallpaper(xmb_handle_t *xmb, bool reset,
bool menu_dynamic_wallpaper_enable,
unsigned xmb_color_theme,
const char *path_menu_wallpaper,
const char *dir_dynamic_wallpapers)
static void xmb_update_dynamic_wallpaper(xmb_handle_t *xmb, bool reset)
{
const char *path = xmb_path_dynamic_wallpaper(xmb,
menu_dynamic_wallpaper_enable,
xmb_color_theme,
path_menu_wallpaper,
dir_dynamic_wallpapers
);
const char *path = xmb_path_dynamic_wallpaper(xmb);

if (!string_is_equal(path, xmb->bg_file_path) || reset)
{
Expand All @@ -1229,16 +1220,14 @@ static void xmb_update_dynamic_wallpaper(xmb_handle_t *xmb, bool reset,
video_driver_supports_rgba(), 0,
menu_display_handle_wallpaper_upload, NULL);

if (xmb->bg_file_path)
free(xmb->bg_file_path);
free(xmb->bg_file_path);
xmb->bg_file_path = strdup(path);
}
else
{
xmb_load_image(xmb, NULL, MENU_IMAGE_NONE);

if (xmb->bg_file_path)
free(xmb->bg_file_path);
free(xmb->bg_file_path);
xmb->bg_file_path = NULL;
}
}
Expand Down Expand Up @@ -3165,12 +3154,7 @@ static void xmb_populate_entries(void *data,
xmb_unload_icon_thumbnail_textures(xmb);

if (xmb->allow_dynamic_wallpaper)
xmb_update_dynamic_wallpaper(xmb, false,
settings->bools.menu_dynamic_wallpaper_enable,
settings->uints.menu_xmb_color_theme,
settings->paths.path_menu_wallpaper,
settings->paths.directory_dynamic_wallpapers
);
xmb_update_dynamic_wallpaper(xmb, false);

/* Determine whether to show entry index */
xmb->entry_index_str[0] = '\0';
Expand Down Expand Up @@ -5597,6 +5581,7 @@ static enum menu_action xmb_parse_menu_entry_action(
|| xmb->want_fullscreen_thumbnails)
{
xmb_hide_fullscreen_thumbnails(xmb, true);
new_action = MENU_ACTION_NOOP;
}
break;
case MENU_ACTION_SCAN:
Expand Down Expand Up @@ -6494,12 +6479,7 @@ static void xmb_context_reset_internal(xmb_handle_t *xmb,
xmb->assets_missing = false;
if (!xmb_context_reset_textures(xmb, iconpath, menu_xmb_theme))
xmb->assets_missing = true;
xmb_update_dynamic_wallpaper(xmb, true,
settings->bools.menu_dynamic_wallpaper_enable,
settings->uints.menu_xmb_color_theme,
settings->paths.path_menu_wallpaper,
settings->paths.directory_dynamic_wallpapers
);
xmb_update_dynamic_wallpaper(xmb, true);

/* Reset previous selection buffer */
if (xmb->depth > 2)
Expand Down Expand Up @@ -9108,6 +9088,20 @@ static int xmb_list_bind_init(menu_file_list_cbs_t *cbs,
static int xmb_list_push(void *data, void *userdata,
menu_displaylist_info_t *info, unsigned type)
{
#if 1
switch (type)
{
case DISPLAYLIST_MENU_SETTINGS_LIST:
{
xmb_handle_t *xmb = (xmb_handle_t*)userdata;
xmb_update_dynamic_wallpaper(xmb, false);
break;
}
}

/* Use common lists for all drivers */
return -1;
#else
int ret = -1;
core_info_list_t *list = NULL;
settings_t *settings = config_get_ptr();
Expand Down Expand Up @@ -9143,9 +9137,6 @@ static int xmb_list_push(void *data, void *userdata,
= settings->paths.menu_content_show_settings_password;
const char *kiosk_mode_password = settings->paths.kiosk_mode_password;

/* Use common lists for all drivers */
return -1;

switch (type)
{
case DISPLAYLIST_LOAD_CONTENT_LIST:
Expand Down Expand Up @@ -9403,6 +9394,7 @@ static int xmb_list_push(void *data, void *userdata,
break;
}
return ret;
#endif
}

static bool xmb_menu_init_list(void *data)
Expand Down
2 changes: 2 additions & 0 deletions menu/menu_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -18785,6 +18785,8 @@ static bool setting_append_list(
general_write_handler,
general_read_handler);
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
(*list)[list_info->index - 1].action_left = &setting_uint_action_left_with_refresh;
(*list)[list_info->index - 1].action_right = &setting_uint_action_right_with_refresh;
(*list)[list_info->index - 1].get_string_representation =
&setting_get_string_representation_uint_xmb_menu_color_theme;
menu_settings_list_current_add_range(list, list_info, 0, XMB_THEME_LAST-1, 1, true, true);
Expand Down

0 comments on commit b5e0142

Please sign in to comment.