Browse Source

added mini stuff

config
Anselm R. Garbe 18 years ago
parent
commit
66da15324e
4 changed files with 69 additions and 46 deletions
  1. +31
    -20
      client.c
  2. +27
    -21
      dev.c
  3. +6
    -3
      dwm.h
  4. +5
    -2
      event.c

+ 31
- 20
client.c View File

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


+ 27
- 21
dev.c View File

@ -20,27 +20,33 @@ const char *browse[] = { "firefox", NULL };
const char *xlock[] = { "xlock", NULL }; const char *xlock[] = { "xlock", NULL };
static Key key[] = { static Key key[] = {
{ Mod1Mask, XK_Return, spawn, { .argv = term } },
{ Mod1Mask, XK_w, spawn, { .argv = browse } },
{ Mod1Mask, XK_l, spawn, { .argv = xlock } },
{ 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 = Tirc } },
{ 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 } },
/* 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 = Tirc } },
{ Mod1Mask, XK_3, view, { .i = Twww } },
{ Mod1Mask, XK_4, 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 = 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 **********/ /********** CUSTOMIZE **********/


+ 6
- 3
dwm.h View File

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


+ 5
- 2
event.c View File

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


Loading…
Cancel
Save