mirror of
https://git.suckless.org/dwm
synced 2024-12-27 03:16:32 +00:00
changed arrange functions to contain the Monitor as first argument
This commit is contained in:
parent
4426032450
commit
2e8e5509d9
3 changed files with 51 additions and 53 deletions
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT/X Consortium License
|
MIT/X Consortium License
|
||||||
|
|
||||||
© 2006-2007 Anselm R. Garbe <garbeam at gmail dot com>
|
© 2006-2008 Anselm R. Garbe <garbeam at gmail dot com>
|
||||||
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||||
© 2006-2007 Jukka Salmi <jukka at salmi dot ch>
|
© 2006-2007 Jukka Salmi <jukka at salmi dot ch>
|
||||||
© 2007 Premysl Hruby <dfenze at gmail dot com>
|
© 2007 Premysl Hruby <dfenze at gmail dot com>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/* appearance */
|
/* appearance */
|
||||||
#define BARPOS BarTop /* BarBot, BarOff */
|
#define BARPOS BarTop /* BarBot, BarOff */
|
||||||
#define BORDERPX 1
|
#define BORDERPX 1
|
||||||
#define FONT "-*-terminus-medium-*-*-*-*-*-*-*-*-*-*-*"
|
#define FONT "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*"
|
||||||
#define NORMBORDERCOLOR "#cccccc"
|
#define NORMBORDERCOLOR "#cccccc"
|
||||||
#define NORMBGCOLOR "#cccccc"
|
#define NORMBGCOLOR "#cccccc"
|
||||||
#define NORMFGCOLOR "#000000"
|
#define NORMFGCOLOR "#000000"
|
||||||
|
|
100
dwm.c
100
dwm.c
|
@ -99,9 +99,10 @@ typedef struct {
|
||||||
const char *arg;
|
const char *arg;
|
||||||
} Key;
|
} Key;
|
||||||
|
|
||||||
|
typedef struct Monitor Monitor;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *symbol;
|
const char *symbol;
|
||||||
void (*arrange)(void);
|
void (*arrange)(Monitor *);
|
||||||
} Layout;
|
} Layout;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -116,14 +117,16 @@ typedef struct {
|
||||||
regex_t *tagregex;
|
regex_t *tagregex;
|
||||||
} Regs;
|
} Regs;
|
||||||
|
|
||||||
typedef struct {
|
struct Monitor {
|
||||||
Window barwin;
|
unsigned int id;
|
||||||
int sx, sy, sw, sh, wax, way, wah, waw;
|
int sx, sy, sw, sh, wax, way, wah, waw;
|
||||||
|
double mwfact;
|
||||||
Bool *seltags;
|
Bool *seltags;
|
||||||
Bool *prevtags;
|
Bool *prevtags;
|
||||||
Layout *layout;
|
Layout *layout;
|
||||||
double mwfact;
|
Window barwin;
|
||||||
} Monitor;
|
};
|
||||||
|
|
||||||
|
|
||||||
/* function declarations */
|
/* function declarations */
|
||||||
void applyrules(Client *c);
|
void applyrules(Client *c);
|
||||||
|
@ -148,7 +151,7 @@ void *emallocz(unsigned int size);
|
||||||
void enternotify(XEvent *e);
|
void enternotify(XEvent *e);
|
||||||
void eprint(const char *errstr, ...);
|
void eprint(const char *errstr, ...);
|
||||||
void expose(XEvent *e);
|
void expose(XEvent *e);
|
||||||
void floating(void); /* default floating layout */
|
void floating(Monitor *m); /* default floating layout */
|
||||||
void focus(Client *c);
|
void focus(Client *c);
|
||||||
void focusin(XEvent *e);
|
void focusin(XEvent *e);
|
||||||
void focusnext(const char *arg);
|
void focusnext(const char *arg);
|
||||||
|
@ -188,7 +191,7 @@ void spawn(const char *arg);
|
||||||
void tag(const char *arg);
|
void tag(const char *arg);
|
||||||
unsigned int textnw(const char *text, unsigned int len);
|
unsigned int textnw(const char *text, unsigned int len);
|
||||||
unsigned int textw(const char *text);
|
unsigned int textw(const char *text);
|
||||||
void tile(void);
|
void tile(Monitor *m);
|
||||||
void togglebar(const char *arg);
|
void togglebar(const char *arg);
|
||||||
void togglefloating(const char *arg);
|
void togglefloating(const char *arg);
|
||||||
void toggletag(const char *arg);
|
void toggletag(const char *arg);
|
||||||
|
@ -304,7 +307,7 @@ arrange(void) {
|
||||||
else
|
else
|
||||||
ban(c);
|
ban(c);
|
||||||
|
|
||||||
monitors[selmonitor].layout->arrange();
|
monitors[selmonitor].layout->arrange(&monitors[selmonitor]);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
restack();
|
restack();
|
||||||
}
|
}
|
||||||
|
@ -719,12 +722,12 @@ expose(XEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
floating(void) { /* default floating layout */
|
floating(Monitor *m) { /* default floating layout */
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
domwfact = dozoom = False;
|
domwfact = dozoom = False;
|
||||||
for(c = clients; c; c = c->next)
|
for(c = clients; c; c = c->next)
|
||||||
if(isvisible(c, selmonitor))
|
if(isvisible(c, m->id))
|
||||||
resize(c, c->x, c->y, c->w, c->h, True);
|
resize(c, c->x, c->y, c->w, c->h, True);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1598,6 +1601,7 @@ setup(void) {
|
||||||
for(i = 0; i < mcount; i++) {
|
for(i = 0; i < mcount; i++) {
|
||||||
/* init geometry */
|
/* init geometry */
|
||||||
m = &monitors[i];
|
m = &monitors[i];
|
||||||
|
m->id = i;
|
||||||
|
|
||||||
if (mcount != 1 && isxinerama) {
|
if (mcount != 1 && isxinerama) {
|
||||||
m->sx = info[i].x_org;
|
m->sx = info[i].x_org;
|
||||||
|
@ -1714,56 +1718,50 @@ textw(const char *text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tile(void) {
|
tile(Monitor *m) {
|
||||||
unsigned int i, j, n, nx, ny, nw, nh, mw, th;
|
unsigned int i, n, nx, ny, nw, nh, mw, th;
|
||||||
Client *c, *mc;
|
Client *c, *mc;
|
||||||
|
|
||||||
domwfact = dozoom = True;
|
domwfact = dozoom = True;
|
||||||
|
|
||||||
nx = ny = nw = 0; /* gcc stupidity requires this */
|
nx = ny = nw = 0; /* gcc stupidity requires this */
|
||||||
|
|
||||||
for (i = 0; i < mcount; i++) {
|
for(n = 0, c = nexttiled(clients, m->id); c; c = nexttiled(c->next, m->id))
|
||||||
Monitor *m = &monitors[i];
|
n++;
|
||||||
|
|
||||||
for(n = 0, c = nexttiled(clients, i); c; c = nexttiled(c->next, i))
|
/* window geoms */
|
||||||
n++;
|
mw = (n == 1) ? m->waw : m->mwfact * m->waw;
|
||||||
|
th = (n > 1) ? m->wah / (n - 1) : 0;
|
||||||
|
if(n > 1 && th < bh)
|
||||||
|
th = m->wah;
|
||||||
|
|
||||||
/* window geoms */
|
for(i = 0, c = mc = nexttiled(clients, m->id); c; c = nexttiled(c->next, m->id)) {
|
||||||
mw = (n == 1) ? m->waw : m->mwfact * m->waw;
|
if(i == 0) { /* master */
|
||||||
th = (n > 1) ? m->wah / (n - 1) : 0;
|
nx = m->wax;
|
||||||
if(n > 1 && th < bh)
|
ny = m->way;
|
||||||
th = m->wah;
|
nw = mw - 2 * c->border;
|
||||||
|
nh = m->wah - 2 * c->border;
|
||||||
for(j = 0, c = mc = nexttiled(clients, i); c; c = nexttiled(c->next, i)) {
|
|
||||||
if(j == 0) { /* master */
|
|
||||||
nx = m->wax;
|
|
||||||
ny = m->way;
|
|
||||||
nw = mw - 2 * c->border;
|
|
||||||
nh = m->wah - 2 * c->border;
|
|
||||||
}
|
|
||||||
else { /* tile window */
|
|
||||||
if(j == 1) {
|
|
||||||
ny = m->way;
|
|
||||||
nx += mc->w + 2 * mc->border;
|
|
||||||
nw = m->waw - mw - 2 * c->border;
|
|
||||||
}
|
|
||||||
if(j + 1 == n) /* remainder */
|
|
||||||
nh = (m->way + m->wah) - ny - 2 * c->border;
|
|
||||||
else
|
|
||||||
nh = th - 2 * c->border;
|
|
||||||
}
|
|
||||||
fprintf(stderr, "tile(%d, %d, %d, %d)\n", nx, ny, nw, nh);
|
|
||||||
resize(c, nx, ny, nw, nh, RESIZEHINTS);
|
|
||||||
if((RESIZEHINTS) && ((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw)))
|
|
||||||
/* client doesn't accept size constraints */
|
|
||||||
resize(c, nx, ny, nw, nh, False);
|
|
||||||
if(n > 1 && th != m->wah)
|
|
||||||
ny = c->y + c->h + 2 * c->border;
|
|
||||||
|
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
|
else { /* tile window */
|
||||||
|
if(i == 1) {
|
||||||
|
ny = m->way;
|
||||||
|
nx += mc->w + 2 * mc->border;
|
||||||
|
nw = m->waw - mw - 2 * c->border;
|
||||||
|
}
|
||||||
|
if(i + 1 == n) /* remainder */
|
||||||
|
nh = (m->way + m->wah) - ny - 2 * c->border;
|
||||||
|
else
|
||||||
|
nh = th - 2 * c->border;
|
||||||
|
}
|
||||||
|
resize(c, nx, ny, nw, nh, RESIZEHINTS);
|
||||||
|
if((RESIZEHINTS) && ((c->h < bh) || (c->h > nh) || (c->w < bh) || (c->w > nw)))
|
||||||
|
/* client doesn't accept size constraints */
|
||||||
|
resize(c, nx, ny, nw, nh, False);
|
||||||
|
if(n > 1 && th != m->wah)
|
||||||
|
ny = c->y + c->h + 2 * c->border;
|
||||||
|
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "done\n");
|
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
togglebar(const char *arg) {
|
togglebar(const char *arg) {
|
||||||
|
@ -2045,7 +2043,7 @@ selectmonitor(const char *arg) {
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[]) {
|
main(int argc, char *argv[]) {
|
||||||
if(argc == 2 && !strcmp("-v", argv[1]))
|
if(argc == 2 && !strcmp("-v", argv[1]))
|
||||||
eprint("dwm-"VERSION", © 2006-2007 Anselm R. Garbe, Sander van Dijk, "
|
eprint("dwm-"VERSION", © 2006-2008 Anselm R. Garbe, Sander van Dijk, "
|
||||||
"Jukka Salmi, Premysl Hruby, Szabolcs Nagy, Christof Musik\n");
|
"Jukka Salmi, Premysl Hruby, Szabolcs Nagy, Christof Musik\n");
|
||||||
else if(argc != 1)
|
else if(argc != 1)
|
||||||
eprint("usage: dwm [-v]\n");
|
eprint("usage: dwm [-v]\n");
|
||||||
|
|
Loading…
Reference in a new issue