Skip to content

Commit

Permalink
implement transition rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Arian8j2 committed Jan 25, 2022
1 parent a211a09 commit e678419
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/config_libconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,37 @@ timing_function parse_timing_function(const char *timing_name) {
return NULL;
}

static inline void parse_cfg_condlst_trns(options_t *opt, const config_t *pcfg, const char *name) {
config_setting_t *setting = config_lookup(pcfg, name);
if (setting) {
int length = config_setting_length(setting);

for (int i = 0; i < length; i++) {
const char *elem = config_setting_get_string_elem(setting, i);

char rule[512];
unsigned long elem_index = 0;

for (int rule_index = 0; elem_index < strlen(elem); elem_index++) {
char character = elem[elem_index];
if (character == ':') {
rule[rule_index] = '\0';
break;
}


if (!isspace(character)) {
rule[rule_index] = character;
rule_index++;
}
}

int *direction = (int*) parse_transition_direction(rule);
c2_parse(&opt->transition_rules, &elem[elem_index + 1], direction);
}
}
}

/**
* Parse a configuration file from default location.
*
Expand Down Expand Up @@ -740,6 +771,8 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
opt->transition_timing_function = res;
}
}

parse_cfg_condlst_trns(opt, &cfg, "transition-rule");
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,7 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
c2_list_postprocess(ps, ps->o.invert_color_list) &&
c2_list_postprocess(ps, ps->o.opacity_rules) &&
c2_list_postprocess(ps, ps->o.rounded_corners_blacklist) &&
c2_list_postprocess(ps, ps->o.transition_rules) &&
c2_list_postprocess(ps, ps->o.focus_blacklist))) {
log_error("Post-processing of conditionals failed, some of your rules "
"might not work");
Expand Down Expand Up @@ -2350,6 +2351,7 @@ static void session_destroy(session_t *ps) {
free_wincondlst(&ps->o.paint_blacklist);
free_wincondlst(&ps->o.unredir_if_possible_blacklist);
free_wincondlst(&ps->o.rounded_corners_blacklist);
free_wincondlst(&ps->o.transition_rules);

// Free tracked atom list
{
Expand Down
9 changes: 9 additions & 0 deletions src/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,14 @@ void win_update_opacity_rule(session_t *ps, struct managed_win *w) {
w->opacity_is_set = is_set;
}

void win_update_transition_rule(session_t *ps, struct managed_win *w) {
void *val;
if (c2_match(ps, w, ps->o.transition_rules, &val)) {
// uses multiple casters to trick compiler to not give warnings
w->transition_direction = (unsigned int)(long)val;
}
}

/**
* Function to be called on window data changes.
*
Expand All @@ -1129,6 +1137,7 @@ void win_on_factor_change(session_t *ps, struct managed_win *w) {
// state of the window
win_update_focused(ps, w);

win_update_transition_rule(ps, w);
win_determine_shadow(ps, w);
win_determine_clip_shadow_above(ps, w);
win_determine_invert_color(ps, w);
Expand Down

0 comments on commit e678419

Please sign in to comment.