added mini stuff

This commit is contained in:
Anselm R. Garbe 2006-07-13 21:42:17 +02:00
parent 7fe717c29f
commit 66da15324e
4 changed files with 69 additions and 46 deletions

View File

@ -11,10 +11,11 @@
#include "dwm.h"
static void (*arrange)(Arg *) = tiling;
void (*arrange)(Arg *) = tiling;
static Rule rule[] = {
{ "Firefox-bin", "Gecko", { [Twww] = "www" } },
/* class instance tags floating */
{ "Firefox-bin", "Gecko", { [Twww] = "www" }, False },
};
static Client *
@ -64,27 +65,27 @@ view(Arg *arg)
}
void
tag(Arg *arg)
tappend(Arg *arg)
{
int i, n;
if(!sel)
return;
if(arg->i == tsel) {
for(n = i = 0; i < TLast; i++)
if(sel->tags[i])
n++;
if(n < 2)
return;
}
if(sel->tags[arg->i])
sel->tags[arg->i] = NULL; /* toggle tag */
else
sel->tags[arg->i] = tags[arg->i];
arrange(NULL);
}
void
ttrunc(Arg *arg)
{
int i;
if(!sel)
return;
for(i = 0; i < TLast; i++)
sel->tags[i] = NULL;
tappend(arg);
}
static void
ban_client(Client *c)
{
@ -122,13 +123,18 @@ tiling(Arg *arg)
w = sw - mw;
arrange = tiling;
for(n = 0, c = clients; c; c = c->next)
if(c->tags[tsel])
if(c->tags[tsel] && !c->floating)
n++;
h = (n > 1) ? sh / (n - 1) : sh;
for(i = 0, c = clients; c; c = c->next) {
if(c->tags[tsel]) {
if(c->floating) {
craise(c);
resize(c, True);
continue;
}
if(n == 1) {
c->x = sx;
c->y = sy;
@ -330,14 +336,13 @@ init_tags(Client *c)
if(XGetClassHint(dpy, c->win, &ch)) {
if(ch.res_class && ch.res_name) {
fprintf(stderr, "%s:%s\n", 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)))
{
fprintf(stderr, "->>>%s:%s\n", ch.res_class, ch.res_name);
for(j = 0; j < TLast; j++)
c->tags[j] = rule[i].tags[j];
c->floating = rule[i].floating;
matched = True;
break;
}
@ -357,6 +362,7 @@ manage(Window w, XWindowAttributes *wa)
{
Client *c, **l;
XSetWindowAttributes twa;
Window trans;
c = emallocz(sizeof(Client));
c->win = w;
@ -370,7 +376,7 @@ manage(Window w, XWindowAttributes *wa)
update_size(c);
XSelectInput(dpy, c->win,
StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
XGetTransientForHint(dpy, c->win, &c->trans);
XGetTransientForHint(dpy, c->win, &trans);
twa.override_redirect = 1;
twa.background_pixmap = ParentRelative;
twa.event_mask = ExposureMask;
@ -396,6 +402,11 @@ manage(Window w, XWindowAttributes *wa)
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
GrabModeAsync, GrabModeSync, None, None);
if(!c->floating)
c->floating = trans
|| ((c->maxw == c->minw) && (c->maxh == c->minh));
arrange(NULL);
if(c->tags[tsel])
focus(c);

30
dev.c
View File

@ -20,9 +20,8 @@ const char *browse[] = { "firefox", NULL };
const char *xlock[] = { "xlock", NULL };
static Key key[] = {
{ Mod1Mask, XK_Return, spawn, { .argv = term } },
{ Mod1Mask, XK_w, spawn, { .argv = browse } },
{ Mod1Mask, XK_l, spawn, { .argv = xlock } },
/* modifier key function arguments */
{ Mod1Mask, XK_Return, zoom, { 0 } },
{ Mod1Mask, XK_k, prevc, { 0 } },
{ Mod1Mask, XK_j, nextc, { 0 } },
{ Mod1Mask, XK_m, max, { 0 } },
@ -32,15 +31,22 @@ static Key key[] = {
{ Mod1Mask, XK_3, view, { .i = Twww } },
{ Mod1Mask, XK_4, view, { .i = Twork } },
{ Mod1Mask, XK_space, tiling, { 0 } },
{ Mod1Mask | ShiftMask, XK_Return, zoom, { 0 } },
{ Mod1Mask | ShiftMask, XK_space, floating, { 0 } },
{ Mod1Mask | ShiftMask, XK_0, tag, { .i = Tscratch } },
{ Mod1Mask | ShiftMask, XK_1, tag, { .i = Tdev } },
{ Mod1Mask | ShiftMask, XK_2, tag, { .i = Tirc } },
{ Mod1Mask | ShiftMask, XK_3, tag, { .i = Twww } },
{ Mod1Mask | ShiftMask, XK_4, tag, { .i = Twork } },
{ Mod1Mask | ShiftMask, XK_c, ckill, { 0 } },
{ Mod1Mask | ShiftMask, XK_q, quit, { 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 = Tirc } },
{ Mod1Mask|ShiftMask, XK_3, ttrunc, { .i = Twww } },
{ Mod1Mask|ShiftMask, XK_4, ttrunc, { .i = Twork } },
{ Mod1Mask|ShiftMask, XK_c, ckill, { 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 = Tirc } },
{ ControlMask, XK_3, tappend, { .i = Twww } },
{ ControlMask, XK_4, tappend, { .i = Twork } },
};
/********** CUSTOMIZE **********/

9
dwm.h
View File

@ -66,8 +66,8 @@ struct Client {
int grav;
unsigned int border;
long flags;
Bool floating;
Window win;
Window trans;
Window title;
Client *next;
Client *revert;
@ -77,6 +77,7 @@ struct Rule {
const char *class;
const char *instance;
char *tags[TLast];
Bool floating;
};
struct Key {
@ -91,7 +92,8 @@ extern Window root;
extern Atom wm_atom[WMLast], net_atom[NetLast];
extern Cursor cursor[CurLast];
extern Bool running, issel;
extern void (*handler[LASTEvent]) (XEvent *);
extern void (*handler[LASTEvent])(XEvent *);
extern void (*arrange)(Arg *);
extern int tsel, screen, sx, sy, sw, sh, mw, th;
extern char *tags[TLast];
@ -117,7 +119,8 @@ extern void prevc(Arg *arg);
extern void max(Arg *arg);
extern void floating(Arg *arg);
extern void tiling(Arg *arg);
extern void tag(Arg *arg);
extern void ttrunc(Arg *arg);
extern void tappend(Arg *arg);
extern void view(Arg *arg);
extern void zoom(Arg *arg);
extern void gravitate(Client *c, Bool invert);

View File

@ -89,6 +89,7 @@ configurerequest(XEvent *e)
if(ev->value_mask & CWBorderWidth)
c->border = ev->border_width;
gravitate(c, False);
resize(c, True);
}
wc.x = ev->x;
@ -179,6 +180,7 @@ static void
propertynotify(XEvent *e)
{
XPropertyEvent *ev = &e->xproperty;
Window trans;
Client *c;
if(ev->state == PropertyDelete)
@ -192,9 +194,10 @@ propertynotify(XEvent *e)
switch (ev->atom) {
default: break;
case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(dpy, c->win, &c->trans);
XGetTransientForHint(dpy, c->win, &trans);
if(!c->floating && (c->floating = (trans != 0)))
arrange(NULL);
break;
update_size(c);
case XA_WM_NORMAL_HINTS:
update_size(c);
break;