- * set the override_redirect flag. Clients are organized in a global
- * linked client list, the focus history is remembered through a global
- * stack list. Each client contains a bit array to indicate the tags of a
+ * set the override_redirect flag. Clients are organized in a linked client
+ * list on each monitor, the focus history is remembered through a stack list
+ * on each monitor. Each client contains a bit array to indicate the tags of a
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
#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 BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
#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 LENGTH(X) (sizeof X / sizeof X[0])
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#define MIN(A, B) ((A) < (B) ? (A) : (B))
#define LENGTH(X) (sizeof X / sizeof X[0])
#define MAX(A, B) ((A) > (B) ? (A) : (B))
#define MIN(A, B) ((A) < (B) ? (A) : (B))
int wx, wy, ww, wh; /* window area */
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
Bool showbar;
Bool topbar;
int wx, wy, ww, wh; /* window area */
unsigned int seltags;
unsigned int sellt;
unsigned int tagset[2];
Bool showbar;
Bool topbar;
-static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h);
+static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
static void arrange(void);
static void attach(Client *c);
static void attachstack(Client *c);
static void arrange(void);
static void attach(Client *c);
static void attachstack(Client *c);
static void detach(Client *c);
static void detachstack(Client *c);
static void die(const char *errstr, ...);
static void detach(Client *c);
static void detachstack(Client *c);
static void die(const char *errstr, ...);
static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
static void enternotify(XEvent *e);
static void expose(XEvent *e);
static void focus(Client *c);
static void focusin(XEvent *e);
static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
static void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
static void enternotify(XEvent *e);
static void expose(XEvent *e);
static void focus(Client *c);
static void focusin(XEvent *e);
static long getstate(Window w);
static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
static void grabbuttons(Client *c, Bool focused);
static long getstate(Window w);
static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
static void grabbuttons(Client *c, Bool focused);
static void maprequest(XEvent *e);
static void monocle(Monitor *m);
static void movemouse(const Arg *arg);
static void maprequest(XEvent *e);
static void monocle(Monitor *m);
static void movemouse(const Arg *arg);
-static void resize(Client *c, int x, int y, int w, int h);
+static void resize(Client *c, int x, int y, int w, int h, Bool interact);
static void setclientstate(Client *c, long state);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void setclientstate(Client *c, long state);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
static void sigchld(int signal);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void sigchld(int signal);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static int textnw(const char *text, unsigned int len);
static void tile(Monitor *);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static int textnw(const char *text, unsigned int len);
static void tile(Monitor *);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unmanage(Client *c);
static void unmapnotify(XEvent *e);
static void updategeom(void);
static void unmanage(Client *c);
static void unmapnotify(XEvent *e);
static void updategeom(void);
static void updatetitle(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
static void updatetitle(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
-static int sx, sy, sw, sh; /* X display screen geometry x, y, width, height */
+static int sw, sh; /* X display screen geometry x, y, width, height */
static int bh, blw = 0; /* bar geometry */
static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0;
static int bh, blw = 0; /* bar geometry */
static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0;
static Atom wmatom[WMLast], netatom[NetLast];
static Bool otherwm;
static Bool running = True;
static Atom wmatom[WMLast], netatom[NetLast];
static Bool otherwm;
static Bool running = True;
r = &rules[i];
if((!r->title || strstr(c->name, r->title))
&& (!r->class || (ch.res_class && strstr(ch.res_class, r->class)))
r = &rules[i];
if((!r->title || strstr(c->name, r->title))
&& (!r->class || (ch.res_class && strstr(ch.res_class, r->class)))
-applysizehints(Client *c, int *x, int *y, int *w, int *h) {
+applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) {
-
- if(*x > sx + sw)
- *x = sw - WIDTH(c);
- if(*y > sy + sh)
- *y = sh - HEIGHT(c);
- if(*x + *w + 2 * c->bw < sx)
- *x = sx;
- if(*y + *h + 2 * c->bw < sy)
- *y = sy;
+ if(interact) {
+ if(*x > sw)
+ *x = sw - WIDTH(c);
+ if(*y > sh)
+ *y = sh - HEIGHT(c);
+ if(*x + *w + 2 * c->bw < 0)
+ *x = 0;
+ if(*y + *h + 2 * c->bw < 0)
+ *y = 0;
+ }
+ else {
+ if(*x > m->mx + m->mw)
+ *x = m->mx + m->mw - WIDTH(c);
+ if(*y > m->my + m->mh)
+ *y = m->my + m->mh - HEIGHT(c);
+ if(*x + *w + 2 * c->bw < m->mx)
+ *x = m->mx;
+ if(*y + *h + 2 * c->bw < m->my)
+ *y = m->my;
+ }
if(resizehints || c->isfloating) {
/* see last two sentences in ICCCM 4.1.2.3 */
baseismin = c->basew == c->minw && c->baseh == c->minh;
if(resizehints || c->isfloating) {
/* see last two sentences in ICCCM 4.1.2.3 */
baseismin = c->basew == c->minw && c->baseh == c->minh;
/* adjust for aspect limits */
if(c->mina > 0 && c->maxa > 0) {
if(c->maxa < (float)*w / *h)
/* adjust for aspect limits */
if(c->mina > 0 && c->maxa > 0) {
if(c->maxa < (float)*w / *h)
for(i = 0; i < LENGTH(buttons); i++)
if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
for(i = 0; i < LENGTH(buttons); i++)
if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
/* this causes an error if some other window manager is running */
XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
XSync(dpy, False);
/* this causes an error if some other window manager is running */
XSelectInput(dpy, DefaultRootWindow(dpy), SubstructureRedirectMask);
XSync(dpy, False);
- if((c->x - sx + c->w) > sw && c->isfloating)
- c->x = sx + (sw / 2 - c->w / 2); /* center in x direction */
- if((c->y - sy + c->h) > sh && c->isfloating)
- c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
+ if((c->x - m->mx + c->w) > m->mw && c->isfloating)
+ c->x = m->mx + (m->mw / 2 - c->w / 2); /* center in x direction */
+ if((c->y - m->my + c->h) > m->mh && c->isfloating)
+ c->y = m->my + (m->mh / 2 - c->h / 2); /* center in y direction */
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
}
else
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
}
else
-#ifdef XINERAMA
- {
- buf[0] = m->screen_number + '0';
- buf[1] = '\0';
- dc.w = TEXTW(buf);
- drawtext(buf, selmon == m ? dc.sel : dc.norm, True);
+ if(mons->next) { /* more than a single monitor */
+ dc.w = TEXTW(monsyms[m->screen_number]);
+ drawtext(monsyms[m->screen_number], selmon == m ? dc.sel : dc.norm, False);
m->btx = dc.x;
for(i = 0; i < LENGTH(tags); i++) {
dc.w = TEXTW(tags[i]);
col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
drawtext(tags[i], col, urg & 1 << i);
m->btx = dc.x;
for(i = 0; i < LENGTH(tags); i++) {
dc.w = TEXTW(tags[i]);
col = m->tagset[m->seltags] & 1 << i ? dc.sel : dc.norm;
drawtext(tags[i], col, urg & 1 << i);
- if((dc.w = dc.x - x) > bh) {
- dc.x = x;
- if(sel) {
- drawtext(sel->name, dc.sel, False);
- drawsquare(sel->isfixed, sel->isfloating, False, dc.sel);
- }
- else
- drawtext(NULL, dc.norm, False);
- }
- dc.w = m->ww - x;
- drawtext(NULL, dc.norm, False);
+ if(m->sel) {
+ col = m == selmon ? dc.sel : dc.norm;
+ drawtext(m->sel->name, col, False);
+ drawsquare(m->sel->isfixed, m->sel->isfloating, False, col);
+ }
+ else
+ drawtext(NULL, dc.norm, False);
}
XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
XSync(dpy, False);
}
void
}
XCopyArea(dpy, dc.drawable, m->barwin, dc.gc, 0, 0, m->ww, bh, 0, 0);
XSync(dpy, False);
}
void
XCrossingEvent *ev = &e->xcrossing;
if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
return;
XCrossingEvent *ev = &e->xcrossing;
if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
return;
- if(!c || !ISVISIBLE((c->m), c))
- for(c = stack; c && !ISVISIBLE(selmon, c); c = c->snext);
- if(sel && sel != c) {
- grabbuttons(sel, False);
- XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
- }
+ if(!c || !ISVISIBLE(c))
+ for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
+ if(selmon->sel)
+ unfocus(selmon->sel);
}
else
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
}
else
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
focusin(XEvent *e) { /* there are some broken focus acquiring clients */
XFocusChangeEvent *ev = &e->xfocus;
focusin(XEvent *e) { /* there are some broken focus acquiring clients */
XFocusChangeEvent *ev = &e->xfocus;
- if(sel && ev->window != sel->win)
- XSetInputFocus(dpy, sel->win, RevertToPointerRoot, CurrentTime);
+ if(selmon->sel && ev->window != selmon->sel->win)
+ XSetInputFocus(dpy, selmon->sel->win, RevertToPointerRoot, CurrentTime);
unsigned long
getcolor(const char *colstr) {
Colormap cmap = DefaultColormap(dpy, screen);
unsigned long
getcolor(const char *colstr) {
Colormap cmap = DefaultColormap(dpy, screen);
+Bool
+getrootptr(int *x, int *y) {
+ int di;
+ unsigned int dui;
+ Window dummy;
+
+ return XQueryPointer(dpy, root, &dummy, &dummy, x, y, &di, &di, &dui);
+}
+
strncpy(text, (char *)name.value, size - 1);
else {
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
strncpy(text, (char *)name.value, size - 1);
else {
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
buttons[i].mask | modifiers[j],
c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
buttons[i].mask | modifiers[j],
c->win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
}
XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
}
unsigned int i, j;
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
KeyCode code;
unsigned int i, j;
unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
KeyCode code;
ev.xclient.message_type = wmatom[WMProtocols];
ev.xclient.format = 32;
ev.xclient.data.l[0] = wmatom[WMDelete];
ev.xclient.data.l[1] = CurrentTime;
ev.xclient.message_type = wmatom[WMProtocols];
ev.xclient.format = 32;
ev.xclient.data.l[0] = wmatom[WMDelete];
ev.xclient.data.l[1] = CurrentTime;
- XSendEvent(dpy, sel->win, False, NoEventMask, &ev);
+ XSendEvent(dpy, selmon->sel->win, False, NoEventMask, &ev);
- if(c->x + WIDTH(c) > sx + sw)
- c->x = sx + sw - WIDTH(c);
- if(c->y + HEIGHT(c) > sy + sh)
- c->y = sy + sh - HEIGHT(c);
- c->x = MAX(c->x, sx);
+ if(c->x + WIDTH(c) > c->mon->mx + c->mon->mw)
+ c->x = c->mon->mx + c->mon->mw - WIDTH(c);
+ if(c->y + HEIGHT(c) > c->mon->my + c->mon->mh)
+ c->y = c->mon->my + c->mon->mh - HEIGHT(c);
+ c->x = MAX(c->x, c->mon->mx);
- c->y = MAX(c->y, ((selmon->by == 0) && (c->x + (c->w / 2) >= selmon->wx)
- && (c->x + (c->w / 2) < selmon->wx + selmon->ww)) ? bh : sy);
+ c->y = MAX(c->y, ((c->mon->by == 0) && (c->x + (c->w / 2) >= c->mon->wx)
+ && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
wc.border_width = c->bw;
XConfigureWindow(dpy, w, CWBorderWidth, &wc);
XSetWindowBorder(dpy, w, dc.norm[ColBorder]);
- for(c = nexttiled(m, clients); c; c = nexttiled(m, c->next))
- resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw);
+ for(c = nexttiled(m->clients); c; c = nexttiled(c->next))
+ resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False);
- int x, y, ocx, ocy, di, nx, ny;
- unsigned int dui;
+ int x, y, ocx, ocy, nx, ny;
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurMove], CurrentTime) != GrabSuccess)
return;
if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, cursor[CurMove], CurrentTime) != GrabSuccess)
return;
- XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui);
+ if(!getrootptr(&x, &y))
+ return;
ny = selmon->wy;
else if(abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
ny = selmon->wy + selmon->wh - HEIGHT(c);
ny = selmon->wy;
else if(abs((selmon->wy + selmon->wh) - (ny + HEIGHT(c))) < snap)
ny = selmon->wy + selmon->wh - HEIGHT(c);
- if(!lt[selmon->sellt]->arrange || c->isfloating)
- resize(c, nx, ny, c->w, c->h);
+ if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+ resize(c, nx, ny, c->w, c->h, True);
break;
}
}
while(ev.type != ButtonRelease);
XUngrabPointer(dpy, CurrentTime);
break;
}
}
while(ev.type != ButtonRelease);
XUngrabPointer(dpy, CurrentTime);
+Monitor *
+ptrtomon(int x, int y) {
+ Monitor *m;
+
+ for(m = mons; m; m = m->next)
+ if(INRECT(x, y, m->wx, m->wy, m->ww, m->wh))
+ return m;
+ return selmon;
+}
+
switch (ev->atom) {
default: break;
case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(dpy, c->win, &trans);
switch (ev->atom) {
default: break;
case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(dpy, c->win, &trans);
-resize(Client *c, int x, int y, int w, int h) {
+resize(Client *c, int x, int y, int w, int h, Bool interact) {
- if(applysizehints(c, &x, &y, &w, &h)) {
+ if(applysizehints(c, &x, &y, &w, &h, interact)) {
- XConfigureWindow(dpy, c->win,
- CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
+ XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
case MotionNotify:
nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
case MotionNotify:
nw = MAX(ev.xmotion.x - ocx - 2 * c->bw + 1, 1);
nh = MAX(ev.xmotion.y - ocy - 2 * c->bw + 1, 1);
if(snap && nw >= selmon->wx && nw <= selmon->wx + selmon->ww
&& nh >= selmon->wy && nh <= selmon->wy + selmon->wh) {
if(snap && nw >= selmon->wx && nw <= selmon->wx + selmon->ww
&& nh >= selmon->wy && nh <= selmon->wy + selmon->wh) {
- if(!lt[selmon->sellt]->arrange || c->isfloating)
- resize(c, c->x, c->y, nw, nh);
+ if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
+ resize(c, c->x, c->y, nw, nh, True);
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
XUngrabPointer(dpy, CurrentTime);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->bw - 1, c->h + c->bw - 1);
XUngrabPointer(dpy, CurrentTime);
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
- if(m == selmon && (sel->isfloating || !lt[m->sellt]->arrange))
- XRaiseWindow(dpy, sel->win);
- if(lt[m->sellt]->arrange) {
+ if(m->sel->isfloating || !m->lt[m->sellt]->arrange)
+ XRaiseWindow(dpy, m->sel->win);
+ if(m->lt[m->sellt]->arrange) {
- for(c = stack; c; c = c->snext)
- if(!c->isfloating && ISVISIBLE(m, c)) {
+ for(c = m->stack; c; c = c->snext)
+ if(!c->isfloating && ISVISIBLE(c)) {
XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
wc.sibling = c->win;
}
XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
wc.sibling = c->win;
}
XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
PropModeReplace, (unsigned char *)data, 2);
XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
PropModeReplace, (unsigned char *)data, 2);
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
initfont(font);
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
initfont(font);
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
bh = dc.h = dc.font.height + 2;
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
bh = dc.h = dc.font.height + 2;
/* init atoms */
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
/* init atoms */
wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
/* init cursors */
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
/* init cursors */
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(!dc.font.set)
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(!dc.font.set)
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
/* EWMH support per view */
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
PropModeReplace, (unsigned char *) netatom, NetLast);
/* EWMH support per view */
XChangeProperty(dpy, root, netatom[NetSupported], XA_ATOM, 32,
PropModeReplace, (unsigned char *) netatom, NetLast);
/* select for events */
wa.cursor = cursor[CurNormal];
wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask
/* select for events */
wa.cursor = cursor[CurNormal];
wa.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|ButtonPressMask
|PropertyChangeMask;
XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
XSelectInput(dpy, root, wa.event_mask);
|PropertyChangeMask;
XChangeWindowAttributes(dpy, root, CWEventMask|CWCursor, &wa);
XSelectInput(dpy, root, wa.event_mask);
XMoveWindow(dpy, c->win, c->x, c->y);
XMoveWindow(dpy, c->win, c->x, c->y);
- if(!lt[c->m->sellt]->arrange || c->isfloating)
- resize(c, c->x, c->y, c->w, c->h);
+ if(!c->mon->lt[c->mon->sellt]->arrange || c->isfloating)
+ resize(c, c->x, c->y, c->w, c->h, False);
- unsigned int i;
- Monitor *m;
-
- for(i = 0, m = mons; m; m = m->next, i++)
- if(i == arg->ui) {
- sel->m = m;
- arrange();
- break;
- }
+ if(!selmon->sel || !mons->next)
+ return;
+ sendmon(selmon->sel, dirtomon(arg->i));
- for(n = 0, c = nexttiled(m, clients); c; c = nexttiled(m, c->next), n++);
+ for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
- resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw);
-
+ resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw, False);
-
- for(i = 0, c = nexttiled(m, c->next); c; c = nexttiled(m, c->next), i++) {
+ for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
- sel->isfloating = !sel->isfloating || sel->isfixed;
- if(sel->isfloating)
- resize(sel, sel->x, sel->y, sel->w, sel->h);
+ selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
+ if(selmon->sel->isfloating)
+ resize(selmon->sel, selmon->sel->x, selmon->sel->y,
+ selmon->sel->w, selmon->sel->h, False);
+void
+unfocus(Client *c) {
+ if(!c)
+ return;
+ grabbuttons(c, False);
+ XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
+ XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
+}
+
XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
detach(c);
detachstack(c);
XConfigureWindow(dpy, c->win, CWBorderWidth, &wc); /* restore border */
detach(c);
detachstack(c);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
setclientstate(c, WithdrawnState);
free(c);
XSync(dpy, False);
XSetErrorHandler(xerror);
XUngrabServer(dpy);
XUngrabButton(dpy, AnyButton, AnyModifier, c->win);
setclientstate(c, WithdrawnState);
free(c);
XSync(dpy, False);
XSetErrorHandler(xerror);
XUngrabServer(dpy);
wa.override_redirect = True;
wa.background_pixmap = ParentRelative;
wa.event_mask = ButtonPressMask|ExposureMask;
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),
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]);
CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa);
XDefineCursor(dpy, m->barwin, cursor[CurNormal]);
#ifdef XINERAMA
XineramaScreenInfo *info = NULL;
if(XineramaIsActive(dpy))
info = XineramaQueryScreens(dpy, &n);
#ifdef XINERAMA
XineramaScreenInfo *info = NULL;
if(XineramaIsActive(dpy))
info = XineramaQueryScreens(dpy, &n);
/* initialise monitor(s) */
#ifdef XINERAMA
if(XineramaIsActive(dpy)) {
for(i = 0, m = newmons; m; m = m->next, i++) {
m->screen_number = info[i].screen_number;
/* initialise monitor(s) */
#ifdef XINERAMA
if(XineramaIsActive(dpy)) {
for(i = 0, m = newmons; m; m = m->next, i++) {
m->screen_number = info[i].screen_number;
-
- /* reassign left over clients with disappeared screen number */
- for(c = clients; c; c = c->next)
- if(c->m->screen_number >= n)
- c->m = newmons;
-
+ /* reassign left over clients of disappeared monitors */
+ for(tm = mons; tm; tm = tm->next)
+ while(tm->clients) {
+ c = tm->clients;
+ tm->clients = c->next;
+ detachstack(c);
+ c->mon = newmons;
+ attach(c);
+ attachstack(c);
+ }
- 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 */
if(!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
strcpy(stext, "dwm-"VERSION);
drawbar(selmon);
if(!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
strcpy(stext, "dwm-"VERSION);
drawbar(selmon);
wmh->flags &= ~XUrgencyHint;
XSetWMHints(dpy, c->win, wmh);
}
else
c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
wmh->flags &= ~XUrgencyHint;
XSetWMHints(dpy, c->win, wmh);
}
else
c->isurgent = (wmh->flags & XUrgencyHint) ? True : False;
+Client *
+wintoclient(Window w) {
+ Client *c;
+ Monitor *m;
+
+ for(m = mons; m; m = m->next)
+ for(c = m->clients; c; c = c->next)
+ if(c->win == w)
+ return c;
+ return NULL;
+}
+
+Monitor *
+wintomon(Window w) {
+ int x, y;
+ Client *c;
+ Monitor *m;
+
+ if(w == root && getrootptr(&x, &y))
+ return ptrtomon(x, y);
+ for(m = mons; m; m = m->next)
+ if(w == m->barwin)
+ return m;
+ if((c = wintoclient(w)))
+ return c->mon;
+ return selmon;
+}
+
/* There's no way to check accesses to destroyed windows, thus those cases are
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
* default error handler, which may call exit. */
/* There's no way to check accesses to destroyed windows, thus those cases are
* ignored (especially on UnmapNotify's). Other types of errors call Xlibs
* default error handler, which may call exit. */
- if(!lt[selmon->sellt]->arrange || lt[selmon->sellt]->arrange == monocle || (sel && sel->isfloating))
+ if(!selmon->lt[selmon->sellt]->arrange
+ || selmon->lt[selmon->sellt]->arrange == monocle
+ || (selmon->sel && selmon->sel->isfloating))
- if(c == nexttiled(selmon, clients))
- if(!c || !(c = nexttiled(selmon, c->next)))
+ if(c == nexttiled(selmon->clients))
+ if(!c || !(c = nexttiled(c->next)))
die("dwm-"VERSION", © 2006-2009 dwm engineers, see LICENSE for details\n");
else if(argc != 1)
die("usage: dwm [-v]\n");
die("dwm-"VERSION", © 2006-2009 dwm engineers, see LICENSE for details\n");
else if(argc != 1)
die("usage: dwm [-v]\n");
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fputs("warning: no locale support\n", stderr);
if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
fputs("warning: no locale support\n", stderr);