diff options
Diffstat (limited to 'tabbed.c')
| -rw-r--r-- | tabbed.c | 77 |
1 files changed, 53 insertions, 24 deletions
@@ -49,7 +49,7 @@ enum { ColFG, ColBG, ColLast }; /* color */ enum { WMProtocols, WMDelete, WMName, WMState, WMFullscreen, - XEmbed, WMSelectTab, WMLast }; /* default atoms */ + XEmbed, WMSelectTab, WMMotifHints, WMLast }; /* default atoms */ typedef union { int i; @@ -103,7 +103,7 @@ static void expose(const XEvent *e); static void focus(int c); static void focusin(const XEvent *e); static void focusonce(const Arg *arg); -static void focusurgent(const Arg *arg); +/* static void focusurgent(const Arg *arg); */ static void fullscreen(const Arg *arg); static char *getatom(int a); static int getclient(Window w); @@ -128,7 +128,8 @@ static void setup(void); static void sigchld(int unused); static void spawn(const Arg *arg); static int textnw(const char *text, unsigned int len); -static void toggle(const Arg *arg); +/* static void toggle(const Arg *arg); */ +static void toggleframe(const Arg *arg); static void unmanage(int c); static void unmapnotify(const XEvent *e); static void updatenumlockmask(void); @@ -156,7 +157,7 @@ static int bh, obh, wx, wy, ww, wh; static unsigned int numlockmask; static Bool running = True, nextfocus, doinitspawn = True, fillagain = False, closelastclient = False, - killclientsfirst = False; + killclientsfirst = False, maximize = False; static Display *dpy; static DC dc; static Atom wmatom[WMLast]; @@ -326,6 +327,7 @@ drawbar(void) XftColor *col; int c, cc, fc, width; char *name = NULL; + char tabtitle[256]; if (nclients == 0) { dc.x = 0; @@ -367,10 +369,13 @@ drawbar(void) } else { col = clients[c]->urgent ? dc.urg : dc.norm; } - drawtext(clients[c]->name, col); + snprintf(tabtitle, sizeof(tabtitle), "%d: %s", + c + 1, clients[c]->name); + drawtext(tabtitle, col); dc.x += dc.w; clients[c]->tabx = dc.x; } + XCopyArea(dpy, dc.drawable, win, dc.gc, 0, 0, ww, bh, 0, 0); XSync(dpy, False); } @@ -506,21 +511,22 @@ focusonce(const Arg *arg) nextfocus = True; } -void -focusurgent(const Arg *arg) -{ - int c; - - if (sel < 0) - return; - - for (c = (sel + 1) % nclients; c != sel; c = (c + 1) % nclients) { - if (clients[c]->urgent) { - focus(c); - return; - } - } -} +/* void + * focusurgent(const Arg *arg) + * { + * int c; + * + * if (sel < 0) + * return; + * + * for (c = (sel + 1) % nclients; c != sel; c = (c + 1) % nclients) { + * if (clients[c]->urgent) { + * focus(c); + * return; + * } + * } + * } + */ void fullscreen(const Arg *arg) @@ -995,6 +1001,7 @@ setup(void) wmatom[WMSelectTab] = XInternAtom(dpy, "_TABBED_SELECT_TAB", False); wmatom[WMState] = XInternAtom(dpy, "_NET_WM_STATE", False); wmatom[XEmbed] = XInternAtom(dpy, "_XEMBED", False); + wmatom[WMMotifHints] = XInternAtom(dpy, "_MOTIF_WM_HINTS", False); /* init appearance */ wx = 0; @@ -1003,6 +1010,11 @@ setup(void) wh = 600; isfixed = 0; + if (maximize) { + ww = DisplayWidth(dpy, screen); + wh = DisplayHeight(dpy, screen); + } + if (geometry) { tx = ty = tw = th = 0; bitm = XParseGeometry(geometry, &tx, &ty, (unsigned *)&tw, @@ -1060,7 +1072,7 @@ setup(void) size_hint->width = ww; size_hint->min_height = bh + 1; } else { - size_hint->flags = PMaxSize | PMinSize; + size_hint->flags = PPosition | PMaxSize | PMinSize; size_hint->min_width = size_hint->max_width = ww; size_hint->min_height = size_hint->max_height = wh; } @@ -1071,6 +1083,10 @@ setup(void) XSetWMProtocols(dpy, win, &wmatom[WMDelete], 1); + long hints[5] = {hideframe ? 2 : 0, 0, 0, 0, 0}; + XChangeProperty(dpy, win, wmatom[WMMotifHints], XA_ATOM, + 32, PropModeReplace, (unsigned char *)&hints, 5); + snprintf(winid, sizeof(winid), "%lu", win); setenv("XEMBED", winid, 1); @@ -1117,10 +1133,20 @@ textnw(const char *text, unsigned int len) return ext.xOff; } +/* void + * toggle(const Arg *arg) + * { + * *(Bool*) arg->v = !*(Bool*) arg->v; + * } + */ + void -toggle(const Arg *arg) +toggleframe(const Arg *arg) { - *(Bool*) arg->v = !*(Bool*) arg->v; + hideframe = !hideframe; + long hints[5] = {hideframe ? 2 : 0, 0, 0, 0, 0}; + XChangeProperty(dpy, win, wmatom[WMMotifHints], XA_ATOM, + 32, PropModeReplace, (unsigned char *)&hints, 5); } void @@ -1268,7 +1294,7 @@ xsettitle(Window w, const char *str) void usage(void) { - die("usage: %s [-dfksv] [-g geometry] [-n name] [-p [s+/-]pos]\n" + die("usage: %s [-dfkmsv] [-g geometry] [-n name] [-p [s+/-]pos]\n" " [-r narg] [-o color] [-O color] [-t color] [-T color]\n" " [-u color] [-U color] command...\n", argv0); } @@ -1297,6 +1323,9 @@ main(int argc, char *argv[]) case 'k': killclientsfirst = True; break; + case 'm': + maximize = True; + break; case 'n': wmname = EARGF(usage()); break; |
