Skip to content

Commit c11476e

Browse files
committed
opt: optimize code struct
1 parent f2eb995 commit c11476e

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

src/mango.c

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,43 +1263,34 @@ void applyrules(Client *c) {
12631263
}
12641264

12651265
void set_tagin_animation(Monitor *m, Client *c) {
1266-
c->animation.tagining = true;
1266+
if (c->animation.running) {
1267+
c->animainit_geom.x = c->animation.current.x;
1268+
c->animainit_geom.y = c->animation.current.y;
1269+
return;
1270+
}
1271+
12671272
if (m->pertag->curtag > m->pertag->prevtag) {
1268-
if (c->animation.running) {
1269-
c->animainit_geom.x = c->animation.current.x;
1270-
c->animainit_geom.y = c->animation.current.y;
1271-
} else {
1272-
c->animainit_geom.x = tag_animation_direction == VERTICAL
1273-
? c->animation.current.x
1274-
: c->mon->m.x + c->mon->m.width;
1275-
c->animainit_geom.y = tag_animation_direction == VERTICAL
1276-
? c->mon->m.y + c->mon->m.height
1277-
: c->animation.current.y;
1278-
}
1273+
1274+
c->animainit_geom.x = tag_animation_direction == VERTICAL
1275+
? c->animation.current.x
1276+
: c->mon->m.x + c->mon->m.width;
1277+
c->animainit_geom.y = tag_animation_direction == VERTICAL
1278+
? c->mon->m.y + c->mon->m.height
1279+
: c->animation.current.y;
12791280

12801281
} else {
1281-
if (c->animation.running) {
1282-
c->animainit_geom.x = c->animation.current.x;
1283-
c->animainit_geom.y = c->animation.current.y;
1284-
} else {
1285-
c->animainit_geom.x = tag_animation_direction == VERTICAL
1286-
? c->animation.current.x
1287-
: m->m.x - c->geom.width;
1288-
c->animainit_geom.y = tag_animation_direction == VERTICAL
1289-
? m->m.y - c->geom.height
1290-
: c->animation.current.y;
1291-
}
1282+
1283+
c->animainit_geom.x = tag_animation_direction == VERTICAL
1284+
? c->animation.current.x
1285+
: m->m.x - c->geom.width;
1286+
c->animainit_geom.y = tag_animation_direction == VERTICAL
1287+
? m->m.y - c->geom.height
1288+
: c->animation.current.y;
12921289
}
12931290
}
12941291

12951292
void set_arrange_visible(Monitor *m, Client *c, bool want_animation) {
12961293

1297-
m->visible_clients++;
1298-
1299-
if (ISTILED(c)) {
1300-
m->visible_tiling_clients++;
1301-
}
1302-
13031294
if (!c->is_clip_to_hide || !ISTILED(c) || !is_scroller_layout(c->mon)) {
13041295
c->is_clip_to_hide = false;
13051296
wlr_scene_node_set_enabled(&c->scene->node, true);
@@ -1309,6 +1300,7 @@ void set_arrange_visible(Monitor *m, Client *c, bool want_animation) {
13091300

13101301
if (!c->animation.tag_from_rule && want_animation &&
13111302
m->pertag->prevtag != 0 && m->pertag->curtag != 0 && animations) {
1303+
c->animation.tagining = true;
13121304
set_tagin_animation(m, c);
13131305
} else {
13141306
c->animainit_geom.x = c->animation.current.x;
@@ -1322,8 +1314,6 @@ void set_arrange_visible(Monitor *m, Client *c, bool want_animation) {
13221314
}
13231315

13241316
void set_tagout_animation(Monitor *m, Client *c) {
1325-
c->animation.tagouting = true;
1326-
c->animation.tagining = false;
13271317
if (m->pertag->curtag > m->pertag->prevtag) {
13281318
c->pending = c->geom;
13291319
c->pending.x = tag_animation_direction == VERTICAL
@@ -1349,6 +1339,8 @@ void set_tagout_animation(Monitor *m, Client *c) {
13491339
void set_arrange_hidden(Monitor *m, Client *c, bool want_animation) {
13501340
if ((c->tags & (1 << (m->pertag->prevtag - 1))) &&
13511341
m->pertag->prevtag != 0 && m->pertag->curtag != 0 && animations) {
1342+
c->animation.tagouting = true;
1343+
c->animation.tagining = false;
13521344
set_tagout_animation(m, c);
13531345
} else {
13541346
wlr_scene_node_set_enabled(&c->scene->node, false);
@@ -1380,6 +1372,11 @@ arrange(Monitor *m, bool want_animation) {
13801372

13811373
if (c->mon == m) {
13821374
if (VISIBLEON(c, m)) {
1375+
1376+
m->visible_clients++;
1377+
if (ISTILED(c))
1378+
m->visible_tiling_clients++;
1379+
13831380
set_arrange_visible(m, c, want_animation);
13841381
} else {
13851382
set_arrange_hidden(m, c, want_animation);

0 commit comments

Comments
 (0)