dwm-meillo
changeset 53:529901e6a227
added mini stuff
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Thu, 13 Jul 2006 21:42:17 +0200 |
parents | d18f6dd0cf23 |
children | a64602deac83 |
files | client.c dev.c dwm.h event.c |
diffstat | 4 files changed, 69 insertions(+), 46 deletions(-) [+] |
line diff
1.1 --- a/client.c Thu Jul 13 20:28:19 2006 +0200 1.2 +++ b/client.c Thu Jul 13 21:42:17 2006 +0200 1.3 @@ -11,10 +11,11 @@ 1.4 1.5 #include "dwm.h" 1.6 1.7 -static void (*arrange)(Arg *) = tiling; 1.8 +void (*arrange)(Arg *) = tiling; 1.9 1.10 static Rule rule[] = { 1.11 - { "Firefox-bin", "Gecko", { [Twww] = "www" } }, 1.12 + /* class instance tags floating */ 1.13 + { "Firefox-bin", "Gecko", { [Twww] = "www" }, False }, 1.14 }; 1.15 1.16 static Client * 1.17 @@ -64,25 +65,25 @@ 1.18 } 1.19 1.20 void 1.21 -tag(Arg *arg) 1.22 +tappend(Arg *arg) 1.23 { 1.24 - int i, n; 1.25 if(!sel) 1.26 return; 1.27 1.28 - if(arg->i == tsel) { 1.29 - for(n = i = 0; i < TLast; i++) 1.30 - if(sel->tags[i]) 1.31 - n++; 1.32 - if(n < 2) 1.33 - return; 1.34 - } 1.35 + sel->tags[arg->i] = tags[arg->i]; 1.36 + arrange(NULL); 1.37 +} 1.38 1.39 - if(sel->tags[arg->i]) 1.40 - sel->tags[arg->i] = NULL; /* toggle tag */ 1.41 - else 1.42 - sel->tags[arg->i] = tags[arg->i]; 1.43 - arrange(NULL); 1.44 +void 1.45 +ttrunc(Arg *arg) 1.46 +{ 1.47 + int i; 1.48 + if(!sel) 1.49 + return; 1.50 + 1.51 + for(i = 0; i < TLast; i++) 1.52 + sel->tags[i] = NULL; 1.53 + tappend(arg); 1.54 } 1.55 1.56 static void 1.57 @@ -122,13 +123,18 @@ 1.58 w = sw - mw; 1.59 arrange = tiling; 1.60 for(n = 0, c = clients; c; c = c->next) 1.61 - if(c->tags[tsel]) 1.62 + if(c->tags[tsel] && !c->floating) 1.63 n++; 1.64 1.65 h = (n > 1) ? sh / (n - 1) : sh; 1.66 1.67 for(i = 0, c = clients; c; c = c->next) { 1.68 if(c->tags[tsel]) { 1.69 + if(c->floating) { 1.70 + craise(c); 1.71 + resize(c, True); 1.72 + continue; 1.73 + } 1.74 if(n == 1) { 1.75 c->x = sx; 1.76 c->y = sy; 1.77 @@ -330,14 +336,13 @@ 1.78 1.79 if(XGetClassHint(dpy, c->win, &ch)) { 1.80 if(ch.res_class && ch.res_name) { 1.81 - fprintf(stderr, "%s:%s\n", ch.res_class, ch.res_name); 1.82 for(i = 0; i < len; i++) 1.83 if(!strncmp(rule[i].class, ch.res_class, sizeof(rule[i].class)) 1.84 && !strncmp(rule[i].instance, ch.res_name, sizeof(rule[i].instance))) 1.85 { 1.86 - fprintf(stderr, "->>>%s:%s\n", ch.res_class, ch.res_name); 1.87 for(j = 0; j < TLast; j++) 1.88 c->tags[j] = rule[i].tags[j]; 1.89 + c->floating = rule[i].floating; 1.90 matched = True; 1.91 break; 1.92 } 1.93 @@ -357,6 +362,7 @@ 1.94 { 1.95 Client *c, **l; 1.96 XSetWindowAttributes twa; 1.97 + Window trans; 1.98 1.99 c = emallocz(sizeof(Client)); 1.100 c->win = w; 1.101 @@ -370,7 +376,7 @@ 1.102 update_size(c); 1.103 XSelectInput(dpy, c->win, 1.104 StructureNotifyMask | PropertyChangeMask | EnterWindowMask); 1.105 - XGetTransientForHint(dpy, c->win, &c->trans); 1.106 + XGetTransientForHint(dpy, c->win, &trans); 1.107 twa.override_redirect = 1; 1.108 twa.background_pixmap = ParentRelative; 1.109 twa.event_mask = ExposureMask; 1.110 @@ -396,6 +402,11 @@ 1.111 GrabModeAsync, GrabModeSync, None, None); 1.112 XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, 1.113 GrabModeAsync, GrabModeSync, None, None); 1.114 + 1.115 + if(!c->floating) 1.116 + c->floating = trans 1.117 + || ((c->maxw == c->minw) && (c->maxh == c->minh)); 1.118 + 1.119 arrange(NULL); 1.120 if(c->tags[tsel]) 1.121 focus(c);
2.1 --- a/dev.c Thu Jul 13 20:28:19 2006 +0200 2.2 +++ b/dev.c Thu Jul 13 21:42:17 2006 +0200 2.3 @@ -20,27 +20,33 @@ 2.4 const char *xlock[] = { "xlock", NULL }; 2.5 2.6 static Key key[] = { 2.7 - { Mod1Mask, XK_Return, spawn, { .argv = term } }, 2.8 - { Mod1Mask, XK_w, spawn, { .argv = browse } }, 2.9 - { Mod1Mask, XK_l, spawn, { .argv = xlock } }, 2.10 - { Mod1Mask, XK_k, prevc, { 0 } }, 2.11 - { Mod1Mask, XK_j, nextc, { 0 } }, 2.12 - { Mod1Mask, XK_m, max, { 0 } }, 2.13 - { Mod1Mask, XK_0, view, { .i = Tscratch } }, 2.14 - { Mod1Mask, XK_1, view, { .i = Tdev } }, 2.15 - { Mod1Mask, XK_2, view, { .i = Tirc } }, 2.16 - { Mod1Mask, XK_3, view, { .i = Twww } }, 2.17 - { Mod1Mask, XK_4, view, { .i = Twork } }, 2.18 - { Mod1Mask, XK_space, tiling, { 0 } }, 2.19 - { Mod1Mask | ShiftMask, XK_Return, zoom, { 0 } }, 2.20 - { Mod1Mask | ShiftMask, XK_space, floating, { 0 } }, 2.21 - { Mod1Mask | ShiftMask, XK_0, tag, { .i = Tscratch } }, 2.22 - { Mod1Mask | ShiftMask, XK_1, tag, { .i = Tdev } }, 2.23 - { Mod1Mask | ShiftMask, XK_2, tag, { .i = Tirc } }, 2.24 - { Mod1Mask | ShiftMask, XK_3, tag, { .i = Twww } }, 2.25 - { Mod1Mask | ShiftMask, XK_4, tag, { .i = Twork } }, 2.26 - { Mod1Mask | ShiftMask, XK_c, ckill, { 0 } }, 2.27 - { Mod1Mask | ShiftMask, XK_q, quit, { 0 } }, 2.28 + /* modifier key function arguments */ 2.29 + { Mod1Mask, XK_Return, zoom, { 0 } }, 2.30 + { Mod1Mask, XK_k, prevc, { 0 } }, 2.31 + { Mod1Mask, XK_j, nextc, { 0 } }, 2.32 + { Mod1Mask, XK_m, max, { 0 } }, 2.33 + { Mod1Mask, XK_0, view, { .i = Tscratch } }, 2.34 + { Mod1Mask, XK_1, view, { .i = Tdev } }, 2.35 + { Mod1Mask, XK_2, view, { .i = Tirc } }, 2.36 + { Mod1Mask, XK_3, view, { .i = Twww } }, 2.37 + { Mod1Mask, XK_4, view, { .i = Twork } }, 2.38 + { Mod1Mask, XK_space, tiling, { 0 } }, 2.39 + { Mod1Mask|ShiftMask, XK_space, floating, { 0 } }, 2.40 + { Mod1Mask|ShiftMask, XK_0, ttrunc, { .i = Tscratch } }, 2.41 + { Mod1Mask|ShiftMask, XK_1, ttrunc, { .i = Tdev } }, 2.42 + { Mod1Mask|ShiftMask, XK_2, ttrunc, { .i = Tirc } }, 2.43 + { Mod1Mask|ShiftMask, XK_3, ttrunc, { .i = Twww } }, 2.44 + { Mod1Mask|ShiftMask, XK_4, ttrunc, { .i = Twork } }, 2.45 + { Mod1Mask|ShiftMask, XK_c, ckill, { 0 } }, 2.46 + { Mod1Mask|ShiftMask, XK_q, quit, { 0 } }, 2.47 + { Mod1Mask|ShiftMask, XK_Return, spawn, { .argv = term } }, 2.48 + { Mod1Mask|ShiftMask, XK_w, spawn, { .argv = browse } }, 2.49 + { Mod1Mask|ShiftMask, XK_l, spawn, { .argv = xlock } }, 2.50 + { ControlMask, XK_0, tappend, { .i = Tscratch } }, 2.51 + { ControlMask, XK_1, tappend, { .i = Tdev } }, 2.52 + { ControlMask, XK_2, tappend, { .i = Tirc } }, 2.53 + { ControlMask, XK_3, tappend, { .i = Twww } }, 2.54 + { ControlMask, XK_4, tappend, { .i = Twork } }, 2.55 }; 2.56 2.57 /********** CUSTOMIZE **********/
3.1 --- a/dwm.h Thu Jul 13 20:28:19 2006 +0200 3.2 +++ b/dwm.h Thu Jul 13 21:42:17 2006 +0200 3.3 @@ -66,8 +66,8 @@ 3.4 int grav; 3.5 unsigned int border; 3.6 long flags; 3.7 + Bool floating; 3.8 Window win; 3.9 - Window trans; 3.10 Window title; 3.11 Client *next; 3.12 Client *revert; 3.13 @@ -77,6 +77,7 @@ 3.14 const char *class; 3.15 const char *instance; 3.16 char *tags[TLast]; 3.17 + Bool floating; 3.18 }; 3.19 3.20 struct Key { 3.21 @@ -91,7 +92,8 @@ 3.22 extern Atom wm_atom[WMLast], net_atom[NetLast]; 3.23 extern Cursor cursor[CurLast]; 3.24 extern Bool running, issel; 3.25 -extern void (*handler[LASTEvent]) (XEvent *); 3.26 +extern void (*handler[LASTEvent])(XEvent *); 3.27 +extern void (*arrange)(Arg *); 3.28 3.29 extern int tsel, screen, sx, sy, sw, sh, mw, th; 3.30 extern char *tags[TLast]; 3.31 @@ -117,7 +119,8 @@ 3.32 extern void max(Arg *arg); 3.33 extern void floating(Arg *arg); 3.34 extern void tiling(Arg *arg); 3.35 -extern void tag(Arg *arg); 3.36 +extern void ttrunc(Arg *arg); 3.37 +extern void tappend(Arg *arg); 3.38 extern void view(Arg *arg); 3.39 extern void zoom(Arg *arg); 3.40 extern void gravitate(Client *c, Bool invert);
4.1 --- a/event.c Thu Jul 13 20:28:19 2006 +0200 4.2 +++ b/event.c Thu Jul 13 21:42:17 2006 +0200 4.3 @@ -89,6 +89,7 @@ 4.4 if(ev->value_mask & CWBorderWidth) 4.5 c->border = ev->border_width; 4.6 gravitate(c, False); 4.7 + resize(c, True); 4.8 } 4.9 4.10 wc.x = ev->x; 4.11 @@ -179,6 +180,7 @@ 4.12 propertynotify(XEvent *e) 4.13 { 4.14 XPropertyEvent *ev = &e->xproperty; 4.15 + Window trans; 4.16 Client *c; 4.17 4.18 if(ev->state == PropertyDelete) 4.19 @@ -192,9 +194,10 @@ 4.20 switch (ev->atom) { 4.21 default: break; 4.22 case XA_WM_TRANSIENT_FOR: 4.23 - XGetTransientForHint(dpy, c->win, &c->trans); 4.24 + XGetTransientForHint(dpy, c->win, &trans); 4.25 + if(!c->floating && (c->floating = (trans != 0))) 4.26 + arrange(NULL); 4.27 break; 4.28 - update_size(c); 4.29 case XA_WM_NORMAL_HINTS: 4.30 update_size(c); 4.31 break;