replaced togglelayout with setlayout

This commit is contained in:
Anselm R. Garbe 2007-02-19 18:33:15 +01:00
parent 3794c62945
commit 879241c05c
5 changed files with 29 additions and 21 deletions

View File

@ -63,7 +63,7 @@ static Key key[] = { \
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \ { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \ { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
{ MODKEY, XK_space, togglelayout, { 0 } }, \ { MODKEY, XK_space, setlayout, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \ { MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \
{ MODKEY, XK_0, view, { .i = -1 } }, \ { MODKEY, XK_0, view, { .i = -1 } }, \
{ MODKEY, XK_1, view, { .i = 0 } }, \ { MODKEY, XK_1, view, { .i = 0 } }, \

View File

@ -58,8 +58,8 @@ static Key key[] = { \
{ MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \ { MODKEY|ControlMask|ShiftMask, XK_8, toggletag, { .i = 7 } }, \
{ MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \ { MODKEY|ControlMask|ShiftMask, XK_9, toggletag, { .i = 8 } }, \
{ MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \ { MODKEY|ShiftMask, XK_c, killclient, { 0 } }, \
{ MODKEY, XK_space, togglelayout, { 0 } }, \ { MODKEY, XK_space, setlayout, { .i = -1 } }, \
{ MODKEY|ShiftMask, XK_space, toggleversatile { 0 } }, \ { MODKEY|ShiftMask, XK_space, toggleversatile,{ 0 } }, \
{ MODKEY, XK_0, view, { .i = -1 } }, \ { MODKEY, XK_0, view, { .i = -1 } }, \
{ MODKEY, XK_1, view, { .i = 0 } }, \ { MODKEY, XK_1, view, { .i = 0 } }, \
{ MODKEY, XK_2, view, { .i = 1 } }, \ { MODKEY, XK_2, view, { .i = 1 } }, \
@ -86,7 +86,7 @@ static Key key[] = { \
* xprop | awk -F '"' '/^WM_CLASS/ { printf("%s:%s:",$4,$2) }; /^WM_NAME/ { printf("%s\n",$2) }' */ * xprop | awk -F '"' '/^WM_CLASS/ { printf("%s:%s:",$4,$2) }; /^WM_NAME/ { printf("%s\n",$2) }' */
#define RULES \ #define RULES \
static Rule rule[] = { \ static Rule rule[] = { \
/* class:instance:title regex tags regex versatile */ \ /* class:instance:title regex tags regex isversatile */ \
{ "Gimp", NULL, True }, \ { "Gimp", NULL, True }, \
{ "MPlayer", NULL, True }, \ { "MPlayer", NULL, True }, \
{ "Acroread", NULL, True }, \ { "Acroread", NULL, True }, \

2
dwm.h
View File

@ -134,10 +134,10 @@ extern void initlayouts(void); /* initialize layout array */
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 setlayout(Arg *arg); /* sets layout, -1 toggles */
extern void settags(Client *c, Client *trans); /* sets tags of c */ extern void settags(Client *c, Client *trans); /* sets tags of c */
extern void tag(Arg *arg); /* tags c with arg's index */ extern void tag(Arg *arg); /* tags c with arg's index */
extern void toggleversatile(Arg *arg); /* toggles focusesd client between versatile/and non-versatile state */ extern void toggleversatile(Arg *arg); /* toggles focusesd client between versatile/and non-versatile state */
extern void togglelayout(Arg *arg); /* toggles layout */
extern void toggletag(Arg *arg); /* toggles c tags with arg's index */ extern void toggletag(Arg *arg); /* toggles c tags with arg's index */
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 versatile(void); /* arranges all windows versatile */ extern void versatile(void); /* arranges all windows versatile */

View File

@ -140,7 +140,8 @@ buttonpress(XEvent *e) {
if(ev->x < x + blw) if(ev->x < x + blw)
switch(ev->button) { switch(ev->button) {
case Button1: case Button1:
togglelayout(NULL); a.i = -1;
setlayout(&a);
break; break;
case Button4: case Button4:
a.i = 1; a.i = 1;

View File

@ -190,6 +190,28 @@ restack(void) {
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev)); while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
} }
void
setlayout(Arg *arg) {
unsigned int i;
if(arg->i == -1) {
for(i = 0; i < nlayouts && lt != &layout[i]; i++);
if(i == nlayouts - 1)
lt = &layout[0];
else
lt = &layout[++i];
}
else {
if(arg->i < 0 || arg->i >= nlayouts)
return;
lt = &layout[arg->i];
}
if(sel)
lt->arrange();
else
drawstatus();
}
void void
settags(Client *c, Client *trans) { settags(Client *c, Client *trans) {
char prop[512]; char prop[512];
@ -252,21 +274,6 @@ toggletag(Arg *arg) {
lt->arrange(); lt->arrange();
} }
void
togglelayout(Arg *arg) {
unsigned int i;
for(i = 0; i < nlayouts && lt != &layout[i]; i++);
if(i == nlayouts - 1)
lt = &layout[0];
else
lt = &layout[++i];
if(sel)
lt->arrange();
else
drawstatus();
}
void void
toggleversatile(Arg *arg) { toggleversatile(Arg *arg) {
if(!sel || lt->arrange == versatile) if(!sel || lt->arrange == versatile)