summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client.c51
-rw-r--r--dev.c48
-rw-r--r--dwm.h9
-rw-r--r--event.c7
4 files changed, 69 insertions, 46 deletions
diff --git a/client.c b/client.c
index 6d7bd92..3fb2318 100644
--- a/client.c
+++ b/client.c
@@ -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];
+ 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);
diff --git a/dev.c b/dev.c
index 5e338b3..4c6e45f 100644
--- a/dev.c
+++ b/dev.c
@@ -20,27 +20,33 @@ 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 } },
- { 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 **********/
diff --git a/dwm.h b/dwm.h
index 8af63f0..ee15949 100644
--- a/dwm.h
+++ b/dwm.h
@@ -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);
diff --git a/event.c b/event.c
index 937bee2..e85e11f 100644
--- a/event.c
+++ b/event.c
@@ -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;