X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=58a5746bb5a4f5e1b98b32c47ce7766de4ca35f8;hp=a58eb2a4c930ef3fc2a4e0516be2be00e66b402d;hb=e5a1e77351bb4538a1a475739a00dcb41aa35701;hpb=b1a28ae1dab34a159e7cf17a82ecda0635e72f97 diff --git a/dwm.c b/dwm.c index a58eb2a..58a5746 100644 --- a/dwm.c +++ b/dwm.c @@ -58,7 +58,8 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ enum { NetSupported, NetWMName, NetWMState, - NetWMFullscreen, NetActiveWindow, NetLast }; /* EWMH atoms */ + NetWMFullscreen, NetActiveWindow, NetWMWindowType, + NetWMWindowTypeDialog, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ @@ -237,6 +238,7 @@ static void updatebars(void); static void updatenumlockmask(void); static void updatesizehints(Client *c); static void updatestatus(void); +static void updatewindowtype(Client *c); static void updatetitle(Client *c); static void updatewmhints(Client *c); static void view(const Arg *arg); @@ -338,14 +340,14 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) { *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(*x >= m->wx + m->ww) + *x = m->wx + m->ww - WIDTH(c); + if(*y >= m->wy + m->wh) + *y = m->wy + m->wh - HEIGHT(c); + if(*x + *w + 2 * c->bw <= m->wx) + *x = m->wx; + if(*y + *h + 2 * c->bw <= m->wy) + *y = m->wy; } if(*h < bh) *h = bh; @@ -1028,7 +1030,7 @@ grabkeys(void) { void incnmaster(const Arg *arg) { - selmon->nmaster = MAX(selmon->nmaster + arg->i, 1); + selmon->nmaster = MAX(selmon->nmaster + arg->i, 0); arrange(selmon); } @@ -1144,7 +1146,7 @@ manage(Window w, XWindowAttributes *wa) { c->y = c->mon->my + c->mon->mh - HEIGHT(c); c->x = MAX(c->x, c->mon->mx); /* only fix client y-offset, if the client center might cover the bar */ - c->y = MAX(c->y, ((c->mon->by == 0) && (c->x + (c->w / 2) >= c->mon->wx) + c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); c->bw = borderpx; } @@ -1152,6 +1154,7 @@ manage(Window w, XWindowAttributes *wa) { XConfigureWindow(dpy, w, CWBorderWidth, &wc); XSetWindowBorder(dpy, w, dc.norm[ColBorder]); configure(c); /* propagates border_width, if size doesn't change */ + updatewindowtype(c); updatesizehints(c); updatewmhints(c); XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask); @@ -1308,6 +1311,8 @@ propertynotify(XEvent *e) { if(c == c->mon->sel) drawbar(c->mon); } + if(ev->atom == netatom[NetWMWindowType]) + updatewindowtype(c); } } @@ -1562,6 +1567,8 @@ setup(void) { netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); + netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); + netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); /* init cursors */ cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr); cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing); @@ -1606,7 +1613,7 @@ showhide(Client *c) { } else { /* hide clients bottom up */ showhide(c->snext); - XMoveWindow(dpy, c->win, c->w * -2, c->y); + XMoveWindow(dpy, c->win, WIDTH(c) * -2, c->y); } } @@ -1659,23 +1666,28 @@ textnw(const char *text, unsigned int len) { void tile(Monitor *m) { - unsigned int i, n, mw, mh, tw, th; + unsigned int i, n, h, mw, my, ty; Client *c; for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); if(n == 0) return; - mh = (n > m->nmaster) ? m->wh / m->nmaster : m->wh / n; - mw = (n > m->nmaster) ? m->ww * m->mfact : m->ww; - th = (n > m->nmaster) ? m->wh / (n - m->nmaster) : 0; - tw = m->ww - mw; - - for(i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) - if(i < m->nmaster) - resize(c, m->wx, m->wy + (i*mh), mw - (2*c->bw), mh - (2*c->bw), False); - else - resize(c, m->wx + mw, m->wy + ((i - m->nmaster)*th), tw - (2*c->bw), th - (2*c->bw), False); + if(n > m->nmaster) + mw = m->nmaster ? m->ww * m->mfact : 0; + else + mw = m->ww; + for(i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) + if(i < m->nmaster) { + h = (m->wh - my) / (MIN(n, m->nmaster) - i); + resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False); + my += HEIGHT(c); + } + else { + h = (m->wh - ty) / (n - i); + resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False); + ty += HEIGHT(c); + } } void @@ -1962,6 +1974,25 @@ updatestatus(void) { } void +updatewindowtype(Client *c) +{ + Atom wtype, real; + int format; + unsigned long n, extra; + unsigned char *p = NULL; + + if(XGetWindowProperty(dpy, c->win, netatom[NetWMWindowType], 0L, + sizeof(Atom), False, XA_ATOM, &real, &format, + &n, &extra, (unsigned char **)&p) == Success && p) { + wtype = *(Atom *)p; + XFree(p); + + if(wtype == netatom[NetWMWindowTypeDialog]) + c->isfloating = True; + } +} + +void updatewmhints(Client *c) { XWMHints *wmh;