forked from mirror/dwm
changes monitor structure to be a list
This commit is contained in:
parent
c2fff604a7
commit
78f56672b5
1 changed files with 171 additions and 135 deletions
306
dwm.c
306
dwm.c
|
@ -44,7 +44,7 @@
|
||||||
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
|
||||||
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask))
|
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask))
|
||||||
#define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
|
#define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
|
||||||
#define ISVISIBLE(M, C) ((M) == (&mon[C->mon]) && (C->tags & M->tagset[M->seltags]))
|
#define ISVISIBLE(M, C) ((M) == (C->m) && (C->tags & M->tagset[M->seltags]))
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||||
|
@ -77,6 +77,7 @@ typedef struct {
|
||||||
const Arg arg;
|
const Arg arg;
|
||||||
} Button;
|
} Button;
|
||||||
|
|
||||||
|
typedef struct Monitor Monitor;
|
||||||
typedef struct Client Client;
|
typedef struct Client Client;
|
||||||
struct Client {
|
struct Client {
|
||||||
char name[256];
|
char name[256];
|
||||||
|
@ -85,10 +86,10 @@ struct Client {
|
||||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||||
int bw, oldbw;
|
int bw, oldbw;
|
||||||
unsigned int tags;
|
unsigned int tags;
|
||||||
unsigned int mon;
|
|
||||||
Bool isfixed, isfloating, isurgent;
|
Bool isfixed, isfloating, isurgent;
|
||||||
Client *next;
|
Client *next;
|
||||||
Client *snext;
|
Client *snext;
|
||||||
|
Monitor *m;
|
||||||
Window win;
|
Window win;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,7 +116,12 @@ typedef struct {
|
||||||
} Key;
|
} Key;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char symbol[4];
|
const char *symbol;
|
||||||
|
void (*arrange)(Monitor *);
|
||||||
|
} Layout;
|
||||||
|
|
||||||
|
struct Monitor {
|
||||||
|
int screen_number;
|
||||||
float mfact;
|
float mfact;
|
||||||
int by, btx; /* bar geometry */
|
int by, btx; /* bar geometry */
|
||||||
int wx, wy, ww, wh; /* window area */
|
int wx, wy, ww, wh; /* window area */
|
||||||
|
@ -125,12 +131,8 @@ typedef struct {
|
||||||
Bool showbar;
|
Bool showbar;
|
||||||
Bool topbar;
|
Bool topbar;
|
||||||
Window barwin;
|
Window barwin;
|
||||||
} Monitor;
|
Monitor *next;
|
||||||
|
};
|
||||||
typedef struct {
|
|
||||||
const char *symbol;
|
|
||||||
void (*arrange)(Monitor *);
|
|
||||||
} Layout;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *class;
|
const char *class;
|
||||||
|
@ -149,6 +151,7 @@ static void attachstack(Client *c);
|
||||||
static void buttonpress(XEvent *e);
|
static void buttonpress(XEvent *e);
|
||||||
static void checkotherwm(void);
|
static void checkotherwm(void);
|
||||||
static void cleanup(void);
|
static void cleanup(void);
|
||||||
|
static void cleanupmons(void);
|
||||||
static void clearurgent(Client *c);
|
static void clearurgent(Client *c);
|
||||||
static void configure(Client *c);
|
static void configure(Client *c);
|
||||||
static void configurenotify(XEvent *e);
|
static void configurenotify(XEvent *e);
|
||||||
|
@ -206,6 +209,7 @@ static void toggleview(const Arg *arg);
|
||||||
static void unmanage(Client *c);
|
static void unmanage(Client *c);
|
||||||
static void unmapnotify(XEvent *e);
|
static void unmapnotify(XEvent *e);
|
||||||
static void updategeom(void);
|
static void updategeom(void);
|
||||||
|
static void updatebars(void);
|
||||||
static void updatenumlockmask(void);
|
static void updatenumlockmask(void);
|
||||||
static void updatesizehints(Client *c);
|
static void updatesizehints(Client *c);
|
||||||
static void updatestatus(void);
|
static void updatestatus(void);
|
||||||
|
@ -252,8 +256,7 @@ static Cursor cursor[CurLast];
|
||||||
static Display *dpy;
|
static Display *dpy;
|
||||||
static DC dc;
|
static DC dc;
|
||||||
static Layout *lt[] = { NULL, NULL };
|
static Layout *lt[] = { NULL, NULL };
|
||||||
static Monitor *mon = NULL, *selmon = NULL;
|
static Monitor *mons = NULL, *selmon = NULL;
|
||||||
static unsigned int nmons = 0;
|
|
||||||
static Window root;
|
static Window root;
|
||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -285,7 +288,7 @@ applyrules(Client *c) {
|
||||||
if(ch.res_name)
|
if(ch.res_name)
|
||||||
XFree(ch.res_name);
|
XFree(ch.res_name);
|
||||||
}
|
}
|
||||||
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : mon[c->mon].tagset[mon[c->mon].seltags];
|
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->m->tagset[c->m->seltags];
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
|
@ -355,13 +358,14 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h) {
|
||||||
|
|
||||||
void
|
void
|
||||||
arrange(void) {
|
arrange(void) {
|
||||||
unsigned int i;
|
Monitor *m;
|
||||||
|
|
||||||
showhide(stack);
|
showhide(stack);
|
||||||
focus(NULL);
|
focus(NULL);
|
||||||
for(i = 0; i < nmons; i++) {
|
for(m = mons; m; m = m->next) {
|
||||||
if(lt[mon[i].sellt]->arrange)
|
if(lt[m->sellt]->arrange)
|
||||||
lt[mon[i].sellt]->arrange(&mon[i]);
|
lt[m->sellt]->arrange(m);
|
||||||
restack(&mon[i]);
|
restack(m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,7 +433,6 @@ checkotherwm(void) {
|
||||||
|
|
||||||
void
|
void
|
||||||
cleanup(void) {
|
cleanup(void) {
|
||||||
unsigned int i;
|
|
||||||
Arg a = {.ui = ~0};
|
Arg a = {.ui = ~0};
|
||||||
Layout foo = { "", NULL };
|
Layout foo = { "", NULL };
|
||||||
|
|
||||||
|
@ -447,13 +450,24 @@ cleanup(void) {
|
||||||
XFreeCursor(dpy, cursor[CurNormal]);
|
XFreeCursor(dpy, cursor[CurNormal]);
|
||||||
XFreeCursor(dpy, cursor[CurResize]);
|
XFreeCursor(dpy, cursor[CurResize]);
|
||||||
XFreeCursor(dpy, cursor[CurMove]);
|
XFreeCursor(dpy, cursor[CurMove]);
|
||||||
for(i = 0; i < nmons; i++)
|
cleanupmons();
|
||||||
XDestroyWindow(dpy, mon[i].barwin);
|
|
||||||
free(mon);
|
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cleanupmons(void) {
|
||||||
|
Monitor *m;
|
||||||
|
|
||||||
|
while(mons) {
|
||||||
|
m = mons->next;
|
||||||
|
XUnmapWindow(dpy, mons->barwin);
|
||||||
|
XDestroyWindow(dpy, mons->barwin);
|
||||||
|
free(mons);
|
||||||
|
mons = m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
clearurgent(Client *c) {
|
clearurgent(Client *c) {
|
||||||
XWMHints *wmh;
|
XWMHints *wmh;
|
||||||
|
@ -486,7 +500,7 @@ configure(Client *c) {
|
||||||
|
|
||||||
void
|
void
|
||||||
configurenotify(XEvent *e) {
|
configurenotify(XEvent *e) {
|
||||||
unsigned int i;
|
Monitor *m;
|
||||||
XConfigureEvent *ev = &e->xconfigure;
|
XConfigureEvent *ev = &e->xconfigure;
|
||||||
|
|
||||||
if(ev->window == root && (ev->width != sw || ev->height != sh)) {
|
if(ev->window == root && (ev->width != sw || ev->height != sh)) {
|
||||||
|
@ -496,8 +510,9 @@ configurenotify(XEvent *e) {
|
||||||
if(dc.drawable != 0)
|
if(dc.drawable != 0)
|
||||||
XFreePixmap(dpy, dc.drawable);
|
XFreePixmap(dpy, dc.drawable);
|
||||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
||||||
for(i = 0; i < nmons; i++)
|
updatebars();
|
||||||
XMoveResizeWindow(dpy, mon[i].barwin, mon[i].wx, mon[i].by, mon[i].ww, bh);
|
for(m = mons; m; m = m->next)
|
||||||
|
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
|
||||||
arrange();
|
arrange();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -526,7 +541,7 @@ configurerequest(XEvent *e) {
|
||||||
c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
|
c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
|
||||||
if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
|
if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
|
||||||
configure(c);
|
configure(c);
|
||||||
if(ISVISIBLE((&mon[c->mon]), c))
|
if(ISVISIBLE((c->m), c))
|
||||||
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -588,7 +603,7 @@ drawbar(Monitor *m) {
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for(c = clients; c; c = c->next) {
|
for(c = clients; c; c = c->next) {
|
||||||
if(m == &mon[c->mon]) {
|
if(m == c->m) {
|
||||||
occ |= c->tags;
|
occ |= c->tags;
|
||||||
if(c->isurgent)
|
if(c->isurgent)
|
||||||
urg |= c->tags;
|
urg |= c->tags;
|
||||||
|
@ -598,9 +613,11 @@ drawbar(Monitor *m) {
|
||||||
dc.x = 0;
|
dc.x = 0;
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
dc.w = TEXTW(m->symbol);
|
dc.w = TEXTW(m->symbol);
|
||||||
drawtext(m->symbol, selmon == m ? dc.sel : dc.norm, False);
|
drawtext(NULL, selmon == m ? dc.sel : dc.norm, False);
|
||||||
dc.x += dc.w;
|
dc.x += dc.w;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
#endif /* XINERAMA */
|
#endif /* XINERAMA */
|
||||||
m->btx = dc.x;
|
m->btx = dc.x;
|
||||||
|
@ -648,10 +665,10 @@ drawbar(Monitor *m) {
|
||||||
|
|
||||||
void
|
void
|
||||||
drawbars() {
|
drawbars() {
|
||||||
unsigned int i;
|
Monitor *m;
|
||||||
|
|
||||||
for(i = 0; i < nmons; i++)
|
for(m = mons; m; m = m->next)
|
||||||
drawbar(&mon[i]);
|
drawbar(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -718,20 +735,20 @@ enternotify(XEvent *e) {
|
||||||
|
|
||||||
void
|
void
|
||||||
expose(XEvent *e) {
|
expose(XEvent *e) {
|
||||||
unsigned int i;
|
Monitor *m;
|
||||||
XExposeEvent *ev = &e->xexpose;
|
XExposeEvent *ev = &e->xexpose;
|
||||||
|
|
||||||
if(ev->count == 0)
|
if(ev->count == 0)
|
||||||
for(i = 0; i < nmons; i++)
|
for(m = mons; m; m = m->next)
|
||||||
if(ev->window == mon[i].barwin) {
|
if(ev->window == m->barwin) {
|
||||||
drawbar(&mon[i]);
|
drawbar(m);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
focus(Client *c) {
|
focus(Client *c) {
|
||||||
if(!c || !ISVISIBLE((&mon[c->mon]), c))
|
if(!c || !ISVISIBLE((c->m), c))
|
||||||
for(c = stack; c && !ISVISIBLE(selmon, c); c = c->snext);
|
for(c = stack; c && !ISVISIBLE(selmon, c); c = c->snext);
|
||||||
if(sel && sel != c) {
|
if(sel && sel != c) {
|
||||||
grabbuttons(sel, False);
|
grabbuttons(sel, False);
|
||||||
|
@ -763,11 +780,16 @@ focusin(XEvent *e) { /* there are some broken focus acquiring clients */
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
void
|
void
|
||||||
focusmon(const Arg *arg) {
|
focusmon(const Arg *arg) {
|
||||||
if(arg->ui >= nmons)
|
unsigned int i;
|
||||||
return;
|
Monitor *m;
|
||||||
selmon = &mon[arg->ui];
|
|
||||||
focus(NULL);
|
for(i = 0, m = mons; m; m = m->next, i++)
|
||||||
drawbars();
|
if(i == arg->ui) {
|
||||||
|
selmon = m;
|
||||||
|
focus(NULL);
|
||||||
|
drawbars();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* XINERAMA */
|
#endif /* XINERAMA */
|
||||||
|
|
||||||
|
@ -993,7 +1015,7 @@ manage(Window w, XWindowAttributes *wa) {
|
||||||
die("fatal: could not malloc() %u bytes\n", sizeof(Client));
|
die("fatal: could not malloc() %u bytes\n", sizeof(Client));
|
||||||
*c = cz;
|
*c = cz;
|
||||||
c->win = w;
|
c->win = w;
|
||||||
for(c->mon = 0; selmon != &mon[c->mon]; c->mon++);
|
c->m = selmon;
|
||||||
|
|
||||||
/* geometry */
|
/* geometry */
|
||||||
c->x = wa->x;
|
c->x = wa->x;
|
||||||
|
@ -1356,7 +1378,7 @@ setup(void) {
|
||||||
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
|
||||||
|
|
||||||
/* init cursors */
|
/* init cursors */
|
||||||
wa.cursor = cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
|
||||||
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
|
||||||
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
|
||||||
|
|
||||||
|
@ -1374,22 +1396,11 @@ setup(void) {
|
||||||
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
|
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
|
||||||
|
|
||||||
/* init bars */
|
/* init bars */
|
||||||
wa.override_redirect = True;
|
|
||||||
wa.background_pixmap = ParentRelative;
|
|
||||||
wa.event_mask = ButtonPressMask|ExposureMask;
|
|
||||||
for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) {
|
for(blw = i = 0; LENGTH(layouts) > 1 && i < LENGTH(layouts); i++) {
|
||||||
w = TEXTW(layouts[i].symbol);
|
w = TEXTW(layouts[i].symbol);
|
||||||
blw = MAX(blw, w);
|
blw = MAX(blw, w);
|
||||||
}
|
}
|
||||||
|
updatebars();
|
||||||
for(i = 0; i < nmons; i++) {
|
|
||||||
mon[i].barwin = XCreateWindow(dpy, root, mon[i].wx, mon[i].by, mon[i].ww, bh, 0, DefaultDepth(dpy, screen),
|
|
||||||
|
|
||||||
CopyFromParent, DefaultVisual(dpy, screen),
|
|
||||||
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
|
||||||
XDefineCursor(dpy, mon[i].barwin, cursor[CurNormal]);
|
|
||||||
XMapRaised(dpy, mon[i].barwin);
|
|
||||||
}
|
|
||||||
updatestatus();
|
updatestatus();
|
||||||
|
|
||||||
/* EWMH support per view */
|
/* EWMH support per view */
|
||||||
|
@ -1410,9 +1421,9 @@ void
|
||||||
showhide(Client *c) {
|
showhide(Client *c) {
|
||||||
if(!c)
|
if(!c)
|
||||||
return;
|
return;
|
||||||
if(ISVISIBLE((&mon[c->mon]), c)) { /* show clients top down */
|
if(ISVISIBLE((c->m), c)) { /* show clients top down */
|
||||||
XMoveWindow(dpy, c->win, c->x, c->y);
|
XMoveWindow(dpy, c->win, c->x, c->y);
|
||||||
if(!lt[mon[c->mon].sellt]->arrange || c->isfloating)
|
if(!lt[c->m->sellt]->arrange || c->isfloating)
|
||||||
resize(c, c->x, c->y, c->w, c->h);
|
resize(c, c->x, c->y, c->w, c->h);
|
||||||
showhide(c->snext);
|
showhide(c->snext);
|
||||||
}
|
}
|
||||||
|
@ -1453,10 +1464,15 @@ tag(const Arg *arg) {
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
void
|
void
|
||||||
tagmon(const Arg *arg) {
|
tagmon(const Arg *arg) {
|
||||||
if(!sel || arg->ui >= nmons)
|
unsigned int i;
|
||||||
return;
|
Monitor *m;
|
||||||
sel->mon = arg->ui;
|
|
||||||
arrange();
|
for(i = 0, m = mons; m; m = m->next, i++)
|
||||||
|
if(i == arg->ui) {
|
||||||
|
sel->m = m;
|
||||||
|
arrange();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif /* XINERAMA */
|
#endif /* XINERAMA */
|
||||||
|
|
||||||
|
@ -1578,92 +1594,112 @@ unmapnotify(XEvent *e) {
|
||||||
unmanage(c);
|
unmanage(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
updatebars(void) {
|
||||||
|
Monitor *m;
|
||||||
|
XSetWindowAttributes wa;
|
||||||
|
|
||||||
|
wa.cursor = cursor[CurNormal];
|
||||||
|
wa.override_redirect = True;
|
||||||
|
wa.background_pixmap = ParentRelative;
|
||||||
|
wa.event_mask = ButtonPressMask|ExposureMask;
|
||||||
|
|
||||||
|
for(m = mons; m; m = m->next) {
|
||||||
|
m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen),
|
||||||
|
|
||||||
|
CopyFromParent, DefaultVisual(dpy, screen),
|
||||||
|
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
|
||||||
|
XDefineCursor(dpy, m->barwin, cursor[CurNormal]);
|
||||||
|
XMapRaised(dpy, m->barwin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updategeom(void) {
|
updategeom(void) {
|
||||||
#ifdef XINERAMA
|
int i, n;
|
||||||
int n;
|
|
||||||
unsigned int i = 0;
|
|
||||||
Client *c;
|
Client *c;
|
||||||
|
Monitor *newmons = NULL, *m;
|
||||||
|
|
||||||
|
#ifdef XINERAMA
|
||||||
XineramaScreenInfo *info = NULL;
|
XineramaScreenInfo *info = NULL;
|
||||||
|
|
||||||
/* window area geometry */
|
if(XineramaIsActive(dpy))
|
||||||
if(XineramaIsActive(dpy) && (info = XineramaQueryScreens(dpy, &n))) {
|
info = XineramaQueryScreens(dpy, &n);
|
||||||
if(n != nmons) {
|
#endif
|
||||||
for(c = clients; c; c = c->next)
|
/* allocate monitor(s) for the new geometry setup */
|
||||||
if(c->mon >= n)
|
for(i = 0; i < n; i++) {
|
||||||
c->mon = n - 1;
|
m = (Monitor *)malloc(sizeof(Monitor));
|
||||||
if(!(mon = (Monitor *)realloc(mon, sizeof(Monitor) * n)))
|
m->next = newmons;
|
||||||
die("fatal: could not realloc() %u bytes\n", sizeof(Monitor) * nmons);
|
newmons = m;
|
||||||
selmon = NULL;
|
}
|
||||||
}
|
|
||||||
for(i = 0; i < n ; i++) {
|
/* initialise monitor(s) */
|
||||||
/* TODO: consider re-using XineramaScreenInfo */
|
#ifdef XINERAMA
|
||||||
mon[i].symbol[0] = '[';
|
if(XineramaIsActive(dpy)) {
|
||||||
mon[i].symbol[1] = '0' + info[i].screen_number;
|
for(i = 0, m = newmons; m; m = m->next, i++) {
|
||||||
mon[i].symbol[2] = ']';
|
m->screen_number = info[i].screen_number;
|
||||||
mon[i].symbol[3] = 0;
|
m->wx = info[i].x_org;
|
||||||
if(!selmon) { /* not initialised yet */
|
m->wy = info[i].y_org;
|
||||||
mon[i].mfact = mfact;
|
m->ww = info[i].width;
|
||||||
mon[i].showbar = showbar;
|
m->wh = info[i].height;
|
||||||
mon[i].topbar = topbar;
|
|
||||||
mon[i].tagset[0] = mon[i].tagset[1] = 1;
|
|
||||||
}
|
|
||||||
mon[i].wx = info[i].x_org;
|
|
||||||
mon[i].wy = mon[i].showbar && mon[i].topbar ? info[i].y_org + bh : info[i].y_org;
|
|
||||||
mon[i].ww = info[i].width;
|
|
||||||
mon[i].wh = mon[i].showbar ? info[i].height - bh : info[i].height;
|
|
||||||
mon[i].seltags = 0;
|
|
||||||
mon[i].sellt = 0;
|
|
||||||
if(mon[i].showbar)
|
|
||||||
mon[i].by = mon[i].topbar ? info[i].y_org : mon[i].wy + mon[i].wh;
|
|
||||||
else
|
|
||||||
mon[i].by = -bh;
|
|
||||||
}
|
|
||||||
nmons = (unsigned int)n;
|
|
||||||
if(!selmon) {
|
|
||||||
selmon = &mon[0];
|
|
||||||
int di, x, y;
|
|
||||||
unsigned int dui;
|
|
||||||
Window dummy;
|
|
||||||
if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
|
|
||||||
for(i = 0; i < nmons; i++)
|
|
||||||
if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)) {
|
|
||||||
selmon = &mon[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
XFree(info);
|
XFree(info);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* XINERAMA */
|
#endif
|
||||||
|
/* default monitor setup */
|
||||||
{
|
{
|
||||||
if(!mon) {
|
m->screen_number = 0;
|
||||||
nmons = 1;
|
m->wx = sx;
|
||||||
if(!(mon = (Monitor *)malloc(sizeof(Monitor))))
|
m->wy = sy;
|
||||||
die("fatal: could not malloc() %u bytes\n", sizeof(Monitor));
|
m->ww = sw;
|
||||||
}
|
m->wh = sh;
|
||||||
if(!selmon) {
|
|
||||||
mon[0].symbol[0] = '[';
|
|
||||||
mon[0].symbol[1] = '0';
|
|
||||||
mon[0].symbol[2] = ']';
|
|
||||||
mon[0].symbol[3] = 0;
|
|
||||||
mon[0].mfact = mfact;
|
|
||||||
mon[0].showbar = showbar;
|
|
||||||
mon[0].topbar = topbar;
|
|
||||||
mon[0].tagset[0] = mon[0].tagset[1] = 1;
|
|
||||||
}
|
|
||||||
mon[0].wx = sx;
|
|
||||||
mon[0].wy = mon[0].showbar && mon[0].topbar ? sy + bh : sy;
|
|
||||||
mon[0].ww = sw;
|
|
||||||
mon[0].wh = mon[0].showbar ? sh - bh : sh;
|
|
||||||
mon[0].seltags = 0;
|
|
||||||
mon[0].sellt = 0;
|
|
||||||
if(mon[0].showbar)
|
|
||||||
mon[0].by = mon[0].topbar ? sy : mon[0].wy + mon[0].wh;
|
|
||||||
else
|
|
||||||
mon[0].by = -bh;
|
|
||||||
selmon = &mon[0];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* bar geometry setup */
|
||||||
|
for(m = newmons; m; m = m->next) {
|
||||||
|
/* TODO: consider removing the following values from config.h */
|
||||||
|
m->seltags = 0;
|
||||||
|
m->sellt = 0;
|
||||||
|
m->tagset[0] = m->tagset[1] = 1;
|
||||||
|
m->mfact = mfact;
|
||||||
|
m->showbar = showbar;
|
||||||
|
m->topbar = topbar;
|
||||||
|
if(m->showbar) {
|
||||||
|
m->wh -= bh;
|
||||||
|
m->by = m->topbar ? m->wy : m->wy + m->wh;
|
||||||
|
m->wy = m->topbar ? m->wy + bh : m->wy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m->by = -bh;
|
||||||
|
/* reassign all clients with same screen number */
|
||||||
|
for(c = clients; c; c = c->next)
|
||||||
|
if(c->m->screen_number == m->screen_number)
|
||||||
|
c->m = m;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reassign left over clients with disappeared screen number */
|
||||||
|
for(c = clients; c; c = c->next)
|
||||||
|
if(c->m->screen_number >= n)
|
||||||
|
c->m = newmons;
|
||||||
|
|
||||||
|
/* select focused monitor */
|
||||||
|
if(!selmon) {
|
||||||
|
selmon = newmons;
|
||||||
|
int di, x, y;
|
||||||
|
unsigned int dui;
|
||||||
|
Window dummy;
|
||||||
|
if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
|
||||||
|
for(m = newmons; m; m = m->next)
|
||||||
|
if(INRECT(x, y, m->wx, m->wy, m->ww, m->wh)) {
|
||||||
|
selmon = m;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* final assignment of new monitors */
|
||||||
|
cleanupmons();
|
||||||
|
mons = newmons;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue