Improve code of funcs "arrange" and "arrangemon"

This commit is contained in:
Alex Kotov 2021-11-20 20:25:45 +05:00
parent 1d95ddcfdc
commit fbe103ade6
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 43 additions and 30 deletions

View File

@ -407,42 +407,39 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, int bw, int interact)
void
arrange(Monitor *m)
{
if (m)
showhide(m->stack);
else for (m = mons; m; m = m->next)
if (m) {
showhide(m->stack);
} else {
for (m = mons; m; m = m->next) {
showhide(m->stack);
}
}
if (m) {
arrangemon(m);
restack(m);
} else for (m = mons; m; m = m->next)
arrangemon(m);
} else {
for (m = mons; m; m = m->next) {
arrangemon(m);
}
}
}
void
arrangemon(Monitor *m)
{
unsigned int visible_clients = 0;
for (const Client *client = m->clients; client; client = client->next) {
if (ISVISIBLE(client)) ++visible_clients;
if (ISVISIBLE(client)) {
++visible_clients;
}
}
if (m->lt[m->sellt]->arrange)
if (m->lt[m->sellt]->arrange) {
m->lt[m->sellt]->arrange(m);
else {
const int border_width = settings_get_border_width();
/* <>< case; rather than providing an arrange function and upsetting other logic that tests for its presence, simply add borders here */
for (Client *c = selmon->clients; c; c = c->next)
if (ISVISIBLE(c) && c->bw == 0)
resize(
c,
c->x,
c->y,
c->w - 2 * border_width,
c->h - 2 * border_width,
border_width,
0
);
} else {
floating(selmon);
}
}

View File

@ -1,8 +1,7 @@
#ifndef _DWM_LAYOUTS_C
#define _DWM_LAYOUTS_C
void
centeredmaster(Monitor *m)
void centeredmaster(Monitor *m)
{
unsigned int n = 0;
for (Client *c = nexttiled(m->clients); c; c = nexttiled(c->next), ++n);
@ -103,8 +102,26 @@ centeredmaster(Monitor *m)
}
}
void
horizontile(Monitor *m)
void floating(Monitor *m)
{
const int border_width = settings_get_border_width();
for (Client *c = m->clients; c; c = c->next) {
if (ISVISIBLE(c) && c->bw == 0) {
resize(
c,
c->x,
c->y,
c->w - 2 * border_width,
c->h - 2 * border_width,
border_width,
0
);
}
}
}
void horizontile(Monitor *m)
{
unsigned int n = 0;
for (Client *c = nexttiled(m->clients); c; c = nexttiled(c->next), ++n);
@ -173,8 +190,7 @@ horizontile(Monitor *m)
}
}
void
monocle(Monitor *m)
void monocle(Monitor *m)
{
bool any_is_fullscreen = false;
for (Client *c = nexttiled(m->clients); c; c = nexttiled(c->next)) {
@ -199,8 +215,7 @@ monocle(Monitor *m)
}
}
void
tile(Monitor *m)
void tile(Monitor *m)
{
unsigned int n = 0;
for (Client *c = nexttiled(m->clients); c; c = nexttiled(c->next), ++n);

View File

@ -2,6 +2,7 @@
#define _DWM_LAYOUTS_H
static void centeredmaster(Monitor *m);
static void floating(Monitor *m);
static void horizontile(Monitor *);
static void monocle(Monitor *m);
static void tile(Monitor *);