Skip to content

Commit

Permalink
dirty experimental patch
Browse files Browse the repository at this point in the history
  • Loading branch information
fdev31 committed Mar 4, 2023
1 parent 893a4e8 commit d6197fa
Showing 1 changed file with 34 additions and 39 deletions.
73 changes: 34 additions & 39 deletions src/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "types.h"
#include "uthash_extra.h"
#include "utils.h"
#include "win_defs.h"
#include "x.h"

#ifdef CONFIG_DBUS
Expand Down Expand Up @@ -180,6 +181,14 @@ static inline void group_on_factor_change(session_t *ps, xcb_window_t leader) {
}
}

static inline bool is_transient(session_t *ps, const struct managed_win *w) {
return
(w->window_type < WINTYPE_NORMAL || w->window_type > WINTYPE_NORMAL)
||
((w->window_type != WINTYPE_TOOLTIP)
&& wid_has_prop(ps, w->client_win, ps->atoms->aWM_TRANSIENT_FOR));
}

static inline const char *win_get_name_if_managed(const struct win *w) {
if (!w->managed) {
return "(unmanaged)";
Expand Down Expand Up @@ -493,42 +502,28 @@ static void init_animation(session_t *ps, struct managed_win *w) {
else
animation = ps->o.animation_for_open_window;

if (w->window_type != WINTYPE_TOOLTIP &&
wid_has_prop(ps, w->client_win, ps->atoms->aWM_TRANSIENT_FOR)) {
animation = ps->o.animation_for_transient_window;
}


anim_x = &w->animation_center_x, anim_y = &w->animation_center_y;
anim_w = &w->animation_w, anim_h = &w->animation_h;

if (w->dwm_mask & ANIM_PREV_TAG) {
animation = ps->o.animation_for_prev_tag;

if (ps->o.enable_fading_prev_tag) {
w->opacity_target_old = fmax(w->opacity_target, w->opacity_target_old);
w->state = WSTATE_FADING;
w->animation_is_tag |= ANIM_FADE;
}
if (ps->o.animation_for_prev_tag >= OPEN_WINDOW_ANIMATION_ZOOM) {
w->animation_is_tag |= ANIM_FAST;
w->dwm_mask |= ANIM_SPECIAL_MINIMIZE;
goto revert;
}
w->animation_is_tag |= ANIM_SLOW;
} else if (w->dwm_mask & ANIM_NEXT_TAG) {
animation = ps->o.animation_for_next_tag;
w->animation_is_tag |= animation >= OPEN_WINDOW_ANIMATION_ZOOM ? ANIM_FAST : ANIM_SLOW;
if (ps->o.enable_fading_next_tag) {
w->opacity = 0.0;
w->state = WSTATE_FADING;
if (is_transient(ps, w)) {
animation = ps->o.animation_for_transient_window;
} else {
if (w->dwm_mask & ANIM_NEXT_TAG) {
animation = ps->o.animation_for_next_tag;
w->animation_is_tag |= animation >= OPEN_WINDOW_ANIMATION_ZOOM ? ANIM_FAST : ANIM_SLOW;
if (ps->o.enable_fading_next_tag) {
w->opacity = 0.0;
w->state = WSTATE_FADING;
}
} else if (w->dwm_mask & ANIM_UNMAP) {
animation = ps->o.animation_for_unmap_window;
}
} else if (w->dwm_mask & ANIM_UNMAP) {
animation = ps->o.animation_for_unmap_window;
revert:
}

if (w->dwm_mask & ANIM_UNMAP) {
anim_x = &w->animation_dest_center_x, anim_y = &w->animation_dest_center_y;
anim_w = &w->animation_dest_w, anim_h = &w->animation_dest_h;
}
}

double angle;
switch (animation) {
Expand Down Expand Up @@ -575,14 +570,14 @@ static void init_animation(session_t *ps, struct managed_win *w) {
*anim_h = w->pending_g.height;
break;
case OPEN_WINDOW_ANIMATION_SLIDE_IN:
*anim_x = w->pending_g.x + w->pending_g.width * 0.5;
*anim_y = w->pending_g.y + w->pending_g.height * 0.5;
*anim_w = w->pending_g.width;
*anim_h = w->pending_g.height;
w->animation_center_x = w->pending_g.x + w->pending_g.width * 0.5;
w->animation_w = w->pending_g.width;
w->animation_h = w->pending_g.height;
*anim_y = w->pending_g.y;
break;
case OPEN_WINDOW_ANIMATION_SLIDE_IN_CENTER:
*anim_x = randr_mon_center_x;
*anim_y = w->g.y + w->pending_g.height * 0.5;
*anim_y = w->g.y - (w->pending_g.height*0.4);
*anim_w = w->pending_g.width;
*anim_h = w->pending_g.height;
break;
Expand Down Expand Up @@ -686,10 +681,9 @@ 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)
w->dwm_mask = ANIM_NEXT_TAG;
if (!was_visible && w->g.x == w->pending_g.x && w->g.y == w->pending_g.y && w->g.width == w->pending_g.width && w->g.height == w->pending_g.height) {
w->dwm_mask |= ANIM_NEXT_TAG;
}

if (!was_visible || w->dwm_mask) {

Expand Down Expand Up @@ -2639,6 +2633,7 @@ bool destroy_win_start(session_t *ps, struct win *w) {
}

void unmap_win_start(session_t *ps, struct managed_win *w) {
w->dwm_mask |= ANIM_UNMAP;
assert(w);
assert(w->base.managed);
assert(w->a._class != XCB_WINDOW_CLASS_INPUT_ONLY);
Expand Down

0 comments on commit d6197fa

Please sign in to comment.