X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=241c090b7c8262eac9b8ac79a211e602c633ffda;hp=71ab0f2ae30a36c6acbfc6de7323d2079ea8e954;hb=a2449d2026aa94558773653b1ae1834e32ce64ba;hpb=e5d1064c01081044c63325f4c195fcec58442654 diff --git a/dwm.c b/dwm.c index 71ab0f2..241c090 100644 --- a/dwm.c +++ b/dwm.c @@ -61,7 +61,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { SchemeNorm, SchemeSel, SchemeLast }; /* color schemes */ enum { NetSupported, NetWMName, NetWMState, NetWMFullscreen, NetWMWindowOpacity, NetActiveWindow, NetWMWindowType, - NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ + NetWMWindowTypeDialog, NetClientList, NetSupportingWMCheck, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ @@ -187,13 +187,14 @@ static void monocle(Monitor *m); static void motionnotify(XEvent *e); static void movemouse(const Arg *arg); static Client *nexttiled(Client *c); +static Client *snexttiled(Client *c); static Client *nextvisible(Client *c); static void pop(Client *); static void propertynotify(XEvent *e); static void quit(const Arg *arg); static Monitor *recttomon(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 resizeclient(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, Client *base); +static void resizeclient(Client *c, int x, int y, int w, int h, Client *base); static void resizemouse(const Arg *arg); static void restack(Monitor *m); static void run(void); @@ -317,12 +318,12 @@ update_window_opacities(Monitor *m) { } for (c = m->clients; c; c = c->next) { if (ISVISIBLE(c)) { - if (c->isfloating || c == m->sel || (c == master && selection_floating)) { + if (c->isfloating || c == m->sel || (selection_floating && (c == master || c == slave))) { window_set_opaque(c); } else if (c == master || c == slave) { window_set_translucent(c); } else { - window_set_invisible(c); + window_set_opaque(c); } } } @@ -374,7 +375,7 @@ applyrules(Client *c) { Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) { Bool baseismin; - Monitor *m = c->mon; + // Monitor *m = c->mon; /* set minimum possible */ *w = MAX(1, *w); @@ -389,16 +390,17 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) { if(*y + *h + 2 * c->bw < 0) *y = 0; } - else { - 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; - } + // jason: let windows be offscreen + //else { + // 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; if(*w < bh) @@ -599,6 +601,7 @@ clientmessage(XEvent *e) { || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); } else if(cme->message_type == netatom[NetActiveWindow]) { + // Jason added this so apps can't steal focus: return; if(!ISVISIBLE(c)) { c->mon->seltags ^= 1; @@ -842,6 +845,8 @@ enternotify(XEvent *e) { Monitor *m; XCrossingEvent *ev = &e->xcrossing; + return; // jason: added to stop mouse focus + if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root) return; c = wintoclient(ev->window); @@ -887,6 +892,7 @@ focus(Client *c) { XDeleteProperty(dpy, root, netatom[NetActiveWindow]); } selmon->sel = c; + arrange(selmon); update_window_opacities(selmon); drawbars(); if(c && (!root || (c->win!=root)) ) @@ -1195,8 +1201,14 @@ monocle(Monitor *m) { n++; if(n > 0) /* override layout symbol */ snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n); - 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); + for(c = snexttiled(m->stack); c; c = snexttiled(c->snext)) { + if (c == m->sel) { + resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False, 0); + } else { + // this window is should not be visible. move off top, but don't change h/w + resize(c, m->wx, m->wy - 4000, c->w, c->h, False, 0); + } + } } void @@ -1265,7 +1277,7 @@ movemouse(const Arg *arg) { togglefloating(NULL); } if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) - resize(c, nx, ny, c->w, c->h, True); + resize(c, nx, ny, c->w, c->h, True, 0); break; } } while(ev.type != ButtonRelease); @@ -1284,6 +1296,12 @@ nexttiled(Client *c) { } Client * +snexttiled(Client *c) { + for(; c && (c->isfloating || !ISVISIBLE(c)); c = c->snext); + return c; +} + +Client * nextvisible(Client *c) { for(; c && !ISVISIBLE(c); c = c->next); return c; @@ -1352,21 +1370,28 @@ recttomon(int x, int y, int w, int h) { } void -resize(Client *c, int x, int y, int w, int h, Bool interact) { +resize(Client *c, int x, int y, int w, int h, Bool interact, Client *base) { if(applysizehints(c, &x, &y, &w, &h, interact)) - resizeclient(c, x, y, w, h); + resizeclient(c, x, y, w, h, base); } void -resizeclient(Client *c, int x, int y, int w, int h) { +resizeclient(Client *c, int x, int y, int w, int h, Client *base) { XWindowChanges wc; + unsigned long mask = CWX|CWY|CWWidth|CWHeight|CWBorderWidth; c->oldx = c->x; c->x = wc.x = x; c->oldy = c->y; c->y = wc.y = y; c->oldw = c->w; c->w = wc.width = w; c->oldh = c->h; c->h = wc.height = h; + // base = 0; + if (base) { + wc.stack_mode = Above; + wc.sibling = base->win; + mask |= CWStackMode|CWSibling; + } wc.border_width = c->bw; - XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); + XConfigureWindow(dpy, c->win, mask, &wc); configure(c); XSync(dpy, False); } @@ -1413,7 +1438,7 @@ resizemouse(const Arg *arg) { togglefloating(NULL); } if(!selmon->lt[selmon->sellt]->arrange || c->isfloating) - resize(c, c->x, c->y, nw, nh, True); + resize(c, c->x, c->y, nw, nh, True, 0); break; } } while(ev.type != ButtonRelease); @@ -1441,10 +1466,11 @@ restack(Monitor *m) { if(m->lt[m->sellt]->arrange) { wc.stack_mode = Below; wc.sibling = m->barwin; - for(c = m->stack; c; c = c->snext) + for(c = m->clients; c; c = c->next) if(!c->isfloating && ISVISIBLE(c)) { XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); wc.sibling = c->win; + wc.stack_mode = Above; } } XSync(dpy, False); @@ -1555,7 +1581,7 @@ setfullscreen(Client *c, Bool fullscreen) { c->oldbw = c->bw; c->bw = 0; c->isfloating = True; - resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh); + resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh, 0); XRaiseWindow(dpy, c->win); } else { @@ -1568,7 +1594,7 @@ setfullscreen(Client *c, Bool fullscreen) { c->y = c->oldy; c->w = c->oldw; c->h = c->oldh; - resizeclient(c, c->x, c->y, c->w, c->h); + resizeclient(c, c->x, c->y, c->w, c->h, 0); arrange(c->mon); } } @@ -1631,6 +1657,7 @@ setup(void) { netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); + netatom[NetSupportingWMCheck] = XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); /* init cursors */ cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr); cursor[CurResize] = drw_cur_create(drw, XC_sizing); @@ -1666,7 +1693,7 @@ showhide(Client *c) { if(ISVISIBLE(c)) { /* show clients top down */ XMoveWindow(dpy, c->win, c->x, c->y); if((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen) - resize(c, c->x, c->y, c->w, c->h, False); + resize(c, c->x, c->y, c->w, c->h, False, 0); showhide(c->snext); } else { /* hide clients bottom up */ @@ -1692,8 +1719,8 @@ spawn(const Arg *arg) { break; } } - _SWM_WS[8] = swm_tags[tag][0]; - _SWM_WS[9] = swm_tags[tag][1]; + WORKSPACE_NUMBER[17] = workspace_numbers_str[tag][0]; + WORKSPACE_NUMBER[18] = workspace_numbers_str[tag][1]; } if(arg->v == dmenucmd) dmenumon[0] = '0' + selmon->num; @@ -1745,54 +1772,73 @@ tile(Monitor *m) { 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); + resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False, 0); 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); + resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False, 0); ty += HEIGHT(c); } } +#define TAB_HEIGHT 19 +#define TAB_PAD 7 + void jason_layout(Monitor *m) { - unsigned int i, n, mw; - Client *c, *vis_slave; - - for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++); - if(n == 0) { + unsigned int i, tiled_count, mw, right_width, tab_counts[2] = {0,0}, cur_tab = 0, *tab_count; + int tab_top; + Client *c, *vis_slave = 0, *base = 0; + + tab_count = &(tab_counts[0]); + + for(tiled_count = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), tiled_count++) { + if (tiled_count == 0) { // master + if (c->next) { + if (m->sel && (m->sel == c || m->sel->isfloating || !ISVISIBLE(m->sel))) { + vis_slave = nexttiled(c->next); + } else { + vis_slave = m->sel; + } + } + } else { + if (c == vis_slave) { + tab_count = &(tab_counts[1]); + } else { + (*tab_count) += 1; + } + } + } + if(tiled_count == 0) { return; } - c = nexttiled(m->clients); - if (c == m->sel) { - // if master is selected, show first slave - vis_slave = nexttiled(c->next); - } else { - vis_slave = m->sel; - } - if(n > 1 || (n == 1 && !c->screen_hog)) { + if(tiled_count > 1 || (tiled_count == 1 && !nexttiled(m->clients)->screen_hog)) { mw = m->ww * m->mfact; } else { - // one of these: - // * zero tiled windows - // * one tiled window that's not a screen hog - // * miltiple tiled windows mw = m->ww; } + right_width = m->ww - mw; + tab_count = &(tab_counts[0]); + tab_top = m->wy - (m->wh - (2 * (TAB_HEIGHT + TAB_PAD))) + TAB_HEIGHT; for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) { if (i == 0) { - resize(c, m->wx, m->wy, mw, m->wh, False); + resize(c, m->wx, m->wy, mw, m->wh, False, 0); } else { if (c == vis_slave) { - resize(c, m->wx + mw, m->wy, m->ww - mw, m->wh, False); + resize(c, m->wx + mw, m->wy + TAB_HEIGHT + TAB_PAD, right_width, m->wh - 2 * (TAB_HEIGHT + TAB_PAD), False, base); + tab_count = &(tab_counts[1]); + tab_top = m->wy + m->wh - TAB_HEIGHT; + cur_tab = 0; } else { // this function does not get called when focus changes // resize(c, m->wx + m->ww, m->wy, m->ww - mw, m->wh, False); - resize(c, m->wx + mw, m->wy, m->ww - mw, m->wh, False); + resize(c, m->wx + mw + right_width * cur_tab / (*tab_count), tab_top, right_width, m->wh - 2 * (TAB_HEIGHT + TAB_PAD), False, base); + cur_tab += 1; } } + base = c; } } @@ -1813,7 +1859,7 @@ togglefloating(const Arg *arg) { 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); + selmon->sel->w, selmon->sel->h, False, 0); arrange(selmon); } @@ -1906,6 +1952,12 @@ updatebars(void) { m->barwin = XCreateWindow(dpy, root, m->wx, m->by, m->ww, bh, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect|CWBackPixmap|CWEventMask, &wa); + XChangeProperty(dpy, root, netatom[NetSupportingWMCheck], XA_WINDOW, 32, + PropModeReplace, (unsigned char *) &(m->barwin), 1); + XChangeProperty(dpy, m->barwin, netatom[NetSupportingWMCheck], XA_WINDOW, 32, + PropModeReplace, (unsigned char *) &(m->barwin), 1); + XChangeProperty(dpy, m->barwin, netatom[NetWMName], XA_STRING, 8, + PropModeReplace, (unsigned char *) "dwm", 3); XDefineCursor(dpy, m->barwin, cursor[CurNormal]->cursor); XMapRaised(dpy, m->barwin); }