Store themes as references to avoid passing large structs by value
This commit is contained in:
parent
d25f504b15
commit
1ebf67b850
3 changed files with 8 additions and 8 deletions
2
main.c
2
main.c
|
|
@ -222,7 +222,7 @@ static void toggle_theme(void) {
|
|||
}
|
||||
|
||||
static void set_theme(bool is_alternate) {
|
||||
ul_theme_apply(&(ul_themes_themes[is_alternate ? conf_opts.theme.alternate_id : conf_opts.theme.default_id]));
|
||||
ul_theme_apply(ul_themes_themes[is_alternate ? conf_opts.theme.alternate_id : conf_opts.theme.default_id]);
|
||||
}
|
||||
|
||||
static void toggle_pw_btn_clicked_cb(lv_event_t *event) {
|
||||
|
|
|
|||
12
themes.c
12
themes.c
|
|
@ -659,16 +659,16 @@ static const ul_theme ul_themes_pmos_dark = {
|
|||
*/
|
||||
|
||||
const int ul_themes_num_themes = 4;
|
||||
const ul_theme ul_themes_themes[] = {
|
||||
ul_themes_breezy_light,
|
||||
ul_themes_breezy_dark,
|
||||
ul_themes_pmos_light,
|
||||
ul_themes_pmos_dark
|
||||
const ul_theme *ul_themes_themes[] = {
|
||||
&ul_themes_breezy_light,
|
||||
&ul_themes_breezy_dark,
|
||||
&ul_themes_pmos_light,
|
||||
&ul_themes_pmos_dark
|
||||
};
|
||||
|
||||
ul_themes_theme_id_t ul_themes_find_theme_with_name(const char *name) {
|
||||
for (int i = 0; i < ul_themes_num_themes; ++i) {
|
||||
if (strcmp(ul_themes_themes[i].name, name) == 0) {
|
||||
if (strcmp(ul_themes_themes[i]->name, name) == 0) {
|
||||
ul_log(UL_LOG_LEVEL_VERBOSE, "Found theme: %s\n", name);
|
||||
return i;
|
||||
}
|
||||
|
|
|
|||
2
themes.h
2
themes.h
|
|
@ -35,7 +35,7 @@ typedef enum {
|
|||
|
||||
/* Themes */
|
||||
extern const int ul_themes_num_themes;
|
||||
extern const ul_theme ul_themes_themes[];
|
||||
extern const ul_theme *ul_themes_themes[];
|
||||
|
||||
/**
|
||||
* Find the first theme with a given name.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue