fmdm
This commit is contained in:
parent
11498264d5
commit
c9a7d4309e
115
client.c
115
client.c
|
@ -14,14 +14,13 @@
|
||||||
void (*arrange)(Arg *) = tiling;
|
void (*arrange)(Arg *) = tiling;
|
||||||
|
|
||||||
static Rule rule[] = {
|
static Rule rule[] = {
|
||||||
/* class instance tags floating */
|
|
||||||
{ "Firefox-bin", "Gecko", { [Twww] = "www" }, False },
|
{ "Firefox-bin", "Gecko", { [Twww] = "www" }, False },
|
||||||
};
|
};
|
||||||
|
|
||||||
static Client *
|
static Client *
|
||||||
next(Client *c)
|
next(Client *c)
|
||||||
{
|
{
|
||||||
for(; c && !c->tags[tsel]; c = c->next);
|
for(; c ; c = c->next);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +68,6 @@ view(Arg *arg)
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
|
|
||||||
for(c = clients; c; c = next(c->next))
|
for(c = clients; c; c = next(c->next))
|
||||||
draw_client(c);
|
|
||||||
draw_bar();
|
draw_bar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +77,6 @@ tappend(Arg *arg)
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sel->tags[arg->i] = tags[arg->i];
|
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +88,6 @@ ttrunc(Arg *arg)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(i = 0; i < TLast; i++)
|
for(i = 0; i < TLast; i++)
|
||||||
sel->tags[i] = NULL;
|
|
||||||
tappend(arg);
|
tappend(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,26 +98,6 @@ ban_client(Client *c)
|
||||||
XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
|
XMoveWindow(dpy, c->title, c->tx + 2 * sw, c->ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
floating(Arg *arg)
|
|
||||||
{
|
|
||||||
Client *c;
|
|
||||||
|
|
||||||
arrange = floating;
|
|
||||||
for(c = clients; c; c = c->next) {
|
|
||||||
if(c->tags[tsel])
|
|
||||||
resize(c, True);
|
|
||||||
else
|
|
||||||
ban_client(c);
|
|
||||||
}
|
|
||||||
if(sel && !sel->tags[tsel]) {
|
|
||||||
if((sel = next(clients))) {
|
|
||||||
craise(sel);
|
|
||||||
focus(sel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
tiling(Arg *arg)
|
tiling(Arg *arg)
|
||||||
{
|
{
|
||||||
|
@ -131,7 +107,6 @@ tiling(Arg *arg)
|
||||||
w = sw - mw;
|
w = sw - mw;
|
||||||
arrange = tiling;
|
arrange = tiling;
|
||||||
for(n = 0, c = clients; c; c = c->next)
|
for(n = 0, c = clients; c; c = c->next)
|
||||||
if(c->tags[tsel] && !c->floating)
|
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
if(n > 1)
|
if(n > 1)
|
||||||
|
@ -140,7 +115,6 @@ tiling(Arg *arg)
|
||||||
h = sh - bh;
|
h = sh - bh;
|
||||||
|
|
||||||
for(i = 0, c = clients; c; c = c->next) {
|
for(i = 0, c = clients; c; c = c->next) {
|
||||||
if(c->tags[tsel]) {
|
|
||||||
if(c->floating) {
|
if(c->floating) {
|
||||||
craise(c);
|
craise(c);
|
||||||
resize(c, True);
|
resize(c, True);
|
||||||
|
@ -167,10 +141,7 @@ tiling(Arg *arg)
|
||||||
resize(c, False);
|
resize(c, False);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else
|
if(!sel ) {
|
||||||
ban_client(c);
|
|
||||||
}
|
|
||||||
if(!sel || (sel && !sel->tags[tsel])) {
|
|
||||||
if((sel = next(clients))) {
|
if((sel = next(clients))) {
|
||||||
craise(sel);
|
craise(sel);
|
||||||
focus(sel);
|
focus(sel);
|
||||||
|
@ -186,7 +157,7 @@ prevc(Arg *arg)
|
||||||
if(!sel)
|
if(!sel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if((c = sel->revert && sel->revert->tags[tsel] ? sel->revert : NULL)) {
|
if((c = sel->revert ? sel->revert : NULL)) {
|
||||||
craise(c);
|
craise(c);
|
||||||
focus(c);
|
focus(c);
|
||||||
}
|
}
|
||||||
|
@ -228,7 +199,7 @@ resize_title(Client *c)
|
||||||
c->tw = 0;
|
c->tw = 0;
|
||||||
for(i = 0; i < TLast; i++)
|
for(i = 0; i < TLast; i++)
|
||||||
if(c->tags[i])
|
if(c->tags[i])
|
||||||
c->tw += textw(c->tags[i]) + dc.font.height;
|
c->tw += dc.font.height;
|
||||||
c->tw += textw(c->name) + dc.font.height;
|
c->tw += textw(c->name) + dc.font.height;
|
||||||
if(c->tw > c->w)
|
if(c->tw > c->w)
|
||||||
c->tw = c->w + 2;
|
c->tw = c->w + 2;
|
||||||
|
@ -325,50 +296,11 @@ focus(Client *c)
|
||||||
|
|
||||||
XFlush(dpy);
|
XFlush(dpy);
|
||||||
sel = c;
|
sel = c;
|
||||||
if(old && old != c)
|
|
||||||
draw_client(old);
|
|
||||||
draw_client(c);
|
|
||||||
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
|
||||||
XFlush(dpy);
|
XFlush(dpy);
|
||||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
init_tags(Client *c)
|
|
||||||
{
|
|
||||||
XClassHint ch;
|
|
||||||
static unsigned int len = rule ? sizeof(rule) / sizeof(rule[0]) : 0;
|
|
||||||
unsigned int i, j;
|
|
||||||
Bool matched = False;
|
|
||||||
|
|
||||||
if(!len) {
|
|
||||||
c->tags[tsel] = tags[tsel];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(XGetClassHint(dpy, c->win, &ch)) {
|
|
||||||
if(ch.res_class && ch.res_name) {
|
|
||||||
for(i = 0; i < len; i++)
|
|
||||||
if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class))
|
|
||||||
&& !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance)))
|
|
||||||
{
|
|
||||||
for(j = 0; j < TLast; j++)
|
|
||||||
c->tags[j] = rule[i].tags[j];
|
|
||||||
c->floating = rule[i].floating;
|
|
||||||
matched = True;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(ch.res_class)
|
|
||||||
XFree(ch.res_class);
|
|
||||||
if(ch.res_name)
|
|
||||||
XFree(ch.res_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!matched)
|
|
||||||
c->tags[tsel] = tags[tsel];
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
manage(Window w, XWindowAttributes *wa)
|
manage(Window w, XWindowAttributes *wa)
|
||||||
{
|
{
|
||||||
|
@ -401,7 +333,6 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &twa);
|
||||||
|
|
||||||
update_name(c);
|
update_name(c);
|
||||||
init_tags(c);
|
|
||||||
|
|
||||||
for(l = &clients; *l; l = &(*l)->next);
|
for(l = &clients; *l; l = &(*l)->next);
|
||||||
c->next = *l; /* *l == nil */
|
c->next = *l; /* *l == nil */
|
||||||
|
@ -420,16 +351,9 @@ manage(Window w, XWindowAttributes *wa)
|
||||||
|
|
||||||
arrange(NULL);
|
arrange(NULL);
|
||||||
/* mapping the window now prevents flicker */
|
/* mapping the window now prevents flicker */
|
||||||
if(c->tags[tsel]) {
|
|
||||||
XMapRaised(dpy, c->win);
|
XMapRaised(dpy, c->win);
|
||||||
XMapRaised(dpy, c->title);
|
XMapRaised(dpy, c->title);
|
||||||
focus(c);
|
focus(c);
|
||||||
}
|
|
||||||
else {
|
|
||||||
ban_client(c);
|
|
||||||
XMapRaised(dpy, c->win);
|
|
||||||
XMapRaised(dpy, c->title);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -583,34 +507,3 @@ getclient(Window w)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
draw_client(Client *c)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
if(c == sel) {
|
|
||||||
draw_bar();
|
|
||||||
XUnmapWindow(dpy, c->title);
|
|
||||||
XSetWindowBorder(dpy, c->win, dc.fg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
XSetWindowBorder(dpy, c->win, dc.bg);
|
|
||||||
XMapWindow(dpy, c->title);
|
|
||||||
|
|
||||||
dc.x = dc.y = 0;
|
|
||||||
|
|
||||||
dc.w = 0;
|
|
||||||
for(i = 0; i < TLast; i++) {
|
|
||||||
if(c->tags[i]) {
|
|
||||||
dc.x += dc.w;
|
|
||||||
dc.w = textw(c->tags[i]) + dc.font.height;
|
|
||||||
drawtext(c->tags[i], False, True);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dc.x += dc.w;
|
|
||||||
dc.w = textw(c->name) + dc.font.height;
|
|
||||||
drawtext(c->name, False, True);
|
|
||||||
XCopyArea(dpy, dc.drawable, c->title, dc.gc,
|
|
||||||
0, 0, c->tw, c->th, 0, 0);
|
|
||||||
XFlush(dpy);
|
|
||||||
}
|
|
||||||
|
|
28
dev.c
28
dev.c
|
@ -12,38 +12,10 @@
|
||||||
|
|
||||||
/********** CUSTOMIZE **********/
|
/********** CUSTOMIZE **********/
|
||||||
|
|
||||||
const char *term[] = {
|
|
||||||
"urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn",
|
|
||||||
"-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL
|
|
||||||
};
|
|
||||||
const char *browse[] = { "firefox", NULL };
|
|
||||||
const char *xlock[] = { "xlock", NULL };
|
|
||||||
|
|
||||||
static Key key[] = {
|
static Key key[] = {
|
||||||
/* modifier key function arguments */
|
/* modifier key function arguments */
|
||||||
{ Mod1Mask, XK_Return, zoom, { 0 } },
|
|
||||||
{ Mod1Mask, XK_k, prevc, { 0 } },
|
|
||||||
{ Mod1Mask, XK_j, nextc, { 0 } },
|
|
||||||
{ Mod1Mask, XK_m, max, { 0 } },
|
|
||||||
{ Mod1Mask, XK_0, view, { .i = Tscratch } },
|
|
||||||
{ Mod1Mask, XK_1, view, { .i = Tdev } },
|
|
||||||
{ Mod1Mask, XK_2, view, { .i = Twww } },
|
|
||||||
{ Mod1Mask, XK_3, view, { .i = Twork } },
|
|
||||||
{ Mod1Mask, XK_space, tiling, { 0 } },
|
|
||||||
{ Mod1Mask|ShiftMask, XK_space, floating, { 0 } },
|
|
||||||
{ Mod1Mask|ShiftMask, XK_0, ttrunc, { .i = Tscratch } },
|
|
||||||
{ Mod1Mask|ShiftMask, XK_1, ttrunc, { .i = Tdev } },
|
|
||||||
{ Mod1Mask|ShiftMask, XK_2, ttrunc, { .i = Twww } },
|
|
||||||
{ Mod1Mask|ShiftMask, XK_3, ttrunc, { .i = Twork } },
|
|
||||||
{ Mod1Mask|ShiftMask, XK_c, ckill, { 0 } },
|
|
||||||
{ Mod1Mask|ShiftMask, XK_q, quit, { 0 } },
|
{ Mod1Mask|ShiftMask, XK_q, quit, { 0 } },
|
||||||
{ Mod1Mask|ShiftMask, XK_Return, spawn, { .argv = term } },
|
|
||||||
{ Mod1Mask|ShiftMask, XK_w, spawn, { .argv = browse } },
|
|
||||||
{ Mod1Mask|ShiftMask, XK_l, spawn, { .argv = xlock } },
|
|
||||||
{ ControlMask, XK_0, tappend, { .i = Tscratch } },
|
|
||||||
{ ControlMask, XK_1, tappend, { .i = Tdev } },
|
|
||||||
{ ControlMask, XK_2, tappend, { .i = Twww } },
|
|
||||||
{ ControlMask, XK_3, tappend, { .i = Twork } },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/********** CUSTOMIZE **********/
|
/********** CUSTOMIZE **********/
|
||||||
|
|
5
event.c
5
event.c
|
@ -141,10 +141,6 @@ expose(XEvent *e)
|
||||||
XExposeEvent *ev = &e->xexpose;
|
XExposeEvent *ev = &e->xexpose;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
if(ev->count == 0) {
|
|
||||||
if((c = gettitle(ev->window)))
|
|
||||||
draw_client(c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -200,7 +196,6 @@ propertynotify(XEvent *e)
|
||||||
}
|
}
|
||||||
if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) {
|
if(ev->atom == XA_WM_NAME || ev->atom == net_atom[NetWMName]) {
|
||||||
update_name(c);
|
update_name(c);
|
||||||
draw_client(c);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue