Skip to content

animation: add animation exclude #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: implement-window-animations
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/backend/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,9 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {

// Only animate opacity here if we are resizing
// a transparent window
double animation_progress_opacity = w->animation_progress < ps->o.animation_opacity_min ? ps->o.animation_opacity_min : w->animation_progress;
process_window_for_painting(ps, w, w->win_image,
w->opacity >= 1 ? 1.0 : w->animation_progress,
w->opacity >= 1 ? 1.0 : animation_progress_opacity,
&reg_bound, &reg_visible,
&reg_paint, &reg_paint_in_bound);

Expand All @@ -489,7 +490,7 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) {
// move so slightly they will keep flickering
if (resizing) {
process_window_for_painting(ps, w, w->old_win_image,
1.0 - w->animation_progress,
1.0 - animation_progress_opacity,
&reg_bound, &reg_visible,
&reg_paint, &reg_paint_in_bound);
}
Expand Down
4 changes: 3 additions & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable,
.animation_window_mass = 1.0,
.animation_dampening = 25,
.animation_clamping = true,
.animation_opacity_min = 0.0,

.inactive_opacity = 1.0,
.inactive_opacity_override = false,
Expand Down Expand Up @@ -610,7 +611,8 @@ char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable,

.track_leader = false,

.rounded_corners_blacklist = NULL
.rounded_corners_blacklist = NULL,
.animation_blacklist = NULL
};
// clang-format on

Expand Down
5 changes: 4 additions & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ typedef struct options {
double animation_dampening;
/// Whether to clamp animations
bool animation_clamping;
/// TODO: window animation blacklist
/// TODO: open/close animations
/// Animation blacklist. A linked list of conditions.
c2_lptr_t *animation_blacklist;
/// moveing or resizing animation opacity minim, for reduce flicker
double animation_opacity_min;

// === Opacity ===
/// Default opacity for inactive windows.
Expand Down
4 changes: 4 additions & 0 deletions src/config_libconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,10 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
config_lookup_float(&cfg, "animation-dampening", &opt->animation_dampening);
// --animation-clamping
lcfg_lookup_bool(&cfg, "animation-clamping", &opt->animation_clamping);
// --animations-exclude
parse_cfg_condlst(&cfg, &opt->animation_blacklist, "animation-exclude");
// --animation-opacity-min
config_lookup_float(&cfg, "animation-opacity-min", &opt->animation_opacity_min);
// --focus-exclude
parse_cfg_condlst(&cfg, &opt->focus_blacklist, "focus-exclude");
// --invert-color-include
Expand Down
16 changes: 16 additions & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ static void usage(const char *argv0, int ret) {
"--animation-clamping\n"
" Whether to clamp animations (default: true)\n"
"\n"
"--animation-opacity-min (default: 0.0).\n"
" Minimum opacity for pixmap blending during window animation.\n"
"\n"
"--animation-exclude condition\n"
" Exclude conditions for animation.\n"
"\n"
"-i opacity\n"
" Opacity of inactive windows. (0.1 - 1.0)\n"
"\n"
Expand Down Expand Up @@ -924,6 +930,16 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable,
}
break;
}
case 811: {
// --animation-exclude
condlst_add(&opt->animation_blacklist, optarg);
break;
}
case 812: {
// --animation-opacity-min
opt->animation_opacity_min = atof(optarg);
break;
}
default: usage(argv[0], 1); break;
#undef P_CASEBOOL
}
Expand Down
1 change: 1 addition & 0 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,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.animation_blacklist) &&
c2_list_postprocess(ps, ps->o.focus_blacklist))) {
log_error("Post-processing of conditionals failed, some of your rules "
"might not work");
Expand Down
23 changes: 19 additions & 4 deletions src/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,8 @@ void win_process_update_flags(session_t *ps, struct managed_win *w) {
}

// Ignore animations all together if set to none on window type basis
if (ps->o.wintype_option[w->window_type].animation == 0) {
w->g = w->pending_g;

// Update window geometry
} else if (ps->o.animations) {
if (win_should_animate(ps, w)) {
if (!was_visible) {
// Set window-open animation
init_animation(ps, w);
Expand Down Expand Up @@ -989,6 +986,24 @@ bool win_should_fade(session_t *ps, const struct managed_win *w) {
return ps->o.wintype_option[w->window_type].fade;
}

/**
* Determine if a window should animate.
*/
bool win_should_animate(session_t *ps, const struct managed_win *w) {
if (!ps->o.animations) {
return false;
}
if (ps->o.wintype_option[w->window_type].animation == 0) {
log_debug("Animation disabled by window_type");
return false;
}
if (c2_match(ps, w, ps->o.animation_blacklist, NULL)) {
log_debug("Animation disabled by animation_exclude");
return false;
}
return true;
}

/**
* Reread _COMPTON_SHADOW property from a window.
*
Expand Down
3 changes: 3 additions & 0 deletions src/win.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ bool win_check_flags_all(struct managed_win *w, uint64_t flags);
/// Mark properties as stale for a window
void win_set_properties_stale(struct managed_win *w, const xcb_atom_t *prop, int nprops);

/// Determine if a window should animate
bool attr_pure win_should_animate(session_t *ps, const struct managed_win *w);

static inline attr_unused void win_set_property_stale(struct managed_win *w, xcb_atom_t prop) {
return win_set_properties_stale(w, (xcb_atom_t[]){prop}, 1);
}
Expand Down