/* Set when in cycle (alt-tab) mode */
struct view *cycle_view;
+ struct theme *theme;
struct menu *rootmenu;
};
struct wlr_texture *xbm_iconify_inactive_unpressed;
};
-extern struct theme theme;
-
/**
* parse_hexstr - parse #rrggbb
* @hex: hex string to be parsed
void parse_hexstr(const char *hex, float *rgba);
/**
- * theme_init - read theme incl. buttons into global theme struct
+ * theme_init - read openbox theme and generate button textures
+ * @theme: global theme struct
+ * @renderer: wlr_renderer for creating button textures
* @theme_name: theme-name in <theme-dir>/<theme-name>/openbox-3/themerc
* Note <theme-dir> is obtained in theme-dir.c
*/
-void theme_init(struct wlr_renderer *renderer, const char *theme_name);
+void theme_init(struct theme *theme, struct wlr_renderer *renderer,
+ const char *theme_name);
/**
* theme_builin - apply built-in theme similar to Clearlooks
* Note: Only used if no theme can be found. Default values for individual
* theme options are as per openbox spec and are typically black/white.
*/
-void theme_builtin(void);
+void theme_builtin(struct theme *theme);
#endif /* __LABWC_THEME_H */
/**
* xbm_load - load theme xbm files into global theme struct
*/
-void xbm_load(struct wlr_renderer *renderer);
+void xbm_load(struct theme *theme, struct wlr_renderer *renderer);
#endif /* __LABWC_XBM_H */
server_init(&server);
server_start(&server);
- theme_init(server.renderer, rc.theme_name);
+ theme_init(&theme, server.renderer, rc.theme_name);
+ server.theme = &theme;
struct menu rootmenu = { 0 };
menu_init_rootmenu(&server, &rootmenu);
if (!menuitem) {
return NULL;
}
+ struct theme *theme = server->theme;
menuitem->geo_box.width = MENUWIDTH;
menuitem->geo_box.height = MENUHEIGHT;
menuitem->active_texture = texture_create(server, &menuitem->geo_box,
- text, theme.menu_items_active_bg_color,
- theme.menu_items_active_text_color);
+ text, theme->menu_items_active_bg_color,
+ theme->menu_items_active_text_color);
menuitem->inactive_texture = texture_create(server, &menuitem->geo_box,
- text, theme.menu_items_bg_color, theme.menu_items_text_color);
+ text, theme->menu_items_bg_color, theme->menu_items_text_color);
wl_list_insert(&menu->menuitems, &menuitem->link);
return menuitem;
}
return;
}
+ struct theme *theme = view->server->theme;
+
/* render border */
- float *color = theme.window_active_handle_bg_color;
+ float *color = theme->window_active_handle_bg_color;
enum deco_part border[4] = {
LAB_DECO_PART_TOP,
LAB_DECO_PART_RIGHT,
/* render title */
struct wlr_seat *seat = view->server->seat.seat;
if (view->surface == seat->keyboard_state.focused_surface) {
- color = theme.window_active_title_bg_color;
+ color = theme->window_active_title_bg_color;
} else {
- color = theme.window_inactive_title_bg_color;
+ color = theme->window_inactive_title_bg_color;
}
struct wlr_box box = deco_box(view, LAB_DECO_PART_TITLE);
render_rect(output, output_damage, &box, color);
if (view->surface == seat->keyboard_state.focused_surface) {
box = deco_box(view, LAB_DECO_BUTTON_CLOSE);
render_icon(output, output_damage, &box,
- theme.xbm_close_active_unpressed);
+ theme->xbm_close_active_unpressed);
box = deco_box(view, LAB_DECO_BUTTON_MAXIMIZE);
render_icon(output, output_damage, &box,
- theme.xbm_maximize_active_unpressed);
+ theme->xbm_maximize_active_unpressed);
box = deco_box(view, LAB_DECO_BUTTON_ICONIFY);
render_icon(output, output_damage, &box,
- theme.xbm_iconify_active_unpressed);
+ theme->xbm_iconify_active_unpressed);
} else {
box = deco_box(view, LAB_DECO_BUTTON_CLOSE);
render_icon(output, output_damage, &box,
- theme.xbm_close_inactive_unpressed);
+ theme->xbm_close_inactive_unpressed);
box = deco_box(view, LAB_DECO_BUTTON_MAXIMIZE);
render_icon(output, output_damage, &box,
- theme.xbm_maximize_inactive_unpressed);
+ theme->xbm_maximize_inactive_unpressed);
box = deco_box(view, LAB_DECO_BUTTON_ICONIFY);
render_icon(output, output_damage, &box,
- theme.xbm_iconify_inactive_unpressed);
+ theme->xbm_iconify_inactive_unpressed);
}
}
/* TODO: use rc.config_path */
rcxml_finish();
rcxml_read(NULL);
- theme_init(g_server->renderer, rc.theme_name);
+ theme_init(g_server->theme, g_server->renderer, rc.theme_name);
menu_reconfigure(g_server, g_server->rootmenu);
damage_all_outputs(g_server);
}
#include "theme/theme.h"
-void theme_builtin(void)
+void theme_builtin(struct theme *theme)
{
- parse_hexstr("#589bda", theme.window_active_title_bg_color);
- parse_hexstr("#3c7cb7", theme.window_active_handle_bg_color);
- parse_hexstr("#efece6", theme.window_inactive_title_bg_color);
- parse_hexstr("#ffffff", theme.window_active_button_unpressed_image_color);
- parse_hexstr("#000000", theme.window_inactive_button_unpressed_image_color);
- parse_hexstr("#fcfbfa", theme.menu_items_bg_color);
- parse_hexstr("#000000", theme.menu_items_text_color);
- parse_hexstr("#4a90d9", theme.menu_items_active_bg_color);
- parse_hexstr("#ffffff", theme.menu_items_active_text_color);
+ parse_hexstr("#589bda", theme->window_active_title_bg_color);
+ parse_hexstr("#3c7cb7", theme->window_active_handle_bg_color);
+ parse_hexstr("#efece6", theme->window_inactive_title_bg_color);
+ parse_hexstr("#ffffff", theme->window_active_button_unpressed_image_color);
+ parse_hexstr("#000000", theme->window_inactive_button_unpressed_image_color);
+ parse_hexstr("#fcfbfa", theme->menu_items_bg_color);
+ parse_hexstr("#000000", theme->menu_items_text_color);
+ parse_hexstr("#4a90d9", theme->menu_items_active_bg_color);
+ parse_hexstr("#ffffff", theme->menu_items_active_text_color);
}
return (bool)g_pattern_match_simple(pattern, string);
}
-static void entry(const char *key, const char *value)
+static void entry(struct theme *theme, const char *key, const char *value)
{
if (!key || !value) {
return;
}
if (match(key, "window.active.title.bg.color")) {
- parse_hexstr(value, theme.window_active_title_bg_color);
+ parse_hexstr(value, theme->window_active_title_bg_color);
} else if (match(key, "window.active.handle.bg.color")) {
- parse_hexstr(value, theme.window_active_handle_bg_color);
+ parse_hexstr(value, theme->window_active_handle_bg_color);
} else if (match(key, "window.inactive.title.bg.color")) {
- parse_hexstr(value, theme.window_inactive_title_bg_color);
+ parse_hexstr(value, theme->window_inactive_title_bg_color);
} else if (match(key, "window.active.button.unpressed.image.color")) {
- parse_hexstr(value, theme.window_active_button_unpressed_image_color);
+ parse_hexstr(value, theme->window_active_button_unpressed_image_color);
} else if (match(key, "window.inactive.button.unpressed.image.color")) {
- parse_hexstr(value, theme.window_inactive_button_unpressed_image_color);
+ parse_hexstr(value, theme->window_inactive_button_unpressed_image_color);
} else if (match(key, "menu.items.bg.color")) {
- parse_hexstr(value, theme.menu_items_bg_color);
+ parse_hexstr(value, theme->menu_items_bg_color);
} else if (match(key, "menu.items.text.color")) {
- parse_hexstr(value, theme.menu_items_text_color);
+ parse_hexstr(value, theme->menu_items_text_color);
} else if (match(key, "menu.items.active.bg.color")) {
- parse_hexstr(value, theme.menu_items_active_bg_color);
+ parse_hexstr(value, theme->menu_items_active_bg_color);
} else if (match(key, "menu.items.active.text.color")) {
- parse_hexstr(value, theme.menu_items_active_text_color);
+ parse_hexstr(value, theme->menu_items_active_text_color);
}
}
}
static void
-process_line(char *line)
+process_line(struct theme *theme, char *line)
{
if (line[0] == '\0' || line[0] == '#') {
return;
}
char *key = NULL, *value = NULL;
parse_config_line(line, &key, &value);
- entry(key, value);
+ entry(theme, key, value);
}
static void
-theme_read(const char *theme_name)
+theme_read(struct theme *theme, const char *theme_name)
{
FILE *stream = NULL;
char *line = NULL;
}
if (!stream) {
info("cannot find theme (%s), using built-in", theme_name);
- theme_builtin();
+ theme_builtin(theme);
return;
}
info("read themerc (%s)", themerc);
if (p) {
*p = '\0';
}
- process_line(line);
+ process_line(theme, line);
}
free(line);
fclose(stream);
}
void
-theme_init(struct wlr_renderer *renderer, const char *theme_name)
+theme_init(struct theme *theme, struct wlr_renderer *renderer,
+ const char *theme_name)
{
- theme_read(theme_name);
- xbm_load(renderer);
+ theme_read(theme, theme_name);
+ xbm_load(theme, renderer);
}
}
void
-xbm_load(struct wlr_renderer *r)
+xbm_load(struct theme *theme, struct wlr_renderer *r)
{
- parse_set_color(theme.window_active_button_unpressed_image_color);
- load_button(r, "close.xbm", &theme.xbm_close_active_unpressed,
+ parse_set_color(theme->window_active_button_unpressed_image_color);
+ load_button(r, "close.xbm", &theme->xbm_close_active_unpressed,
close_button_normal);
- load_button(r, "max.xbm", &theme.xbm_maximize_active_unpressed,
+ load_button(r, "max.xbm", &theme->xbm_maximize_active_unpressed,
max_button_normal);
- load_button(r, "iconify.xbm", &theme.xbm_iconify_active_unpressed,
+ load_button(r, "iconify.xbm", &theme->xbm_iconify_active_unpressed,
iconify_button_normal);
- parse_set_color(theme.window_inactive_button_unpressed_image_color);
- load_button(r, "close.xbm", &theme.xbm_close_inactive_unpressed,
+ parse_set_color(theme->window_inactive_button_unpressed_image_color);
+ load_button(r, "close.xbm", &theme->xbm_close_inactive_unpressed,
close_button_normal);
- load_button(r, "max.xbm", &theme.xbm_maximize_inactive_unpressed,
+ load_button(r, "max.xbm", &theme->xbm_maximize_inactive_unpressed,
max_button_normal);
- load_button(r, "iconify.xbm", &theme.xbm_iconify_inactive_unpressed,
+ load_button(r, "iconify.xbm", &theme->xbm_iconify_inactive_unpressed,
iconify_button_normal);
}