Move the initialization of wintype options into common function
Make sure the wintype options are properly initialized even when there is no config file specified/supported. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
94d500bd53
commit
8f05b03411
44
src/config.c
44
src/config.c
|
@ -340,3 +340,47 @@ condlst_add(session_t *ps, c2_lptr_t **pcondlst, const char *pattern) {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void parse_config(session_t *ps, bool *shadow_enable, bool *fading_enable,
|
||||||
|
win_option_mask_t *winopt_mask) {
|
||||||
|
#ifdef CONFIG_LIBCONFIG
|
||||||
|
parse_config_libconfig(ps, shadow_enable, fading_enable, winopt_mask);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Apply default wintype options that does not depends on global options.
|
||||||
|
// For example, wintype shadow option will depend on the global shadow
|
||||||
|
// option, so it is not set here.
|
||||||
|
//
|
||||||
|
// Except desktop windows are always drawn without shadow.
|
||||||
|
if (!winopt_mask[WINTYPE_DESKTOP].shadow) {
|
||||||
|
winopt_mask[WINTYPE_DESKTOP].shadow = true;
|
||||||
|
ps->o.wintype_option[WINTYPE_DESKTOP].shadow = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Focused/unfocused state only apply to a few window types, all other windows
|
||||||
|
// are always considered focused.
|
||||||
|
const wintype_t nofocus_type[] =
|
||||||
|
{ WINTYPE_UNKNOWN, WINTYPE_NORMAL, WINTYPE_UTILITY };
|
||||||
|
for (unsigned long i = 0; i < ARR_SIZE(nofocus_type); i++) {
|
||||||
|
if (!winopt_mask[nofocus_type[i]].focus) {
|
||||||
|
winopt_mask[nofocus_type[i]].focus = true;
|
||||||
|
ps->o.wintype_option[nofocus_type[i]].focus = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (unsigned long i = 0; i < NUM_WINTYPES; i++) {
|
||||||
|
if (!winopt_mask[i].focus) {
|
||||||
|
winopt_mask[i].focus = true;
|
||||||
|
ps->o.wintype_option[i].focus = true;
|
||||||
|
}
|
||||||
|
if (!winopt_mask[i].full_shadow) {
|
||||||
|
winopt_mask[i].full_shadow = true;
|
||||||
|
ps->o.wintype_option[i].full_shadow = false;
|
||||||
|
}
|
||||||
|
if (!winopt_mask[i].opacity) {
|
||||||
|
winopt_mask[i].opacity = true;
|
||||||
|
// Opacity is not set to a concrete number here because the opacity logic
|
||||||
|
// is complicated, and needs an "unset" state
|
||||||
|
ps->o.wintype_option[i].opacity = NAN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
11
src/config.h
11
src/config.h
|
@ -25,16 +25,11 @@ bool parse_rule_opacity(session_t *, const char *);
|
||||||
bool condlst_add(session_t *, c2_lptr_t **, const char *);
|
bool condlst_add(session_t *, c2_lptr_t **, const char *);
|
||||||
|
|
||||||
#ifdef CONFIG_LIBCONFIG
|
#ifdef CONFIG_LIBCONFIG
|
||||||
FILE *
|
|
||||||
open_config_file(char *cpath, char **path);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
parse_cfg_condlst(session_t *ps, const config_t *pcfg, c2_lptr_t **pcondlst,
|
parse_config_libconfig(session_t *ps, bool *shadow_enable,
|
||||||
const char *name);
|
bool *fading_enable, win_option_mask_t *winopt_mask);
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
parse_config(session_t *ps, bool *shadow_enable,
|
parse_config(session_t *ps, bool *shadow_enable,
|
||||||
bool *fading_enable, win_option_mask_t *winopt_mask);
|
bool *fading_enable, win_option_mask_t *winopt_mask);
|
||||||
#else
|
|
||||||
static inline void parse_config() {}
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -156,8 +156,8 @@ parse_cfg_condlst_opct(session_t *ps, const config_t *pcfg, const char *name) {
|
||||||
/**
|
/**
|
||||||
* Parse a configuration file from default location.
|
* Parse a configuration file from default location.
|
||||||
*/
|
*/
|
||||||
void parse_config(session_t *ps, bool *shadow_enable, bool *fading_enable,
|
void parse_config_libconfig(session_t *ps, bool *shadow_enable,
|
||||||
win_option_mask_t *winopt_mask)
|
bool *fading_enable, win_option_mask_t *winopt_mask)
|
||||||
{
|
{
|
||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
@ -429,42 +429,5 @@ void parse_config(session_t *ps, bool *shadow_enable, bool *fading_enable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply default wintype options that does not depends on global options.
|
|
||||||
// For example, wintype shadow option will depend on the global shadow
|
|
||||||
// option, so it is not set here.
|
|
||||||
//
|
|
||||||
// Except desktop windows are always drawn without shadow.
|
|
||||||
if (!winopt_mask[WINTYPE_DESKTOP].shadow) {
|
|
||||||
winopt_mask[WINTYPE_DESKTOP].shadow = true;
|
|
||||||
ps->o.wintype_option[WINTYPE_DESKTOP].shadow = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Focused/unfocused state only apply to a few window types, all other windows
|
|
||||||
// are always considered focused.
|
|
||||||
const wintype_t nofocus_type[] =
|
|
||||||
{ WINTYPE_UNKNOWN, WINTYPE_NORMAL, WINTYPE_UTILITY };
|
|
||||||
for (unsigned long i = 0; i < ARR_SIZE(nofocus_type); i++) {
|
|
||||||
if (!winopt_mask[nofocus_type[i]].focus) {
|
|
||||||
winopt_mask[nofocus_type[i]].focus = true;
|
|
||||||
ps->o.wintype_option[nofocus_type[i]].focus = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (unsigned long i = 0; i < NUM_WINTYPES; i++) {
|
|
||||||
if (!winopt_mask[i].focus) {
|
|
||||||
winopt_mask[i].focus = true;
|
|
||||||
ps->o.wintype_option[i].focus = true;
|
|
||||||
}
|
|
||||||
if (!winopt_mask[i].full_shadow) {
|
|
||||||
winopt_mask[i].full_shadow = true;
|
|
||||||
ps->o.wintype_option[i].full_shadow = false;
|
|
||||||
}
|
|
||||||
if (!winopt_mask[i].opacity) {
|
|
||||||
winopt_mask[i].opacity = true;
|
|
||||||
// Opacity is not set to a concrete number here because the opacity logic
|
|
||||||
// is complicated, and needs an "unset" state
|
|
||||||
ps->o.wintype_option[i].opacity = NAN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
config_destroy(&cfg);
|
config_destroy(&cfg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue