mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Compare commits
28 Commits
OPENBSD_5_
...
v5.1
Author | SHA1 | Date | |
---|---|---|---|
601779351c | |||
5f79bace21 | |||
de5efc6a54 | |||
1603d18560 | |||
96ebac8b04 | |||
cbe46b651f | |||
901a75d3c6 | |||
58077c157b | |||
ce34d0066e | |||
7c7a5bdcdc | |||
54c1b90725 | |||
3c67ec8ccc | |||
b1d81b7eb6 | |||
513c35dca9 | |||
f067809af4 | |||
a90a0b5705 | |||
2bac9a6be9 | |||
9eaece0541 | |||
5bc15cdb58 | |||
10622cf40d | |||
a64855f9cc | |||
e6d9effa8d | |||
b11c12e99b | |||
c9a14a8f40 | |||
e0c9657773 | |||
f769df540d | |||
d90ab51111 | |||
50aff37f50 |
47
Makefile
47
Makefile
@ -1,24 +1,47 @@
|
||||
# $OpenBSD$
|
||||
|
||||
.include <bsd.xconf.mk>
|
||||
# cwm makefile for BSD make and GNU make
|
||||
# uses pkg-config, DESTDIR and PREFIX
|
||||
|
||||
PROG= cwm
|
||||
|
||||
PREFIX= /usr/local
|
||||
|
||||
SRCS= calmwm.c screen.c xmalloc.c client.c menu.c \
|
||||
search.c util.c xutil.c conf.c xevents.c group.c \
|
||||
kbfunc.c mousefunc.c font.c parse.y
|
||||
|
||||
CPPFLAGS+= -I${X11BASE}/include -I${X11BASE}/include/freetype2 -I${.CURDIR}
|
||||
OBJS= calmwm.o screen.o xmalloc.o client.o menu.o \
|
||||
search.o util.o xutil.o conf.o xevents.o group.o \
|
||||
kbfunc.o mousefunc.o font.o strlcpy.o strlcat.o y.tab.o \
|
||||
strtonum.o fgetln.o
|
||||
|
||||
CFLAGS+= -Wall
|
||||
CPPFLAGS+= `pkg-config --cflags fontconfig x11 xft xinerama xrandr`
|
||||
|
||||
LDADD+= -L${X11BASE}/lib -lXft -lXrender -lX11 -lxcb -lXau -lXdmcp \
|
||||
-lfontconfig -lexpat -lfreetype -lz -lXinerama -lXrandr -lXext
|
||||
CFLAGS= -Wall -O2 -g
|
||||
|
||||
MANDIR= ${X11BASE}/man/man
|
||||
MAN= cwm.1 cwmrc.5
|
||||
LDFLAGS+= `pkg-config --libs fontconfig x11 xft xinerama xrandr`
|
||||
|
||||
obj: _xenocara_obj
|
||||
MANPREFIX= ${PREFIX}/share/man
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
.include <bsd.xorg.mk>
|
||||
all: ${PROG}
|
||||
|
||||
clean:
|
||||
rm -rf ${OBJS} ${PROG} y.tab.c
|
||||
|
||||
y.tab.c: parse.y
|
||||
yacc parse.y
|
||||
|
||||
${PROG}: ${OBJS} y.tab.o
|
||||
${CC} ${OBJS} ${LDFLAGS} -o ${PROG}
|
||||
|
||||
.c.o:
|
||||
${CC} -c ${CFLAGS} ${CPPFLAGS} $<
|
||||
|
||||
install: ${PROG}
|
||||
install -d ${DESTDIR}${PREFIX}/bin ${DESTDIR}${MANPREFIX}/man1 ${DESTDIR}${MANPREFIX}/man5
|
||||
install -m 755 cwm ${DESTDIR}${PREFIX}/bin
|
||||
install -m 644 cwm.1 ${DESTDIR}${MANPREFIX}/man1
|
||||
install -m 644 cwmrc.5 ${DESTDIR}${MANPREFIX}/man5
|
||||
|
||||
release:
|
||||
VERSION=$$(git describe --tags | sed 's/^v//;s/-[^.]*$$//') && \
|
||||
git archive --prefix=cwm-$$VERSION/ -o cwm-$$VERSION.tar.gz HEAD
|
||||
|
24
README
Normal file
24
README
Normal file
@ -0,0 +1,24 @@
|
||||
This is a port of OpenBSD's excellent cwm[0] to Linux and other
|
||||
Unices.
|
||||
|
||||
cwm is a window manager for X11 which contains many features that
|
||||
concentrate on the efficiency and transparency of window
|
||||
management. cwm also aims to maintain the simplest and most
|
||||
pleasant aesthetic.
|
||||
|
||||
This port requires pkg-config, Xft, Xinerama and Xrandr. The included
|
||||
Makefile should work with both GNU make and BSD make.
|
||||
|
||||
This version actively tracks changes in the OpenBSD CVS repository.
|
||||
Releases are roughly coordinated.
|
||||
|
||||
The revision controlled version is at https://github.com/chneukirchen/cwm
|
||||
Releases can be found at http://chneukirchen.org/releases
|
||||
|
||||
ChangeLog:
|
||||
|
||||
2012-05-02: First public release 5.1 of portable cwm.
|
||||
|
||||
--Christian Neukirchen <chneukirchen@gmail.com>
|
||||
|
||||
[0]: http://www.openbsd.org/cgi-bin/cvsweb/xenocara/app/cwm/
|
12
calmwm.h
12
calmwm.h
@ -21,6 +21,18 @@
|
||||
#ifndef _CALMWM_H_
|
||||
#define _CALMWM_H_
|
||||
|
||||
/* ugly stuff */
|
||||
#ifndef TAILQ_END
|
||||
#define TAILQ_END(head) NULL
|
||||
#endif
|
||||
#ifndef __dead
|
||||
#define __dead
|
||||
#endif
|
||||
char *fgetln(FILE *, size_t *);
|
||||
long long strtonum(const char *, long long, long long, const char **);
|
||||
size_t strlcpy(char *, const char *, size_t);
|
||||
size_t strlcat(char *, const char *, size_t);
|
||||
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
106
fgetln.c
Normal file
106
fgetln.c
Normal file
@ -0,0 +1,106 @@
|
||||
/* $NetBSD: fgetln.c,v 1.9 2008/04/29 06:53:03 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_NBTOOL_CONFIG_H
|
||||
#include "nbtool_config.h"
|
||||
#endif
|
||||
|
||||
#if !HAVE_FGETLN
|
||||
#include <stdlib.h>
|
||||
#ifndef HAVE_NBTOOL_CONFIG_H
|
||||
/* These headers are required, but included from nbtool_config.h */
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
char *
|
||||
fgetln(FILE *fp, size_t *len)
|
||||
{
|
||||
static char *buf = NULL;
|
||||
static size_t bufsiz = 0;
|
||||
char *ptr;
|
||||
|
||||
|
||||
if (buf == NULL) {
|
||||
bufsiz = BUFSIZ;
|
||||
if ((buf = malloc(bufsiz)) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fgets(buf, bufsiz, fp) == NULL)
|
||||
return NULL;
|
||||
|
||||
*len = 0;
|
||||
while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
|
||||
size_t nbufsiz = bufsiz + BUFSIZ;
|
||||
char *nbuf = realloc(buf, nbufsiz);
|
||||
|
||||
if (nbuf == NULL) {
|
||||
int oerrno = errno;
|
||||
free(buf);
|
||||
errno = oerrno;
|
||||
buf = NULL;
|
||||
return NULL;
|
||||
} else
|
||||
buf = nbuf;
|
||||
|
||||
if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL) {
|
||||
buf[bufsiz] = '\0';
|
||||
*len = strlen(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
*len = bufsiz;
|
||||
bufsiz = nbufsiz;
|
||||
}
|
||||
|
||||
*len = (ptr - buf) + 1;
|
||||
return buf;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *p;
|
||||
size_t len;
|
||||
|
||||
while ((p = fgetln(stdin, &len)) != NULL) {
|
||||
(void)printf("%zu %s", len, p);
|
||||
free(p);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
1
kbfunc.c
1
kbfunc.c
@ -25,6 +25,7 @@
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <paths.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
61
strlcat.c
Normal file
61
strlcat.c
Normal file
@ -0,0 +1,61 @@
|
||||
/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* OPENBSD ORIGINAL: lib/libc/string/strlcat.c */
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Appends src to string dst of size siz (unlike strncat, siz is the
|
||||
* full size of dst, not space left). At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
|
||||
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
|
||||
* If retval >= siz, truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
strlcat(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
size_t n = siz;
|
||||
size_t dlen;
|
||||
|
||||
/* Find the end of dst and adjust bytes left but don't go past end */
|
||||
while (n-- != 0 && *d != '\0')
|
||||
d++;
|
||||
dlen = d - dst;
|
||||
n = siz - dlen;
|
||||
|
||||
if (n == 0)
|
||||
return(dlen + strlen(s));
|
||||
while (*s != '\0') {
|
||||
if (n != 1) {
|
||||
*d++ = *s;
|
||||
n--;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
*d = '\0';
|
||||
|
||||
return(dlen + (s - src)); /* count does not include NUL */
|
||||
}
|
||||
|
||||
#endif /* !HAVE_STRLCAT */
|
57
strlcpy.c
Normal file
57
strlcpy.c
Normal file
@ -0,0 +1,57 @@
|
||||
/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* OPENBSD ORIGINAL: lib/libc/string/strlcpy.c */
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Copy src to string dst of size siz. At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz == 0).
|
||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
strlcpy(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
size_t n = siz;
|
||||
|
||||
/* Copy as many bytes as will fit */
|
||||
if (n != 0 && --n != 0) {
|
||||
do {
|
||||
if ((*d++ = *s++) == 0)
|
||||
break;
|
||||
} while (--n != 0);
|
||||
}
|
||||
|
||||
/* Not enough room in dst, add NUL and traverse rest of src */
|
||||
if (n == 0) {
|
||||
if (siz != 0)
|
||||
*d = '\0'; /* NUL-terminate dst */
|
||||
while (*s++)
|
||||
;
|
||||
}
|
||||
|
||||
return(s - src - 1); /* count does not include NUL */
|
||||
}
|
||||
|
||||
#endif /* !HAVE_STRLCPY */
|
70
strtonum.c
Normal file
70
strtonum.c
Normal file
@ -0,0 +1,70 @@
|
||||
/* $OpenBSD: strtonum.c,v 1.6 2004/08/03 19:38:01 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Ted Unangst and Todd Miller
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* OPENBSD ORIGINAL: lib/libc/stdlib/strtonum.c */
|
||||
|
||||
#ifndef HAVE_STRTONUM
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define INVALID 1
|
||||
#define TOOSMALL 2
|
||||
#define TOOLARGE 3
|
||||
|
||||
long long
|
||||
strtonum(const char *numstr, long long minval, long long maxval,
|
||||
const char **errstrp)
|
||||
{
|
||||
long long ll = 0;
|
||||
char *ep;
|
||||
int error = 0;
|
||||
struct errval {
|
||||
const char *errstr;
|
||||
int err;
|
||||
} ev[4] = {
|
||||
{ NULL, 0 },
|
||||
{ "invalid", EINVAL },
|
||||
{ "too small", ERANGE },
|
||||
{ "too large", ERANGE },
|
||||
};
|
||||
|
||||
ev[0].err = errno;
|
||||
errno = 0;
|
||||
if (minval > maxval)
|
||||
error = INVALID;
|
||||
else {
|
||||
ll = strtoll(numstr, &ep, 10);
|
||||
if (numstr == ep || *ep != '\0')
|
||||
error = INVALID;
|
||||
else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval)
|
||||
error = TOOSMALL;
|
||||
else if ((ll == LLONG_MAX && errno == ERANGE) || ll > maxval)
|
||||
error = TOOLARGE;
|
||||
}
|
||||
if (errstrp != NULL)
|
||||
*errstrp = ev[error].errstr;
|
||||
errno = ev[error].err;
|
||||
if (error)
|
||||
ll = 0;
|
||||
|
||||
return (ll);
|
||||
}
|
||||
|
||||
#endif /* HAVE_STRTONUM */
|
Reference in New Issue
Block a user