Compare commits
81 Commits
Author | SHA1 | Date | |
---|---|---|---|
5ed9c48196 | |||
3c91283ede | |||
e941181f46 | |||
43e82adf0d | |||
42cf1c7d8f | |||
dce4fb3737 | |||
646b351cc7 | |||
e3b7e1d620 | |||
04db03a4e6 | |||
4a4817b3aa | |||
7e1182ce55 | |||
40529e1469 | |||
14343e69cc | |||
35db6d8afc | |||
3d1090ba89 | |||
18248ebf4b | |||
b468873b2b | |||
cdec9782a1 | |||
6af273771c | |||
4fb31e0896 | |||
b800a1d136 | |||
33a74489f0 | |||
5364697914 | |||
7edc596311 | |||
68b400e95d | |||
656882d76f | |||
1479e76f01 | |||
f2544a3318 | |||
aafeaf7317 | |||
f21d46ea7d | |||
c0ba635c50 | |||
0a673ad7a3 | |||
3aabc08ede | |||
d456617f0e | |||
61fe833a06 | |||
917e281634 | |||
31451c3ad3 | |||
344f35f9f5 | |||
87adcd263b | |||
fd3c19bd55 | |||
1bdb393f81 | |||
940feed314 | |||
606b44179d | |||
20f6917910 | |||
820cbb3545 | |||
90f3238301 | |||
3bfc43c3d0 | |||
c1128417a9 | |||
1b62f8fa58 | |||
54c3044dec | |||
51336aa4a3 | |||
c4b6ac812e | |||
873bcb97a9 | |||
907db0a851 | |||
4e7c469862 | |||
26445a0dc9 | |||
b5068e32e9 | |||
f099d2d5b5 | |||
80a9da555e | |||
d21026f0a1 | |||
e5a1e77351 | |||
8262d9e663 | |||
90af1ced3c | |||
5ccd42f807 | |||
1586b7a02d | |||
2420071f4c | |||
04c26574b8 | |||
b1a28ae1da | |||
f68a01cd76 | |||
2b625eb73e | |||
0f1f30daca | |||
dec4850d05 | |||
0de4197cc5 | |||
a372248b80 | |||
69e7d7dfd3 | |||
c99fe7dd7d | |||
d6670a800d | |||
6288c44697 | |||
d5c5c52b30 | |||
d0b4575bf4 | |||
03518ce49e |
71
.hgtags
71
.hgtags
@ -1,71 +0,0 @@
|
||||
d31b5ad96b0ba7b5b0a30928fcf000428339a577 0.1
|
||||
0a6472e2203994bc5738d40a340d26f7ec9d6062 0.2
|
||||
7e66082e5092fb0bccd18a3695a0bec52c80fdb2 0.3
|
||||
eb3165734f00fe7f7da8aeebaed00e60a57caac9 0.4
|
||||
22213b9a2114167ee8ba019a012e27da0422a61a 0.5
|
||||
c11f86db4550cac5d0a648a3fe4d6d3b9a4fcf7e 0.6
|
||||
3fb41412e2492f66476d92ce8f007a8b48fb1d2a 0.7
|
||||
cd15de32e173f8ce97bfe1c9b6607937b59056b4 0.8
|
||||
fae61afa861755636c4a1070694209ace8efbb6c 0.9
|
||||
bbc98e77ae89a7c9232a5be0835f60ea00d8036e 1.0
|
||||
44a55e6e46bf6c231780b09d919977d6f01083de 1.1
|
||||
e3179ce2b90451d2807cd53b589d768412b8666b 1.2
|
||||
f5f5cbf016a94b48a8fe9c47f0736e96d166d5d4 1.3
|
||||
3cff9403766bf83a9fc2a0aef230115d68de2a8e 1.4
|
||||
728c9089b079721b43c3347124639a29baa22a97 1.5
|
||||
ad3fa2d185426c51fd5deceae809770363f8d33c 1.6
|
||||
4dbdb61c8b8ce21dee5c7050a6b103855964ed20 1.7
|
||||
d5ad819f2a66a40fa75dd2e44429f3bfc884d07b 1.7.1
|
||||
c71952fa3c7ca848ec38a6923b5c6d0e18fff431 1.8
|
||||
a5567a0d30112822db2627a04a2e7aa3b6c38148 1.9
|
||||
12deea36603da407e3f32640048846a3bd74a9ec 2.0
|
||||
a2c465098a3b972bbed00feda9804b6aae1e9531 2.1
|
||||
7e92f58754ae6edb3225f26d754bd89c1ff458cf 2.2
|
||||
719b37b37b0df829d7cf017ac70e353088fe5849 2.3
|
||||
32b246925086910d63147483160281a91a47479f 2.4
|
||||
dcbbfabc8ecc5f33a6cc950584de87da1a368045 2.5
|
||||
c7f84f23ec5aef29988dcdc4ec22a7352ee8f58e 2.5.1
|
||||
5308dd22b6ee8e3218c81d9e7e4125f235bb5778 2.6
|
||||
21951c0dfbae5af68ed77821a4d87253ee91803f 2.7
|
||||
107719a9ce3bd0c79f9f1f626596eb338a276561 2.8
|
||||
3a5910fac3ccb522a98aeeba7af7008530b25092 2.9
|
||||
76b58d21ea98257c05565a3b9c850b9b26a32968 3.0
|
||||
e1c8bef05e6e48df4f26471ea0712aa43ab9d949 3.1
|
||||
4ce65f61f01b055fa6c2901c6d2527ef741aa4bf 3.2
|
||||
f2cabc83a18f9b5b548159329ddd4dee904fa31f 3.2.1
|
||||
d3876aa792923f9a95f7ad0c7f0134533404df35 3.2.2
|
||||
0f91934037b04221ff5d1ba3a6c39c1ff26e3661 3.3
|
||||
9ede7b2d2450537e750d5505789fbe63960e97e6 3.4
|
||||
63ad05e7f9e1f4f1881fb02f529cb6c6ae81e693 3.5
|
||||
75b1b25fe0d7e29400baf30568153f668324928b 3.6
|
||||
20ec6976cee1fcfee0c2f354ae382ee3f9f68efa 3.6.1
|
||||
baee494346e520f8dee2cee9491b8350064770d2 3.7
|
||||
2ea201354cf016407ea93e1e390d1422940d29b0 3.8
|
||||
55478328b2422c700c5404a774c85e77322f41a3 3.9
|
||||
018c3846842291cb6c009dc087e7fe2f0ef53bea 4.0
|
||||
00f4180df72b49aadb2933804fde4bfb33e5666d 4.1
|
||||
c13cb8c6b7a56af74cc88346e71d2490470b546f 4.2
|
||||
e0ec0d5d8b1ef3ee04a83c7c0fee5853aa2ac6a6 4.3
|
||||
408014d2126153d2b0fce26a13ba707db222b7b9 4.4
|
||||
7c117df5d202530e85066d8b1ab02cef605c79ad 4.4.1
|
||||
2acc60d6dfe28c101a8cd44a8aa710a38ae3607c 4.5
|
||||
bcd7e18e196a00cc2e97ff3a4a58f3cdaba13856 4.6
|
||||
d6d3085307d8d98b8b012b669e858fd787befeb1 4.7
|
||||
607015ddb091d49cbd3457af41713691aa69f4d6 4.8
|
||||
22c669b2dd3673785c3476b9976da21e8783f745 4.9
|
||||
06eb9644e2dad7667d97495eb7d7bc62aa0429e8 5.0
|
||||
ce355cea9bb89e162f61913737a46908cdfa7e45 5.1
|
||||
e4bcaca8e6ef13d2c3b81f1218ad15e5da4d68bd 5.2
|
||||
4004d61160355d869a7d2672561caad440751ba0 5.3
|
||||
335301ed102fec9b1a15d06bfa0184d53b38fa54 5.3.1
|
||||
8b7836a471f8f9ee61bec980df00971888d76343 5.4
|
||||
85a78d8afa0fe8b106a8223b5327e5bddb5dd5e3 5.4.1
|
||||
deaa276abac17ca08fbeb936916e4c8292d293a4 5.5
|
||||
5550702215773aad462f22a774dced9b87437c51 5.6
|
||||
e47a47bd3ed42fd3cf023572147b75ebc2adef82 5.6.1
|
||||
257403d4cd962cac03344a871ea56cc742bae38e 5.7
|
||||
48c3f87c335d6606e55fbae97267fa6b39ca56e0 5.7.1
|
||||
15761ac5e2f1e9010900f891616a24a22d82f128 5.7.2
|
||||
60ea8fed13ab750c6717f2764cbf9c13bb6f0d0a 5.8
|
||||
1ed1e75c9c2e395a2c475b52657a430bd95070c7 5.8.1
|
||||
a043f08008051ca02ae87eb170cd066d8c8315a0 5.8.2
|
25
BUGS
25
BUGS
@ -20,31 +20,6 @@ Donald Allen reported this:
|
||||
|
||||
starting emacs from dmenu in archlinux results in missing configure of emacs, but mod1-space or mod1-shift-space fix this problem. this problem is new and did not happen in 1.6 xorg servers
|
||||
|
||||
Starting emacs from xterm doesnt show this problem, he uses tag 8 for emacs
|
||||
|
||||
---
|
||||
|
||||
2009/12/7 Alexandr Krylovskiy <wing_AT_tversu.ru>:
|
||||
> Fullscreen mode with flash applications (youtube, for example) doesn't
|
||||
> work properly neither in tiled nor in floating mode.
|
||||
> Fullscreen window closes immediately after opening.
|
||||
|
||||
This is a known bug (for some curiosity I received the same report via
|
||||
privmail from 2 other people within one week, really strange).
|
||||
The quick fix is commenting out the code in lines 817/818 in hg tip
|
||||
dwm. I cannot confirm this has no side effects (I think it does) and I
|
||||
will address this issue shortly with a real fix.
|
||||
|
||||
---
|
||||
|
||||
SDL seems to not like non-reparenting WMs:
|
||||
|
||||
> I would like to mention SDL problems, however SDL is not crucial to
|
||||
> me anymore; people that really care about it should speak up and
|
||||
> propose dwm / SDL patch or cooperation scheme in that matter.
|
||||
|
||||
Patching SDL, bugging them?
|
||||
|
||||
---
|
||||
|
||||
voltaic reports this:
|
||||
|
10
LICENSE
10
LICENSE
@ -1,16 +1,18 @@
|
||||
MIT/X Consortium License
|
||||
|
||||
© 2006-2011 Anselm R Garbe <anselm@garbe.us>
|
||||
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
© 2006-2014 Anselm R Garbe <anselm@garbe.us>
|
||||
© 2010-2014 Hiltjo Posthuma <hiltjo@codemadness.org>
|
||||
© 2007-2011 Peter Hartlich <sgkkr at hartlich dot com>
|
||||
© 2010-2011 Connor Lane Smith <cls@lubutu.com>
|
||||
© 2006-2009 Jukka Salmi <jukka at salmi dot ch>
|
||||
© 2007-2009 Premysl Hruby <dfenze at gmail dot com>
|
||||
© 2007-2009 Szabolcs Nagy <nszabolcs at gmail dot com>
|
||||
© 2007-2009 Christof Musik <christof at sendfax dot de>
|
||||
© 2009 Mate Nagy <mnagy at port70 dot net>
|
||||
© 2007-2008 Enno Gottox Boland <gottox at s01 dot de>
|
||||
© 2007-2008 Peter Hartlich <sgkkr at hartlich dot com>
|
||||
© 2008 Martin Hurton <martin dot hurton at gmail dot com>
|
||||
© 2008 Neale Pickett <neale dot woozle dot org>
|
||||
© 2009 Mate Nagy <mnagy at port70 dot net>
|
||||
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
|
6
Makefile
6
Makefile
@ -3,7 +3,7 @@
|
||||
|
||||
include config.mk
|
||||
|
||||
SRC = dwm.c
|
||||
SRC = drw.c dwm.c util.c
|
||||
OBJ = ${SRC:.c=.o}
|
||||
|
||||
all: options dwm
|
||||
@ -35,8 +35,8 @@ clean:
|
||||
dist: clean
|
||||
@echo creating dist tarball
|
||||
@mkdir -p dwm-${VERSION}
|
||||
@cp -R LICENSE Makefile README config.def.h config.mk \
|
||||
dwm.1 ${SRC} dwm-${VERSION}
|
||||
@cp -R LICENSE TODO BUGS Makefile README config.def.h config.mk \
|
||||
dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION}
|
||||
@tar -cf dwm-${VERSION}.tar dwm-${VERSION}
|
||||
@gzip dwm-${VERSION}.tar
|
||||
@rm -rf dwm-${VERSION}
|
||||
|
2
README
2
README
@ -40,7 +40,7 @@ like this in your .xinitrc:
|
||||
|
||||
while xsetroot -name "`date` `uptime | sed 's/.*,//'`"
|
||||
do
|
||||
sleep 20
|
||||
sleep 1
|
||||
done &
|
||||
exec dwm
|
||||
|
||||
|
2
TODO
2
TODO
@ -1,2 +1,4 @@
|
||||
- add a flag to Key to execute the command on release (needed for commands
|
||||
affecting the keyboard grab, see scrot -s for example)
|
||||
- add updategeom() hook for external tools like dzen
|
||||
- consider onscreenkeyboard hooks for tablet deployment
|
||||
|
41
config.def.h
41
config.def.h
@ -1,30 +1,38 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
/* appearance */
|
||||
static const char font[] = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*";
|
||||
static const char normbordercolor[] = "#cccccc";
|
||||
static const char normbgcolor[] = "#cccccc";
|
||||
static const char normfgcolor[] = "#000000";
|
||||
static const char selbordercolor[] = "#0066ff";
|
||||
static const char selbgcolor[] = "#0066ff";
|
||||
static const char selfgcolor[] = "#ffffff";
|
||||
static const char *fonts[] = {
|
||||
"monospace:size=10"
|
||||
};
|
||||
static const char dmenufont[] = "monospace:size=10";
|
||||
static const char normbordercolor[] = "#444444";
|
||||
static const char normbgcolor[] = "#222222";
|
||||
static const char normfgcolor[] = "#bbbbbb";
|
||||
static const char selbordercolor[] = "#005577";
|
||||
static const char selbgcolor[] = "#005577";
|
||||
static const char selfgcolor[] = "#eeeeee";
|
||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||
static const unsigned int snap = 32; /* snap pixel */
|
||||
static const Bool showbar = True; /* False means no bar */
|
||||
static const Bool topbar = True; /* False means bottom bar */
|
||||
static const int showbar = 1; /* 0 means no bar */
|
||||
static const int topbar = 1; /* 0 means bottom bar */
|
||||
|
||||
/* tagging */
|
||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
||||
static const Rule rules[] = {
|
||||
/* xprop(1):
|
||||
* WM_CLASS(STRING) = instance, class
|
||||
* WM_NAME(STRING) = title
|
||||
*/
|
||||
/* class instance title tags mask isfloating monitor */
|
||||
{ "Gimp", NULL, NULL, 0, True, -1 },
|
||||
{ "Firefox", NULL, NULL, 1 << 8, False, -1 },
|
||||
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
||||
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
||||
};
|
||||
|
||||
/* layout(s) */
|
||||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||
static const Bool resizehints = True; /* True means respect size hints in tiled resizals */
|
||||
static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
|
||||
static const int nmaster = 1; /* number of clients in master area */
|
||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||
|
||||
static const Layout layouts[] = {
|
||||
/* symbol arrange function */
|
||||
@ -45,8 +53,9 @@ static const Layout layouts[] = {
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
||||
/* commands */
|
||||
static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
|
||||
static const char *termcmd[] = { "uxterm", NULL };
|
||||
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
|
||||
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
|
||||
static const char *termcmd[] = { "st", NULL };
|
||||
|
||||
static Key keys[] = {
|
||||
/* modifier key function argument */
|
||||
@ -55,6 +64,8 @@ static Key keys[] = {
|
||||
{ MODKEY, XK_b, togglebar, {0} },
|
||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||
{ MODKEY, XK_Return, zoom, {0} },
|
||||
|
25
config.mk
25
config.mk
@ -1,5 +1,5 @@
|
||||
# dwm version
|
||||
VERSION = 5.9
|
||||
VERSION = 6.1
|
||||
|
||||
# Customize below to fit your system
|
||||
|
||||
@ -10,20 +10,25 @@ MANPREFIX = ${PREFIX}/share/man
|
||||
X11INC = /usr/X11R6/include
|
||||
X11LIB = /usr/X11R6/lib
|
||||
|
||||
# Xinerama
|
||||
XINERAMALIBS = -L${X11LIB} -lXinerama
|
||||
# Xinerama, comment if you don't want it
|
||||
XINERAMALIBS = -lXinerama
|
||||
XINERAMAFLAGS = -DXINERAMA
|
||||
|
||||
# freetype
|
||||
FREETYPELIBS = -lfontconfig -lXft
|
||||
FREETYPEINC = /usr/include/freetype2
|
||||
# OpenBSD (uncomment)
|
||||
#FREETYPEINC = ${X11INC}/freetype2
|
||||
|
||||
# includes and libs
|
||||
INCS = -I. -I/usr/include -I${X11INC}
|
||||
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 ${XINERAMALIBS}
|
||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
||||
|
||||
# flags
|
||||
CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
|
||||
#LDFLAGS = -g ${LIBS}
|
||||
LDFLAGS = -s ${LIBS}
|
||||
CPPFLAGS = -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
||||
LDFLAGS = -s ${LIBS}
|
||||
|
||||
# Solaris
|
||||
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
||||
|
398
drw.c
Normal file
398
drw.c
Normal file
@ -0,0 +1,398 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
#include "drw.h"
|
||||
#include "util.h"
|
||||
|
||||
#define UTF_INVALID 0xFFFD
|
||||
#define UTF_SIZ 4
|
||||
|
||||
static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
||||
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
||||
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
||||
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
||||
|
||||
static long
|
||||
utf8decodebyte(const char c, size_t *i)
|
||||
{
|
||||
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
|
||||
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
||||
return (unsigned char)c & ~utfmask[*i];
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t
|
||||
utf8validate(long *u, size_t i)
|
||||
{
|
||||
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
||||
*u = UTF_INVALID;
|
||||
for (i = 1; *u > utfmax[i]; ++i)
|
||||
;
|
||||
return i;
|
||||
}
|
||||
|
||||
static size_t
|
||||
utf8decode(const char *c, long *u, size_t clen)
|
||||
{
|
||||
size_t i, j, len, type;
|
||||
long udecoded;
|
||||
|
||||
*u = UTF_INVALID;
|
||||
if (!clen)
|
||||
return 0;
|
||||
udecoded = utf8decodebyte(c[0], &len);
|
||||
if (!BETWEEN(len, 1, UTF_SIZ))
|
||||
return 1;
|
||||
for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
|
||||
udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
|
||||
if (type)
|
||||
return j;
|
||||
}
|
||||
if (j < len)
|
||||
return 0;
|
||||
*u = udecoded;
|
||||
utf8validate(u, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
Drw *
|
||||
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
|
||||
{
|
||||
Drw *drw;
|
||||
|
||||
drw = ecalloc(1, sizeof(Drw));
|
||||
drw->dpy = dpy;
|
||||
drw->screen = screen;
|
||||
drw->root = root;
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||
drw->gc = XCreateGC(dpy, root, 0, NULL);
|
||||
drw->fontcount = 0;
|
||||
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
|
||||
return drw;
|
||||
}
|
||||
|
||||
void
|
||||
drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||
{
|
||||
drw->w = w;
|
||||
drw->h = h;
|
||||
if (drw->drawable)
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
|
||||
}
|
||||
|
||||
void
|
||||
drw_free(Drw *drw)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < drw->fontcount; i++)
|
||||
drw_font_free(drw->fonts[i]);
|
||||
XFreePixmap(drw->dpy, drw->drawable);
|
||||
XFreeGC(drw->dpy, drw->gc);
|
||||
free(drw);
|
||||
}
|
||||
|
||||
/* This function is an implementation detail. Library users should use
|
||||
* drw_font_create instead.
|
||||
*/
|
||||
static Fnt *
|
||||
drw_font_xcreate(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
||||
{
|
||||
Fnt *font;
|
||||
XftFont *xfont = NULL;
|
||||
FcPattern *pattern = NULL;
|
||||
|
||||
if (fontname) {
|
||||
/* Using the pattern found at font->xfont->pattern does not yield same
|
||||
* the same substitution results as using the pattern returned by
|
||||
* FcNameParse; using the latter results in the desired fallback
|
||||
* behaviour whereas the former just results in
|
||||
* missing-character-rectangles being drawn, at least with some fonts.
|
||||
*/
|
||||
if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
|
||||
fprintf(stderr, "error, cannot load font: '%s'\n", fontname);
|
||||
return NULL;
|
||||
}
|
||||
if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
|
||||
fprintf(stderr, "error, cannot load font: '%s'\n", fontname);
|
||||
XftFontClose(drw->dpy, xfont);
|
||||
return NULL;
|
||||
}
|
||||
} else if (fontpattern) {
|
||||
if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
|
||||
fprintf(stderr, "error, cannot load font pattern.\n");
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
die("no font specified.\n");
|
||||
}
|
||||
|
||||
font = ecalloc(1, sizeof(Fnt));
|
||||
font->xfont = xfont;
|
||||
font->pattern = pattern;
|
||||
font->ascent = xfont->ascent;
|
||||
font->descent = xfont->descent;
|
||||
font->h = font->ascent + font->descent;
|
||||
font->dpy = drw->dpy;
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
Fnt*
|
||||
drw_font_create(Drw *drw, const char *fontname)
|
||||
{
|
||||
return drw_font_xcreate(drw, fontname, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
drw_load_fonts(Drw* drw, const char *fonts[], size_t fontcount)
|
||||
{
|
||||
size_t i;
|
||||
Fnt *font;
|
||||
|
||||
for (i = 0; i < fontcount; i++) {
|
||||
if (drw->fontcount >= DRW_FONT_CACHE_SIZE) {
|
||||
die("font cache exhausted.\n");
|
||||
} else if ((font = drw_font_xcreate(drw, fonts[i], NULL))) {
|
||||
drw->fonts[drw->fontcount++] = font;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
drw_font_free(Fnt *font)
|
||||
{
|
||||
if (!font)
|
||||
return;
|
||||
if (font->pattern)
|
||||
FcPatternDestroy(font->pattern);
|
||||
XftFontClose(font->dpy, font->xfont);
|
||||
free(font);
|
||||
}
|
||||
|
||||
Clr *
|
||||
drw_clr_create(Drw *drw, const char *clrname)
|
||||
{
|
||||
Clr *clr;
|
||||
|
||||
clr = ecalloc(1, sizeof(Clr));
|
||||
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen),
|
||||
clrname, &clr->rgb))
|
||||
die("error, cannot allocate color '%s'\n", clrname);
|
||||
clr->pix = clr->rgb.pixel;
|
||||
|
||||
return clr;
|
||||
}
|
||||
|
||||
void
|
||||
drw_clr_free(Clr *clr)
|
||||
{
|
||||
free(clr);
|
||||
}
|
||||
|
||||
void
|
||||
drw_setscheme(Drw *drw, ClrScheme *scheme)
|
||||
{
|
||||
drw->scheme = scheme;
|
||||
}
|
||||
|
||||
void
|
||||
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int empty, int invert)
|
||||
{
|
||||
if (!drw->scheme)
|
||||
return;
|
||||
XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme->bg->pix : drw->scheme->fg->pix);
|
||||
if (filled)
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w + 1, h + 1);
|
||||
else if (empty)
|
||||
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
}
|
||||
|
||||
int
|
||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, const char *text, int invert)
|
||||
{
|
||||
char buf[1024];
|
||||
int tx, ty, th;
|
||||
Extnts tex;
|
||||
XftDraw *d = NULL;
|
||||
Fnt *curfont, *nextfont;
|
||||
size_t i, len;
|
||||
int utf8strlen, utf8charlen, render;
|
||||
long utf8codepoint = 0;
|
||||
const char *utf8str;
|
||||
FcCharSet *fccharset;
|
||||
FcPattern *fcpattern;
|
||||
FcPattern *match;
|
||||
XftResult result;
|
||||
int charexists = 0;
|
||||
|
||||
if (!drw->scheme || !drw->fontcount)
|
||||
return 0;
|
||||
|
||||
if (!(render = x || y || w || h)) {
|
||||
w = ~w;
|
||||
} else {
|
||||
XSetForeground(drw->dpy, drw->gc, invert ?
|
||||
drw->scheme->fg->pix : drw->scheme->bg->pix);
|
||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||
DefaultVisual(drw->dpy, drw->screen),
|
||||
DefaultColormap(drw->dpy, drw->screen));
|
||||
}
|
||||
|
||||
curfont = drw->fonts[0];
|
||||
while (1) {
|
||||
utf8strlen = 0;
|
||||
utf8str = text;
|
||||
nextfont = NULL;
|
||||
while (*text) {
|
||||
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
||||
for (i = 0; i < drw->fontcount; i++) {
|
||||
charexists = charexists || XftCharExists(drw->dpy, drw->fonts[i]->xfont, utf8codepoint);
|
||||
if (charexists) {
|
||||
if (drw->fonts[i] == curfont) {
|
||||
utf8strlen += utf8charlen;
|
||||
text += utf8charlen;
|
||||
} else {
|
||||
nextfont = drw->fonts[i];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!charexists || (nextfont && nextfont != curfont))
|
||||
break;
|
||||
else
|
||||
charexists = 0;
|
||||
}
|
||||
|
||||
if (utf8strlen) {
|
||||
drw_font_getexts(curfont, utf8str, utf8strlen, &tex);
|
||||
/* shorten text if necessary */
|
||||
for (len = MIN(utf8strlen, (sizeof buf) - 1); len && (tex.w > w - drw->fonts[0]->h || w < drw->fonts[0]->h); len--)
|
||||
drw_font_getexts(curfont, utf8str, len, &tex);
|
||||
|
||||
if (len) {
|
||||
memcpy(buf, utf8str, len);
|
||||
buf[len] = '\0';
|
||||
if (len < utf8strlen)
|
||||
for (i = len; i && i > len - 3; buf[--i] = '.');
|
||||
|
||||
if (render) {
|
||||
th = curfont->ascent + curfont->descent;
|
||||
ty = y + (h / 2) - (th / 2) + curfont->ascent;
|
||||
tx = x + (h / 2);
|
||||
XftDrawStringUtf8(d, invert ? &drw->scheme->bg->rgb : &drw->scheme->fg->rgb, curfont->xfont, tx, ty, (XftChar8 *)buf, len);
|
||||
}
|
||||
x += tex.w;
|
||||
w -= tex.w;
|
||||
}
|
||||
}
|
||||
|
||||
if (!*text) {
|
||||
break;
|
||||
} else if (nextfont) {
|
||||
charexists = 0;
|
||||
curfont = nextfont;
|
||||
} else {
|
||||
/* Regardless of whether or not a fallback font is found, the
|
||||
* character must be drawn.
|
||||
*/
|
||||
charexists = 1;
|
||||
|
||||
if (drw->fontcount >= DRW_FONT_CACHE_SIZE)
|
||||
continue;
|
||||
|
||||
fccharset = FcCharSetCreate();
|
||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||
|
||||
if (!drw->fonts[0]->pattern) {
|
||||
/* Refer to the comment in drw_font_xcreate for more
|
||||
* information. */
|
||||
die("the first font in the cache must be loaded from a font string.\n");
|
||||
}
|
||||
|
||||
fcpattern = FcPatternDuplicate(drw->fonts[0]->pattern);
|
||||
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
||||
|
||||
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
||||
FcDefaultSubstitute(fcpattern);
|
||||
match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result);
|
||||
|
||||
FcCharSetDestroy(fccharset);
|
||||
FcPatternDestroy(fcpattern);
|
||||
|
||||
if (match) {
|
||||
curfont = drw_font_xcreate(drw, NULL, match);
|
||||
if (curfont && XftCharExists(drw->dpy, curfont->xfont, utf8codepoint)) {
|
||||
drw->fonts[drw->fontcount++] = curfont;
|
||||
} else {
|
||||
drw_font_free(curfont);
|
||||
curfont = drw->fonts[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (d)
|
||||
XftDrawDestroy(d);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void
|
||||
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||
{
|
||||
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
||||
XSync(drw->dpy, False);
|
||||
}
|
||||
|
||||
void
|
||||
drw_font_getexts(Fnt *font, const char *text, unsigned int len, Extnts *tex)
|
||||
{
|
||||
XGlyphInfo ext;
|
||||
|
||||
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
||||
tex->h = font->h;
|
||||
tex->w = ext.xOff;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
drw_font_getexts_width(Fnt *font, const char *text, unsigned int len)
|
||||
{
|
||||
Extnts tex;
|
||||
|
||||
drw_font_getexts(font, text, len, &tex);
|
||||
|
||||
return tex.w;
|
||||
}
|
||||
|
||||
Cur *
|
||||
drw_cur_create(Drw *drw, int shape)
|
||||
{
|
||||
Cur *cur;
|
||||
|
||||
cur = ecalloc(1, sizeof(Cur));
|
||||
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
||||
|
||||
return cur;
|
||||
}
|
||||
|
||||
void
|
||||
drw_cur_free(Drw *drw, Cur *cursor)
|
||||
{
|
||||
if (!cursor)
|
||||
return;
|
||||
XFreeCursor(drw->dpy, cursor->cursor);
|
||||
free(cursor);
|
||||
}
|
74
drw.h
Normal file
74
drw.h
Normal file
@ -0,0 +1,74 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#define DRW_FONT_CACHE_SIZE 32
|
||||
|
||||
typedef struct {
|
||||
unsigned long pix;
|
||||
XftColor rgb;
|
||||
} Clr;
|
||||
|
||||
typedef struct {
|
||||
Cursor cursor;
|
||||
} Cur;
|
||||
|
||||
typedef struct {
|
||||
Display *dpy;
|
||||
int ascent;
|
||||
int descent;
|
||||
unsigned int h;
|
||||
XftFont *xfont;
|
||||
FcPattern *pattern;
|
||||
} Fnt;
|
||||
|
||||
typedef struct {
|
||||
Clr *fg;
|
||||
Clr *bg;
|
||||
Clr *border;
|
||||
} ClrScheme;
|
||||
|
||||
typedef struct {
|
||||
unsigned int w, h;
|
||||
Display *dpy;
|
||||
int screen;
|
||||
Window root;
|
||||
Drawable drawable;
|
||||
GC gc;
|
||||
ClrScheme *scheme;
|
||||
size_t fontcount;
|
||||
Fnt *fonts[DRW_FONT_CACHE_SIZE];
|
||||
} Drw;
|
||||
|
||||
typedef struct {
|
||||
unsigned int w;
|
||||
unsigned int h;
|
||||
} Extnts;
|
||||
|
||||
/* Drawable abstraction */
|
||||
Drw *drw_create(Display *, int, Window, unsigned int, unsigned int);
|
||||
void drw_resize(Drw *, unsigned int, unsigned int);
|
||||
void drw_free(Drw *);
|
||||
|
||||
/* Fnt abstraction */
|
||||
Fnt *drw_font_create(Drw *, const char *);
|
||||
void drw_load_fonts(Drw *, const char *[], size_t);
|
||||
void drw_font_free(Fnt *);
|
||||
void drw_font_getexts(Fnt *, const char *, unsigned int, Extnts *);
|
||||
unsigned int drw_font_getexts_width(Fnt *, const char *, unsigned int);
|
||||
|
||||
/* Colour abstraction */
|
||||
Clr *drw_clr_create(Drw *, const char *);
|
||||
void drw_clr_free(Clr *);
|
||||
|
||||
/* Cursor abstraction */
|
||||
Cur *drw_cur_create(Drw *, int);
|
||||
void drw_cur_free(Drw *, Cur *);
|
||||
|
||||
/* Drawing context manipulation */
|
||||
void drw_setfont(Drw *, Fnt *);
|
||||
void drw_setscheme(Drw *, ClrScheme *);
|
||||
|
||||
/* Drawing functions */
|
||||
void drw_rect(Drw *, int, int, unsigned int, unsigned int, int, int, int);
|
||||
int drw_text(Drw *, int, int, unsigned int, unsigned int, const char *, int);
|
||||
|
||||
/* Map functions */
|
||||
void drw_map(Drw *, Window, int, int, unsigned int, unsigned int);
|
15
dwm.1
15
dwm.1
@ -57,7 +57,7 @@ click on a tag label adds/removes that tag to/from the focused window.
|
||||
.TP
|
||||
.B Mod1\-Shift\-Return
|
||||
Start
|
||||
.BR uxterm (1).
|
||||
.BR st(1).
|
||||
.TP
|
||||
.B Mod1\-,
|
||||
Focus previous screen, if any.
|
||||
@ -92,12 +92,18 @@ Focus next window.
|
||||
.B Mod1\-k
|
||||
Focus previous window.
|
||||
.TP
|
||||
.B Mod1\-h
|
||||
Decrease master area size.
|
||||
.B Mod1\-i
|
||||
Increase clients in master area.
|
||||
.TP
|
||||
.B Mod1\-d
|
||||
Decrease clients in master area.
|
||||
.TP
|
||||
.B Mod1\-l
|
||||
Increase master area size.
|
||||
.TP
|
||||
.B Mod1\-h
|
||||
Decrease master area size.
|
||||
.TP
|
||||
.B Mod1\-Return
|
||||
Zooms/cycles focused window to/from master area (tiled layouts only).
|
||||
.TP
|
||||
@ -144,7 +150,8 @@ Resize focused window while dragging. Tiled windows will be toggled to the float
|
||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||
code. This keeps it fast, secure and simple.
|
||||
.SH SEE ALSO
|
||||
.BR dmenu (1)
|
||||
.BR dmenu (1),
|
||||
.BR st (1)
|
||||
.SH BUGS
|
||||
Java applications which use the XToolkit/XAWT backend may draw grey windows
|
||||
only. The XToolkit/XAWT backend breaks ICCCM-compliance in recent JDK 1.5 and early
|
||||
|
42
transient.c
Normal file
42
transient.c
Normal file
@ -0,0 +1,42 @@
|
||||
/* cc transient.c -o transient -lX11 */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
int main(void) {
|
||||
Display *d;
|
||||
Window r, f, t = None;
|
||||
XSizeHints h;
|
||||
XEvent e;
|
||||
|
||||
d = XOpenDisplay(NULL);
|
||||
if (!d)
|
||||
exit(1);
|
||||
r = DefaultRootWindow(d);
|
||||
|
||||
f = XCreateSimpleWindow(d, r, 100, 100, 400, 400, 0, 0, 0);
|
||||
h.min_width = h.max_width = h.min_height = h.max_height = 400;
|
||||
h.flags = PMinSize | PMaxSize;
|
||||
XSetWMNormalHints(d, f, &h);
|
||||
XStoreName(d, f, "floating");
|
||||
XMapWindow(d, f);
|
||||
|
||||
XSelectInput(d, f, ExposureMask);
|
||||
while (1) {
|
||||
XNextEvent(d, &e);
|
||||
|
||||
if (t == None) {
|
||||
sleep(5);
|
||||
t = XCreateSimpleWindow(d, r, 50, 50, 100, 100, 0, 0, 0);
|
||||
XSetTransientForHint(d, t, f);
|
||||
XStoreName(d, t, "transient");
|
||||
XMapWindow(d, t);
|
||||
XSelectInput(d, t, ExposureMask);
|
||||
}
|
||||
}
|
||||
|
||||
XCloseDisplay(d);
|
||||
exit(0);
|
||||
}
|
33
util.c
Normal file
33
util.c
Normal file
@ -0,0 +1,33 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
void *
|
||||
ecalloc(size_t nmemb, size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if (!(p = calloc(nmemb, size)))
|
||||
perror(NULL);
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
die(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
||||
fputc(' ', stderr);
|
||||
perror(NULL);
|
||||
}
|
||||
|
||||
exit(1);
|
||||
}
|
8
util.h
Normal file
8
util.h
Normal file
@ -0,0 +1,8 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
|
||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
||||
|
||||
void die(const char *errstr, ...);
|
||||
void *ecalloc(size_t, size_t);
|
Reference in New Issue
Block a user