about summary refs log tree commit diff stats
path: root/config.def.h
blob: 92620255a85115eab5f655d0e2e3954e8e48b838 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* See LICENSE file for copyright and license details. */

/* appearance */
#define BORDERPX        1
#define FONT            "-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*"
#define NORMBORDERCOLOR "#cccccc"
#define NORMBGCOLOR     "#cccccc"
#define NORMFGCOLOR     "#000000"
#define SELBORDERCOLOR  "#0066ff"
#define SELBGCOLOR      "#0066ff"
#define SELFGCOLOR      "#ffffff"
#define SNAP            32    /* snap pixel */

/* tagging */
const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };

Rule rules[] = {
	/* class      instance    title       tags ref      isfloating */
	{ "Gimp",     NULL,       NULL,       NULL,         True },
};

/* layout(s) */
#define RESIZEHINTS True  /* False - respect size hints in tiled resizals */
#define MFACT       0.55  /* master factor [0.1 .. 0.9] */
#include "tile.c"
Layout layouts[] = {
	/* symbol     arrange  geom */
	{ "[]=",      tile,    tilegeom }, /* first entry is default */
	{ "><>",      NULL,             }, /* no layout function means floating behavior */
};

/* key definitions */
#define MODKEY Mod1Mask
Key keys[] = {
	/* modifier                     key        function        argument */
	{ MODKEY,                       XK_p,      spawn,          "exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" },
	{ MODKEY|ShiftMask,             XK_Return, spawn,          "exec uxterm" },
	{ MODKEY,                       XK_j,      focusnext,      NULL },
	{ MODKEY,                       XK_k,      focusprev,      NULL },
	{ MODKEY,                       XK_h,      setmfact,       "-0.05" },
	{ MODKEY,                       XK_l,      setmfact,       "+0.05" },
	{ MODKEY,                       XK_Return, zoom,           NULL },
	{ MODKEY,                       XK_m,      togglelayout,   "<M>" },
	{ MODKEY,                       XK_Tab,    viewprevtag,    NULL },
	{ MODKEY|ShiftMask,             XK_c,      killclient,     NULL },
	{ MODKEY,                       XK_space,  togglelayout,   NULL },
	{ MODKEY|ShiftMask,             XK_space,  togglefloating, NULL },
	{ MODKEY,                       XK_0,      view,           NULL },
	{ MODKEY,                       XK_1,      view,           tags[0] },
	{ MODKEY,                       XK_2,      view,           tags[1] },
	{ MODKEY,                       XK_3,      view,           tags[2] },
	{ MODKEY,                       XK_4,      view,           tags[3] },
	{ MODKEY,                       XK_5,      view,           tags[4] },
	{ MODKEY,                       XK_6,      view,           tags[5] },
	{ MODKEY,                       XK_7,      view,           tags[6] },
	{ MODKEY,                       XK_8,      view,           tags[7] },
	{ MODKEY,                       XK_9,      view,           tags[8] },
	{ MODKEY|ControlMask,           XK_1,      toggleview,     tags[0] },
	{ MODKEY|ControlMask,           XK_2,      toggleview,     tags[1] },
	{ MODKEY|ControlMask,           XK_3,      toggleview,     tags[2] },
	{ MODKEY|ControlMask,           XK_4,      toggleview,     tags[3] },
	{ MODKEY|ControlMask,           XK_5,      toggleview,     tags[4] },
	{ MODKEY|ControlMask,           XK_6,      toggleview,     tags[5] },
	{ MODKEY|ControlMask,           XK_7,      toggleview,     tags[6] },
	{ MODKEY|ControlMask,           XK_8,      toggleview,     tags[7] },
	{ MODKEY|ControlMask,           XK_9,      toggleview,     tags[8] },
	{ MODKEY|ShiftMask,             XK_0,      tag,            NULL },
	{ MODKEY|ShiftMask,             XK_1,      tag,            tags[0] },
	{ MODKEY|ShiftMask,             XK_2,      tag,            tags[1] },
	{ MODKEY|ShiftMask,             XK_3,      tag,            tags[2] },
	{ MODKEY|ShiftMask,             XK_4,      tag,            tags[3] },
	{ MODKEY|ShiftMask,             XK_5,      tag,            tags[4] },
	{ MODKEY|ShiftMask,             XK_6,      tag,            tags[5] },
	{ MODKEY|ShiftMask,             XK_7,      tag,            tags[6] },
	{ MODKEY|ShiftMask,             XK_8,      tag,            tags[7] },
	{ MODKEY|ShiftMask,             XK_9,      tag,            tags[8] },
	{ MODKEY|ControlMask|ShiftMask, XK_1,      toggletag,      tags[0] },
	{ MODKEY|ControlMask|ShiftMask, XK_2,      toggletag,      tags[1] },
	{ MODKEY|ControlMask|ShiftMask, XK_3,      toggletag,      tags[2] },
	{ MODKEY|ControlMask|ShiftMask, XK_4,      toggletag,      tags[3] },
	{ MODKEY|ControlMask|ShiftMask, XK_5,      toggletag,      tags[4] },
	{ MODKEY|ControlMask|ShiftMask, XK_6,      toggletag,      tags[5] },
	{ MODKEY|ControlMask|ShiftMask, XK_7,      toggletag,      tags[6] },
	{ MODKEY|ControlMask|ShiftMask, XK_8,      toggletag,      tags[7] },
	{ MODKEY|ControlMask|ShiftMask, XK_9,      toggletag,      tags[8] },
	{ MODKEY|ShiftMask,             XK_q,      quit,           NULL },
};
; } Client * getctitle(Window w) { Client *c; for(c = clients; c; c = c->next) if(c->title == w) return c; return NULL; } void gravitate(Client *c, Bool invert) { int dx = 0, dy = 0; switch(c->grav) { default: break; case StaticGravity: case NorthWestGravity: case NorthGravity: case NorthEastGravity: dy = c->border; break; case EastGravity: case CenterGravity: case WestGravity: dy = -(c->h / 2) + c->border; break; case SouthEastGravity: case SouthGravity: case SouthWestGravity: dy = -(c->h); break; } switch (c->grav) { default: break; case StaticGravity: case NorthWestGravity: case WestGravity: case SouthWestGravity: dx = c->border; break; case NorthGravity: case CenterGravity: case SouthGravity: dx = -(c->w / 2) + c->border; break; case NorthEastGravity: case EastGravity: case SouthEastGravity: dx = -(c->w + c->border); break; } if(invert) { dx = -dx; dy = -dy; } c->x += dx; c->y += dy; } void higher(Client *c) { XRaiseWindow(dpy, c->win); XRaiseWindow(dpy, c->title); } void killclient(Arg *arg) { if(!sel) return; if(sel->proto & PROTODELWIN) sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]); else XKillClient(dpy, sel->win); } void manage(Window w, XWindowAttributes *wa) { Client *c; Window trans; XSetWindowAttributes twa; c = emallocz(sizeof(Client)); c->tags = emallocz(ntags * sizeof(Bool)); c->win = w; c->x = c->tx = wa->x; c->y = c->ty = wa->y; c->w = c->tw = wa->width; c->h = wa->height; c->th = bh; c->border = 0; setsize(c); if(c->h != sh && c->y < bh) c->y = c->ty = bh; c->proto = getproto(c->win); XSelectInput(dpy, c->win, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); XGetTransientForHint(dpy, c->win, &trans); twa.override_redirect = 1; twa.background_pixmap = ParentRelative; twa.event_mask = ExposureMask | EnterWindowMask; c->title = XCreateWindow(dpy, root, c->tx, c->ty, c->tw, c->th, 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa); if(clients) clients->prev = c; c->next = clients; clients = c; XGrabButton(dpy, Button1, MODKEY, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button1, MODKEY | LockMask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button1, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button1, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button2, MODKEY, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button2, MODKEY | LockMask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button2, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button2, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button3, MODKEY, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button3, MODKEY | LockMask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button3, MODKEY | NUMLOCKMASK, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); XGrabButton(dpy, Button3, MODKEY | NUMLOCKMASK | LockMask, c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); settags(c); if(!c->isfloat) c->isfloat = trans || (c->maxw && c->minw && c->maxw == c->minw && c->maxh == c->minh); settitle(c); arrange(NULL); /* mapping the window now prevents flicker */ XMapRaised(dpy, c->win); XMapRaised(dpy, c->title); if(c->tags[tsel]) focus(c); } void resize(Client *c, Bool sizehints, Corner sticky) { int bottom = c->y + c->h; int right = c->x + c->w; /*XConfigureEvent e;*/ XWindowChanges wc; if(sizehints) { if(c->incw) c->w -= (c->w - c->basew) % c->incw; if(c->inch) c->h -= (c->h - c->baseh) % c->inch; if(c->minw && c->w < c->minw) c->w = c->minw; if(c->minh && c->h < c->minh) c->h = c->minh; if(c->maxw && c->w > c->maxw) c->w = c->maxw; if(c->maxh && c->h > c->maxh) c->h = c->maxh; } if(c->x > right) /* might happen on restart */ c->x = right - c->w; if(c->y > bottom) c->y = bottom - c->h; if(sticky == TopRight || sticky == BotRight) c->x = right - c->w; if(sticky == BotLeft || sticky == BotRight) c->y = bottom - c->h; resizetitle(c); wc.x = c->x; wc.y = c->y; wc.width = c->w; wc.height = c->h; if(c->w == sw && c->h == sh) wc.border_width = 0; else wc.border_width = 1; XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); XSync(dpy, False); } void setsize(Client *c) { long msize; XSizeHints size; if(!XGetWMNormalHints(dpy, c->win, &size, &msize) || !size.flags) size.flags = PSize; c->flags = size.flags; if(c->flags & PBaseSize) { c->basew = size.base_width; c->baseh = size.base_height; } else c->basew = c->baseh = 0; if(c->flags & PResizeInc) { c->incw = size.width_inc; c->inch = size.height_inc; } else c->incw = c->inch = 0; if(c->flags & PMaxSize) { c->maxw = size.max_width; c->maxh = size.max_height; } else c->maxw = c->maxh = 0; if(c->flags & PMinSize) { c->minw = size.min_width; c->minh = size.min_height; } else c->minw = c->minh = 0; if(c->flags & PWinGravity) c->grav = size.win_gravity; else c->grav = NorthWestGravity; } void settitle(Client *c) { char **list = NULL; int n; XTextProperty name; name.nitems = 0; c->name[0] = 0; XGetTextProperty(dpy, c->win, &name, netatom[NetWMName]); if(!name.nitems) XGetWMName(dpy, c->win, &name); if(!name.nitems) return; if(name.encoding == XA_STRING) strncpy(c->name, (char *)name.value, sizeof(c->name)); else { if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success && n > 0 && *list) { strncpy(c->name, *list, sizeof(c->name)); XFreeStringList(list); } } XFree(name.value); resizetitle(c); } void togglemax(Arg *arg) { int ox, oy, ow, oh; XEvent ev; if(!sel) return; if((sel->ismax = !sel->ismax)) { ox = sel->x; oy = sel->y; ow = sel->w; oh = sel->h; sel->x = sx; sel->y = sy + bh; sel->w = sw - 2; sel->h = sh - 2 - bh; higher(sel); resize(sel, arrange == dofloat, TopLeft); sel->x = ox; sel->y = oy; sel->w = ow; sel->h = oh; } else resize(sel, False, TopLeft); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); } void unmanage(Client *c) { XGrabServer(dpy); XSetErrorHandler(xerrordummy); XUngrabButton(dpy, AnyButton, AnyModifier, c->win); XDestroyWindow(dpy, c->title); if(c->prev) c->prev->next = c->next; if(c->next) c->next->prev = c->prev; if(c == clients) clients = c->next; if(sel == c) sel = getnext(clients); free(c->tags); free(c); XSync(dpy, False); XSetErrorHandler(xerror); XUngrabServer(dpy); arrange(NULL); if(sel) focus(sel); } void zoom(Arg *arg) { Client *c; if(!sel || (arrange != dotile) || sel->isfloat || sel->ismax) return; if(sel == getnext(clients)) { if((c = getnext(sel->next))) sel = c; else return; } /* pop */ if(sel->prev) sel->prev->next = sel->next; if(sel->next) sel->next->prev = sel->prev; sel->prev = NULL; clients->prev = sel; sel->next = clients; clients = sel; arrange(NULL); focus(sel); }