several additions in mouse handling ;)

This commit is contained in:
Anselm R. Garbe 2006-07-16 00:47:40 +02:00
parent e6cbe9c11e
commit 901b3ed9b7
5 changed files with 59 additions and 65 deletions

View File

@ -192,7 +192,7 @@ lower(Client *c)
void void
manage(Window w, XWindowAttributes *wa) manage(Window w, XWindowAttributes *wa)
{ {
Client *c, **l; Client *c;
XSetWindowAttributes twa; XSetWindowAttributes twa;
Window trans; Window trans;
@ -223,10 +223,11 @@ manage(Window w, XWindowAttributes *wa)
settitle(c); settitle(c);
settags(c); settags(c);
for(l = &clients; *l; l = &(*l)->next); c->next = clients;
c->next = *l; /* *l == nil */ clients = c;
*l = c;
XGrabButton(dpy, Button1, ControlMask, c->win, False, ButtonPressMask,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask, XGrabButton(dpy, Button1, Mod1Mask, c->win, False, ButtonPressMask,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask, XGrabButton(dpy, Button2, Mod1Mask, c->win, False, ButtonPressMask,
@ -234,8 +235,8 @@ manage(Window w, XWindowAttributes *wa)
XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask, XGrabButton(dpy, Button3, Mod1Mask, c->win, False, ButtonPressMask,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
if(!c->dofloat) if(!c->isfloat)
c->dofloat = trans c->isfloat = trans
|| ((c->maxw == c->minw) && (c->maxh == c->minh)); || ((c->maxw == c->minw) && (c->maxh == c->minh));
arrange(NULL); arrange(NULL);

63
dwm.1
View File

@ -5,63 +5,44 @@ dwm \- dynamic window manager
.B dwm .B dwm
.RB [ \-v ] .RB [ \-v ]
.SH DESCRIPTION .SH DESCRIPTION
.SS Overview
.B dwm .B dwm
is a dynamic window manager for X11. It consists of a small status bar at the is a dynamic window manager for X11. It consists of a small status bar and
top of the screen and arranges windows in either a tiled or floating mode. arranges windows in either a tiled or floating mode.
.P .P
If In tiled mode
.B dwm .B dwm
is in tiled mode, it consists of two columns. The left master column manages all windows in a left master column and a right stacking column. The
contains only one window per time, the right column contains all other windows master column contains a single window, the left stacking column all other
in a stack. In tiled mode windows. Dialog windows are treated floating.
.B dwm
.B don't
handles incremental resizals, some terminal programs like
.B xterm
may not work correctly with this in tiled mode.
.P .P
If In floating mode
.B dwm .B dwm
is in floating mode, it arranges all windows with the reqyested geometry and manages all windows in a conventional way. They can be resized and moved freely
allows the user to move or resize them. Some windows, like with the mouse.
dialog windows, are treated floating even if
.B dwm
is in tiled mode. In floating mode
.B dwm
handles incremental resizals.
.P .P
Windows are grouped by tags. You can view all windows with a specific tag per Windows are grouped by tags. You can view all windows with a specific tag per
time. However, each window is allowed to contain more than one tag, which time. However, each window is allowed to contain more than one tag, which
allows to make windows visible in all views. allows to make windows visible in all views.
.P .P
.B dwm .B dwm
reads from reads from standard input to display status text, if written.
.I stdin
to display status text, if written.
.P .P
.B dwm .B dwm
draws 1-pixel borders around windows to indicate the focus state and save as draws 1-pixel borders around windows to indicate the focus state and providing as
much screen real estate as possible. Unfocused windows contain a small bar much screen real estate as possible. Unfocused windows contain a small bar
in front of the window indicating the tags and the window title. in front of the window indicating the tags and the window title.
.SS Options .SH OPTIONS
.TP .TP
.B \-v .B \-v
prints version information to prints version information to standard output, then exits.
.I stdout .SH CUSTOMIZATION
, then exits.
.SS Customization
.B dwm .B dwm
is customized through editing its source code. It is assumed that is customized through editing its source code. It is assumed that
dwm users are high experienced users who know how a window manager works
and who are able to patch
.B dwm .B dwm
for their needs. This keeps users know to patch it for their needs. This keeps it fast, secure and simple,
.B dwm because it does not process any input data, except window properties and
fast, secure and simple, because it does not process any input data, except the status text read from standard input.
window properties and the status text read from .SS Keyboard Control
.I stdin .
.SS Default Key Bindings
.TP 16 .TP 16
.I Key .I Key
.I Action .I Action
@ -71,7 +52,7 @@ Zoom
.B window .B window
to the to the
.B master .B master
track column
.TP .TP
.B Mod1-k .B Mod1-k
Focus previous Focus previous
@ -127,7 +108,7 @@ Append
.B nth .B nth
tag to cureent tag to cureent
.B window .B window
.SS Default Mouse Bindings .SS Mouse Control
.TP .TP
.B Mod1-Button1 .B Mod1-Button1
Moves current Moves current
@ -142,7 +123,3 @@ Lowers current
Resizes current Resizes current
.B window .B window
while dragging while dragging
.SH BUGS
Some terminal programs do not behave correctly in tiled mode, because
incremental resizals are ignored to use maximum screen real estate. You can
patch the code to fix this.

4
dwm.h
View File

@ -71,7 +71,7 @@ struct Client {
int grav; int grav;
unsigned int border; unsigned int border;
long flags; long flags;
Bool dofloat; Bool isfloat;
Window win; Window win;
Window title; Window title;
Client *next; Client *next;
@ -82,7 +82,7 @@ struct Rule {
const char *class; const char *class;
const char *instance; const char *instance;
char *tags[TLast]; char *tags[TLast];
Bool dofloat; Bool isfloat;
}; };
struct Key { struct Key {

24
event.c
View File

@ -14,8 +14,8 @@
/********** CUSTOMIZE **********/ /********** CUSTOMIZE **********/
const char *term[] = { const char *term[] = {
"urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-fn", "urxvtc", "-tr", "+sb", "-bg", "black", "-fg", "white", "-cr", "white",
"-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*",NULL "-fn", "-*-terminus-medium-*-*-*-13-*-*-*-*-*-iso10646-*", NULL
}; };
const char *browse[] = { "firefox", NULL }; const char *browse[] = { "firefox", NULL };
const char *xlock[] = { "xlock", NULL }; const char *xlock[] = { "xlock", NULL };
@ -128,6 +128,8 @@ buttonpress(XEvent *e)
Client *c; Client *c;
if(barwin == ev->window) { if(barwin == ev->window) {
switch(ev->button) {
default:
x = 0; x = 0;
for(a.i = 0; a.i < TLast; a.i++) { for(a.i = 0; a.i < TLast; a.i++) {
x += textw(tags[a.i]); x += textw(tags[a.i]);
@ -136,10 +138,24 @@ buttonpress(XEvent *e)
break; break;
} }
} }
break;
case Button4:
a.i = (tsel + 1 < TLast) ? tsel + 1 : 0;
view(&a);
break;
case Button5:
a.i = (tsel - 1 >= 0) ? tsel - 1 : TLast - 1;
view(&a);
break;
}
} }
else if((c = getclient(ev->window))) { else if((c = getclient(ev->window))) {
if(arrange == dotile && !c->dofloat) if(arrange == dotile && !c->isfloat) {
if((ev->state & ControlMask) && (ev->button == Button1))
zoom(NULL);
return; return;
}
/* floating windows */
higher(c); higher(c);
switch(ev->button) { switch(ev->button) {
default: default:
@ -297,7 +313,7 @@ propertynotify(XEvent *e)
default: break; default: break;
case XA_WM_TRANSIENT_FOR: case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(dpy, c->win, &trans); XGetTransientForHint(dpy, c->win, &trans);
if(!c->dofloat && (c->dofloat = (trans != 0))) if(!c->isfloat && (c->isfloat = (trans != 0)))
arrange(NULL); arrange(NULL);
break; break;
case XA_WM_NORMAL_HINTS: case XA_WM_NORMAL_HINTS:

8
tag.c
View File

@ -17,7 +17,7 @@ char *tags[TLast] = {
}; };
static Rule rule[] = { static Rule rule[] = {
/* class instance tags dofloat */ /* class instance tags isfloat */
{ "Firefox-bin", "Gecko", { [Twww] = "www" }, False }, { "Firefox-bin", "Gecko", { [Twww] = "www" }, False },
}; };
@ -67,7 +67,7 @@ dotile(Arg *arg)
w = sw - mw; w = sw - mw;
arrange = dotile; arrange = dotile;
for(n = 0, c = clients; c; c = c->next) for(n = 0, c = clients; c; c = c->next)
if(c->tags[tsel] && !c->dofloat) if(c->tags[tsel] && !c->isfloat)
n++; n++;
if(n > 1) if(n > 1)
@ -77,7 +77,7 @@ dotile(Arg *arg)
for(i = 0, c = clients; c; c = c->next) { for(i = 0, c = clients; c; c = c->next) {
if(c->tags[tsel]) { if(c->tags[tsel]) {
if(c->dofloat) { if(c->isfloat) {
higher(c); higher(c);
resize(c, True); resize(c, True);
continue; continue;
@ -155,7 +155,7 @@ settags(Client *c)
{ {
for(j = 0; j < TLast; j++) for(j = 0; j < TLast; j++)
c->tags[j] = rule[i].tags[j]; c->tags[j] = rule[i].tags[j];
c->dofloat = rule[i].dofloat; c->isfloat = rule[i].isfloat;
matched = True; matched = True;
break; break;
} }