changed focusmon/tagmon to work on prev/next instead (-1/+1), changed shortcuts to Mod1-, Mod1-. and Mod1-Shift-, Mod1-Shift-.

This commit is contained in:
Anselm R Garbe 2009-07-02 20:37:26 +01:00
parent 5dd92c7655
commit a9e145fe6d
3 changed files with 49 additions and 31 deletions

View File

@ -71,10 +71,10 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_w, focusmon, {.ui = 0 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_e, focusmon, {.ui = 1 } }, { MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_w, tagmon, {.ui = 0 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_e, tagmon, {.ui = 1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
TAGKEYS( XK_1, 0) TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1) TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2) TAGKEYS( XK_3, 2)

26
dwm.1
View File

@ -19,14 +19,14 @@ layout applied.
Windows are grouped by tags. Each window can be tagged with one or multiple Windows are grouped by tags. Each window can be tagged with one or multiple
tags. Selecting certain tags displays all windows with these tags. tags. Selecting certain tags displays all windows with these tags.
.P .P
dwm contains a small status bar which displays all available tags, the layout, Each screen contains a small status bar which displays all available tags, the layout,
the title of the focused window, and the text read from the root window name the title of the focused window, and the text read from the root window name
property. A floating window is indicated with an empty square and a maximised property, if the screen is focused. A floating window is indicated with an
floating window is indicated with a filled square before the windows title. empty square and a maximised floating window is indicated with a filled square
The selected tags are indicated with a different color. The tags of the focused before the windows title. The selected tags are indicated with a different
window are indicated with a filled square in the top left corner. The tags color. The tags of the focused window are indicated with a filled square in the
which are applied to one or more windows are indicated with an empty square in top left corner. The tags which are applied to one or more windows are
the top left corner. indicated with an empty square in the top left corner.
.P .P
dwm draws a small border around windows to indicate the focus state. dwm draws a small border around windows to indicate the focus state.
.SH OPTIONS .SH OPTIONS
@ -57,6 +57,18 @@ click on a tag label adds/removes that tag to/from the focused window.
Start Start
.BR xterm. .BR xterm.
.TP .TP
.B Mod1\-,
Focus previous screen, if any.
.TP
.B Mod1\-.
Focus next screen, if any.
.TP
.B Mod1\-Shift\-,
Send focused window to previous screen, if any.
.TP
.B Mod1\-Shift\-,
Send focused window to next screen, if any.
.TP
.B Mod1\-b .B Mod1\-b
Toggles bar on and off. Toggles bar on and off.
.TP .TP

46
dwm.c
View File

@ -11,9 +11,9 @@
* in O(1) time. * in O(1) time.
* *
* Each child of the root window is called a client, except windows which have * Each child of the root window is called a client, except windows which have
* set the override_redirect flag. Clients are organized in a global * set the override_redirect flag. Clients are organized in a linked client
* linked client list, the focus history is remembered through a global * list on each monitor, the focus history is remembered through a stack list
* stack list. Each client contains a bit array to indicate the tags of a * on each monitor. Each client contains a bit array to indicate the tags of a
* client. * client.
* *
* Keys and tagging rules are organized as arrays and defined in config.h. * Keys and tagging rules are organized as arrays and defined in config.h.
@ -164,6 +164,7 @@ static void destroynotify(XEvent *e);
static void detach(Client *c); static void detach(Client *c);
static void detachstack(Client *c); static void detachstack(Client *c);
static void die(const char *errstr, ...); static void die(const char *errstr, ...);
static Monitor *dirtomon(int dir);
static void drawbar(Monitor *m); static void drawbar(Monitor *m);
static void drawbars(void); static void drawbars(void);
static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]); static void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
@ -180,7 +181,6 @@ static long getstate(Window w);
static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
static void grabbuttons(Client *c, Bool focused); static void grabbuttons(Client *c, Bool focused);
static void grabkeys(void); static void grabkeys(void);
static Monitor *idxtomon(unsigned int n);
static void initfont(const char *fontstr); static void initfont(const char *fontstr);
static Bool isprotodel(Client *c); static Bool isprotodel(Client *c);
static void keypress(XEvent *e); static void keypress(XEvent *e);
@ -621,6 +621,22 @@ die(const char *errstr, ...) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
Monitor *
dirtomon(int dir) {
Monitor *m = NULL;
if(dir > 0)
if(!(m = selmon->next))
m = mons;
else {
if(selmon == mons)
for(m = mons; m->next; m = m->next);
else
for(m = mons; m->next != selmon; m = m->next);
}
return m;
}
void void
drawbar(Monitor *m) { drawbar(Monitor *m) {
int x; int x;
@ -797,10 +813,11 @@ focusin(XEvent *e) { /* there are some broken focus acquiring clients */
void void
focusmon(const Arg *arg) { focusmon(const Arg *arg) {
Monitor *m; Monitor *m = NULL;
if(!(m = idxtomon(arg->ui)) || m == selmon) if(!mons->next)
return; return;
m = dirtomon(arg->i);
unfocus(selmon->sel); unfocus(selmon->sel);
selmon = m; selmon = m;
focus(NULL); focus(NULL);
@ -934,15 +951,6 @@ grabkeys(void) {
} }
} }
Monitor *
idxtomon(unsigned int n) {
unsigned int i;
Monitor *m;
for(m = mons, i = 0; m && i != n; m = m->next, i++);
return m;
}
void void
initfont(const char *fontstr) { initfont(const char *fontstr) {
char *def, **missing; char *def, **missing;
@ -1512,11 +1520,9 @@ tag(const Arg *arg) {
void void
tagmon(const Arg *arg) { tagmon(const Arg *arg) {
Monitor *m; if(!selmon->sel || !mons->next)
return
if(!selmon->sel || !(m = idxtomon(arg->ui))) sendmon(selmon->sel, dirtomon(arg->i));
return;
sendmon(selmon->sel, m);
} }
int int