mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
feat: optimize slide animation for master layout
This commit is contained in:
parent
c54ff1e27f
commit
ba346e5092
1 changed files with 29 additions and 6 deletions
35
main.c
35
main.c
|
|
@ -100,7 +100,7 @@ enum { LyrBg, LyrBottom, LyrTile, LyrFloat, LyrFS, LyrTop, LyrOverlay,
|
||||||
enum { NetWMWindowTypeDialog, NetWMWindowTypeSplash, NetWMWindowTypeToolbar,
|
enum { NetWMWindowTypeDialog, NetWMWindowTypeSplash, NetWMWindowTypeToolbar,
|
||||||
NetWMWindowTypeUtility, NetLast }; /* EWMH atoms */
|
NetWMWindowTypeUtility, NetLast }; /* EWMH atoms */
|
||||||
#endif
|
#endif
|
||||||
enum { UP, DOWN, LEFT, RIGHT }; /* movewin */
|
enum { UP, DOWN, LEFT, RIGHT, UNDIR }; /* movewin */
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -3549,10 +3549,28 @@ void exchange_client(const Arg *arg) {
|
||||||
exchange_two_client(c, direction_select(arg));
|
exchange_two_client(c, direction_select(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int is_special_animaiton_rule(Client *c) {
|
||||||
|
int visible_client_number = 0;
|
||||||
|
Client *count_c;
|
||||||
|
wl_list_for_each(count_c, &clients, link)
|
||||||
|
if (count_c && VISIBLEON(count_c,selmon) && !count_c->isminied){
|
||||||
|
visible_client_number++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (visible_client_number == 1) {
|
||||||
|
return DOWN;
|
||||||
|
} else if (!c->isfloating && new_is_master) {
|
||||||
|
return LEFT;
|
||||||
|
} else {
|
||||||
|
return UNDIR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void set_open_animaiton(Client *c, struct wlr_box geo) {
|
void set_open_animaiton(Client *c, struct wlr_box geo) {
|
||||||
int slide_direction;
|
int slide_direction;
|
||||||
int horizontal,horizontal_value;
|
int horizontal,horizontal_value;
|
||||||
int vertical,vertical_value;
|
int vertical,vertical_value;
|
||||||
|
int special_direction;
|
||||||
if (strcmp(animation_type, "zoom") == 0 || (c->animation_type && strcmp(c->animation_type, "zoom") == 0)) {
|
if (strcmp(animation_type, "zoom") == 0 || (c->animation_type && strcmp(c->animation_type, "zoom") == 0)) {
|
||||||
c->animainit_geom.width = geo.width * zoom_initial_ratio;
|
c->animainit_geom.width = geo.width * zoom_initial_ratio;
|
||||||
c->animainit_geom.height = geo.height * zoom_initial_ratio;
|
c->animainit_geom.height = geo.height * zoom_initial_ratio;
|
||||||
|
|
@ -3560,11 +3578,16 @@ void set_open_animaiton(Client *c, struct wlr_box geo) {
|
||||||
c->animainit_geom.y = geo.y + (geo.height - c->animainit_geom.height)/2;
|
c->animainit_geom.y = geo.y + (geo.height - c->animainit_geom.height)/2;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
horizontal = c->mon->w.x + c->mon->w.width - c->geom.x < c->geom.x - c->mon->w.x ? RIGHT : LEFT;
|
special_direction = is_special_animaiton_rule(c);
|
||||||
horizontal_value = horizontal == LEFT ? c->geom.x - c->mon->w.x : c->mon->w.x + c->mon->w.width - c->geom.x;
|
if (special_direction == UNDIR) {
|
||||||
vertical = c->mon->w.y + c->mon->w.height - c->geom.y < c->geom.y - c->mon->w.y ? DOWN : UP;
|
horizontal = c->mon->w.x + c->mon->w.width - c->geom.x < c->geom.x - c->mon->w.x ? RIGHT : LEFT;
|
||||||
vertical_value = vertical == UP ? c->geom.y - c->mon->w.y : c->mon->w.y + c->mon->w.height - c->geom.y;
|
horizontal_value = horizontal == LEFT ? c->geom.x - c->mon->w.x : c->mon->w.x + c->mon->w.width - c->geom.x;
|
||||||
slide_direction = (horizontal_value < vertical_value) || (!c->isfloating && new_is_master) ? horizontal : vertical;
|
vertical = c->mon->w.y + c->mon->w.height - c->geom.y < c->geom.y - c->mon->w.y ? DOWN : UP;
|
||||||
|
vertical_value = vertical == UP ? c->geom.y - c->mon->w.y : c->mon->w.y + c->mon->w.height - c->geom.y;
|
||||||
|
slide_direction = horizontal_value < vertical_value ? horizontal : vertical;
|
||||||
|
} else {
|
||||||
|
slide_direction = special_direction;
|
||||||
|
}
|
||||||
c->animainit_geom.width = c->geom.width;
|
c->animainit_geom.width = c->geom.width;
|
||||||
c->animainit_geom.height = c->geom.height;
|
c->animainit_geom.height = c->geom.height;
|
||||||
switch (slide_direction)
|
switch (slide_direction)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue