mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
opt: optimzie code struct
This commit is contained in:
parent
c03ba0436d
commit
b6b56a91ef
2 changed files with 86 additions and 86 deletions
85
src/animation/tag.h
Normal file
85
src/animation/tag.h
Normal file
|
|
@ -0,0 +1,85 @@
|
||||||
|
void set_tagin_animation(Monitor *m, Client *c) {
|
||||||
|
if (c->animation.running) {
|
||||||
|
c->animainit_geom.x = c->animation.current.x;
|
||||||
|
c->animainit_geom.y = c->animation.current.y;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m->pertag->curtag > m->pertag->prevtag) {
|
||||||
|
|
||||||
|
c->animainit_geom.x = tag_animation_direction == VERTICAL
|
||||||
|
? c->animation.current.x
|
||||||
|
: c->mon->m.x + c->mon->m.width;
|
||||||
|
c->animainit_geom.y = tag_animation_direction == VERTICAL
|
||||||
|
? c->mon->m.y + c->mon->m.height
|
||||||
|
: c->animation.current.y;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
c->animainit_geom.x = tag_animation_direction == VERTICAL
|
||||||
|
? c->animation.current.x
|
||||||
|
: m->m.x - c->geom.width;
|
||||||
|
c->animainit_geom.y = tag_animation_direction == VERTICAL
|
||||||
|
? m->m.y - c->geom.height
|
||||||
|
: c->animation.current.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_arrange_visible(Monitor *m, Client *c, bool want_animation) {
|
||||||
|
|
||||||
|
if (!c->is_clip_to_hide || !ISTILED(c) || !is_scroller_layout(c->mon)) {
|
||||||
|
c->is_clip_to_hide = false;
|
||||||
|
wlr_scene_node_set_enabled(&c->scene->node, true);
|
||||||
|
wlr_scene_node_set_enabled(&c->scene_surface->node, true);
|
||||||
|
}
|
||||||
|
client_set_suspended(c, false);
|
||||||
|
|
||||||
|
if (!c->animation.tag_from_rule && want_animation &&
|
||||||
|
m->pertag->prevtag != 0 && m->pertag->curtag != 0 && animations) {
|
||||||
|
c->animation.tagining = true;
|
||||||
|
set_tagin_animation(m, c);
|
||||||
|
} else {
|
||||||
|
c->animainit_geom.x = c->animation.current.x;
|
||||||
|
c->animainit_geom.y = c->animation.current.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
c->animation.tag_from_rule = false;
|
||||||
|
c->animation.tagouting = false;
|
||||||
|
c->animation.tagouted = false;
|
||||||
|
resize(c, c->geom, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_tagout_animation(Monitor *m, Client *c) {
|
||||||
|
if (m->pertag->curtag > m->pertag->prevtag) {
|
||||||
|
c->pending = c->geom;
|
||||||
|
c->pending.x = tag_animation_direction == VERTICAL
|
||||||
|
? c->animation.current.x
|
||||||
|
: c->mon->m.x - c->geom.width;
|
||||||
|
c->pending.y = tag_animation_direction == VERTICAL
|
||||||
|
? c->mon->m.y - c->geom.height
|
||||||
|
: c->animation.current.y;
|
||||||
|
|
||||||
|
resize(c, c->geom, 0);
|
||||||
|
} else {
|
||||||
|
c->pending = c->geom;
|
||||||
|
c->pending.x = tag_animation_direction == VERTICAL
|
||||||
|
? c->animation.current.x
|
||||||
|
: c->mon->m.x + c->mon->m.width;
|
||||||
|
c->pending.y = tag_animation_direction == VERTICAL
|
||||||
|
? c->mon->m.y + c->mon->m.height
|
||||||
|
: c->animation.current.y;
|
||||||
|
resize(c, c->geom, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_arrange_hidden(Monitor *m, Client *c, bool want_animation) {
|
||||||
|
if ((c->tags & (1 << (m->pertag->prevtag - 1))) &&
|
||||||
|
m->pertag->prevtag != 0 && m->pertag->curtag != 0 && animations) {
|
||||||
|
c->animation.tagouting = true;
|
||||||
|
c->animation.tagining = false;
|
||||||
|
set_tagout_animation(m, c);
|
||||||
|
} else {
|
||||||
|
wlr_scene_node_set_enabled(&c->scene->node, false);
|
||||||
|
client_set_suspended(c, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
87
src/mango.c
87
src/mango.c
|
|
@ -850,6 +850,7 @@ static struct wlr_xwayland *xwayland;
|
||||||
#include "animation/client.h"
|
#include "animation/client.h"
|
||||||
#include "animation/common.h"
|
#include "animation/common.h"
|
||||||
#include "animation/layer.h"
|
#include "animation/layer.h"
|
||||||
|
#include "animation/tag.h"
|
||||||
#include "config/parse_config.h"
|
#include "config/parse_config.h"
|
||||||
#include "dispatch/bind_define.h"
|
#include "dispatch/bind_define.h"
|
||||||
#include "ext-protocol/all.h"
|
#include "ext-protocol/all.h"
|
||||||
|
|
@ -1267,92 +1268,6 @@ void applyrules(Client *c) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_tagin_animation(Monitor *m, Client *c) {
|
|
||||||
if (c->animation.running) {
|
|
||||||
c->animainit_geom.x = c->animation.current.x;
|
|
||||||
c->animainit_geom.y = c->animation.current.y;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m->pertag->curtag > m->pertag->prevtag) {
|
|
||||||
|
|
||||||
c->animainit_geom.x = tag_animation_direction == VERTICAL
|
|
||||||
? c->animation.current.x
|
|
||||||
: c->mon->m.x + c->mon->m.width;
|
|
||||||
c->animainit_geom.y = tag_animation_direction == VERTICAL
|
|
||||||
? c->mon->m.y + c->mon->m.height
|
|
||||||
: c->animation.current.y;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
c->animainit_geom.x = tag_animation_direction == VERTICAL
|
|
||||||
? c->animation.current.x
|
|
||||||
: m->m.x - c->geom.width;
|
|
||||||
c->animainit_geom.y = tag_animation_direction == VERTICAL
|
|
||||||
? m->m.y - c->geom.height
|
|
||||||
: c->animation.current.y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_arrange_visible(Monitor *m, Client *c, bool want_animation) {
|
|
||||||
|
|
||||||
if (!c->is_clip_to_hide || !ISTILED(c) || !is_scroller_layout(c->mon)) {
|
|
||||||
c->is_clip_to_hide = false;
|
|
||||||
wlr_scene_node_set_enabled(&c->scene->node, true);
|
|
||||||
wlr_scene_node_set_enabled(&c->scene_surface->node, true);
|
|
||||||
}
|
|
||||||
client_set_suspended(c, false);
|
|
||||||
|
|
||||||
if (!c->animation.tag_from_rule && want_animation &&
|
|
||||||
m->pertag->prevtag != 0 && m->pertag->curtag != 0 && animations) {
|
|
||||||
c->animation.tagining = true;
|
|
||||||
set_tagin_animation(m, c);
|
|
||||||
} else {
|
|
||||||
c->animainit_geom.x = c->animation.current.x;
|
|
||||||
c->animainit_geom.y = c->animation.current.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
c->animation.tag_from_rule = false;
|
|
||||||
c->animation.tagouting = false;
|
|
||||||
c->animation.tagouted = false;
|
|
||||||
resize(c, c->geom, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_tagout_animation(Monitor *m, Client *c) {
|
|
||||||
if (m->pertag->curtag > m->pertag->prevtag) {
|
|
||||||
c->pending = c->geom;
|
|
||||||
c->pending.x = tag_animation_direction == VERTICAL
|
|
||||||
? c->animation.current.x
|
|
||||||
: c->mon->m.x - c->geom.width;
|
|
||||||
c->pending.y = tag_animation_direction == VERTICAL
|
|
||||||
? c->mon->m.y - c->geom.height
|
|
||||||
: c->animation.current.y;
|
|
||||||
|
|
||||||
resize(c, c->geom, 0);
|
|
||||||
} else {
|
|
||||||
c->pending = c->geom;
|
|
||||||
c->pending.x = tag_animation_direction == VERTICAL
|
|
||||||
? c->animation.current.x
|
|
||||||
: c->mon->m.x + c->mon->m.width;
|
|
||||||
c->pending.y = tag_animation_direction == VERTICAL
|
|
||||||
? c->mon->m.y + c->mon->m.height
|
|
||||||
: c->animation.current.y;
|
|
||||||
resize(c, c->geom, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_arrange_hidden(Monitor *m, Client *c, bool want_animation) {
|
|
||||||
if ((c->tags & (1 << (m->pertag->prevtag - 1))) &&
|
|
||||||
m->pertag->prevtag != 0 && m->pertag->curtag != 0 && animations) {
|
|
||||||
c->animation.tagouting = true;
|
|
||||||
c->animation.tagining = false;
|
|
||||||
set_tagout_animation(m, c);
|
|
||||||
} else {
|
|
||||||
wlr_scene_node_set_enabled(&c->scene->node, false);
|
|
||||||
client_set_suspended(c, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void // 17
|
void // 17
|
||||||
arrange(Monitor *m, bool want_animation) {
|
arrange(Monitor *m, bool want_animation) {
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue