From f5e83515070263e87bda2aa02852d2236265b711 Mon Sep 17 00:00:00 2001 From: Arda Atci Date: Sat, 4 Feb 2023 07:09:20 +0300 Subject: [PATCH] shadow fix --- src/backend/backend.c | 2 +- src/picom.c | 8 ++++---- src/win.c | 12 +++++++----- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/backend/backend.c b/src/backend/backend.c index d53577c..d373f82 100644 --- a/src/backend/backend.c +++ b/src/backend/backend.c @@ -497,7 +497,7 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) { } // Draw window on target - bool is_animating = 0 <= w->animation_progress && w->animation_progress < 1.0; + bool is_animating = 0 < w->animation_progress && w->animation_progress < 1.0; if (w->frame_opacity == 1 && !is_animating) { ps->backend_data->ops->compose(ps->backend_data, w->win_image, window_coord, NULL, dest_coord, diff --git a/src/picom.c b/src/picom.c index 7357c69..2e813fb 100644 --- a/src/picom.c +++ b/src/picom.c @@ -739,7 +739,7 @@ paint_preprocess(session_t *ps, bool *fade_running, bool *animation_running) { // IMPORTANT: These window animation steps must happen before any other // [pre]processing. This is because it changes the window's geometry. if (ps->o.animations && - !isnan(w->animation_progress) && w->animation_progress != 1.0 && + !isnan(w->animation_progress) && w->animation_progress <= 0.999999999 && ps->o.wintype_option[w->window_type].animation != 0 && win_is_mapped_in_x(w)) { @@ -893,14 +893,14 @@ paint_preprocess(session_t *ps, bool *fade_running, bool *animation_running) { // We can't check for 1 here as sometimes 1 = 0.999999999999999 // in case of floating numbers if (w->animation_progress >= 0.999999999) { + win_process_update_flags(ps, w); w->animation_progress = 1; w->animation_velocity_x = 0.0; w->animation_velocity_y = 0.0; w->animation_velocity_w = 0.0; w->animation_velocity_h = 0.0; - w->opacity = win_calc_opacity_target(ps, w); + w->opacity = win_calc_opacity_target(ps, w); } - *animation_running = true; } @@ -2412,7 +2412,6 @@ static session_t *session_init(int argc, char **argv, Display *dpy, ev_idle_init(&ps->draw_idle, draw_callback); ev_init(&ps->fade_timer, fade_timer_callback); - ev_init(&ps->animation_timer, animation_timer_callback); // Set up SIGUSR1 signal handler to reset program ev_signal_init(&ps->usr1_signal, reset_enable, SIGUSR1); @@ -2512,6 +2511,7 @@ static session_t *session_init(int argc, char **argv, Display *dpy, } free_winprop(&prop); } + ev_init(&ps->animation_timer, animation_timer_callback); if (fork && stderr_logger) { // Remove the stderr logger if we will fork diff --git a/src/win.c b/src/win.c index a710543..bf4299f 100644 --- a/src/win.c +++ b/src/win.c @@ -674,9 +674,9 @@ void win_process_update_flags(session_t *ps, struct managed_win *w) { if (win_should_animate(ps, w)) { win_update_bounding_shape(ps, w); if (w->pending_g.y < 0 && w->g.y > 0 && abs(w->pending_g.y - w->g.y) >= w->pending_g.height) - w->dwm_mask = ANIM_PREV_TAG; + w->dwm_mask = ANIM_PREV_TAG; else if (w->pending_g.y > 0 && w->g.y < 0 && abs(w->pending_g.y - w->g.y) >= w->pending_g.height) - w->dwm_mask = ANIM_NEXT_TAG; + w->dwm_mask = ANIM_NEXT_TAG; if (!was_visible || w->dwm_mask) { @@ -1467,8 +1467,10 @@ void win_on_factor_change(session_t *ps, struct managed_win *w) { // focused state of the window win_update_focused(ps, w); - win_determine_shadow(ps, w); - win_determine_clip_shadow_above(ps, w); + if (w->animation_progress > 0.9999 || w->animation_progress < 0.0001) { + win_determine_shadow(ps, w); + win_determine_clip_shadow_above(ps, w); + } win_determine_invert_color(ps, w); win_determine_blur_background(ps, w); win_determine_rounded_corners(ps, w); @@ -1779,7 +1781,7 @@ struct win *fill_win(session_t *ps, struct win *w) { .animation_velocity_y = 0.0, // updated by window geometry changes .animation_velocity_w = 0.0, // updated by window geometry changes .animation_velocity_h = 0.0, // updated by window geometry changes - .animation_progress = 1.0, // updated by window geometry changes + .animation_progress = 0.0, // updated by window geometry changes .animation_inv_og_distance = NAN, // updated by window geometry changes .reg_ignore_valid = false, // set to true when damaged .flags = WIN_FLAGS_IMAGES_NONE, // updated by property/attributes/etc