Skip to content

Commit

Permalink
closes #26
Browse files Browse the repository at this point in the history
  • Loading branch information
FT-Labs committed Nov 22, 2023
1 parent b73e6a0 commit 9b06fae
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 65 deletions.
2 changes: 1 addition & 1 deletion src/backend/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ void paint_all_new(session_t *ps, struct managed_win *t) {
}

// 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,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/gl/gl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ void x_rect_to_coords(int nrects, const rect_t *rects, coord_t image_dst,
int extent_height, int texture_height, int root_height,
bool y_inverted, GLint *coord, GLuint *indices) {
image_dst.y = root_height - image_dst.y;
image_dst.y -= extent_height;
image_dst.y -= extent_height;


for (int i = 0; i < nrects; i++) {
Expand Down
47 changes: 24 additions & 23 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,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 <= 0.999999999 &&
!isnan(w->animation_progress) && w->animation_progress != 1.0 &&
ps->o.wintype_option[w->window_type].animation != 0 &&
win_is_mapped_in_x(w))
{
Expand All @@ -814,15 +814,15 @@ paint_preprocess(session_t *ps, bool *fade_running, bool *animation_running) {
w->animation_dest_center_y - w->animation_center_y;
double neg_displacement_w = w->animation_dest_w - w->animation_w;
double neg_displacement_h = w->animation_dest_h - w->animation_h;
double animation_stiffness = ps->o.animation_stiffness;
if (!(w->animation_is_tag & ANIM_IN_TAG)) {
if (w->animation_is_tag & ANIM_SLOW)
animation_stiffness = ps->o.animation_stiffness_tag_change;
else if (w->animation_is_tag & ANIM_FAST)
animation_stiffness = ps->o.animation_stiffness_tag_change * 1.5;
}
if (w->state == WSTATE_FADING && !(w->animation_is_tag & ANIM_FADE))
w->opacity_target = win_calc_opacity_target(ps, w);
double animation_stiffness = ps->o.animation_stiffness;
if (!(w->animation_is_tag & ANIM_IN_TAG)) {
if (w->animation_is_tag & ANIM_SLOW)
animation_stiffness = ps->o.animation_stiffness_tag_change;
else if (w->animation_is_tag & ANIM_FAST)
animation_stiffness = ps->o.animation_stiffness_tag_change * 1.5;
}
if (w->state == WSTATE_FADING && !(w->animation_is_tag & ANIM_FADE))
w->opacity_target = win_calc_opacity_target(ps, w);
double acceleration_x =
(animation_stiffness * neg_displacement_x -
ps->o.animation_dampening * w->animation_velocity_x) /
Expand Down Expand Up @@ -925,17 +925,18 @@ paint_preprocess(session_t *ps, bool *fade_running, bool *animation_running) {
w->g.width = (uint16_t)new_animation_w;
w->g.height = (uint16_t)new_animation_h;

if (w->animation_is_tag > ANIM_IN_TAG && (((w->animation_is_tag & ANIM_FADE) && w->opacity_target == w->opacity) || ((w->g.width == 0 || w->g.height == 0) && (w->animation_dest_w == 0 || w->animation_dest_h == 0)))) {
w->g.x = w->pending_g.x;
w->g.y = w->pending_g.y;
if (ps->o.animation_for_next_tag < OPEN_WINDOW_ANIMATION_ZOOM) {
w->g.width = w->pending_g.width;
w->g.height = w->pending_g.height;
} else {
w->g.width = 0;
w->g.height = 0;
}
}

if (w->animation_is_tag > ANIM_IN_TAG && (((w->animation_is_tag & ANIM_FADE) && w->opacity_target == w->opacity) || ((w->g.width == 0 || w->g.height == 0) && (w->animation_dest_w == 0 || w->animation_dest_h == 0)))) {
w->g.x = w->pending_g.x;
w->g.y = w->pending_g.y;
if (ps->o.animation_for_next_tag < OPEN_WINDOW_ANIMATION_ZOOM) {
w->g.width = w->pending_g.width;
w->g.height = w->pending_g.height;
} else {
w->g.width = 0;
w->g.height = 0;
}
}

// Submit window size change
if (size_changed) {
Expand Down Expand Up @@ -2595,6 +2596,8 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
ev_init(&ps->draw_timer, 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);
Expand Down Expand Up @@ -2685,8 +2688,6 @@ static session_t *session_init(int argc, char **argv, Display *dpy,

write_pid(ps);

ev_init(&ps->animation_timer, animation_timer_callback);

if (fork && stderr_logger) {
// Remove the stderr logger if we will fork
log_remove_target_tls(stderr_logger);
Expand Down
49 changes: 16 additions & 33 deletions src/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,17 +476,11 @@ static void win_update_properties(session_t *ps, struct managed_win *w) {
static void init_animation(session_t *ps, struct managed_win *w) {
CLEAR_MASK(w->animation_is_tag)
static int32_t randr_mon_center_x, randr_mon_center_y;
if (w->randr_monitor == -1) {
win_update_monitor(&ps->monitors, w);
if (w->randr_monitor != -1) {
auto e = pixman_region32_extents(&ps->monitors.regions[w->randr_monitor]);
randr_mon_center_x = (e->x2 + e->x1) / 2, randr_mon_center_y = (e->y2 + e->y1) / 2;
} else {
randr_mon_center_x = ps->root_width / 2, randr_mon_center_y = ps->root_height / 2;
}
} else {
if (w->randr_monitor != -1) {
auto e = pixman_region32_extents(&ps->monitors.regions[w->randr_monitor]);
randr_mon_center_x = (e->x2 + e->x1) / 2, randr_mon_center_y = (e->y2 + e->y1) / 2;
} else {
randr_mon_center_x = ps->root_width / 2, randr_mon_center_y = ps->root_height / 2;
}
static double *anim_x, *anim_y, *anim_w, *anim_h;
enum open_window_animation animation;
Expand Down Expand Up @@ -689,7 +683,6 @@ void win_process_update_flags(session_t *ps, struct managed_win *w) {

// Determine if a window should animate
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;
else if (w->pending_g.y > 0 && w->g.y < 0 && abs(w->pending_g.y - w->g.y) >= w->pending_g.height)
Expand Down Expand Up @@ -760,12 +753,12 @@ void win_process_update_flags(session_t *ps, struct managed_win *w) {
w->g = w->pending_g;
}

if (win_check_flags_all(w, WIN_FLAGS_SIZE_STALE)) {
win_on_win_size_change(ps, w);
win_update_bounding_shape(ps, w);
damaged = true;
win_clear_flags(w, WIN_FLAGS_SIZE_STALE);
}
if (win_check_flags_all(w, WIN_FLAGS_SIZE_STALE)) {
win_on_win_size_change(ps, w);
win_update_bounding_shape(ps, w);
damaged = true;
win_clear_flags(w, WIN_FLAGS_SIZE_STALE);
}

if (win_check_flags_all(w, WIN_FLAGS_POSITION_STALE)) {
damaged = true;
Expand Down Expand Up @@ -1142,8 +1135,8 @@ bool win_should_fade(session_t *ps, const struct managed_win *w) {
* 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.animations) {
return true;
}
if (ps->o.wintype_option[w->window_type].animation == 0) {
log_debug("Animation disabled by window_type");
Expand Down Expand Up @@ -1496,10 +1489,8 @@ void win_on_factor_change(session_t *ps, struct managed_win *w) {
// focused state of the window
win_update_focused(ps, w);

if (w->animation_progress > 0.99999999 || (w->animation_progress == 0.0 && ps->animation_time != 0L)) {
win_determine_shadow(ps, w);
win_determine_clip_shadow_above(ps, w);
}
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);
Expand Down Expand Up @@ -1810,7 +1801,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 = 0.0, // updated by window geometry changes
.animation_progress = 1.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
Expand Down Expand Up @@ -2697,8 +2688,8 @@ void unmap_win_start(session_t *ps, struct managed_win *w) {
w->opacity_target = win_calc_opacity_target(ps, w);

if (ps->o.animations && ps->o.animation_for_unmap_window != OPEN_WINDOW_ANIMATION_NONE && ps->o.wintype_option[w->window_type].animation) {
w->dwm_mask = ANIM_UNMAP;
init_animation(ps, w);
w->dwm_mask = ANIM_UNMAP;
init_animation(ps, w);

double x_dist = w->animation_dest_center_x - w->animation_center_x;
double y_dist = w->animation_dest_center_y - w->animation_center_y;
Expand Down Expand Up @@ -3059,10 +3050,6 @@ win_is_fullscreen_xcb(xcb_connection_t *c, const struct atom *a, const xcb_windo
void win_set_flags(struct managed_win *w, uint64_t flags) {
log_debug("Set flags %" PRIu64 " to window %#010x (%s)", flags, w->base.id, w->name);
if (unlikely(w->state == WSTATE_DESTROYING)) {
if (w->animation_progress != 1.0) {
// Return because animation will trigger some of the flags
return;
}
log_error("Flags set on a destroyed window %#010x (%s)", w->base.id, w->name);
return;
}
Expand All @@ -3075,10 +3062,6 @@ void win_clear_flags(struct managed_win *w, uint64_t flags) {
log_debug("Clear flags %" PRIu64 " from window %#010x (%s)", flags, w->base.id,
w->name);
if (unlikely(w->state == WSTATE_DESTROYING)) {
if (w->animation_progress != 1.0) {
// Return because animation will trigger some of the flags
return;
}
log_warn("Flags cleared on a destroyed window %#010x (%s)", w->base.id,
w->name);
return;
Expand Down
14 changes: 7 additions & 7 deletions src/win.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ struct managed_win {
/// opacity state, window geometry, window mapped/unmapped state,
/// window mode of the windows above. DOES NOT INCLUDE the body of THIS WINDOW.
/// NULL means reg_ignore has not been calculated for this window.
/// 1 = tag prev , 2 = tag next, 4 = unmap
uint32_t dwm_mask;
/// 1 = tag prev , 2 = tag next, 4 = unmap
uint32_t dwm_mask;
rc_region_t *reg_ignore;
/// Whether the reg_ignore of all windows beneath this window are valid
bool reg_ignore_valid;
Expand Down Expand Up @@ -198,11 +198,11 @@ struct managed_win {
/// Inverse of the window distance at the start of animation, for
/// tracking animation progress
double animation_inv_og_distance;
/// Animation info if it is a tag change & check if its changing window sizes
/// 0: no tag change
/// 1: normal tag change animation
/// 2: tag change animation that effects window size
uint16_t animation_is_tag;
/// Animation info if it is a tag change & check if its changing window sizes
/// 0: no tag change
/// 1: normal tag change animation
/// 2: tag change animation that effects window size
uint16_t animation_is_tag;

// Client window related members
/// ID of the top-level client window of the window.
Expand Down

0 comments on commit 9b06fae

Please sign in to comment.