Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1bae806fe5 | |||
| 2f76a5cc49 | |||
| ab2253a0ee | |||
| c23f9dfe2e | |||
| eda3495acf | |||
| 1448916be3 | |||
| f12825443e | |||
| c750f87edd | |||
|
|
a9aa0d8ffb | ||
|
|
85fe518c1a | ||
|
|
244fa852fe | ||
|
|
7c3abae4e6 | ||
|
|
93f26863d1 | ||
|
|
74edc27caa | ||
|
|
693d94d350 | ||
|
|
cfb8627a80 | ||
|
|
fcb2476b69 | ||
|
|
8933ebcf50 | ||
|
|
5687f46964 |
20
.gitignore
vendored
Normal file
20
.gitignore
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Ignore dotfiles by default
|
||||||
|
.*
|
||||||
|
|
||||||
|
# Ignore common (generated) file types
|
||||||
|
*.a
|
||||||
|
*.o
|
||||||
|
*.d
|
||||||
|
*.so
|
||||||
|
*.out
|
||||||
|
*.hex
|
||||||
|
*.gz
|
||||||
|
|
||||||
|
# Ignore specific project files
|
||||||
|
compile_commands.json
|
||||||
|
/bin/
|
||||||
|
/config.mk
|
||||||
|
|
||||||
|
# Unignore specific files.
|
||||||
|
!.gitignore
|
||||||
|
!.clang-format
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
MIT/X Consortium License
|
MIT/X Consortium License
|
||||||
|
|
||||||
|
© 2010-2026 Hiltjo Posthuma <hiltjo@codemadness.org>
|
||||||
© 2006-2019 Anselm R Garbe <anselm@garbe.ca>
|
© 2006-2019 Anselm R Garbe <anselm@garbe.ca>
|
||||||
© 2006-2009 Jukka Salmi <jukka at salmi dot ch>
|
© 2006-2009 Jukka Salmi <jukka at salmi dot ch>
|
||||||
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
© 2006-2007 Sander van Dijk <a dot h dot vandijk at gmail dot com>
|
||||||
@@ -11,7 +12,6 @@ MIT/X Consortium License
|
|||||||
© 2008 Martin Hurton <martin dot hurton at gmail dot com>
|
© 2008 Martin Hurton <martin dot hurton at gmail dot com>
|
||||||
© 2008 Neale Pickett <neale dot woozle dot org>
|
© 2008 Neale Pickett <neale dot woozle dot org>
|
||||||
© 2009 Mate Nagy <mnagy at port70 dot net>
|
© 2009 Mate Nagy <mnagy at port70 dot net>
|
||||||
© 2010-2016 Hiltjo Posthuma <hiltjo@codemadness.org>
|
|
||||||
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
|
© 2010-2012 Connor Lane Smith <cls@lubutu.com>
|
||||||
© 2011 Christoph Lohmann <20h@r-36.net>
|
© 2011 Christoph Lohmann <20h@r-36.net>
|
||||||
© 2015-2016 Quentin Rameau <quinq@fifth.space>
|
© 2015-2016 Quentin Rameau <quinq@fifth.space>
|
||||||
107
Makefile
107
Makefile
@@ -1,45 +1,92 @@
|
|||||||
# dwm - dynamic window manager
|
# dwm - dynamic window manager
|
||||||
# See LICENSE file for copyright and license details.
|
# See LICENSE file for copyright and license details.
|
||||||
|
|
||||||
include config.mk
|
-include config.mk
|
||||||
|
|
||||||
SRC = drw.c dwm.c util.c
|
VERSION = 6.7
|
||||||
OBJ = ${SRC:.c=.o}
|
|
||||||
|
|
||||||
all: dwm
|
INSTALL ?= install
|
||||||
|
GZIP ?= gzip
|
||||||
|
TAR ?= tar
|
||||||
|
|
||||||
.c.o:
|
CFLAGS := -Os $(CFLAGS) -g -std=gnu99\
|
||||||
${CC} -c ${CFLAGS} $<
|
-Wall -Wextra -Wpedantic -Wno-pointer-arith
|
||||||
|
CPPFLAGS := -DNDEBUG $(CPPFLAGS)\
|
||||||
|
-DVERSION=\"$(VERSION)\" -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700L -DXINERAMA
|
||||||
|
LDFLAGS := -flto $(LDFLAGS)
|
||||||
|
LDLIBS := $(LDLIBS) -lm
|
||||||
|
|
||||||
${OBJ}: config.h config.mk
|
# Use pkg-config to locate dependencies, and set the correct flags.
|
||||||
|
ifeq (,$(shell command -v pkg-config))
|
||||||
|
$(error Failed to locate pkg-config, please make sure it is installed or acessible through PATH.)
|
||||||
|
else
|
||||||
|
CPPFLAGS += $(shell pkg-config --cflags-only-I fontconfig freetype2 x11 xft xinerama)
|
||||||
|
LDFLAGS += $(shell pkg-config --libs-only-L fontconfig freetype2 x11 xft xinerama)
|
||||||
|
LDLIBS += $(shell pkg-config --libs-only-l fontconfig freetype2 x11 xft xinerama)
|
||||||
|
endif
|
||||||
|
|
||||||
config.h:
|
SRC := $(wildcard src/*.c)
|
||||||
cp config.def.h $@
|
OBJ := $(addsuffix .o,$(SRC))
|
||||||
|
DEP := $(addsuffix .d,$(SRC))
|
||||||
|
|
||||||
dwm: ${OBJ}
|
# Set Q to @ to silence commands being printed, unless --no-silent has been set
|
||||||
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
ifeq (0, $(words $(findstring --no-silent,$(MAKEFLAGS))))
|
||||||
|
Q=@
|
||||||
|
endif
|
||||||
|
|
||||||
clean:
|
msg = @printf '%-8s %s\n' "$(1)" "$(2)"
|
||||||
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
|
|
||||||
|
|
||||||
dist: clean
|
.PHONY:
|
||||||
mkdir -p dwm-${VERSION}
|
all: bin/dwm
|
||||||
cp -R LICENSE 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}
|
|
||||||
|
|
||||||
install: all
|
.PHONY:
|
||||||
mkdir -p ${DESTDIR}${PREFIX}/bin
|
install: $(DESTDIR)/bin/dwm $(DESTDIR)/share/man/man1/dwm.1.gz
|
||||||
cp -f dwm ${DESTDIR}${PREFIX}/bin
|
$(DESTDIR)/bin/%: bin/%
|
||||||
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
$(call msg,INSTALL,$@)
|
||||||
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
$(Q)$(INSTALL) -D -m0755 $< $@
|
||||||
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
|
||||||
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
|
||||||
|
|
||||||
|
$(DESTDIR)/share/man/%: man/%
|
||||||
|
$(call msg,INSTALL,$@)
|
||||||
|
$(Q)$(INSTALL) -D -m0644 $< $@
|
||||||
|
|
||||||
|
.PHONY:
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
|
$(Q)$(RM) $(DESTDIR)/bin/dwm\
|
||||||
${DESTDIR}${MANPREFIX}/man1/dwm.1
|
$(DESTDIR)/share/man/man1/dwm.1.gz
|
||||||
|
|
||||||
.PHONY: all clean dist install uninstall
|
.PHONY:
|
||||||
|
clean:
|
||||||
|
$(call msg,CLEAN,src/)
|
||||||
|
$(Q)$(RM) $(OBJ)
|
||||||
|
$(call msg,CLEAN,man/)
|
||||||
|
$(Q)$(RM) $(MAN)
|
||||||
|
$(call msg,CLEAN,bin/)
|
||||||
|
$(Q)$(RM) -r bin/
|
||||||
|
|
||||||
|
# Links together the object files into the final binary.
|
||||||
|
bin/dwm: $(OBJ) | bin/
|
||||||
|
$(call msg,LD,$@)
|
||||||
|
$(Q)$(CC) $(LDFLAGS) $(LDLIBS) -o $@ $^
|
||||||
|
|
||||||
|
# Compiles C sources into Object files
|
||||||
|
%.c.o: %.c
|
||||||
|
$(call msg,CC,$@)
|
||||||
|
$(Q)$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
|
# Compress files requested for compression using GZIP
|
||||||
|
%.gz: %
|
||||||
|
$(call msg,GZIP,$@)
|
||||||
|
$(Q)$(GZIP) -k $<
|
||||||
|
|
||||||
|
# Create directories
|
||||||
|
%/:
|
||||||
|
$(call msg-mkdir,$@)
|
||||||
|
$(Q)mkdir $@
|
||||||
|
|
||||||
|
# Generate and include dependencies,
|
||||||
|
# ignoring any errors that may occur when doing so.
|
||||||
|
%.c.d: %.c
|
||||||
|
$(Q)$(CC) -MM $(CPPFLAGS) -MF $@ $<
|
||||||
|
ifeq (0, $(words $(findstring $(MAKECMDGOALS), clean)))
|
||||||
|
-include $(DEP)
|
||||||
|
endif
|
||||||
|
|||||||
39
config.mk
39
config.mk
@@ -1,39 +0,0 @@
|
|||||||
# dwm version
|
|
||||||
VERSION = 6.5
|
|
||||||
|
|
||||||
# Customize below to fit your system
|
|
||||||
|
|
||||||
# paths
|
|
||||||
PREFIX = /usr/local
|
|
||||||
MANPREFIX = ${PREFIX}/share/man
|
|
||||||
|
|
||||||
X11INC = /usr/X11R6/include
|
|
||||||
X11LIB = /usr/X11R6/lib
|
|
||||||
|
|
||||||
# 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
|
|
||||||
#MANPREFIX = ${PREFIX}/man
|
|
||||||
|
|
||||||
# includes and libs
|
|
||||||
INCS = -I${X11INC} -I${FREETYPEINC}
|
|
||||||
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
|
|
||||||
|
|
||||||
# flags
|
|
||||||
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
|
|
||||||
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
|
|
||||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
|
|
||||||
LDFLAGS = ${LIBS}
|
|
||||||
|
|
||||||
# Solaris
|
|
||||||
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
|
|
||||||
#LDFLAGS = ${LIBS}
|
|
||||||
|
|
||||||
# compiler and linker
|
|
||||||
CC = cc
|
|
||||||
@@ -36,6 +36,7 @@ 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 nmaster = 1; /* number of clients in master area */
|
||||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||||
|
static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */
|
||||||
|
|
||||||
static const Layout layouts[] = {
|
static const Layout layouts[] = {
|
||||||
/* symbol arrange function */
|
/* symbol arrange function */
|
||||||
@@ -9,54 +9,40 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define UTF_INVALID 0xFFFD
|
#define UTF_INVALID 0xFFFD
|
||||||
#define UTF_SIZ 4
|
|
||||||
|
|
||||||
static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
static int
|
||||||
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
utf8decode(const char *s_in, long *u, int *err)
|
||||||
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))
|
static const unsigned char lens[] = {
|
||||||
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
/* 0XXXX */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
return (unsigned char)c & ~utfmask[*i];
|
/* 10XXX */ 0, 0, 0, 0, 0, 0, 0, 0, /* invalid */
|
||||||
return 0;
|
/* 110XX */ 2, 2, 2, 2,
|
||||||
}
|
/* 1110X */ 3, 3,
|
||||||
|
/* 11110 */ 4,
|
||||||
static size_t
|
/* 11111 */ 0, /* invalid */
|
||||||
utf8validate(long *u, size_t i)
|
};
|
||||||
{
|
static const unsigned char leading_mask[] = { 0x7F, 0x1F, 0x0F, 0x07 };
|
||||||
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
static const unsigned int overlong[] = { 0x0, 0x80, 0x0800, 0x10000 };
|
||||||
*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;
|
|
||||||
|
|
||||||
|
const unsigned char *s = (const unsigned char *)s_in;
|
||||||
|
int len = lens[*s >> 3];
|
||||||
*u = UTF_INVALID;
|
*u = UTF_INVALID;
|
||||||
if (!clen)
|
*err = 1;
|
||||||
return 0;
|
if (len == 0)
|
||||||
udecoded = utf8decodebyte(c[0], &len);
|
|
||||||
if (!BETWEEN(len, 1, UTF_SIZ))
|
|
||||||
return 1;
|
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);
|
|
||||||
|
|
||||||
|
long cp = s[0] & leading_mask[len - 1];
|
||||||
|
for (int i = 1; i < len; ++i) {
|
||||||
|
if (s[i] == '\0' || (s[i] & 0xC0) != 0x80)
|
||||||
|
return i;
|
||||||
|
cp = (cp << 6) | (s[i] & 0x3F);
|
||||||
|
}
|
||||||
|
/* out of range, surrogate, overlong encoding */
|
||||||
|
if (cp > 0x10FFFF || (cp >> 11) == 0x1B || cp < overlong[len - 1])
|
||||||
|
return len;
|
||||||
|
|
||||||
|
*err = 0;
|
||||||
|
*u = cp;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,8 +178,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
|||||||
die("error, cannot allocate color '%s'", clrname);
|
die("error, cannot allocate color '%s'", clrname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
/* Create color schemes. */
|
||||||
* returned color scheme when done using it. */
|
|
||||||
Clr *
|
Clr *
|
||||||
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||||
{
|
{
|
||||||
@@ -201,7 +186,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
|||||||
Clr *ret;
|
Clr *ret;
|
||||||
|
|
||||||
/* need at least two colors for a scheme */
|
/* need at least two colors for a scheme */
|
||||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(Clr))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < clrcount; i++)
|
for (i = 0; i < clrcount; i++)
|
||||||
@@ -209,6 +194,30 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_clr_free(Drw *drw, Clr *c)
|
||||||
|
{
|
||||||
|
if (!drw || !c)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* c is typedef XftColor Clr */
|
||||||
|
XftColorFree(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||||
|
DefaultColormap(drw->dpy, drw->screen), c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_scm_free(Drw *drw, Clr *scm, size_t clrcount)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!drw || !scm)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < clrcount; i++)
|
||||||
|
drw_clr_free(drw, &scm[i]);
|
||||||
|
free(scm);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_setfontset(Drw *drw, Fnt *set)
|
drw_setfontset(Drw *drw, Fnt *set)
|
||||||
{
|
{
|
||||||
@@ -238,11 +247,11 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int
|
|||||||
int
|
int
|
||||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
||||||
{
|
{
|
||||||
int i, ty, ellipsis_x = 0;
|
int ty, ellipsis_x = 0;
|
||||||
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
|
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len, hash, h0, h1;
|
||||||
XftDraw *d = NULL;
|
XftDraw *d = NULL;
|
||||||
Fnt *usedfont, *curfont, *nextfont;
|
Fnt *usedfont, *curfont, *nextfont;
|
||||||
int utf8strlen, utf8charlen, render = x || y || w || h;
|
int utf8strlen, utf8charlen, utf8err, render = x || y || w || h;
|
||||||
long utf8codepoint = 0;
|
long utf8codepoint = 0;
|
||||||
const char *utf8str;
|
const char *utf8str;
|
||||||
FcCharSet *fccharset;
|
FcCharSet *fccharset;
|
||||||
@@ -251,9 +260,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
XftResult result;
|
XftResult result;
|
||||||
int charexists = 0, overflow = 0;
|
int charexists = 0, overflow = 0;
|
||||||
/* keep track of a couple codepoints for which we have no match. */
|
/* keep track of a couple codepoints for which we have no match. */
|
||||||
enum { nomatches_len = 64 };
|
static unsigned int nomatches[128], ellipsis_width, invalid_width;
|
||||||
static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;
|
static const char invalid[] = "<EFBFBD>";
|
||||||
static unsigned int ellipsis_width = 0;
|
|
||||||
|
|
||||||
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -263,6 +271,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
} else {
|
} else {
|
||||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||||
|
if (w < lpad)
|
||||||
|
return x + w;
|
||||||
d = XftDrawCreate(drw->dpy, drw->drawable,
|
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||||
DefaultVisual(drw->dpy, drw->screen),
|
DefaultVisual(drw->dpy, drw->screen),
|
||||||
DefaultColormap(drw->dpy, drw->screen));
|
DefaultColormap(drw->dpy, drw->screen));
|
||||||
@@ -273,12 +283,14 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
usedfont = drw->fonts;
|
usedfont = drw->fonts;
|
||||||
if (!ellipsis_width && render)
|
if (!ellipsis_width && render)
|
||||||
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
||||||
|
if (!invalid_width && render)
|
||||||
|
invalid_width = drw_fontset_getwidth(drw, invalid);
|
||||||
while (1) {
|
while (1) {
|
||||||
ew = ellipsis_len = utf8strlen = 0;
|
ew = ellipsis_len = utf8err = utf8charlen = utf8strlen = 0;
|
||||||
utf8str = text;
|
utf8str = text;
|
||||||
nextfont = NULL;
|
nextfont = NULL;
|
||||||
while (*text) {
|
while (*text) {
|
||||||
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
utf8charlen = utf8decode(text, &utf8codepoint, &utf8err);
|
||||||
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||||
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||||
if (charexists) {
|
if (charexists) {
|
||||||
@@ -300,9 +312,9 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
else
|
else
|
||||||
utf8strlen = ellipsis_len;
|
utf8strlen = ellipsis_len;
|
||||||
} else if (curfont == usedfont) {
|
} else if (curfont == usedfont) {
|
||||||
utf8strlen += utf8charlen;
|
|
||||||
text += utf8charlen;
|
text += utf8charlen;
|
||||||
ew += tmpw;
|
utf8strlen += utf8err ? 0 : utf8charlen;
|
||||||
|
ew += utf8err ? 0 : tmpw;
|
||||||
} else {
|
} else {
|
||||||
nextfont = curfont;
|
nextfont = curfont;
|
||||||
}
|
}
|
||||||
@@ -310,7 +322,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overflow || !charexists || nextfont)
|
if (overflow || !charexists || nextfont || utf8err)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
charexists = 0;
|
charexists = 0;
|
||||||
@@ -325,6 +337,12 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
x += ew;
|
x += ew;
|
||||||
w -= ew;
|
w -= ew;
|
||||||
}
|
}
|
||||||
|
if (utf8err && (!render || invalid_width < w)) {
|
||||||
|
if (render)
|
||||||
|
drw_text(drw, x, y, w, h, 0, invalid, invert);
|
||||||
|
x += invalid_width;
|
||||||
|
w -= invalid_width;
|
||||||
|
}
|
||||||
if (render && overflow)
|
if (render && overflow)
|
||||||
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
||||||
|
|
||||||
@@ -338,11 +356,14 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
* character must be drawn. */
|
* character must be drawn. */
|
||||||
charexists = 1;
|
charexists = 1;
|
||||||
|
|
||||||
for (i = 0; i < nomatches_len; ++i) {
|
hash = (unsigned int)utf8codepoint;
|
||||||
/* avoid calling XftFontMatch if we know we won't find a match */
|
hash = ((hash >> 16) ^ hash) * 0x21F0AAAD;
|
||||||
if (utf8codepoint == nomatches.codepoint[i])
|
hash = ((hash >> 15) ^ hash) * 0xD35A2D97;
|
||||||
goto no_match;
|
h0 = ((hash >> 15) ^ hash) % LENGTH(nomatches);
|
||||||
}
|
h1 = (hash >> 17) % LENGTH(nomatches);
|
||||||
|
/* avoid expensive XftFontMatch call when we know we won't find a match */
|
||||||
|
if (nomatches[h0] == utf8codepoint || nomatches[h1] == utf8codepoint)
|
||||||
|
goto no_match;
|
||||||
|
|
||||||
fccharset = FcCharSetCreate();
|
fccharset = FcCharSetCreate();
|
||||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||||
@@ -371,7 +392,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
curfont->next = usedfont;
|
curfont->next = usedfont;
|
||||||
} else {
|
} else {
|
||||||
xfont_free(usedfont);
|
xfont_free(usedfont);
|
||||||
nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
|
nomatches[nomatches[h0] ? h1 : h0] = utf8codepoint;
|
||||||
no_match:
|
no_match:
|
||||||
usedfont = drw->fonts;
|
usedfont = drw->fonts;
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,9 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
|
|||||||
|
|
||||||
/* Colorscheme abstraction */
|
/* Colorscheme abstraction */
|
||||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||||
|
void drw_clr_free(Drw *drw, Clr *c);
|
||||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||||
|
void drw_scm_free(Drw *drw, Clr *scm, size_t clrcount);
|
||||||
|
|
||||||
/* Cursor abstraction */
|
/* Cursor abstraction */
|
||||||
Cur *drw_cur_create(Drw *drw, int shape);
|
Cur *drw_cur_create(Drw *drw, int shape);
|
||||||
@@ -50,7 +50,6 @@
|
|||||||
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
||||||
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
|
||||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||||
@@ -487,7 +486,7 @@ cleanup(void)
|
|||||||
for (i = 0; i < CurLast; i++)
|
for (i = 0; i < CurLast; i++)
|
||||||
drw_cur_free(drw, cursor[i]);
|
drw_cur_free(drw, cursor[i]);
|
||||||
for (i = 0; i < LENGTH(colors); i++)
|
for (i = 0; i < LENGTH(colors); i++)
|
||||||
free(scheme[i]);
|
drw_scm_free(drw, scheme[i], 3);
|
||||||
free(scheme);
|
free(scheme);
|
||||||
XDestroyWindow(dpy, wmcheckwin);
|
XDestroyWindow(dpy, wmcheckwin);
|
||||||
drw_free(drw);
|
drw_free(drw);
|
||||||
@@ -865,13 +864,14 @@ Atom
|
|||||||
getatomprop(Client *c, Atom prop)
|
getatomprop(Client *c, Atom prop)
|
||||||
{
|
{
|
||||||
int di;
|
int di;
|
||||||
unsigned long dl;
|
unsigned long nitems, dl;
|
||||||
unsigned char *p = NULL;
|
unsigned char *p = NULL;
|
||||||
Atom da, atom = None;
|
Atom da, atom = None;
|
||||||
|
|
||||||
if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
|
if (XGetWindowProperty(dpy, c->win, prop, 0L, sizeof atom, False, XA_ATOM,
|
||||||
&da, &di, &dl, &dl, &p) == Success && p) {
|
&da, &di, &nitems, &dl, &p) == Success && p) {
|
||||||
atom = *(Atom *)p;
|
if (nitems > 0)
|
||||||
|
atom = *(Atom *)p;
|
||||||
XFree(p);
|
XFree(p);
|
||||||
}
|
}
|
||||||
return atom;
|
return atom;
|
||||||
@@ -1172,7 +1172,7 @@ movemouse(const Arg *arg)
|
|||||||
handler[ev.type](&ev);
|
handler[ev.type](&ev);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
|
if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate))
|
||||||
continue;
|
continue;
|
||||||
lasttime = ev.xmotion.time;
|
lasttime = ev.xmotion.time;
|
||||||
|
|
||||||
@@ -1326,7 +1326,7 @@ resizemouse(const Arg *arg)
|
|||||||
handler[ev.type](&ev);
|
handler[ev.type](&ev);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
|
if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate))
|
||||||
continue;
|
continue;
|
||||||
lasttime = ev.xmotion.time;
|
lasttime = ev.xmotion.time;
|
||||||
|
|
||||||
@@ -1851,7 +1851,7 @@ updatebarpos(Monitor *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updateclientlist()
|
updateclientlist(void)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
|
/*
|
||||||
int main(void) {
|
int main(void) {
|
||||||
Display *d;
|
Display *d;
|
||||||
Window r, f, t = None;
|
Window r, f, t = None;
|
||||||
@@ -40,3 +41,4 @@ int main(void) {
|
|||||||
XCloseDisplay(d);
|
XCloseDisplay(d);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -10,17 +11,17 @@ void
|
|||||||
die(const char *fmt, ...)
|
die(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
int saved_errno;
|
||||||
|
|
||||||
|
saved_errno = errno;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
if (fmt[0] && fmt[strlen(fmt)-1] == ':')
|
||||||
fputc(' ', stderr);
|
fprintf(stderr, " %s", strerror(saved_errno));
|
||||||
perror(NULL);
|
fputc('\n', stderr);
|
||||||
} else {
|
|
||||||
fputc('\n', stderr);
|
|
||||||
}
|
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||||
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
||||||
|
#define LENGTH(X) (sizeof (X) / sizeof (X)[0])
|
||||||
|
|
||||||
void die(const char *fmt, ...);
|
void die(const char *fmt, ...);
|
||||||
void *ecalloc(size_t nmemb, size_t size);
|
void *ecalloc(size_t nmemb, size_t size);
|
||||||
Reference in New Issue
Block a user