Compare commits

...

17 Commits
2.3 ... 2.4

Author SHA1 Message Date
683dabe5e6 extended dwm.1 with last change 2006-11-28 17:36:00 +01:00
3aff96177c togglefloat should only work in dotile mode (thanks to Sander for this hint) 2006-11-28 17:35:31 +01:00
0a915eba8f applied Alex Elide's tricky patch, thanks! 2006-11-27 17:51:50 +01:00
19dcbc5717 returning to old Key struct 2006-11-27 17:49:58 +01:00
d2a4952956 applied Szabolcs Nagy's patch (thank you!) 2006-11-27 17:46:02 +01:00
0c97b21b61 applied patch by Jukka 2006-11-27 17:30:06 +01:00
19390b1a91 changing Key.func into Key.func[NFUNCS], this allows sequences execution of functions per keypress (avoids implementing useless masterfunctions which call atomic ones) 2006-11-27 13:21:38 +01:00
8dc86051df added man page entry 2006-11-27 11:05:47 +01:00
46d5f9d1bf added togglefloat to hg tip (i consider this useful for some cases), using MODKEY-Shift-space as shortcut 2006-11-27 10:57:37 +01:00
35e96b8deb applied Jukka's patch preventing some cornercases and making the EOF error message correct 2006-11-27 10:29:47 +01:00
2210ea7e3b applied yet another proposal of Manuel 2006-11-26 15:43:16 +01:00
61a1910f91 applied Jukka's sizeof K&R compliance patch, applied Manuels' last-line printage proposal for stdin reading. 2006-11-26 14:26:53 +01:00
27ef73507b applied Jukka's stdinread patch 2006-11-26 13:31:36 +01:00
2b35fb643e next version will be 2.4 2006-11-25 19:26:31 +01:00
478f6f95f1 applied Manuels patch (thanks to Manuel!) 2006-11-25 19:26:16 +01:00
44411d2d48 small fix of man page 2006-11-24 17:02:41 +01:00
a2175cf71a Added tag 2.3 for changeset 719b37b37b0df829d7cf017ac70e353088fe5849 2006-11-24 15:46:32 +01:00
12 changed files with 59 additions and 34 deletions

View File

@ -21,3 +21,4 @@ a5567a0d30112822db2627a04a2e7aa3b6c38148 1.9
12deea36603da407e3f32640048846a3bd74a9ec 2.0 12deea36603da407e3f32640048846a3bd74a9ec 2.0
a2c465098a3b972bbed00feda9804b6aae1e9531 2.1 a2c465098a3b972bbed00feda9804b6aae1e9531 2.1
7e92f58754ae6edb3225f26d754bd89c1ff458cf 2.2 7e92f58754ae6edb3225f26d754bd89c1ff458cf 2.2
719b37b37b0df829d7cf017ac70e353088fe5849 2.3

View File

@ -361,12 +361,12 @@ updatetitle(Client *c) {
if(!name.nitems) if(!name.nitems)
return; return;
if(name.encoding == XA_STRING) if(name.encoding == XA_STRING)
strncpy(c->name, (char *)name.value, sizeof(c->name)); strncpy(c->name, (char *)name.value, sizeof c->name);
else { else {
if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
&& n > 0 && *list) && n > 0 && *list)
{ {
strncpy(c->name, *list, sizeof(c->name)); strncpy(c->name, *list, sizeof c->name);
XFreeStringList(list); XFreeStringList(list);
} }
} }

View File

@ -23,7 +23,7 @@ const char *tags[] = { "dev", "work", "net", "fnord", NULL };
#define KEYS \ #define KEYS \
static Key key[] = { \ static Key key[] = { \
/* modifier key function arguments */ \ /* modifier key function argument */ \
{ MODKEY|ShiftMask, XK_Return, spawn, \ { MODKEY|ShiftMask, XK_Return, spawn, \
{ .cmd = "exec urxvtc -tr -bg black -fg '#eeeeee' -cr '#eeeeee' +sb -fn '"FONT"'" } }, \ { .cmd = "exec urxvtc -tr -bg black -fg '#eeeeee' -cr '#eeeeee' +sb -fn '"FONT"'" } }, \
{ MODKEY, XK_p, spawn, \ { MODKEY, XK_p, spawn, \
@ -45,6 +45,7 @@ static Key key[] = { \
{ MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \ { MODKEY|ControlMask|ShiftMask, XK_4, toggletag, { .i = 3 } }, \
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
{ MODKEY, XK_space, togglemode, { 0 } }, \ { MODKEY, XK_space, togglemode, { 0 } }, \
{ MODKEY|ShiftMask, XK_space, togglefloat, { 0 } }, \
{ MODKEY, XK_0, viewall, { 0 } }, \ { MODKEY, XK_0, viewall, { 0 } }, \
{ MODKEY, XK_1, view, { .i = 0 } }, \ { MODKEY, XK_1, view, { .i = 0 } }, \
{ MODKEY, XK_2, view, { .i = 1 } }, \ { MODKEY, XK_2, view, { .i = 1 } }, \

View File

@ -23,7 +23,7 @@ const char *tags[] = { "1", "2", "3", "4", "5", NULL };
#define KEYS \ #define KEYS \
static Key key[] = { \ static Key key[] = { \
/* modifier key function arguments */ \ /* modifier key function argument */ \
{ MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \ { MODKEY|ShiftMask, XK_Return, spawn, { .cmd = "exec xterm" } }, \
{ MODKEY, XK_Tab, focusnext, { 0 } }, \ { MODKEY, XK_Tab, focusnext, { 0 } }, \
{ MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \ { MODKEY|ShiftMask, XK_Tab, focusprev, { 0 } }, \
@ -42,6 +42,7 @@ static Key key[] = { \
{ MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \ { MODKEY|ControlMask|ShiftMask, XK_5, toggletag, { .i = 4 } }, \
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
{ MODKEY, XK_space, togglemode, { 0 } }, \ { MODKEY, XK_space, togglemode, { 0 } }, \
{ MODKEY|ShiftMask, XK_space, togglefloat, { 0 } }, \
{ MODKEY, XK_0, viewall, { 0 } }, \ { MODKEY, XK_0, viewall, { 0 } }, \
{ MODKEY, XK_1, view, { .i = 0 } }, \ { MODKEY, XK_1, view, { .i = 0 } }, \
{ MODKEY, XK_2, view, { .i = 1 } }, \ { MODKEY, XK_2, view, { .i = 1 } }, \

View File

@ -1,5 +1,5 @@
# dwm version # dwm version
VERSION = 2.3 VERSION = 2.4
# Customize below to fit your system # Customize below to fit your system

4
draw.c
View File

@ -43,8 +43,8 @@ drawtext(const char *text, unsigned long col[ColLast], Bool ldot, Bool rdot) {
return; return;
w = 0; w = 0;
olen = len = strlen(text); olen = len = strlen(text);
if(len >= sizeof(buf)) if(len >= sizeof buf)
len = sizeof(buf) - 1; len = sizeof buf - 1;
memcpy(buf, text, len); memcpy(buf, text, len);
buf[len] = 0; buf[len] = 0;
h = dc.font.ascent + dc.font.descent; h = dc.font.ascent + dc.font.descent;

5
dwm.1
View File

@ -22,7 +22,7 @@ dwm contains a small status bar which displays all available tags, the mode,
the title of the focused window, and the text read from standard input. The the title of the focused window, and the text read from standard input. The
selected tags are indicated with a different color. The tags of the focused selected tags are indicated with a different color. The tags of the focused
window are indicated with a small point in the top left corner. The tags which window are indicated with a small point in the top left corner. The tags which
are applied by any client are indicated with a small point in the bottom are applied to one or more clients are indicated with a small point in the bottom
right corner. right corner.
.P .P
dwm draws a 1-pixel border around windows to indicate the focus state. dwm draws a 1-pixel border around windows to indicate the focus state.
@ -86,6 +86,9 @@ Close focused window.
.B Mod1-space .B Mod1-space
Toggle between tiling and floating mode (affects all windows). Toggle between tiling and floating mode (affects all windows).
.TP .TP
.B Mod1-Shift-space
Toggle focused window between floating and non-floating state (tiling mode only).
.TP
.B Mod1-[1..n] .B Mod1-[1..n]
View all windows with View all windows with
.BR nth .BR nth

1
dwm.h
View File

@ -164,6 +164,7 @@ extern void focusprev(Arg *arg); /* focuses previous visible client, arg is ign
extern Bool isvisible(Client *c); /* returns True if client is visible */ extern Bool isvisible(Client *c); /* returns True if client is visible */
extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */ extern void resizemaster(Arg *arg); /* resizes the master percent with arg's index value */
extern void restack(void); /* restores z layers of all clients */ extern void restack(void); /* restores z layers of all clients */
extern void togglefloat(Arg *arg); /* toggles focusesd client between floating/non-floating state */
extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */ extern void togglemode(Arg *arg); /* toggles global arrange function (dotile/dofloat) */
extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */ extern void toggleview(Arg *arg); /* toggles the tag with arg's index (in)visible */
extern void view(Arg *arg); /* views the tag with arg's index */ extern void view(Arg *arg); /* views the tag with arg's index */

View File

@ -244,7 +244,7 @@ expose(XEvent *e) {
static void static void
keypress(XEvent *e) { keypress(XEvent *e) {
static unsigned int len = sizeof(key) / sizeof(key[0]); static unsigned int len = sizeof key / sizeof key[0];
unsigned int i; unsigned int i;
KeySym keysym; KeySym keysym;
XKeyEvent *ev = &e->xkey; XKeyEvent *ev = &e->xkey;
@ -256,7 +256,6 @@ keypress(XEvent *e) {
{ {
if(key[i].func) if(key[i].func)
key[i].func(&key[i].arg); key[i].func(&key[i].arg);
return;
} }
} }
} }
@ -355,7 +354,7 @@ void (*handler[LASTEvent]) (XEvent *) = {
void void
grabkeys(void) { grabkeys(void) {
static unsigned int len = sizeof(key) / sizeof(key[0]); static unsigned int len = sizeof key / sizeof key[0];
unsigned int i; unsigned int i;
KeyCode code; KeyCode code;

35
main.c
View File

@ -227,6 +227,7 @@ xerror(Display *dpy, XErrorEvent *ee) {
int int
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
char *p;
int r, xfd; int r, xfd;
fd_set rd; fd_set rd;
@ -267,21 +268,31 @@ main(int argc, char *argv[]) {
if(readin) if(readin)
FD_SET(STDIN_FILENO, &rd); FD_SET(STDIN_FILENO, &rd);
FD_SET(xfd, &rd); FD_SET(xfd, &rd);
r = select(xfd + 1, &rd, NULL, NULL, NULL); if(select(xfd + 1, &rd, NULL, NULL, NULL) == -1) {
if((r == -1) && (errno == EINTR)) if(errno == EINTR)
continue; continue;
if(r > 0) { eprint("select failed\n");
if(readin && FD_ISSET(STDIN_FILENO, &rd)) { }
readin = NULL != fgets(stext, sizeof(stext), stdin); if(FD_ISSET(STDIN_FILENO, &rd)) {
if(readin) switch(r = read(STDIN_FILENO, stext, sizeof stext - 1)) {
stext[strlen(stext) - 1] = 0; case -1:
else strncpy(stext, strerror(errno), sizeof stext - 1);
strcpy(stext, "broken pipe"); stext[sizeof stext - 1] = '\0';
readin = False;
break;
case 0:
strncpy(stext, "EOF", 4);
readin = False;
break;
default:
for(stext[r] = '\0', p = stext + strlen(stext) - 1; p >= stext && *p == '\n'; *p-- = '\0');
for(p = stext + strlen(stext) - 1; p >= stext && *p != '\n'; --p);
if(p > stext)
strncpy(stext, p + 1, sizeof stext);
}
drawstatus(); drawstatus();
} }
} if(FD_ISSET(xfd, &rd))
else if(r < 0)
eprint("select failed\n");
procevent(); procevent();
} }
cleanup(); cleanup();

4
tag.c
View File

@ -50,7 +50,7 @@ initrregs(void) {
if(rreg) if(rreg)
return; return;
len = sizeof(rule) / sizeof(rule[0]); len = sizeof rule / sizeof rule[0];
rreg = emallocz(len * sizeof(RReg)); rreg = emallocz(len * sizeof(RReg));
for(i = 0; i < len; i++) { for(i = 0; i < len; i++) {
if(rule[i].clpattern) { if(rule[i].clpattern) {
@ -83,7 +83,7 @@ settags(Client *c, Client *trans) {
c->tags[i] = trans->tags[i]; c->tags[i] = trans->tags[i];
} }
else if(XGetClassHint(dpy, c->win, &ch)) { else if(XGetClassHint(dpy, c->win, &ch)) {
snprintf(prop, sizeof(prop), "%s:%s:%s", snprintf(prop, sizeof prop, "%s:%s:%s",
ch.res_class ? ch.res_class : "", ch.res_class ? ch.res_class : "",
ch.res_name ? ch.res_name : "", c->name); ch.res_name ? ch.res_name : "", c->name);
for(i = 0; !matched && i < len; i++) for(i = 0; !matched && i < len; i++)

12
view.c
View File

@ -91,7 +91,7 @@ dotile(void) {
c->h = wah - 2 * BORDERPX; c->h = wah - 2 * BORDERPX;
} }
else if(i == 0) { /* master window */ else if(i == 0) { /* master window */
c->w = waw - stackw - 2 * BORDERPX; c->w = mpx - 2 * BORDERPX;
c->h = wah - 2 * BORDERPX; c->h = wah - 2 * BORDERPX;
th = wah / (n - 1); th = wah / (n - 1);
} }
@ -99,7 +99,7 @@ dotile(void) {
c->x += mpx; c->x += mpx;
c->w = stackw - 2 * BORDERPX; c->w = stackw - 2 * BORDERPX;
if(th > bh) { if(th > bh) {
c->y = way + (i - 1) * th; c->y += (i - 1) * th;
c->h = th - 2 * BORDERPX; c->h = th - 2 * BORDERPX;
} }
else /* fallback if th < bh */ else /* fallback if th < bh */
@ -200,6 +200,14 @@ restack(void) {
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
} }
void
togglefloat(Arg *arg) {
if (!sel || arrange == dofloat)
return;
sel->isfloat = !sel->isfloat;
arrange();
}
void void
togglemode(Arg *arg) { togglemode(Arg *arg) {
arrange = (arrange == dofloat) ? dotile : dofloat; arrange = (arrange == dofloat) ? dotile : dofloat;