Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
a686c9ccd2 | |||
9ca5c3b108 | |||
bab5b1178d | |||
ee8fb0c6e4 | |||
0d9d3e79e9 |
1
.hgtags
1
.hgtags
@ -39,3 +39,4 @@ d3876aa792923f9a95f7ad0c7f0134533404df35 3.2.2
|
||||
63ad05e7f9e1f4f1881fb02f529cb6c6ae81e693 3.5
|
||||
75b1b25fe0d7e29400baf30568153f668324928b 3.6
|
||||
20ec6976cee1fcfee0c2f354ae382ee3f9f68efa 3.6.1
|
||||
baee494346e520f8dee2cee9491b8350064770d2 3.7
|
||||
|
70
client.c
70
client.c
@ -154,10 +154,19 @@ focus(Client *c) {
|
||||
|
||||
void
|
||||
killclient(const char *arg) {
|
||||
XEvent ev;
|
||||
|
||||
if(!sel)
|
||||
return;
|
||||
if(isprotodel(sel))
|
||||
sendevent(sel->win, wmatom[WMProtocols], wmatom[WMDelete]);
|
||||
if(isprotodel(sel)) {
|
||||
ev.type = ClientMessage;
|
||||
ev.xclient.window = sel->win;
|
||||
ev.xclient.message_type = wmatom[WMProtocols];
|
||||
ev.xclient.format = 32;
|
||||
ev.xclient.data.l[0] = wmatom[WMDelete];
|
||||
ev.xclient.data.l[1] = CurrentTime;
|
||||
XSendEvent(dpy, sel->win, False, NoEventMask, &ev);
|
||||
}
|
||||
else
|
||||
XKillClient(dpy, sel->win);
|
||||
}
|
||||
@ -218,12 +227,33 @@ manage(Window w, XWindowAttributes *wa) {
|
||||
|
||||
void
|
||||
resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
|
||||
float actual, dx, dy, max, min;
|
||||
float dx, dy, max, min, ratio;
|
||||
XWindowChanges wc;
|
||||
|
||||
if(w <= 0 || h <= 0)
|
||||
return;
|
||||
if(sizehints) {
|
||||
if(c->minay > 0 && c->maxay && (h - c->baseh) > 0) {
|
||||
dx = (float)(w - c->basew);
|
||||
dy = (float)(h - c->baseh);
|
||||
min = (float)(c->minax) / (float)(c->minay);
|
||||
max = (float)(c->maxax) / (float)(c->maxay);
|
||||
ratio = dx / dy;
|
||||
if(max > 0 && min > 0 && ratio > 0) {
|
||||
if(ratio < min) {
|
||||
dy = (dx * min + dy) / (min * min + 1);
|
||||
dx = dy * min;
|
||||
w = (int)dx + c->basew;
|
||||
h = (int)dy + c->baseh;
|
||||
}
|
||||
else if(ratio > max) {
|
||||
dy = (dx * min + dy) / (max * max + 1);
|
||||
dx = dy * min;
|
||||
w = (int)dx + c->basew;
|
||||
h = (int)dy + c->baseh;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(c->minw && w < c->minw)
|
||||
w = c->minw;
|
||||
if(c->minh && h < c->minh)
|
||||
@ -232,28 +262,6 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
|
||||
w = c->maxw;
|
||||
if(c->maxh && h > c->maxh)
|
||||
h = c->maxh;
|
||||
/* inspired by algorithm from fluxbox */
|
||||
if(c->minay > 0 && c->maxay && (h - c->baseh) > 0) {
|
||||
dx = (float)(w - c->basew);
|
||||
dy = (float)(h - c->baseh);
|
||||
min = (float)(c->minax) / (float)(c->minay);
|
||||
max = (float)(c->maxax) / (float)(c->maxay);
|
||||
actual = dx / dy;
|
||||
if(max > 0 && min > 0 && actual > 0) {
|
||||
if(actual < min) {
|
||||
dy = (dx * min + dy) / (min * min + 1);
|
||||
dx = dy * min;
|
||||
w = (int)dx + c->basew;
|
||||
h = (int)dy + c->baseh;
|
||||
}
|
||||
else if(actual > max) {
|
||||
dy = (dx * min + dy) / (max * max + 1);
|
||||
dx = dy * min;
|
||||
w = (int)dx + c->basew;
|
||||
h = (int)dy + c->baseh;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(c->incw)
|
||||
w -= (w - c->basew) % c->incw;
|
||||
if(c->inch)
|
||||
@ -304,6 +312,10 @@ updatesizehints(Client *c) {
|
||||
c->basew = size.base_width;
|
||||
c->baseh = size.base_height;
|
||||
}
|
||||
else if(c->flags & PMinSize) {
|
||||
c->basew = size.min_width;
|
||||
c->baseh = size.min_height;
|
||||
}
|
||||
else
|
||||
c->basew = c->baseh = 0;
|
||||
if(c->flags & PResizeInc) {
|
||||
@ -322,16 +334,20 @@ updatesizehints(Client *c) {
|
||||
c->minw = size.min_width;
|
||||
c->minh = size.min_height;
|
||||
}
|
||||
else if(c->flags & PBaseSize) {
|
||||
c->minw = size.base_width;
|
||||
c->minh = size.base_height;
|
||||
}
|
||||
else
|
||||
c->minw = c->minh = 0;
|
||||
if(c->flags & PAspect) {
|
||||
c->minax = size.min_aspect.x;
|
||||
c->minay = size.min_aspect.y;
|
||||
c->maxax = size.max_aspect.x;
|
||||
c->minay = size.min_aspect.y;
|
||||
c->maxay = size.max_aspect.y;
|
||||
}
|
||||
else
|
||||
c->minax = c->minay = c->maxax = c->maxay = 0;
|
||||
c->minax = c->maxax = c->minay = c->maxay = 0;
|
||||
c->isfixed = (c->maxw && c->minw && c->maxh && c->minh
|
||||
&& c->maxw == c->minw && c->maxh == c->minh);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
# dwm version
|
||||
VERSION = 3.7
|
||||
VERSION = 3.8
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
|
12
draw.c
12
draw.c
@ -95,7 +95,6 @@ drawtext(const char *text, unsigned long col[ColLast]) {
|
||||
int x, y, w, h;
|
||||
static char buf[256];
|
||||
unsigned int len, olen;
|
||||
XGCValues gcv;
|
||||
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
|
||||
|
||||
XSetForeground(dpy, dc.gc, col[ColBG]);
|
||||
@ -124,16 +123,11 @@ drawtext(const char *text, unsigned long col[ColLast]) {
|
||||
}
|
||||
if(w > dc.w)
|
||||
return; /* too long */
|
||||
gcv.foreground = col[ColFG];
|
||||
if(dc.font.set) {
|
||||
XChangeGC(dpy, dc.gc, GCForeground, &gcv);
|
||||
XSetForeground(dpy, dc.gc, col[ColFG]);
|
||||
if(dc.font.set)
|
||||
XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
|
||||
}
|
||||
else {
|
||||
gcv.font = dc.font.xfont->fid;
|
||||
XChangeGC(dpy, dc.gc, GCForeground | GCFont, &gcv);
|
||||
else
|
||||
XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
|
50
dwm.1
50
dwm.1
@ -1,4 +1,4 @@
|
||||
.TH DWM 1 dwm-VERSION
|
||||
.TH DWM 1 dwm\-VERSION
|
||||
.SH NAME
|
||||
dwm \- dynamic window manager
|
||||
.SH SYNOPSIS
|
||||
@ -45,87 +45,87 @@ label toggles between tiled and floating layout.
|
||||
.B Button3
|
||||
click on a tag label adds/removes all windows with that tag to/from the view.
|
||||
.TP
|
||||
.B Mod1-Button1
|
||||
.B Mod1\-Button1
|
||||
click on a tag label applies that tag to the focused window.
|
||||
.TP
|
||||
.B Mod1-Button3
|
||||
.B Mod1\-Button3
|
||||
click on a tag label adds/removes that tag to/from the focused window.
|
||||
.SS Keyboard commands
|
||||
.TP
|
||||
.B Mod1-Shift-Return
|
||||
.B Mod1\-Shift\-Return
|
||||
Start
|
||||
.BR xterm.
|
||||
.TP
|
||||
.B Mod1-Return
|
||||
.B Mod1\-Return
|
||||
Zooms/cycles current window to/from master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-j
|
||||
.B Mod1\-j
|
||||
Focus next window.
|
||||
.TP
|
||||
.B Mod1-k
|
||||
.B Mod1\-k
|
||||
Focus previous window.
|
||||
.TP
|
||||
.B Mod1-Shift-j
|
||||
.B Mod1\-Shift\-j
|
||||
Increase the number of windows in the master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-Shift-k
|
||||
.B Mod1\-Shift\-k
|
||||
Decrease the number of windows in the master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-l
|
||||
.B Mod1\-l
|
||||
Increase master area width (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-h
|
||||
.B Mod1\-h
|
||||
Decrease master area width (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-m
|
||||
.B Mod1\-m
|
||||
Toggles maximization of current window (floating layout only).
|
||||
.TP
|
||||
.B Mod1-Shift-[1..n]
|
||||
.B Mod1\-Shift\-[1..n]
|
||||
Apply
|
||||
.RB nth
|
||||
tag to current window.
|
||||
.TP
|
||||
.B Mod1-Shift-0
|
||||
.B Mod1\-Shift\-0
|
||||
Apply all tags to current window.
|
||||
.TP
|
||||
.B Mod1-Control-Shift-[1..n]
|
||||
.B Mod1\-Control\-Shift\-[1..n]
|
||||
Add/remove
|
||||
.B nth
|
||||
tag to/from current window.
|
||||
.TP
|
||||
.B Mod1-Shift-c
|
||||
.B Mod1\-Shift\-c
|
||||
Close focused window.
|
||||
.TP
|
||||
.B Mod1-space
|
||||
.B Mod1\-space
|
||||
Toggle between tiled and floating layout (affects all windows).
|
||||
.TP
|
||||
.B Mod1-Shift-space
|
||||
.B Mod1\-Shift\-space
|
||||
Toggle focused window between tiled and floating state (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-[1..n]
|
||||
.B Mod1\-[1..n]
|
||||
View all windows with
|
||||
.BR nth
|
||||
tag.
|
||||
.TP
|
||||
.B Mod1-0
|
||||
.B Mod1\-0
|
||||
View all windows with any tag.
|
||||
.TP
|
||||
.B Mod1-Control-[1..n]
|
||||
.B Mod1\-Control\-[1..n]
|
||||
Add/remove all windows with
|
||||
.BR nth
|
||||
tag to/from the view.
|
||||
.TP
|
||||
.B Mod1-Shift-q
|
||||
.B Mod1\-Shift\-q
|
||||
Quit dwm.
|
||||
.SS Mouse commands
|
||||
.TP
|
||||
.B Mod1-Button1
|
||||
.B Mod1\-Button1
|
||||
Move current window while dragging (floating layout only).
|
||||
.TP
|
||||
.B Mod1-Button2
|
||||
.B Mod1\-Button2
|
||||
Zooms/cycles current window to/from master area (tiled layout only).
|
||||
.TP
|
||||
.B Mod1-Button3
|
||||
.B Mod1\-Button3
|
||||
Resize current window while dragging (floating layout only).
|
||||
.SH CUSTOMIZATION
|
||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||
|
3
dwm.h
3
dwm.h
@ -47,7 +47,7 @@ struct Client {
|
||||
int x, y, w, h;
|
||||
int rx, ry, rw, rh; /* revert geometry */
|
||||
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
|
||||
int minax, minay, maxax, maxay;
|
||||
int minax, maxax, minay, maxay;
|
||||
long flags;
|
||||
unsigned int border;
|
||||
Bool isbanned, isfixed, ismax, isfloating;
|
||||
@ -130,7 +130,6 @@ void zoom(const char *arg); /* zooms the focused client to master area, arg is
|
||||
|
||||
/* main.c */
|
||||
void quit(const char *arg); /* quit dwm nicely */
|
||||
void sendevent(Window w, Atom a, long value); /* send synthetic event to w */
|
||||
int xerror(Display *dsply, XErrorEvent *ee); /* dwm's X error handler */
|
||||
|
||||
/* tag.c */
|
||||
|
16
main.c
16
main.c
@ -205,6 +205,8 @@ setup(void) {
|
||||
dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
|
||||
dc.gc = XCreateGC(dpy, root, 0, 0);
|
||||
XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
if(!dc.font.set)
|
||||
XSetFont(dpy, dc.gc, dc.font.xfont->fid);
|
||||
/* multihead support */
|
||||
selscreen = XQueryPointer(dpy, root, &w, &w, &i, &i, &i, &i, &mask);
|
||||
}
|
||||
@ -221,20 +223,6 @@ xerrorstart(Display *dsply, XErrorEvent *ee) {
|
||||
|
||||
/* extern */
|
||||
|
||||
void
|
||||
sendevent(Window w, Atom a, long value) {
|
||||
XEvent e;
|
||||
|
||||
e.type = ClientMessage;
|
||||
e.xclient.window = w;
|
||||
e.xclient.message_type = a;
|
||||
e.xclient.format = 32;
|
||||
e.xclient.data.l[0] = value;
|
||||
e.xclient.data.l[1] = CurrentTime;
|
||||
XSendEvent(dpy, w, False, NoEventMask, &e);
|
||||
XSync(dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
quit(const char *arg) {
|
||||
readin = running = False;
|
||||
|
Reference in New Issue
Block a user