Skip to content

Commit

Permalink
rules: parse and apply the shader option
Browse files Browse the repository at this point in the history
Fixes #1312

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
  • Loading branch information
yshui committed Aug 13, 2024
1 parent 636cb5b commit fda04bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/config_libconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@ parse_rule(struct list_node *rules, config_setting_t *setting, struct script ***
if (animations) {
parse_animations(wopts->animations, animations, out_scripts);
}

config_setting_lookup_string(setting, "shader", &wopts->shader);
return rule;
}

Expand Down Expand Up @@ -764,6 +766,14 @@ bool parse_config_libconfig(options_t *opt, const char *config_file) {
config_setting_t *rules = config_lookup(&cfg, "rules");
if (rules) {
parse_rules(&opt->rules, rules, &opt->all_scripts);
c2_condition_list_foreach(&opt->rules, i) {
auto data = (struct window_maybe_options *)c2_condition_get_data(i);
if (data->shader == NULL) {
continue;
}
data->shader = locate_auxiliary_file(
"shaders", data->shader, config_get_include_dir(&cfg));
}
}

// --dbus
Expand Down
10 changes: 10 additions & 0 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -2253,6 +2253,16 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
log_error("Failed to load window shader source file");
}

c2_condition_list_foreach(&ps->o.rules, i) {
auto data = (struct window_maybe_options *)c2_condition_get_data(i);
if (data->shader == NULL) {
continue;
}
if (load_shader_source(ps, data->shader)) {
log_error("Failed to load shader source file for window rules");
}
}

if (log_get_level_tls() <= LOG_LEVEL_DEBUG) {
HASH_ITER2(ps->shaders, shader) {
log_debug("Shader %s:", shader->key);
Expand Down

0 comments on commit fda04bd

Please sign in to comment.