23 Commits

Author SHA1 Message Date
jmc
964a1e73a7 Okan Demirmen sent me a diff to kill some silly Fa macros, then persuaded
me to clean this page up;

jasper and bernd gave oks for the Fa removal;
2007-06-29 21:10:37 +00:00
365aecd25e implement keyboard initiated movement of windows
enhanced version of diff originally from niallo@
man bits from niallo@
ok niallo@ japser@
2007-06-27 13:28:22 +00:00
a1d4169eb3 modify "exec" dialog so that it auto-completes based on executables in
_PATH_DEFPATH

add an "ssh-to" dialog which auto-completes based on contents of
 ~/.ssh/known_hosts (M-.)

testing and eyeballing by Simon Kuhnle <simonkuhnle at web.de>, todd@, pedro@
mk@ and David Cathcart <david at cathcart.cx>

ok todd@
2007-06-26 19:34:26 +00:00
80d08270b8 don't map hidden windows on re-start.
from aon@iki.fi
2007-06-08 16:29:19 +00:00
35887fbdf6 document the autogroup functionality.
with aon@iki.fi
2007-06-06 22:08:02 +00:00
c025dc9089 make it possible to cycle through the windows when non are selected.
(eg. when they're hidden, now you can cycle through them)

from aon@iki.fi
2007-06-05 19:03:20 +00:00
15fdb76df9 draw window borders when redrawing a window
from aon@iki.fi
2007-06-05 18:57:03 +00:00
9b04f2582b show hidden windows when they should (eg. when the pointer is warped to them)
from aon@iki.fi via bernd@
2007-05-29 22:38:44 +00:00
5a0f777c6f don't give borderless windows a border, when they're inactive
from aon@iki.fi via bernd@
2007-05-29 22:35:04 +00:00
04248d0ed3 add two missing closedir()'s
from Antti Nyknen <aon at iki.fi> via bernd@

ok pedro@
2007-05-28 21:11:39 +00:00
9006bbf20b convert globals from G_foo to Foo, as per TODO.
"looks good" pedro@, ok matthieu@
2007-05-28 18:34:27 +00:00
4a498a4c60 full screen sized windows
ok matthieu@
2007-05-27 09:23:12 +00:00
31356d9833 autoconf junk was zapped, so no need for HAVE_CONFIG_H 2007-05-22 22:14:42 +00:00
2742ebe21c remove useless #ifdef
ok pedro@
2007-05-22 17:59:17 +00:00
2b75f1ef96 remove bogus entry (shortcut for xlock) which has been taken care of (C-M-DEL)
ok pedro@
2007-05-22 17:38:51 +00:00
57da7d7cd8 we don't use this file on openbsd, so zap it.
ok matthieu@ pedro@
2007-05-21 19:24:46 +00:00
c3a569adfb fix optind
ok ray@
2007-05-21 07:53:11 +00:00
22329fd6f6 - new sentence, new line.
- use .Pp instead of just a newline
- no empty lines between sections.

ok jmc@ matthieu@
2007-05-10 21:28:23 +00:00
9d51a8cf84 - add a "-d" option, to specify the display cwm should be started on
- adjust argc/argv by optind
- add an ENVIRONMENT section to the manpage

ok matthieu@ ray@
2007-05-10 17:23:49 +00:00
8d60503290 Apply cwm-3-input_shift.diff from http://aon.iki.fi/cwm/. 2007-04-27 18:10:39 +00:00
890a32aa33 Apply cwm-3-exec.diff from http://aon.iki.fi/cwm/. Document the new
key binding.
2007-04-27 18:08:14 +00:00
fa515a82d0 Remove autoconf crap and other stuff we don't need. 2007-04-27 18:04:40 +00:00
d957b53c6f Simple Makefile to build cwm. 2007-04-27 18:01:38 +00:00
38 changed files with 964 additions and 15379 deletions

25
Makefile Normal file
View File

@ -0,0 +1,25 @@
# $OpenBSD$
.include <bsd.own.mk>
X11BASE?= /usr/X11R6
PROG= cwm
SRCS= calmwm.c draw.c screen.c xmalloc.c client.c grab.c search.c \
util.c xutil.c conf.c input.c xevents.c group.c geographic.c \
kbfunc.c cursor.c font.c
CPPFLAGS+= -I${X11BASE}/include -I${X11BASE}/include/freetype2
LDADD+= -L${X11BASE}/lib -lXft -lXrender -lX11 -lXau -lXdmcp \
-lfontconfig -lexpat -lfreetype -lz -lX11 -lXau -lXdmcp -lXext
MANDIR= ${X11BASE}/man/cat
CLEANFILES= cwm.cat1
obj: _xenocara_obj
.include <bsd.prog.mk>
.include <bsd.xorg.mk>

View File

@ -1,19 +0,0 @@
include $(top_srcdir)/Makefile.am.inc
CC = gcc
man_MANS = cwm.1
bin_PROGRAMS = cwm
cwm_DEPENDENCIES = @ERRO@ @LIBOBJS@
cwm_SOURCES = calmwm.c draw.c screen.c xmalloc.c client.c grab.c \
search.c util.c xutil.c conf.c input.c xevents.c \
group.c geographic.c kbfunc.c cursor.c font.c
cwm_LDADD = @ERRO@ @LIBOBJS@ $(XFT_LIBS)
AM_CFLAGS = -Wall -Icompat $(XFT_CFLAGS)
EXTRA_DIST = LICENSE README cwm.1 strlcpy.c err.c Makefile.am.inc \
compat/sys/queue.h compat/sys/tree.h hash.h calmwm.h \
headers.h strlcat.c

View File

@ -1,3 +0,0 @@
AUTOMAKE_OPTIONS = foreign no-dependencies
DISTCLEANFILES = *~

View File

@ -1,617 +0,0 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/Makefile.am.inc $(top_srcdir)/configure TODO \
acconfig.h config.guess config.sub install-sh missing \
strlcat.c strlcpy.c strsep.c
bin_PROGRAMS = cwm$(EXEEXT)
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_cwm_OBJECTS = calmwm.$(OBJEXT) draw.$(OBJEXT) screen.$(OBJEXT) \
xmalloc.$(OBJEXT) client.$(OBJEXT) grab.$(OBJEXT) \
search.$(OBJEXT) util.$(OBJEXT) xutil.$(OBJEXT) conf.$(OBJEXT) \
input.$(OBJEXT) xevents.$(OBJEXT) group.$(OBJEXT) \
geographic.$(OBJEXT) kbfunc.$(OBJEXT) cursor.$(OBJEXT) \
font.$(OBJEXT)
cwm_OBJECTS = $(am_cwm_OBJECTS)
am__DEPENDENCIES_1 =
DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
depcomp =
am__depfiles_maybe =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(cwm_SOURCES)
DIST_SOURCES = $(cwm_SOURCES)
man1dir = $(mandir)/man1
NROFF = nroff
MANS = $(man_MANS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = gcc
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ERRO = @ERRO@
EXEEXT = @EXEEXT@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
XFT_CFLAGS = @XFT_CFLAGS@
XFT_LIBS = @XFT_LIBS@
X_CFLAGS = @X_CFLAGS@
X_EXTRA_LIBS = @X_EXTRA_LIBS@
X_LIBS = @X_LIBS@
X_PRE_LIBS = @X_PRE_LIBS@
ac_ct_CC = @ac_ct_CC@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
AUTOMAKE_OPTIONS = foreign no-dependencies
DISTCLEANFILES = *~
man_MANS = cwm.1
cwm_DEPENDENCIES = @ERRO@ @LIBOBJS@
cwm_SOURCES = calmwm.c draw.c screen.c xmalloc.c client.c grab.c \
search.c util.c xutil.c conf.c input.c xevents.c \
group.c geographic.c kbfunc.c cursor.c font.c
cwm_LDADD = @ERRO@ @LIBOBJS@ $(XFT_LIBS)
AM_CFLAGS = -Wall -Icompat $(XFT_CFLAGS)
EXTRA_DIST = LICENSE README cwm.1 strlcpy.c err.c Makefile.am.inc \
compat/sys/queue.h compat/sys/tree.h hash.h calmwm.h \
headers.h strlcat.c
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
am--refresh:
@:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.am.inc $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
cd $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) $(top_srcdir)/acconfig.h
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
cwm$(EXEEXT): $(cwm_OBJECTS) $(cwm_DEPENDENCIES)
@rm -f cwm$(EXEEXT)
$(LINK) $(cwm_LDFLAGS) $(cwm_OBJECTS) $(cwm_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.c.o:
$(COMPILE) -c $<
.c.obj:
$(COMPILE) -c `$(CYGPATH_W) '$<'`
uninstall-info-am:
install-man1: $(man1_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man1dir)" || $(mkdir_p) "$(DESTDIR)$(man1dir)"
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
done
uninstall-man1:
@$(NORMAL_UNINSTALL)
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
$(mkdir_p) $(distdir)/compat/sys
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS) $(MANS) config.h
installdirs:
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-man
install-exec-am: install-binPROGRAMS
install-info: install-info-am
install-man: install-man1
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man
uninstall-man: uninstall-man1
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \
dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \
distclean-compile distclean-generic distclean-hdr \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-binPROGRAMS install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-man1 install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \
uninstall-info-am uninstall-man uninstall-man1
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

4
TODO
View File

@ -14,8 +14,6 @@
- ignoreq, always lower them. perhaps implement by lowering the entire - ignoreq, always lower them. perhaps implement by lowering the entire
queue on each XLower... queue on each XLower...
- kbd shortcut for xlock
- search window should try to stay inside of the screen boundaries. - search window should try to stay inside of the screen boundaries.
- geographical keyboard navigation (window switching) - geographical keyboard navigation (window switching)
@ -30,5 +28,3 @@
once before moving on. once before moving on.
- cache all the atoms somewhere. - cache all the atoms somewhere.
- convert globals from G_foo to Foo;

View File

@ -1,27 +0,0 @@
#undef u_int16_t
#undef u_int32_t
#undef u_int64_t
#undef u_int8_t
@BOTTOM@
/* Prototypes for missing functions */
#ifndef HAVE_STRLCPY
size_t strlcpy(char *, const char *, size_t);
#endif
#ifndef HAVE_STRLCAT
size_t strlcat(char *, const char *, size_t);
#endif
#ifndef HAVE_STRSEP
char *strsep(char **, const char *);
#endif /* HAVE_STRSEP */
#ifndef HAVE_ERR
void err(int, const char *, ...);
void warn(const char *, ...);
void errx(int , const char *, ...);
void warnx(const char *, ...);
#endif

949
aclocal.m4 vendored
View File

@ -1,949 +0,0 @@
# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
dnl also defines GSTUFF_PKG_ERRORS on error
AC_DEFUN(PKG_CHECK_MODULES, [
succeeded=no
if test -z "$PKG_CONFIG"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
fi
if test "$PKG_CONFIG" = "no" ; then
echo "*** The pkg-config script could not be found. Make sure it is"
echo "*** in your path, or set the PKG_CONFIG environment variable"
echo "*** to the full path to pkg-config."
echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
else
PKG_CONFIG_MIN_VERSION=0.9.0
if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
AC_MSG_CHECKING(for $2)
if $PKG_CONFIG --exists "$2" ; then
AC_MSG_RESULT(yes)
succeeded=yes
AC_MSG_CHECKING($1_CFLAGS)
$1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
AC_MSG_RESULT($$1_CFLAGS)
AC_MSG_CHECKING($1_LIBS)
$1_LIBS=`$PKG_CONFIG --libs "$2"`
AC_MSG_RESULT($$1_LIBS)
else
$1_CFLAGS=""
$1_LIBS=""
## If we have a custom action on failure, don't print errors, but
## do set a variable so people can do so.
$1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
ifelse([$4], ,echo $$1_PKG_ERRORS,)
fi
AC_SUBST($1_CFLAGS)
AC_SUBST($1_LIBS)
else
echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
echo "*** See http://www.freedesktop.org/software/pkgconfig"
fi
fi
if test $succeeded = yes; then
ifelse([$3], , :, [$3])
else
ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
fi
])
# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION so it can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.9.6])])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
# therefore $ac_aux_dir as well) can be either absolute or relative,
# depending on how configure is run. This is pretty annoying, since
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
# source directory, any form will work fine, but in subdirectories a
# relative path needs to be adjusted first.
#
# $ac_aux_dir/missing
# fails when called from a subdirectory if $ac_aux_dir is relative
# $top_srcdir/$ac_aux_dir/missing
# fails if $ac_aux_dir is absolute,
# fails when called from a subdirectory in a VPATH build with
# a relative $ac_aux_dir
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is `.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
# and then we would define $MISSING as
# MISSING="\${SHELL} $am_aux_dir/missing"
# This will work as long as MISSING is not called from configure, because
# unfortunately $(top_srcdir) has no meaning in configure.
# However there are other variables, like CC, which are often used in
# configure, and could therefore not use this "fixed" $ac_aux_dir.
#
# Another solution, used here, is to always expand $ac_aux_dir to an
# absolute PATH. The drawback is that using absolute paths prevent a
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 7
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])
AC_SUBST([$1_FALSE])
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "GCJ", or "OBJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
[$1], CXX, [depcc="$CXX" am_compiler_list=],
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output
# in D'.
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_$1_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh.
touch sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
case $depmode in
nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
none) break ;;
esac
# We check with `-c' and `-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this.
if depmode=$depmode \
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_$1_dependencies_compiler_type=none
fi
])
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
AM_CONDITIONAL([am__fastdep$1], [
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
])
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
])
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE(dependency-tracking,
[ --disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#serial 3
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[for mf in $CONFIG_FILES; do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named `Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# So let's grep whole file.
if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running `make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# When using ansi2knr, U may be empty or an underscore; expand it
U=`sed -n 's/^U = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
# AM_OUTPUT_DEPENDENCY_COMMANDS
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each `.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS.
AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 12
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
# The call with PACKAGE and VERSION arguments is the old style
# call (pre autoconf-2.50), which is being phased out. PACKAGE
# and VERSION should now be passed to AC_INIT and removed from
# the call to AM_INIT_AUTOMAKE.
# We support both call styles for the transition. After
# the next Automake release, Autoconf can make the AC_INIT
# arguments mandatory, and then we can depend on a new Autoconf
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.58])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
# test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" &&
test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
# test whether we have cygpath
if test -z "$CYGPATH_W"; then
if (cygpath --version) >/dev/null 2>/dev/null; then
CYGPATH_W='cygpath -w'
else
CYGPATH_W=echo
fi
fi
AC_SUBST([CYGPATH_W])
# Define the identity of the package.
dnl Distinguish between old-style and new-style calls.
m4_ifval([$2],
[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
AC_SUBST([PACKAGE], [$1])dnl
AC_SUBST([VERSION], [$2])],
[_AM_SET_OPTIONS([$1])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
_AM_IF_OPTION([no-define],,
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
AM_MISSING_PROG(AUTOCONF, autoconf)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
AM_MISSING_PROG(AUTOHEADER, autoheader)
AM_MISSING_PROG(MAKEINFO, makeinfo)
AM_PROG_INSTALL_SH
AM_PROG_INSTALL_STRIP
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
[_AM_PROG_TAR([v7])])])
_AM_IF_OPTION([no-dependencies],,
[AC_PROVIDE_IFELSE([AC_PROG_CC],
[_AM_DEPENDENCIES(CC)],
[define([AC_PROG_CC],
defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_AM_DEPENDENCIES(CXX)],
[define([AC_PROG_CXX],
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
])
])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
# loop where config.status creates the headers, so we can generate
# our stamp files there.
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
[# Compute $1's index in $config_headers.
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
$1 | $1:* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
install_sh=${install_sh-"$am_aux_dir/install-sh"}
AC_SUBST(install_sh)])
# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
# From Jim Meyering
# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
AC_DEFUN([AM_MAINTAINER_MODE],
[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
dnl maintainer-mode is disabled by default
AC_ARG_ENABLE(maintainer-mode,
[ --enable-maintainer-mode enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer],
USE_MAINTAINER_MODE=$enableval,
USE_MAINTAINER_MODE=no)
AC_MSG_RESULT([$USE_MAINTAINER_MODE])
AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes])
MAINT=$MAINTAINER_MODE_TRUE
AC_SUBST(MAINT)dnl
]
)
AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo done
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# We grep out `Entering directory' and `Leaving directory'
# messages which can occur if `w' ends up in MAKEFLAGS.
# In particular we don't look at `^make:' because GNU make might
# be invoked under some other name (usually "gmake"), in which
# case it prints its new name instead of `make'.
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
am__include=include
am__quote=
_am_result=GNU
fi
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
am__include=.include
am__quote="\""
_am_result=BSD
fi
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# AM_MISSING_PROG(NAME, PROGRAM)
# ------------------------------
AC_DEFUN([AM_MISSING_PROG],
[AC_REQUIRE([AM_MISSING_HAS_RUN])
$1=${$1-"${am_missing_run}$2"}
AC_SUBST($1)])
# AM_MISSING_HAS_RUN
# ------------------
# Define MISSING if not defined so far and test if it supports --run.
# If it does, set am_missing_run to use it, otherwise, to nothing.
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
# Use eval to expand $SHELL
if eval "$MISSING --run true"; then
am_missing_run="$MISSING --run "
else
am_missing_run=
AC_MSG_WARN([`missing' script is too old or missing])
fi
])
# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_MKDIR_P
# ---------------
# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
#
# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
# created by `make install' are always world readable, even if the
# installer happens to have an overly restrictive umask (e.g. 077).
# This was a mistake. There are at least two reasons why we must not
# use `-m 0755':
# - it causes special bits like SGID to be ignored,
# - it may be too restrictive (some setups expect 775 directories).
#
# Do not use -m 0755 and let people choose whatever they expect by
# setting umask.
#
# We cannot accept any implementation of `mkdir' that recognizes `-p'.
# Some implementations (such as Solaris 8's) are not thread-safe: if a
# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
# concurrently, both version can detect that a/ is missing, but only
# one can create it and the other will error out. Consequently we
# restrict ourselves to GNU make (using the --version option ensures
# this.)
AC_DEFUN([AM_PROG_MKDIR_P],
[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
# We used to keeping the `.' as first argument, in order to
# allow $(mkdir_p) to be used without argument. As in
# $(mkdir_p) $(somedir)
# where $(somedir) is conditionally defined. However this is wrong
# for two reasons:
# 1. if the package is installed by a user who cannot write `.'
# make install will fail,
# 2. the above comment should most certainly read
# $(mkdir_p) $(DESTDIR)$(somedir)
# so it does not work when $(somedir) is undefined and
# $(DESTDIR) is not.
# To support the latter case, we have to write
# test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
# so the `.' trick is pointless.
mkdir_p='mkdir -p --'
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because `.' already
# exists.
for d in ./-p ./--version;
do
test -d $d && rmdir $d
done
# $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
if test -f "$ac_aux_dir/mkinstalldirs"; then
mkdir_p='$(mkinstalldirs)'
else
mkdir_p='$(install_sh) -d'
fi
fi
AC_SUBST([mkdir_p])])
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# _AM_MANGLE_OPTION(NAME)
# -----------------------
AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# ------------------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
# _AM_SET_OPTIONS(OPTIONS)
# ----------------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
# -------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# AM_SANITY_CHECK
# ---------------
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftest.file
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftest.file`
fi
rm -f conftest.file
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "$[2]" = conftest.file
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
AC_MSG_RESULT(yes)])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor `install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in `make install-strip', and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using `strip' when the user
# run `make install-strip'. However `strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the `STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
fi
INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# _AM_PROG_TAR(FORMAT)
# --------------------
# Check how to create a tarball in format FORMAT.
# FORMAT should be one of `v7', `ustar', or `pax'.
#
# Substitute a variable $(am__tar) that is a command
# writing to stdout a FORMAT-tarball containing the directory
# $tardir.
# tardir=directory && $(am__tar) > result.tar
#
# Substitute a variable $(am__untar) that extract such
# a tarball read from stdin.
# $(am__untar) < result.tar
AC_DEFUN([_AM_PROG_TAR],
[# Always define AMTAR for backward compatibility.
AM_MISSING_PROG([AMTAR], [tar])
m4_if([$1], [v7],
[am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
[m4_case([$1], [ustar],, [pax],,
[m4_fatal([Unknown tar format])])
AC_MSG_CHECKING([how to create a $1 tar archive])
# Loop over all known methods to create a tar archive until one works.
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
# Do not fold the above two line into one, because Tru64 sh and
# Solaris sh will not grok spaces in the rhs of `-'.
for _am_tool in $_am_tools
do
case $_am_tool in
gnutar)
for _am_tar in tar gnutar gtar;
do
AM_RUN_LOG([$_am_tar --version]) && break
done
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
am__untar="$_am_tar -xf -"
;;
plaintar)
# Must skip GNU tar: if it does not support --format= it doesn't create
# ustar tarball either.
(tar --version) >/dev/null 2>&1 && continue
am__tar='tar chf - "$$tardir"'
am__tar_='tar chf - "$tardir"'
am__untar='tar xf -'
;;
pax)
am__tar='pax -L -x $1 -w "$$tardir"'
am__tar_='pax -L -x $1 -w "$tardir"'
am__untar='pax -r'
;;
cpio)
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
am__untar='cpio -i -H $1 -d'
;;
none)
am__tar=false
am__tar_=false
am__untar=false
;;
esac
# If the value was cached, stop now. We just wanted to have am__tar
# and am__untar set.
test -n "${am_cv_prog_tar_$1}" && break
# tar/untar a dummy directory, and stop if the command works
rm -rf conftest.dir
mkdir conftest.dir
echo GrepMe > conftest.dir/file
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
rm -rf conftest.dir
if test -s conftest.tar; then
AM_RUN_LOG([$am__untar <conftest.tar])
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
fi
done
rm -rf conftest.dir
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR

145
calmwm.c
View File

@ -10,24 +10,24 @@
#include "headers.h" #include "headers.h"
#include "calmwm.h" #include "calmwm.h"
Display *G_dpy; Display *X_Dpy;
XFontStruct *G_font; XFontStruct *X_Font;
Cursor G_cursor_move; Cursor Cursor_move;
Cursor G_cursor_resize; Cursor Cursor_resize;
Cursor G_cursor_select; Cursor Cursor_select;
Cursor G_cursor_default; Cursor Cursor_default;
Cursor G_cursor_question; Cursor Cursor_question;
struct screen_ctx_q G_screenq; struct screen_ctx_q Screenq;
struct screen_ctx *G_curscreen; struct screen_ctx *Curscreen;
u_int G_nscreens; u_int Nscreens;
struct client_ctx_q G_clientq; struct client_ctx_q Clientq;
int G_doshape, G_shape_ev; int Doshape, Shape_ev;
int G_starting; int Starting;
struct conf G_conf; struct conf Conf;
struct fontdesc *DefaultFont; struct fontdesc *DefaultFont;
char *DefaultFontName; char *DefaultFontName;
@ -55,10 +55,15 @@ main(int argc, char **argv)
int ch; int ch;
int conf_flags = 0; int conf_flags = 0;
char *display_name = NULL;
DefaultFontName = "sans-serif:pixelsize=14:bold"; DefaultFontName = "sans-serif:pixelsize=14:bold";
while ((ch = getopt(argc, argv, "sf:")) != -1) { while ((ch = getopt(argc, argv, "d:sf:")) != -1) {
switch (ch) { switch (ch) {
case 'd':
display_name = optarg;
break;
case 's': case 's':
conf_flags |= CONF_STICKY_GROUPS; conf_flags |= CONF_STICKY_GROUPS;
break; break;
@ -69,6 +74,8 @@ main(int argc, char **argv)
errx(1, "Unknown option '%c'", ch); errx(1, "Unknown option '%c'", ch);
} }
} }
argc -= optind;
argv += optind;
/* Ignore a few signals. */ /* Ignore a few signals. */
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
@ -79,12 +86,12 @@ main(int argc, char **argv)
group_init(); group_init();
G_starting = 1; Starting = 1;
conf_setup(&G_conf); conf_setup(&Conf);
G_conf.flags |= conf_flags; Conf.flags |= conf_flags;
client_setup(); client_setup();
x_setup(); x_setup(display_name);
G_starting = 0; Starting = 0;
xev_init(); xev_init();
XEV_QUICK(NULL, NULL, MapRequest, xev_handle_maprequest, NULL); XEV_QUICK(NULL, NULL, MapRequest, xev_handle_maprequest, NULL);
@ -108,45 +115,45 @@ main(int argc, char **argv)
} }
void void
x_setup(void) x_setup(char *display_name)
{ {
int i; int i;
struct screen_ctx *sc; struct screen_ctx *sc;
char *fontname; char *fontname;
TAILQ_INIT(&G_screenq); TAILQ_INIT(&Screenq);
if ((G_dpy = XOpenDisplay("")) == NULL) if ((X_Dpy = XOpenDisplay(display_name)) == NULL)
errx(1, "%s:%d XOpenDisplay()", __FILE__, __LINE__); errx(1, "%s:%d XOpenDisplay()", __FILE__, __LINE__);
XSetErrorHandler(x_errorhandler); XSetErrorHandler(x_errorhandler);
G_doshape = XShapeQueryExtension(G_dpy, &G_shape_ev, &i); Doshape = XShapeQueryExtension(X_Dpy, &Shape_ev, &i);
i = 0; i = 0;
while ((fontname = tryfonts[i++]) != NULL) { while ((fontname = tryfonts[i++]) != NULL) {
if ((G_font = XLoadQueryFont(G_dpy, fontname)) != NULL) if ((X_Font = XLoadQueryFont(X_Dpy, fontname)) != NULL)
break; break;
} }
if (fontname == NULL) if (fontname == NULL)
errx(1, "Couldn't load any fonts."); errx(1, "Couldn't load any fonts.");
G_nscreens = ScreenCount(G_dpy); Nscreens = ScreenCount(X_Dpy);
for (i = 0; i < (int)G_nscreens; i++) { for (i = 0; i < (int)Nscreens; i++) {
XMALLOC(sc, struct screen_ctx); XMALLOC(sc, struct screen_ctx);
x_setupscreen(sc, i); x_setupscreen(sc, i);
TAILQ_INSERT_TAIL(&G_screenq, sc, entry); TAILQ_INSERT_TAIL(&Screenq, sc, entry);
} }
G_cursor_move = XCreateFontCursor(G_dpy, XC_fleur); Cursor_move = XCreateFontCursor(X_Dpy, XC_fleur);
G_cursor_resize = XCreateFontCursor(G_dpy, XC_bottom_right_corner); Cursor_resize = XCreateFontCursor(X_Dpy, XC_bottom_right_corner);
/* (used to be) XCreateFontCursor(G_dpy, XC_hand1); */ /* (used to be) XCreateFontCursor(X_Dpy, XC_hand1); */
G_cursor_select = XCreateFontCursor(G_dpy, XC_hand1); Cursor_select = XCreateFontCursor(X_Dpy, XC_hand1);
/* G_cursor_select = cursor_bigarrow(G_curscreen); */ /* Cursor_select = cursor_bigarrow(Curscreen); */
G_cursor_default = XCreateFontCursor(G_dpy, XC_X_cursor); Cursor_default = XCreateFontCursor(X_Dpy, XC_X_cursor);
/* G_cursor_default = cursor_bigarrow(G_curscreen); */ /* Cursor_default = cursor_bigarrow(Curscreen); */
G_cursor_question = XCreateFontCursor(G_dpy, XC_question_arrow); Cursor_question = XCreateFontCursor(X_Dpy, XC_question_arrow);
} }
int int
@ -162,55 +169,55 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
sc->display = x_screenname(which); sc->display = x_screenname(which);
sc->which = which; sc->which = which;
sc->rootwin = RootWindow(G_dpy, which); sc->rootwin = RootWindow(X_Dpy, which);
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which), XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which),
"black", &sc->fgcolor, &tmp); "black", &sc->fgcolor, &tmp);
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which), XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which),
"#00cc00", &sc->bgcolor, &tmp); "#00cc00", &sc->bgcolor, &tmp);
XAllocNamedColor(G_dpy,DefaultColormap(G_dpy, which), XAllocNamedColor(X_Dpy,DefaultColormap(X_Dpy, which),
"blue", &sc->fccolor, &tmp); "blue", &sc->fccolor, &tmp);
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which), XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which),
"red", &sc->redcolor, &tmp); "red", &sc->redcolor, &tmp);
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which), XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which),
"#00ccc8", &sc->cyancolor, &tmp); "#00ccc8", &sc->cyancolor, &tmp);
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which), XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which),
"white", &sc->whitecolor, &tmp); "white", &sc->whitecolor, &tmp);
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which), XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which),
"black", &sc->blackcolor, &tmp); "black", &sc->blackcolor, &tmp);
TAILQ_FOREACH(kb, &G_conf.keybindingq, entry) TAILQ_FOREACH(kb, &Conf.keybindingq, entry)
xu_key_grab(sc->rootwin, kb->modmask, kb->keysym); xu_key_grab(sc->rootwin, kb->modmask, kb->keysym);
/* Special -- for alt state. */ /* Special -- for alt state. */
/* xu_key_grab(sc->rootwin, 0, XK_Alt_L); */ /* xu_key_grab(sc->rootwin, 0, XK_Alt_L); */
/* xu_key_grab(sc->rootwin, 0, XK_Alt_R); */ /* xu_key_grab(sc->rootwin, 0, XK_Alt_R); */
sc->blackpixl = BlackPixel(G_dpy, sc->which); sc->blackpixl = BlackPixel(X_Dpy, sc->which);
sc->whitepixl = WhitePixel(G_dpy, sc->which); sc->whitepixl = WhitePixel(X_Dpy, sc->which);
sc->bluepixl = sc->fccolor.pixel; sc->bluepixl = sc->fccolor.pixel;
sc->redpixl = sc->redcolor.pixel; sc->redpixl = sc->redcolor.pixel;
sc->cyanpixl = sc->cyancolor.pixel; sc->cyanpixl = sc->cyancolor.pixel;
sc->gray = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin, sc->gray = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin,
gray_bits, gray_width, gray_height, gray_bits, gray_width, gray_height,
sc->blackpixl, sc->whitepixl, DefaultDepth(G_dpy, sc->which)); sc->blackpixl, sc->whitepixl, DefaultDepth(X_Dpy, sc->which));
sc->blue = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin, sc->blue = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin,
gray_bits, gray_width, gray_height, gray_bits, gray_width, gray_height,
sc->bluepixl, sc->whitepixl, DefaultDepth(G_dpy, sc->which)); sc->bluepixl, sc->whitepixl, DefaultDepth(X_Dpy, sc->which));
sc->red = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin, sc->red = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin,
gray_bits, gray_width, gray_height, gray_bits, gray_width, gray_height,
sc->redpixl, sc->whitepixl, DefaultDepth(G_dpy, sc->which)); sc->redpixl, sc->whitepixl, DefaultDepth(X_Dpy, sc->which));
gv.foreground = sc->blackpixl^sc->whitepixl; gv.foreground = sc->blackpixl^sc->whitepixl;
gv.background = sc->whitepixl; gv.background = sc->whitepixl;
gv.function = GXxor; gv.function = GXxor;
gv.line_width = 1; gv.line_width = 1;
gv.subwindow_mode = IncludeInferiors; gv.subwindow_mode = IncludeInferiors;
gv.font = G_font->fid; gv.font = X_Font->fid;
sc->gc = XCreateGC(G_dpy, sc->rootwin, sc->gc = XCreateGC(X_Dpy, sc->rootwin,
GCForeground|GCBackground|GCFunction| GCForeground|GCBackground|GCFunction|
GCLineWidth|GCSubwindowMode|GCFont, &gv); GCLineWidth|GCSubwindowMode|GCFont, &gv);
@ -220,19 +227,19 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
gv2.function = GXxor; gv2.function = GXxor;
gv2.line_width = 1; gv2.line_width = 1;
gv2.subwindow_mode = IncludeInferiors; gv2.subwindow_mode = IncludeInferiors;
gv2.font = G_font->fid; gv2.font = X_Font->fid;
#endif #endif
sc->hlgc = XCreateGC(G_dpy, sc->rootwin, sc->hlgc = XCreateGC(X_Dpy, sc->rootwin,
GCForeground|GCBackground|GCFunction| GCForeground|GCBackground|GCFunction|
GCLineWidth|GCSubwindowMode|GCFont, &gv); GCLineWidth|GCSubwindowMode|GCFont, &gv);
gv1.function = GXinvert; gv1.function = GXinvert;
gv1.subwindow_mode = IncludeInferiors; gv1.subwindow_mode = IncludeInferiors;
gv1.line_width = 1; gv1.line_width = 1;
gv1.font = G_font->fid; gv1.font = X_Font->fid;
sc->invgc = XCreateGC(G_dpy, sc->rootwin, sc->invgc = XCreateGC(X_Dpy, sc->rootwin,
GCFunction|GCSubwindowMode|GCLineWidth|GCFont, &gv1); GCFunction|GCSubwindowMode|GCLineWidth|GCFont, &gv1);
font_init(sc); font_init(sc);
@ -249,21 +256,21 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
search_init(sc); search_init(sc);
/* Deal with existing clients. */ /* Deal with existing clients. */
XQueryTree(G_dpy, sc->rootwin, &w0, &w1, &wins, &nwins); XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins);
for (i = 0; i < nwins; i++) { for (i = 0; i < nwins; i++) {
XGetWindowAttributes(G_dpy, wins[i], &winattr); XGetWindowAttributes(X_Dpy, wins[i], &winattr);
if (winattr.override_redirect || if (winattr.override_redirect ||
winattr.map_state != IsViewable) { winattr.map_state != IsViewable) {
char *name; char *name;
XFetchName(G_dpy, wins[i], &name); XFetchName(X_Dpy, wins[i], &name);
continue; continue;
} }
client_new(wins[i], sc, winattr.map_state != IsUnmapped); client_new(wins[i], sc, winattr.map_state != IsUnmapped);
} }
XFree(wins); XFree(wins);
G_curscreen = sc; /* XXX */ Curscreen = sc; /* XXX */
screen_init(); screen_init();
screen_updatestackingorder(); screen_updatestackingorder();
@ -273,10 +280,10 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
/* Set the root cursor to a nice obnoxious arrow :-) */ /* Set the root cursor to a nice obnoxious arrow :-) */
/* rootattr.cursor = cursor_bigarrow(sc); */ /* rootattr.cursor = cursor_bigarrow(sc); */
XChangeWindowAttributes(G_dpy, sc->rootwin, XChangeWindowAttributes(X_Dpy, sc->rootwin,
/* CWCursor| */CWEventMask, &rootattr); /* CWCursor| */CWEventMask, &rootattr);
XSync(G_dpy, False); XSync(X_Dpy, False);
return (0); return (0);
} }
@ -291,7 +298,7 @@ x_screenname(int which)
errx(1, "Can't handle more than 9 screens. If you need it, " errx(1, "Can't handle more than 9 screens. If you need it, "
"tell <marius@monkey.org>. It's a trivial fix."); "tell <marius@monkey.org>. It's a trivial fix.");
dstr = xstrdup(DisplayString(G_dpy)); dstr = xstrdup(DisplayString(X_Dpy));
if ((cp = rindex(dstr, ':')) == NULL) if ((cp = rindex(dstr, ':')) == NULL)
return (NULL); return (NULL);
@ -314,16 +321,16 @@ x_errorhandler(Display *dpy, XErrorEvent *e)
{ {
char msg[80], number[80], req[80]; char msg[80], number[80], req[80];
XGetErrorText(G_dpy, e->error_code, msg, sizeof(msg)); XGetErrorText(X_Dpy, e->error_code, msg, sizeof(msg));
snprintf(number, sizeof(number), "%d", e->request_code); snprintf(number, sizeof(number), "%d", e->request_code);
XGetErrorDatabaseText(G_dpy, "XRequest", number, XGetErrorDatabaseText(X_Dpy, "XRequest", number,
"<unknown>", req, sizeof(req)); "<unknown>", req, sizeof(req));
warnx("%s(0x%x): %s", req, (u_int)e->resourceid, msg); warnx("%s(0x%x): %s", req, (u_int)e->resourceid, msg);
} }
#endif #endif
if (G_starting && if (Starting &&
e->error_code == BadAccess && e->error_code == BadAccess &&
e->request_code == X_GrabKey) e->request_code == X_GrabKey)
errx(1, "root window unavailable - perhaps another " errx(1, "root window unavailable - perhaps another "

View File

@ -192,7 +192,7 @@ TAILQ_HEAD(xevent_q, xevent);
enum kbtype { enum kbtype {
KB_DELETE, KB_NEWTERM0, KB_NEWTERM1, KB_HIDE, KB_DELETE, KB_NEWTERM0, KB_NEWTERM1, KB_HIDE,
KB_LOWER, KB_RAISE, KB_SEARCH, KB_CYCLE, KB_LABEL, KB_LOWER, KB_RAISE, KB_SEARCH, KB_CYCLE, KB_LABEL,
KB_GROUPSELECT, KB_VERTMAXIMIZE, KB_GROUPSELECT, KB_VERTMAXIMIZE, KB_MAXIMIZE,
/* Group numbers need to be in order. */ /* Group numbers need to be in order. */
KB_GROUP_1, KB_GROUP_2, KB_GROUP_3, KB_GROUP_4, KB_GROUP_5, KB_GROUP_1, KB_GROUP_2, KB_GROUP_3, KB_GROUP_4, KB_GROUP_5,
@ -204,6 +204,11 @@ enum kbtype {
KB__LAST KB__LAST
}; };
#define CWM_BIGMOVE 0x1000
enum directions {
CWM_UP=0, CWM_DOWN, CWM_LEFT, CWM_RIGHT,
};
#define KBFLAG_NEEDCLIENT 0x01 #define KBFLAG_NEEDCLIENT 0x01
#define KBFLAG_FINDCLIENT 0x02 #define KBFLAG_FINDCLIENT 0x02
@ -257,6 +262,7 @@ struct menu {
char print[MENU_MAXENTRY + 1]; char print[MENU_MAXENTRY + 1];
void *ctx; void *ctx;
short lasthit; short lasthit;
short dummy;
}; };
TAILQ_HEAD(menu_q, menu); TAILQ_HEAD(menu_q, menu);
@ -285,7 +291,7 @@ struct mwm_hints {
int input_keycodetrans(KeyCode, u_int, enum ctltype *, char *, int); int input_keycodetrans(KeyCode, u_int, enum ctltype *, char *, int);
int x_errorhandler(Display *, XErrorEvent *); int x_errorhandler(Display *, XErrorEvent *);
void x_setup(void); void x_setup(char *display_name);
char *x_screenname(int); char *x_screenname(int);
void x_loop(void); void x_loop(void);
int x_setupscreen(struct screen_ctx *, u_int); int x_setupscreen(struct screen_ctx *, u_int);
@ -320,7 +326,7 @@ u_long client_bg_pixel(struct client_ctx *);
Pixmap client_bg_pixmap(struct client_ctx *); Pixmap client_bg_pixmap(struct client_ctx *);
void client_map(struct client_ctx *cc); void client_map(struct client_ctx *cc);
void client_mtf(struct client_ctx *cc); void client_mtf(struct client_ctx *cc);
struct client_ctx *client_cyclenext(struct client_ctx *cc, int reverse); struct client_ctx *client_cyclenext(int reverse);
void client_cycleinfo(struct client_ctx *cc); void client_cycleinfo(struct client_ctx *cc);
void client_altrelease(); void client_altrelease();
struct client_ctx *client_mrunext(struct client_ctx *cc); struct client_ctx *client_mrunext(struct client_ctx *cc);
@ -378,6 +384,7 @@ int grab_drag(struct client_ctx *);
void grab_menuinit(struct screen_ctx *); void grab_menuinit(struct screen_ctx *);
void *grab_menu(XButtonEvent *, struct menu_q *); void *grab_menu(XButtonEvent *, struct menu_q *);
void grab_label(struct client_ctx *); void grab_label(struct client_ctx *);
void grab_exec(void);
void xfree(void *); void xfree(void *);
void *xmalloc(size_t); void *xmalloc(size_t);
@ -424,7 +431,10 @@ void kbfunc_client_prevgroup(struct client_ctx *, void *);
void kbfunc_client_nogroup(struct client_ctx *, void *); void kbfunc_client_nogroup(struct client_ctx *, void *);
void kbfunc_client_maximize(struct client_ctx *, void *); void kbfunc_client_maximize(struct client_ctx *, void *);
void kbfunc_client_vmaximize(struct client_ctx *, void *); void kbfunc_client_vmaximize(struct client_ctx *, void *);
void kbfunc_client_move(struct client_ctx *, void *);
void kbfunc_menu_search(struct client_ctx *, void *); void kbfunc_menu_search(struct client_ctx *, void *);
void kbfunc_exec(struct client_ctx *, void *);
void kbfunc_ssh(struct client_ctx *, void *);
void kbfunc_term(struct client_ctx *cc, void *arg); void kbfunc_term(struct client_ctx *cc, void *arg);
void kbfunc_lock(struct client_ctx *cc, void *arg); void kbfunc_lock(struct client_ctx *cc, void *arg);
@ -435,10 +445,11 @@ struct menu *search_start(struct menu_q *menuq,
void (*match)(struct menu_q *, struct menu_q *, char *), void (*match)(struct menu_q *, struct menu_q *, char *),
void (*rank)(struct menu_q *, char *), void (*rank)(struct menu_q *, char *),
void (*print)(struct menu *mi, int), void (*print)(struct menu *mi, int),
char *); char *, int);
void search_match_client(struct menu_q *, struct menu_q *, char *); void search_match_client(struct menu_q *, struct menu_q *, char *);
void search_print_client(struct menu *mi, int list); void search_print_client(struct menu *mi, int list);
void search_match_text(struct menu_q *, struct menu_q *, char *); void search_match_text(struct menu_q *, struct menu_q *, char *);
void search_match_exec(struct menu_q *, struct menu_q *, char *);
void search_rank_text(struct menu_q *, char *); void search_rank_text(struct menu_q *, char *);
void group_init(void); void group_init(void);
@ -482,25 +493,25 @@ struct fontdesc *font_getx(struct screen_ctx *sc, const char *name);
/* Externs */ /* Externs */
extern Display *G_dpy; extern Display *X_Dpy;
extern XFontStruct *G_font; extern XFontStruct *X_Font;
extern Cursor G_cursor_move; extern Cursor Cursor_move;
extern Cursor G_cursor_resize; extern Cursor Cursor_resize;
extern Cursor G_cursor_select; extern Cursor Cursor_select;
extern Cursor G_cursor_default; extern Cursor Cursor_default;
extern Cursor G_cursor_question; extern Cursor Cursor_question;
extern struct screen_ctx_q G_screenq; extern struct screen_ctx_q Screenq;
extern struct screen_ctx *G_curscreen; extern struct screen_ctx *curscreen;
extern u_int G_nscreens; extern u_int Nscreens;
extern struct client_ctx_q G_clientq; extern struct client_ctx_q Clientq;
extern int G_doshape, G_shape_ev; extern int Doshape, Shape_ev;
extern struct conf G_conf; extern struct conf Conf;
extern int G_groupmode; extern int Groupmode;
extern struct fontdesc *DefaultFont; extern struct fontdesc *DefaultFont;

164
client.c
View File

@ -21,7 +21,7 @@ struct client_ctx *_curcc = NULL;
void void
client_setup(void) client_setup(void)
{ {
TAILQ_INIT(&G_clientq); TAILQ_INIT(&Clientq);
} }
struct client_ctx * struct client_ctx *
@ -29,7 +29,7 @@ client_find(Window win)
{ {
struct client_ctx *cc; struct client_ctx *cc;
TAILQ_FOREACH(cc, &G_clientq, entry) TAILQ_FOREACH(cc, &Clientq, entry)
if (cc->pwin == win || cc->win == win) if (cc->pwin == win || cc->win == win)
return (cc); return (cc);
@ -51,7 +51,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
XCALLOC(cc, struct client_ctx); XCALLOC(cc, struct client_ctx);
XGrabServer(G_dpy); XGrabServer(X_Dpy);
cc->state = mapped ? NormalState : IconicState; cc->state = mapped ? NormalState : IconicState;
cc->sc = sc; cc->sc = sc;
@ -70,8 +70,8 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
*/ */
conf_client(cc); conf_client(cc);
XGetWMNormalHints(G_dpy, cc->win, cc->size, &tmp); XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp);
XGetWindowAttributes(G_dpy, cc->win, &wattr); XGetWindowAttributes(X_Dpy, cc->win, &wattr);
if (cc->size->flags & PBaseSize) { if (cc->size->flags & PBaseSize) {
cc->geom.min_dx = cc->size->base_width; cc->geom.min_dx = cc->size->base_width;
@ -96,7 +96,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
if (wattr.map_state != IsViewable) { if (wattr.map_state != IsViewable) {
client_placecalc(cc); client_placecalc(cc);
if ((wmhints = XGetWMHints(G_dpy, cc->win)) != NULL) { if ((wmhints = XGetWMHints(X_Dpy, cc->win)) != NULL) {
if (wmhints->flags & StateHint) if (wmhints->flags & StateHint)
xu_setstate(cc, wmhints->initial_state); xu_setstate(cc, wmhints->initial_state);
@ -107,7 +107,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
if (xu_getstate(cc, &state) < 0) if (xu_getstate(cc, &state) < 0)
state = NormalState; state = NormalState;
XSelectInput(G_dpy, cc->win, XSelectInput(X_Dpy, cc->win,
ColormapChangeMask|EnterWindowMask|PropertyChangeMask|KeyReleaseMask); ColormapChangeMask|EnterWindowMask|PropertyChangeMask|KeyReleaseMask);
x = cc->geom.x - cc->bwidth; x = cc->geom.x - cc->bwidth;
@ -129,24 +129,24 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
/* pxattr.background_pixel = sc->whitepix; */ /* pxattr.background_pixel = sc->whitepix; */
/* cc->pwin = XCreateSimpleWindow(G_dpy, sc->rootwin, */ /* cc->pwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, */
/* x, y, width, height, 1, sc->blackpix, sc->whitepix); */ /* x, y, width, height, 1, sc->blackpix, sc->whitepix); */
cc->pwin = XCreateWindow(G_dpy, sc->rootwin, x, y, cc->pwin = XCreateWindow(X_Dpy, sc->rootwin, x, y,
width, height, 0, /* XXX */ width, height, 0, /* XXX */
DefaultDepth(G_dpy, sc->which), CopyFromParent, DefaultDepth(X_Dpy, sc->which), CopyFromParent,
DefaultVisual(G_dpy, sc->which), DefaultVisual(X_Dpy, sc->which),
CWOverrideRedirect | CWBackPixel | CWEventMask, &pxattr); CWOverrideRedirect | CWBackPixel | CWEventMask, &pxattr);
if (G_doshape) { if (Doshape) {
XRectangle *r; XRectangle *r;
int n, tmp; int n, tmp;
XShapeSelectInput(G_dpy, cc->win, ShapeNotifyMask); XShapeSelectInput(X_Dpy, cc->win, ShapeNotifyMask);
r = XShapeGetRectangles(G_dpy, cc->win, ShapeBounding, &n, &tmp); r = XShapeGetRectangles(X_Dpy, cc->win, ShapeBounding, &n, &tmp);
if (n > 1) if (n > 1)
XShapeCombineShape(G_dpy, cc->pwin, ShapeBounding, XShapeCombineShape(X_Dpy, cc->pwin, ShapeBounding,
0, 0, /* XXX border */ 0, 0, /* XXX border */
cc->win, ShapeBounding, ShapeSet); cc->win, ShapeBounding, ShapeSet);
XFree(r); XFree(r);
@ -155,28 +155,33 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
cc->active = 0; cc->active = 0;
client_draw_border(cc); client_draw_border(cc);
XAddToSaveSet(G_dpy, cc->win); XAddToSaveSet(X_Dpy, cc->win);
XSetWindowBorderWidth(G_dpy, cc->win, 0); XSetWindowBorderWidth(X_Dpy, cc->win, 0);
XReparentWindow(G_dpy, cc->win, cc->pwin, cc->bwidth, cc->bwidth); XReparentWindow(X_Dpy, cc->win, cc->pwin, cc->bwidth, cc->bwidth);
/* Notify client of its configuration. */ /* Notify client of its configuration. */
xev_reconfig(cc); xev_reconfig(cc);
XMapRaised(G_dpy, cc->pwin); if (state == IconicState)
XMapWindow(G_dpy, cc->win); client_hide(cc);
else {
XMapRaised(X_Dpy, cc->pwin);
XMapWindow(X_Dpy, cc->win);
}
xu_setstate(cc, cc->state); xu_setstate(cc, cc->state);
XSync(G_dpy, False); XSync(X_Dpy, False);
XUngrabServer(G_dpy); XUngrabServer(X_Dpy);
TAILQ_INSERT_TAIL(&sc->mruq, cc, mru_entry); TAILQ_INSERT_TAIL(&sc->mruq, cc, mru_entry);
TAILQ_INSERT_TAIL(&G_clientq, cc, entry); TAILQ_INSERT_TAIL(&Clientq, cc, entry);
client_gethints(cc); client_gethints(cc);
client_update(cc); client_update(cc);
if (mapped) { if (mapped) {
if (G_conf.flags & CONF_STICKY_GROUPS) if (Conf.flags & CONF_STICKY_GROUPS)
group_sticky(cc); group_sticky(cc);
else else
group_autogroup(cc); group_autogroup(cc);
@ -195,25 +200,25 @@ client_delete(struct client_ctx *cc, int sendevent, int ignorewindow)
return (1); return (1);
group_client_delete(cc); group_client_delete(cc);
XGrabServer(G_dpy); XGrabServer(X_Dpy);
xu_setstate(cc, WithdrawnState); xu_setstate(cc, WithdrawnState);
XRemoveFromSaveSet(G_dpy, cc->win); XRemoveFromSaveSet(X_Dpy, cc->win);
if (!ignorewindow) { if (!ignorewindow) {
client_gravitate(cc, 0); client_gravitate(cc, 0);
XSetWindowBorderWidth(G_dpy, cc->win, 1); /* XXX */ XSetWindowBorderWidth(X_Dpy, cc->win, 1); /* XXX */
XReparentWindow(G_dpy, cc->win, XReparentWindow(X_Dpy, cc->win,
sc->rootwin, cc->geom.x, cc->geom.y); sc->rootwin, cc->geom.x, cc->geom.y);
} }
if (cc->pwin) if (cc->pwin)
XDestroyWindow(G_dpy, cc->pwin); XDestroyWindow(X_Dpy, cc->pwin);
XSync(G_dpy, False); XSync(X_Dpy, False);
XUngrabServer(G_dpy); XUngrabServer(X_Dpy);
TAILQ_REMOVE(&sc->mruq, cc, mru_entry); TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
TAILQ_REMOVE(&G_clientq, cc, entry); TAILQ_REMOVE(&Clientq, cc, entry);
if (_curcc == cc) if (_curcc == cc)
_curcc = NULL; _curcc = NULL;
@ -273,8 +278,8 @@ client_setactive(struct client_ctx *cc, int fg)
sc = CCTOSC(cc); sc = CCTOSC(cc);
if (fg) { if (fg) {
XInstallColormap(G_dpy, cc->cmap); XInstallColormap(X_Dpy, cc->cmap);
XSetInputFocus(G_dpy, cc->win, XSetInputFocus(X_Dpy, cc->win,
RevertToPointerRoot, CurrentTime); RevertToPointerRoot, CurrentTime);
xu_btn_grab(cc->pwin, Mod1Mask, AnyButton); xu_btn_grab(cc->pwin, Mod1Mask, AnyButton);
xu_btn_grab(cc->pwin, ControlMask|Mod1Mask, Button1); xu_btn_grab(cc->pwin, ControlMask|Mod1Mask, Button1);
@ -334,7 +339,7 @@ client_maximize(struct client_ctx *cc)
XWindowAttributes rootwin_geom; XWindowAttributes rootwin_geom;
struct screen_ctx *sc = CCTOSC(cc); struct screen_ctx *sc = CCTOSC(cc);
XGetWindowAttributes(G_dpy, sc->rootwin, &rootwin_geom); XGetWindowAttributes(X_Dpy, sc->rootwin, &rootwin_geom);
cc->savegeom = cc->geom; cc->savegeom = cc->geom;
cc->geom.x = 0; cc->geom.x = 0;
cc->geom.y = 0; cc->geom.y = 0;
@ -362,10 +367,10 @@ client_restore_geometry(struct client_ctx *cc)
void void
client_resize(struct client_ctx *cc) client_resize(struct client_ctx *cc)
{ {
XMoveResizeWindow(G_dpy, cc->pwin, cc->geom.x - cc->bwidth, XMoveResizeWindow(X_Dpy, cc->pwin, cc->geom.x - cc->bwidth,
cc->geom.y - cc->bwidth, cc->geom.width + cc->bwidth*2, cc->geom.y - cc->bwidth, cc->geom.width + cc->bwidth*2,
cc->geom.height + cc->bwidth*2); cc->geom.height + cc->bwidth*2);
XMoveResizeWindow(G_dpy, cc->win, cc->bwidth, cc->bwidth, XMoveResizeWindow(X_Dpy, cc->win, cc->bwidth, cc->bwidth,
cc->geom.width, cc->geom.height); cc->geom.width, cc->geom.height);
xev_reconfig(cc); xev_reconfig(cc);
client_draw_border(cc); client_draw_border(cc);
@ -374,7 +379,7 @@ client_resize(struct client_ctx *cc)
void void
client_move(struct client_ctx *cc) client_move(struct client_ctx *cc)
{ {
XMoveWindow(G_dpy, cc->pwin, XMoveWindow(X_Dpy, cc->pwin,
cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth); cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth);
xev_reconfig(cc); xev_reconfig(cc);
} }
@ -382,13 +387,13 @@ client_move(struct client_ctx *cc)
void void
client_lower(struct client_ctx *cc) client_lower(struct client_ctx *cc)
{ {
XLowerWindow(G_dpy, cc->pwin); XLowerWindow(X_Dpy, cc->pwin);
} }
void void
client_raise(struct client_ctx *cc) client_raise(struct client_ctx *cc)
{ {
XRaiseWindow(G_dpy, cc->pwin); XRaiseWindow(X_Dpy, cc->pwin);
client_draw_border(cc); client_draw_border(cc);
} }
@ -409,7 +414,11 @@ client_ptrwarp(struct client_ctx *cc)
y = cc->geom.height / 2; y = cc->geom.height / 2;
} }
client_raise(cc); if (cc->state == IconicState)
client_unhide(cc);
else
client_raise(cc);
xu_ptr_setpos(cc->pwin, x, y); xu_ptr_setpos(cc->pwin, x, y);
} }
@ -429,8 +438,8 @@ void
client_hide(struct client_ctx *cc) client_hide(struct client_ctx *cc)
{ {
/* XXX - add wm_state stuff */ /* XXX - add wm_state stuff */
XUnmapWindow(G_dpy, cc->pwin); XUnmapWindow(X_Dpy, cc->pwin);
XUnmapWindow(G_dpy, cc->win); XUnmapWindow(X_Dpy, cc->win);
cc->active = 0; cc->active = 0;
cc->flags |= CLIENT_HIDDEN; cc->flags |= CLIENT_HIDDEN;
@ -443,8 +452,8 @@ client_hide(struct client_ctx *cc)
void void
client_unhide(struct client_ctx *cc) client_unhide(struct client_ctx *cc)
{ {
XMapWindow(G_dpy, cc->win); XMapWindow(X_Dpy, cc->win);
XMapRaised(G_dpy, cc->pwin); XMapRaised(X_Dpy, cc->pwin);
cc->flags &= ~CLIENT_HIDDEN; cc->flags &= ~CLIENT_HIDDEN;
xu_setstate(cc, NormalState); xu_setstate(cc, NormalState);
@ -456,21 +465,19 @@ client_draw_border(struct client_ctx *cc)
struct screen_ctx *sc = CCTOSC(cc); struct screen_ctx *sc = CCTOSC(cc);
if (cc->active) { if (cc->active) {
XSetWindowBackground(G_dpy, cc->pwin, client_bg_pixel(cc)); XSetWindowBackground(X_Dpy, cc->pwin, client_bg_pixel(cc));
XClearWindow(G_dpy, cc->pwin); XClearWindow(X_Dpy, cc->pwin);
if (!cc->highlight && cc->bwidth > 1) if (!cc->highlight && cc->bwidth > 1)
XDrawRectangle(G_dpy, cc->pwin, sc->gc, 1, 1, XDrawRectangle(X_Dpy, cc->pwin, sc->gc, 1, 1,
cc->geom.width + cc->bwidth, cc->geom.width + cc->bwidth,
cc->geom.height + cc->bwidth); cc->geom.height + cc->bwidth);
} else { } else {
XSetWindowBackgroundPixmap(G_dpy, cc->pwin,
client_bg_pixmap(cc));
if (cc->bwidth > 1) if (cc->bwidth > 1)
XSetWindowBackgroundPixmap(G_dpy, XSetWindowBackgroundPixmap(X_Dpy,
cc->pwin, client_bg_pixmap(cc)); cc->pwin, client_bg_pixmap(cc));
XClearWindow(G_dpy, cc->pwin); XClearWindow(X_Dpy, cc->pwin);
} }
} }
@ -524,9 +531,9 @@ client_update(struct client_ctx *cc)
long n; long n;
/* XXX cache these. */ /* XXX cache these. */
wm_delete = XInternAtom(G_dpy, "WM_DELETE_WINDOW", False); wm_delete = XInternAtom(X_Dpy, "WM_DELETE_WINDOW", False);
wm_protocols = XInternAtom(G_dpy, "WM_PROTOCOLS", False); wm_protocols = XInternAtom(X_Dpy, "WM_PROTOCOLS", False);
wm_take_focus = XInternAtom(G_dpy, "WM_TAKE_FOCUS", False); wm_take_focus = XInternAtom(X_Dpy, "WM_TAKE_FOCUS", False);
if ((n = xu_getprop(cc, wm_protocols, if ((n = xu_getprop(cc, wm_protocols,
XA_ATOM, 20L, (u_char **)&p)) <= 0) XA_ATOM, 20L, (u_char **)&p)) <= 0)
@ -547,13 +554,13 @@ client_send_delete(struct client_ctx *cc)
Atom wm_delete, wm_protocols; Atom wm_delete, wm_protocols;
/* XXX - cache */ /* XXX - cache */
wm_delete = XInternAtom(G_dpy, "WM_DELETE_WINDOW", False); wm_delete = XInternAtom(X_Dpy, "WM_DELETE_WINDOW", False);
wm_protocols = XInternAtom(G_dpy, "WM_PROTOCOLS", False); wm_protocols = XInternAtom(X_Dpy, "WM_PROTOCOLS", False);
if (cc->xproto & CLIENT_PROTO_DELETE) if (cc->xproto & CLIENT_PROTO_DELETE)
xu_sendmsg(cc, wm_protocols, wm_delete); xu_sendmsg(cc, wm_protocols, wm_delete);
else else
XKillClient(G_dpy, cc->win); XKillClient(X_Dpy, cc->win);
} }
void void
@ -562,7 +569,7 @@ client_setname(struct client_ctx *cc)
char *newname; char *newname;
struct winname *wn; struct winname *wn;
XFetchName(G_dpy, cc->win, &newname); XFetchName(X_Dpy, cc->win, &newname);
if (newname == NULL) if (newname == NULL)
newname = emptystring; newname = emptystring;
@ -602,14 +609,23 @@ match:
*/ */
struct client_ctx * struct client_ctx *
client_cyclenext(struct client_ctx *cc, int reverse) client_cyclenext(int reverse)
{ {
struct screen_ctx *sc = CCTOSC(cc); struct screen_ctx *sc;
struct client_ctx *cc;
struct client_ctx *(*iter)(struct client_ctx *) = struct client_ctx *(*iter)(struct client_ctx *) =
reverse ? &client_mruprev : &client_mrunext; reverse ? &client_mruprev : &client_mrunext;
/* TODO: maybe this should just be a CIRCLEQ. */ /* TODO: maybe this should just be a CIRCLEQ. */
if (!(cc = _curcc)) {
if (TAILQ_EMPTY(&Clientq))
return(NULL);
cc = TAILQ_FIRST(&Clientq);
}
sc = CCTOSC(cc);
/* if altheld; then reset the iterator to the beginning */ /* if altheld; then reset the iterator to the beginning */
if (!sc->altpersist || sc->cycle_client == NULL) if (!sc->altpersist || sc->cycle_client == NULL)
sc->cycle_client = TAILQ_FIRST(&sc->mruq); sc->cycle_client = TAILQ_FIRST(&sc->mruq);
@ -689,10 +705,10 @@ client_cycleinfo(struct client_ctx *cc)
if ((diff = cc->geom.height - (y + h)) < 0) if ((diff = cc->geom.height - (y + h)) < 0)
y += diff; y += diff;
XReparentWindow(G_dpy, sc->infowin, cc->win, 0, 0); XReparentWindow(X_Dpy, sc->infowin, cc->win, 0, 0);
XMoveResizeWindow(G_dpy, sc->infowin, x, y, w, h); XMoveResizeWindow(X_Dpy, sc->infowin, x, y, w, h);
XMapRaised(G_dpy, sc->infowin); XMapRaised(X_Dpy, sc->infowin);
XClearWindow(G_dpy, sc->infowin); XClearWindow(X_Dpy, sc->infowin);
for (i = 0, n = 0; i < sizeof(list)/sizeof(list[0]); i++) { for (i = 0, n = 0; i < sizeof(list)/sizeof(list[0]); i++) {
if ((ccc = list[i]) == NULL) if ((ccc = list[i]) == NULL)
@ -707,7 +723,7 @@ client_cycleinfo(struct client_ctx *cc)
assert(curn != -1); assert(curn != -1);
/* Highlight the current entry. */ /* Highlight the current entry. */
XFillRectangle(G_dpy, sc->infowin, sc->hlgc, 0, curn*oneh, w, oneh); XFillRectangle(X_Dpy, sc->infowin, sc->hlgc, 0, curn*oneh, w, oneh);
} }
struct client_ctx * struct client_ctx *
@ -754,8 +770,8 @@ client_altrelease()
return; return;
sc = CCTOSC(cc); sc = CCTOSC(cc);
XUnmapWindow(G_dpy, sc->infowin); XUnmapWindow(X_Dpy, sc->infowin);
XReparentWindow(G_dpy, sc->infowin, sc->rootwin, 0, 0); XReparentWindow(X_Dpy, sc->infowin, sc->rootwin, 0, 0);
} }
void void
@ -771,8 +787,8 @@ client_placecalc(struct client_ctx *cc)
height = cc->geom.height; height = cc->geom.height;
width = cc->geom.width; width = cc->geom.width;
ymax = DisplayHeight(G_dpy, sc->which) - cc->bwidth; ymax = DisplayHeight(X_Dpy, sc->which) - cc->bwidth;
xmax = DisplayWidth(G_dpy, sc->which) - cc->bwidth; xmax = DisplayWidth(X_Dpy, sc->which) - cc->bwidth;
yslack = ymax - cc->geom.height; yslack = ymax - cc->geom.height;
xslack = xmax - cc->geom.width; xslack = xmax - cc->geom.width;
@ -827,7 +843,7 @@ client_vertmaximize(struct client_ctx *cc)
cc->geom = cc->savegeom; cc->geom = cc->savegeom;
} else { } else {
struct screen_ctx *sc = CCTOSC(cc); struct screen_ctx *sc = CCTOSC(cc);
int display_height = DisplayHeight(G_dpy, sc->which) - int display_height = DisplayHeight(X_Dpy, sc->which) -
cc->bwidth*2; cc->bwidth*2;
cc->savegeom = cc->geom; cc->savegeom = cc->geom;
@ -876,21 +892,21 @@ client_gethints(struct client_ctx *cc)
Atom mha; Atom mha;
struct mwm_hints *mwmh; struct mwm_hints *mwmh;
if (XGetClassHint(G_dpy, cc->win, &xch)) { if (XGetClassHint(X_Dpy, cc->win, &xch)) {
if (xch.res_name != NULL) if (xch.res_name != NULL)
cc->app_name = xch.res_name; cc->app_name = xch.res_name;
if (xch.res_class != NULL) if (xch.res_class != NULL)
cc->app_class = xch.res_class; cc->app_class = xch.res_class;
} }
mha = XInternAtom(G_dpy, "_MOTIF_WM_HINTS", False); mha = XInternAtom(X_Dpy, "_MOTIF_WM_HINTS", False);
if (xu_getprop(cc, mha, mha, PROP_MWM_HINTS_ELEMENTS, if (xu_getprop(cc, mha, mha, PROP_MWM_HINTS_ELEMENTS,
(u_char **)&mwmh) == MWM_NUMHINTS) (u_char **)&mwmh) == MWM_NUMHINTS)
if (mwmh->flags & MWM_HINTS_DECORATIONS && if (mwmh->flags & MWM_HINTS_DECORATIONS &&
!(mwmh->decorations & MWM_DECOR_ALL) && !(mwmh->decorations & MWM_DECOR_ALL) &&
!(mwmh->decorations & MWM_DECOR_BORDER)) !(mwmh->decorations & MWM_DECOR_BORDER))
cc->bwidth = 0; cc->bwidth = 0;
if (XGetCommand(G_dpy, cc->win, &argv, &argc)) { if (XGetCommand(X_Dpy, cc->win, &argv, &argc)) {
#define MAX_ARGLEN 512 #define MAX_ARGLEN 512
#define ARG_SEP_ " " #define ARG_SEP_ " "
int len = MAX_ARGLEN; int len = MAX_ARGLEN;

View File

@ -1,508 +0,0 @@
/* $OpenBSD$ */
/* $NetBSD: queue.h,v 1.11 1996/05/16 05:17:14 mycroft Exp $ */
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* 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.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
* @(#)queue.h 8.5 (Berkeley) 8/20/94
*/
#ifndef _SYS_QUEUE_H_
#define _SYS_QUEUE_H_
/*
* This file defines five types of data structures: singly-linked lists,
* lists, simple queues, tail queues, and circular queues.
*
*
* A singly-linked list is headed by a single forward pointer. The elements
* are singly linked for minimum space and pointer manipulation overhead at
* the expense of O(n) removal for arbitrary elements. New elements can be
* added to the list after an existing element or at the head of the list.
* Elements being removed from the head of the list should use the explicit
* macro for this purpose for optimum efficiency. A singly-linked list may
* only be traversed in the forward direction. Singly-linked lists are ideal
* for applications with large datasets and few or no removals or for
* implementing a LIFO queue.
*
* A list is headed by a single forward pointer (or an array of forward
* pointers for a hash table header). The elements are doubly linked
* so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before
* or after an existing element or at the head of the list. A list
* may only be traversed in the forward direction.
*
* A simple queue is headed by a pair of pointers, one the head of the
* list and the other to the tail of the list. The elements are singly
* linked to save space, so elements can only be removed from the
* head of the list. New elements can be added to the list before or after
* an existing element, at the head of the list, or at the end of the
* list. A simple queue may only be traversed in the forward direction.
*
* A tail queue is headed by a pair of pointers, one to the head of the
* list and the other to the tail of the list. The elements are doubly
* linked so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before or
* after an existing element, at the head of the list, or at the end of
* the list. A tail queue may be traversed in either direction.
*
* A circle queue is headed by a pair of pointers, one to the head of the
* list and the other to the tail of the list. The elements are doubly
* linked so that an arbitrary element can be removed without a need to
* traverse the list. New elements can be added to the list before or after
* an existing element, at the head of the list, or at the end of the list.
* A circle queue may be traversed in either direction, but has a more
* complex end of list detection.
*
* For details on the use of these macros, see the queue(3) manual page.
*/
/*
* Singly-linked List definitions.
*/
#define SLIST_HEAD(name, type) \
struct name { \
struct type *slh_first; /* first element */ \
}
#define SLIST_HEAD_INITIALIZER(head) \
{ NULL }
#define SLIST_ENTRY(type) \
struct { \
struct type *sle_next; /* next element */ \
}
/*
* Singly-linked List access methods.
*/
#define SLIST_FIRST(head) ((head)->slh_first)
#define SLIST_END(head) NULL
#define SLIST_EMPTY(head) (SLIST_FIRST(head) == SLIST_END(head))
#define SLIST_NEXT(elm, field) ((elm)->field.sle_next)
#define SLIST_FOREACH(var, head, field) \
for((var) = SLIST_FIRST(head); \
(var) != SLIST_END(head); \
(var) = SLIST_NEXT(var, field))
#define SLIST_FOREACH_PREVPTR(var, varp, head, field) \
for ((varp) = &SLIST_FIRST((head)); \
((var) = *(varp)) != SLIST_END(head); \
(varp) = &SLIST_NEXT((var), field))
/*
* Singly-linked List functions.
*/
#define SLIST_INIT(head) { \
SLIST_FIRST(head) = SLIST_END(head); \
}
#define SLIST_INSERT_AFTER(slistelm, elm, field) do { \
(elm)->field.sle_next = (slistelm)->field.sle_next; \
(slistelm)->field.sle_next = (elm); \
} while (0)
#define SLIST_INSERT_HEAD(head, elm, field) do { \
(elm)->field.sle_next = (head)->slh_first; \
(head)->slh_first = (elm); \
} while (0)
#define SLIST_REMOVE_NEXT(head, elm, field) do { \
(elm)->field.sle_next = (elm)->field.sle_next->field.sle_next; \
} while (0)
#define SLIST_REMOVE_HEAD(head, field) do { \
(head)->slh_first = (head)->slh_first->field.sle_next; \
} while (0)
#define SLIST_REMOVE(head, elm, type, field) do { \
if ((head)->slh_first == (elm)) { \
SLIST_REMOVE_HEAD((head), field); \
} \
else { \
struct type *curelm = (head)->slh_first; \
while( curelm->field.sle_next != (elm) ) \
curelm = curelm->field.sle_next; \
curelm->field.sle_next = \
curelm->field.sle_next->field.sle_next; \
} \
} while (0)
/*
* List definitions.
*/
#define LIST_HEAD(name, type) \
struct name { \
struct type *lh_first; /* first element */ \
}
#define LIST_HEAD_INITIALIZER(head) \
{ NULL }
#define LIST_ENTRY(type) \
struct { \
struct type *le_next; /* next element */ \
struct type **le_prev; /* address of previous next element */ \
}
/*
* List access methods
*/
#define LIST_FIRST(head) ((head)->lh_first)
#define LIST_END(head) NULL
#define LIST_EMPTY(head) (LIST_FIRST(head) == LIST_END(head))
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
#define LIST_FOREACH(var, head, field) \
for((var) = LIST_FIRST(head); \
(var)!= LIST_END(head); \
(var) = LIST_NEXT(var, field))
/*
* List functions.
*/
#define LIST_INIT(head) do { \
LIST_FIRST(head) = LIST_END(head); \
} while (0)
#define LIST_INSERT_AFTER(listelm, elm, field) do { \
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
(listelm)->field.le_next->field.le_prev = \
&(elm)->field.le_next; \
(listelm)->field.le_next = (elm); \
(elm)->field.le_prev = &(listelm)->field.le_next; \
} while (0)
#define LIST_INSERT_BEFORE(listelm, elm, field) do { \
(elm)->field.le_prev = (listelm)->field.le_prev; \
(elm)->field.le_next = (listelm); \
*(listelm)->field.le_prev = (elm); \
(listelm)->field.le_prev = &(elm)->field.le_next; \
} while (0)
#define LIST_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
(head)->lh_first = (elm); \
(elm)->field.le_prev = &(head)->lh_first; \
} while (0)
#define LIST_REMOVE(elm, field) do { \
if ((elm)->field.le_next != NULL) \
(elm)->field.le_next->field.le_prev = \
(elm)->field.le_prev; \
*(elm)->field.le_prev = (elm)->field.le_next; \
} while (0)
#define LIST_REPLACE(elm, elm2, field) do { \
if (((elm2)->field.le_next = (elm)->field.le_next) != NULL) \
(elm2)->field.le_next->field.le_prev = \
&(elm2)->field.le_next; \
(elm2)->field.le_prev = (elm)->field.le_prev; \
*(elm2)->field.le_prev = (elm2); \
} while (0)
/*
* Simple queue definitions.
*/
#define SIMPLEQ_HEAD(name, type) \
struct name { \
struct type *sqh_first; /* first element */ \
struct type **sqh_last; /* addr of last next element */ \
}
#define SIMPLEQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).sqh_first }
#define SIMPLEQ_ENTRY(type) \
struct { \
struct type *sqe_next; /* next element */ \
}
/*
* Simple queue access methods.
*/
#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
#define SIMPLEQ_END(head) NULL
#define SIMPLEQ_EMPTY(head) (SIMPLEQ_FIRST(head) == SIMPLEQ_END(head))
#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
#define SIMPLEQ_FOREACH(var, head, field) \
for((var) = SIMPLEQ_FIRST(head); \
(var) != SIMPLEQ_END(head); \
(var) = SIMPLEQ_NEXT(var, field))
/*
* Simple queue functions.
*/
#define SIMPLEQ_INIT(head) do { \
(head)->sqh_first = NULL; \
(head)->sqh_last = &(head)->sqh_first; \
} while (0)
#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
(head)->sqh_last = &(elm)->field.sqe_next; \
(head)->sqh_first = (elm); \
} while (0)
#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.sqe_next = NULL; \
*(head)->sqh_last = (elm); \
(head)->sqh_last = &(elm)->field.sqe_next; \
} while (0)
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
(head)->sqh_last = &(elm)->field.sqe_next; \
(listelm)->field.sqe_next = (elm); \
} while (0)
#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
(head)->sqh_last = &(head)->sqh_first; \
} while (0)
/*
* Tail queue definitions.
*/
#define TAILQ_HEAD(name, type) \
struct name { \
struct type *tqh_first; /* first element */ \
struct type **tqh_last; /* addr of last next element */ \
}
#define TAILQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).tqh_first }
#define TAILQ_ENTRY(type) \
struct { \
struct type *tqe_next; /* next element */ \
struct type **tqe_prev; /* address of previous next element */ \
}
/*
* tail queue access methods
*/
#define TAILQ_FIRST(head) ((head)->tqh_first)
#define TAILQ_END(head) NULL
#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next)
#define TAILQ_LAST(head, headname) \
(*(((struct headname *)((head)->tqh_last))->tqh_last))
/* XXX */
#define TAILQ_PREV(elm, headname, field) \
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
#define TAILQ_EMPTY(head) \
(TAILQ_FIRST(head) == TAILQ_END(head))
#define TAILQ_FOREACH(var, head, field) \
for((var) = TAILQ_FIRST(head); \
(var) != TAILQ_END(head); \
(var) = TAILQ_NEXT(var, field))
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
for((var) = TAILQ_LAST(head, headname); \
(var) != TAILQ_END(head); \
(var) = TAILQ_PREV(var, headname, field))
/*
* Tail queue functions.
*/
#define TAILQ_INIT(head) do { \
(head)->tqh_first = NULL; \
(head)->tqh_last = &(head)->tqh_first; \
} while (0)
#define TAILQ_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \
(head)->tqh_first->field.tqe_prev = \
&(elm)->field.tqe_next; \
else \
(head)->tqh_last = &(elm)->field.tqe_next; \
(head)->tqh_first = (elm); \
(elm)->field.tqe_prev = &(head)->tqh_first; \
} while (0)
#define TAILQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.tqe_next = NULL; \
(elm)->field.tqe_prev = (head)->tqh_last; \
*(head)->tqh_last = (elm); \
(head)->tqh_last = &(elm)->field.tqe_next; \
} while (0)
#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\
(elm)->field.tqe_next->field.tqe_prev = \
&(elm)->field.tqe_next; \
else \
(head)->tqh_last = &(elm)->field.tqe_next; \
(listelm)->field.tqe_next = (elm); \
(elm)->field.tqe_prev = &(listelm)->field.tqe_next; \
} while (0)
#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
(elm)->field.tqe_next = (listelm); \
*(listelm)->field.tqe_prev = (elm); \
(listelm)->field.tqe_prev = &(elm)->field.tqe_next; \
} while (0)
#define TAILQ_REMOVE(head, elm, field) do { \
if (((elm)->field.tqe_next) != NULL) \
(elm)->field.tqe_next->field.tqe_prev = \
(elm)->field.tqe_prev; \
else \
(head)->tqh_last = (elm)->field.tqe_prev; \
*(elm)->field.tqe_prev = (elm)->field.tqe_next; \
} while (0)
#define TAILQ_REPLACE(head, elm, elm2, field) do { \
if (((elm2)->field.tqe_next = (elm)->field.tqe_next) != NULL) \
(elm2)->field.tqe_next->field.tqe_prev = \
&(elm2)->field.tqe_next; \
else \
(head)->tqh_last = &(elm2)->field.tqe_next; \
(elm2)->field.tqe_prev = (elm)->field.tqe_prev; \
*(elm2)->field.tqe_prev = (elm2); \
} while (0)
/*
* Circular queue definitions.
*/
#define CIRCLEQ_HEAD(name, type) \
struct name { \
struct type *cqh_first; /* first element */ \
struct type *cqh_last; /* last element */ \
}
#define CIRCLEQ_HEAD_INITIALIZER(head) \
{ CIRCLEQ_END(&head), CIRCLEQ_END(&head) }
#define CIRCLEQ_ENTRY(type) \
struct { \
struct type *cqe_next; /* next element */ \
struct type *cqe_prev; /* previous element */ \
}
/*
* Circular queue access methods
*/
#define CIRCLEQ_FIRST(head) ((head)->cqh_first)
#define CIRCLEQ_LAST(head) ((head)->cqh_last)
#define CIRCLEQ_END(head) ((void *)(head))
#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
#define CIRCLEQ_EMPTY(head) \
(CIRCLEQ_FIRST(head) == CIRCLEQ_END(head))
#define CIRCLEQ_FOREACH(var, head, field) \
for((var) = CIRCLEQ_FIRST(head); \
(var) != CIRCLEQ_END(head); \
(var) = CIRCLEQ_NEXT(var, field))
#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
for((var) = CIRCLEQ_LAST(head); \
(var) != CIRCLEQ_END(head); \
(var) = CIRCLEQ_PREV(var, field))
/*
* Circular queue functions.
*/
#define CIRCLEQ_INIT(head) do { \
(head)->cqh_first = CIRCLEQ_END(head); \
(head)->cqh_last = CIRCLEQ_END(head); \
} while (0)
#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
(elm)->field.cqe_next = (listelm)->field.cqe_next; \
(elm)->field.cqe_prev = (listelm); \
if ((listelm)->field.cqe_next == CIRCLEQ_END(head)) \
(head)->cqh_last = (elm); \
else \
(listelm)->field.cqe_next->field.cqe_prev = (elm); \
(listelm)->field.cqe_next = (elm); \
} while (0)
#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \
(elm)->field.cqe_next = (listelm); \
(elm)->field.cqe_prev = (listelm)->field.cqe_prev; \
if ((listelm)->field.cqe_prev == CIRCLEQ_END(head)) \
(head)->cqh_first = (elm); \
else \
(listelm)->field.cqe_prev->field.cqe_next = (elm); \
(listelm)->field.cqe_prev = (elm); \
} while (0)
#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \
(elm)->field.cqe_next = (head)->cqh_first; \
(elm)->field.cqe_prev = CIRCLEQ_END(head); \
if ((head)->cqh_last == CIRCLEQ_END(head)) \
(head)->cqh_last = (elm); \
else \
(head)->cqh_first->field.cqe_prev = (elm); \
(head)->cqh_first = (elm); \
} while (0)
#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.cqe_next = CIRCLEQ_END(head); \
(elm)->field.cqe_prev = (head)->cqh_last; \
if ((head)->cqh_first == CIRCLEQ_END(head)) \
(head)->cqh_first = (elm); \
else \
(head)->cqh_last->field.cqe_next = (elm); \
(head)->cqh_last = (elm); \
} while (0)
#define CIRCLEQ_REMOVE(head, elm, field) do { \
if ((elm)->field.cqe_next == CIRCLEQ_END(head)) \
(head)->cqh_last = (elm)->field.cqe_prev; \
else \
(elm)->field.cqe_next->field.cqe_prev = \
(elm)->field.cqe_prev; \
if ((elm)->field.cqe_prev == CIRCLEQ_END(head)) \
(head)->cqh_first = (elm)->field.cqe_next; \
else \
(elm)->field.cqe_prev->field.cqe_next = \
(elm)->field.cqe_next; \
} while (0)
#define CIRCLEQ_REPLACE(head, elm, elm2, field) do { \
if (((elm2)->field.cqe_next = (elm)->field.cqe_next) == \
CIRCLEQ_END(head)) \
(head).cqh_last = (elm2); \
else \
(elm2)->field.cqe_next->field.cqe_prev = (elm2); \
if (((elm2)->field.cqe_prev = (elm)->field.cqe_prev) == \
CIRCLEQ_END(head)) \
(head).cqh_first = (elm2); \
else \
(elm2)->field.cqe_prev->field.cqe_next = (elm2); \
} while (0)
#endif /* !_SYS_QUEUE_H_ */

View File

@ -1,677 +0,0 @@
/* $OpenBSD$ */
/*
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
*
* 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 AUTHOR ``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 AUTHOR 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.
*/
#ifndef _SYS_TREE_H_
#define _SYS_TREE_H_
/*
* This file defines data structures for different types of trees:
* splay trees and red-black trees.
*
* A splay tree is a self-organizing data structure. Every operation
* on the tree causes a splay to happen. The splay moves the requested
* node to the root of the tree and partly rebalances it.
*
* This has the benefit that request locality causes faster lookups as
* the requested nodes move to the top of the tree. On the other hand,
* every lookup causes memory writes.
*
* The Balance Theorem bounds the total access time for m operations
* and n inserts on an initially empty tree as O((m + n)lg n). The
* amortized cost for a sequence of m accesses to a splay tree is O(lg n);
*
* A red-black tree is a binary search tree with the node color as an
* extra attribute. It fulfills a set of conditions:
* - every search path from the root to a leaf consists of the
* same number of black nodes,
* - each red node (except for the root) has a black parent,
* - each leaf node is black.
*
* Every operation on a red-black tree is bounded as O(lg n).
* The maximum height of a red-black tree is 2lg (n+1).
*/
#define SPLAY_HEAD(name, type) \
struct name { \
struct type *sph_root; /* root of the tree */ \
}
#define SPLAY_INITIALIZER(root) \
{ NULL }
#define SPLAY_INIT(root) do { \
(root)->sph_root = NULL; \
} while (0)
#define SPLAY_ENTRY(type) \
struct { \
struct type *spe_left; /* left element */ \
struct type *spe_right; /* right element */ \
}
#define SPLAY_LEFT(elm, field) (elm)->field.spe_left
#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right
#define SPLAY_ROOT(head) (head)->sph_root
#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL)
/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \
SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
(head)->sph_root = tmp; \
} while (0)
#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
(head)->sph_root = tmp; \
} while (0)
#define SPLAY_LINKLEFT(head, tmp, field) do { \
SPLAY_LEFT(tmp, field) = (head)->sph_root; \
tmp = (head)->sph_root; \
(head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
} while (0)
#define SPLAY_LINKRIGHT(head, tmp, field) do { \
SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
tmp = (head)->sph_root; \
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
} while (0)
#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \
SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \
SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\
SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \
SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \
} while (0)
/* Generates prototypes and inline functions */
#define SPLAY_PROTOTYPE(name, type, field, cmp) \
void name##_SPLAY(struct name *, struct type *); \
void name##_SPLAY_MINMAX(struct name *, int); \
struct type *name##_SPLAY_INSERT(struct name *, struct type *); \
struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \
\
/* Finds the node with the same key as elm */ \
static __inline struct type * \
name##_SPLAY_FIND(struct name *head, struct type *elm) \
{ \
if (SPLAY_EMPTY(head)) \
return(NULL); \
name##_SPLAY(head, elm); \
if ((cmp)(elm, (head)->sph_root) == 0) \
return (head->sph_root); \
return (NULL); \
} \
\
static __inline struct type * \
name##_SPLAY_NEXT(struct name *head, struct type *elm) \
{ \
name##_SPLAY(head, elm); \
if (SPLAY_RIGHT(elm, field) != NULL) { \
elm = SPLAY_RIGHT(elm, field); \
while (SPLAY_LEFT(elm, field) != NULL) { \
elm = SPLAY_LEFT(elm, field); \
} \
} else \
elm = NULL; \
return (elm); \
} \
\
static __inline struct type * \
name##_SPLAY_MIN_MAX(struct name *head, int val) \
{ \
name##_SPLAY_MINMAX(head, val); \
return (SPLAY_ROOT(head)); \
}
/* Main splay operation.
* Moves node close to the key of elm to top
*/
#define SPLAY_GENERATE(name, type, field, cmp) \
struct type * \
name##_SPLAY_INSERT(struct name *head, struct type *elm) \
{ \
if (SPLAY_EMPTY(head)) { \
SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \
} else { \
int __comp; \
name##_SPLAY(head, elm); \
__comp = (cmp)(elm, (head)->sph_root); \
if(__comp < 0) { \
SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\
SPLAY_RIGHT(elm, field) = (head)->sph_root; \
SPLAY_LEFT((head)->sph_root, field) = NULL; \
} else if (__comp > 0) { \
SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\
SPLAY_LEFT(elm, field) = (head)->sph_root; \
SPLAY_RIGHT((head)->sph_root, field) = NULL; \
} else \
return ((head)->sph_root); \
} \
(head)->sph_root = (elm); \
return (NULL); \
} \
\
struct type * \
name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
{ \
struct type *__tmp; \
if (SPLAY_EMPTY(head)) \
return (NULL); \
name##_SPLAY(head, elm); \
if ((cmp)(elm, (head)->sph_root) == 0) { \
if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\
} else { \
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
(head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\
name##_SPLAY(head, elm); \
SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
} \
return (elm); \
} \
return (NULL); \
} \
\
void \
name##_SPLAY(struct name *head, struct type *elm) \
{ \
struct type __node, *__left, *__right, *__tmp; \
int __comp; \
\
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
__left = __right = &__node; \
\
while ((__comp = (cmp)(elm, (head)->sph_root))) { \
if (__comp < 0) { \
__tmp = SPLAY_LEFT((head)->sph_root, field); \
if (__tmp == NULL) \
break; \
if ((cmp)(elm, __tmp) < 0){ \
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
break; \
} \
SPLAY_LINKLEFT(head, __right, field); \
} else if (__comp > 0) { \
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
if (__tmp == NULL) \
break; \
if ((cmp)(elm, __tmp) > 0){ \
SPLAY_ROTATE_LEFT(head, __tmp, field); \
if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
break; \
} \
SPLAY_LINKRIGHT(head, __left, field); \
} \
} \
SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
} \
\
/* Splay with either the minimum or the maximum element \
* Used to find minimum or maximum element in tree. \
*/ \
void name##_SPLAY_MINMAX(struct name *head, int __comp) \
{ \
struct type __node, *__left, *__right, *__tmp; \
\
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
__left = __right = &__node; \
\
while (1) { \
if (__comp < 0) { \
__tmp = SPLAY_LEFT((head)->sph_root, field); \
if (__tmp == NULL) \
break; \
if (__comp < 0){ \
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
break; \
} \
SPLAY_LINKLEFT(head, __right, field); \
} else if (__comp > 0) { \
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
if (__tmp == NULL) \
break; \
if (__comp > 0) { \
SPLAY_ROTATE_LEFT(head, __tmp, field); \
if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
break; \
} \
SPLAY_LINKRIGHT(head, __left, field); \
} \
} \
SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
}
#define SPLAY_NEGINF -1
#define SPLAY_INF 1
#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y)
#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y)
#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y)
#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y)
#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \
: name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \
: name##_SPLAY_MIN_MAX(x, SPLAY_INF))
#define SPLAY_FOREACH(x, name, head) \
for ((x) = SPLAY_MIN(name, head); \
(x) != NULL; \
(x) = SPLAY_NEXT(name, head, x))
/* Macros that define a red-black tree */
#define RB_HEAD(name, type) \
struct name { \
struct type *rbh_root; /* root of the tree */ \
}
#define RB_INITIALIZER(root) \
{ NULL }
#define RB_INIT(root) do { \
(root)->rbh_root = NULL; \
} while (0)
#define RB_BLACK 0
#define RB_RED 1
#define RB_ENTRY(type) \
struct { \
struct type *rbe_left; /* left element */ \
struct type *rbe_right; /* right element */ \
struct type *rbe_parent; /* parent element */ \
int rbe_color; /* node color */ \
}
#define RB_LEFT(elm, field) (elm)->field.rbe_left
#define RB_RIGHT(elm, field) (elm)->field.rbe_right
#define RB_PARENT(elm, field) (elm)->field.rbe_parent
#define RB_COLOR(elm, field) (elm)->field.rbe_color
#define RB_ROOT(head) (head)->rbh_root
#define RB_EMPTY(head) (RB_ROOT(head) == NULL)
#define RB_SET(elm, parent, field) do { \
RB_PARENT(elm, field) = parent; \
RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \
RB_COLOR(elm, field) = RB_RED; \
} while (0)
#define RB_SET_BLACKRED(black, red, field) do { \
RB_COLOR(black, field) = RB_BLACK; \
RB_COLOR(red, field) = RB_RED; \
} while (0)
#ifndef RB_AUGMENT
#define RB_AUGMENT(x)
#endif
#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \
(tmp) = RB_RIGHT(elm, field); \
if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field))) { \
RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \
} \
RB_AUGMENT(elm); \
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
else \
RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
} else \
(head)->rbh_root = (tmp); \
RB_LEFT(tmp, field) = (elm); \
RB_PARENT(elm, field) = (tmp); \
RB_AUGMENT(tmp); \
if ((RB_PARENT(tmp, field))) \
RB_AUGMENT(RB_PARENT(tmp, field)); \
} while (0)
#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \
(tmp) = RB_LEFT(elm, field); \
if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field))) { \
RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \
} \
RB_AUGMENT(elm); \
if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \
if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
else \
RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
} else \
(head)->rbh_root = (tmp); \
RB_RIGHT(tmp, field) = (elm); \
RB_PARENT(elm, field) = (tmp); \
RB_AUGMENT(tmp); \
if ((RB_PARENT(tmp, field))) \
RB_AUGMENT(RB_PARENT(tmp, field)); \
} while (0)
/* Generates prototypes and inline functions */
#define RB_PROTOTYPE(name, type, field, cmp) \
void name##_RB_INSERT_COLOR(struct name *, struct type *); \
void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
struct type *name##_RB_REMOVE(struct name *, struct type *); \
struct type *name##_RB_INSERT(struct name *, struct type *); \
struct type *name##_RB_FIND(struct name *, struct type *); \
struct type *name##_RB_NEXT(struct type *); \
struct type *name##_RB_MINMAX(struct name *, int); \
\
/* Main rb operation.
* Moves node close to the key of elm to top
*/
#define RB_GENERATE(name, type, field, cmp) \
void \
name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
{ \
struct type *parent, *gparent, *tmp; \
while ((parent = RB_PARENT(elm, field)) && \
RB_COLOR(parent, field) == RB_RED) { \
gparent = RB_PARENT(parent, field); \
if (parent == RB_LEFT(gparent, field)) { \
tmp = RB_RIGHT(gparent, field); \
if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
RB_COLOR(tmp, field) = RB_BLACK; \
RB_SET_BLACKRED(parent, gparent, field);\
elm = gparent; \
continue; \
} \
if (RB_RIGHT(parent, field) == elm) { \
RB_ROTATE_LEFT(head, parent, tmp, field);\
tmp = parent; \
parent = elm; \
elm = tmp; \
} \
RB_SET_BLACKRED(parent, gparent, field); \
RB_ROTATE_RIGHT(head, gparent, tmp, field); \
} else { \
tmp = RB_LEFT(gparent, field); \
if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
RB_COLOR(tmp, field) = RB_BLACK; \
RB_SET_BLACKRED(parent, gparent, field);\
elm = gparent; \
continue; \
} \
if (RB_LEFT(parent, field) == elm) { \
RB_ROTATE_RIGHT(head, parent, tmp, field);\
tmp = parent; \
parent = elm; \
elm = tmp; \
} \
RB_SET_BLACKRED(parent, gparent, field); \
RB_ROTATE_LEFT(head, gparent, tmp, field); \
} \
} \
RB_COLOR(head->rbh_root, field) = RB_BLACK; \
} \
\
void \
name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \
{ \
struct type *tmp; \
while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \
elm != RB_ROOT(head)) { \
if (RB_LEFT(parent, field) == elm) { \
tmp = RB_RIGHT(parent, field); \
if (RB_COLOR(tmp, field) == RB_RED) { \
RB_SET_BLACKRED(tmp, parent, field); \
RB_ROTATE_LEFT(head, parent, tmp, field);\
tmp = RB_RIGHT(parent, field); \
} \
if ((RB_LEFT(tmp, field) == NULL || \
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
(RB_RIGHT(tmp, field) == NULL || \
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
RB_COLOR(tmp, field) = RB_RED; \
elm = parent; \
parent = RB_PARENT(elm, field); \
} else { \
if (RB_RIGHT(tmp, field) == NULL || \
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\
struct type *oleft; \
if ((oleft = RB_LEFT(tmp, field)))\
RB_COLOR(oleft, field) = RB_BLACK;\
RB_COLOR(tmp, field) = RB_RED; \
RB_ROTATE_RIGHT(head, tmp, oleft, field);\
tmp = RB_RIGHT(parent, field); \
} \
RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
RB_COLOR(parent, field) = RB_BLACK; \
if (RB_RIGHT(tmp, field)) \
RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\
RB_ROTATE_LEFT(head, parent, tmp, field);\
elm = RB_ROOT(head); \
break; \
} \
} else { \
tmp = RB_LEFT(parent, field); \
if (RB_COLOR(tmp, field) == RB_RED) { \
RB_SET_BLACKRED(tmp, parent, field); \
RB_ROTATE_RIGHT(head, parent, tmp, field);\
tmp = RB_LEFT(parent, field); \
} \
if ((RB_LEFT(tmp, field) == NULL || \
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
(RB_RIGHT(tmp, field) == NULL || \
RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
RB_COLOR(tmp, field) = RB_RED; \
elm = parent; \
parent = RB_PARENT(elm, field); \
} else { \
if (RB_LEFT(tmp, field) == NULL || \
RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\
struct type *oright; \
if ((oright = RB_RIGHT(tmp, field)))\
RB_COLOR(oright, field) = RB_BLACK;\
RB_COLOR(tmp, field) = RB_RED; \
RB_ROTATE_LEFT(head, tmp, oright, field);\
tmp = RB_LEFT(parent, field); \
} \
RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
RB_COLOR(parent, field) = RB_BLACK; \
if (RB_LEFT(tmp, field)) \
RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\
RB_ROTATE_RIGHT(head, parent, tmp, field);\
elm = RB_ROOT(head); \
break; \
} \
} \
} \
if (elm) \
RB_COLOR(elm, field) = RB_BLACK; \
} \
\
struct type * \
name##_RB_REMOVE(struct name *head, struct type *elm) \
{ \
struct type *child, *parent, *old = elm; \
int color; \
if (RB_LEFT(elm, field) == NULL) \
child = RB_RIGHT(elm, field); \
else if (RB_RIGHT(elm, field) == NULL) \
child = RB_LEFT(elm, field); \
else { \
struct type *left; \
elm = RB_RIGHT(elm, field); \
while ((left = RB_LEFT(elm, field))) \
elm = left; \
child = RB_RIGHT(elm, field); \
parent = RB_PARENT(elm, field); \
color = RB_COLOR(elm, field); \
if (child) \
RB_PARENT(child, field) = parent; \
if (parent) { \
if (RB_LEFT(parent, field) == elm) \
RB_LEFT(parent, field) = child; \
else \
RB_RIGHT(parent, field) = child; \
RB_AUGMENT(parent); \
} else \
RB_ROOT(head) = child; \
if (RB_PARENT(elm, field) == old) \
parent = elm; \
(elm)->field = (old)->field; \
if (RB_PARENT(old, field)) { \
if (RB_LEFT(RB_PARENT(old, field), field) == old)\
RB_LEFT(RB_PARENT(old, field), field) = elm;\
else \
RB_RIGHT(RB_PARENT(old, field), field) = elm;\
RB_AUGMENT(RB_PARENT(old, field)); \
} else \
RB_ROOT(head) = elm; \
RB_PARENT(RB_LEFT(old, field), field) = elm; \
if (RB_RIGHT(old, field)) \
RB_PARENT(RB_RIGHT(old, field), field) = elm; \
if (parent) { \
left = parent; \
do { \
RB_AUGMENT(left); \
} while ((left = RB_PARENT(left, field))); \
} \
goto color; \
} \
parent = RB_PARENT(elm, field); \
color = RB_COLOR(elm, field); \
if (child) \
RB_PARENT(child, field) = parent; \
if (parent) { \
if (RB_LEFT(parent, field) == elm) \
RB_LEFT(parent, field) = child; \
else \
RB_RIGHT(parent, field) = child; \
RB_AUGMENT(parent); \
} else \
RB_ROOT(head) = child; \
color: \
if (color == RB_BLACK) \
name##_RB_REMOVE_COLOR(head, parent, child); \
return (old); \
} \
\
/* Inserts a node into the RB tree */ \
struct type * \
name##_RB_INSERT(struct name *head, struct type *elm) \
{ \
struct type *tmp; \
struct type *parent = NULL; \
int comp = 0; \
tmp = RB_ROOT(head); \
while (tmp) { \
parent = tmp; \
comp = (cmp)(elm, parent); \
if (comp < 0) \
tmp = RB_LEFT(tmp, field); \
else if (comp > 0) \
tmp = RB_RIGHT(tmp, field); \
else \
return (tmp); \
} \
RB_SET(elm, parent, field); \
if (parent != NULL) { \
if (comp < 0) \
RB_LEFT(parent, field) = elm; \
else \
RB_RIGHT(parent, field) = elm; \
RB_AUGMENT(parent); \
} else \
RB_ROOT(head) = elm; \
name##_RB_INSERT_COLOR(head, elm); \
return (NULL); \
} \
\
/* Finds the node with the same key as elm */ \
struct type * \
name##_RB_FIND(struct name *head, struct type *elm) \
{ \
struct type *tmp = RB_ROOT(head); \
int comp; \
while (tmp) { \
comp = cmp(elm, tmp); \
if (comp < 0) \
tmp = RB_LEFT(tmp, field); \
else if (comp > 0) \
tmp = RB_RIGHT(tmp, field); \
else \
return (tmp); \
} \
return (NULL); \
} \
\
struct type * \
name##_RB_NEXT(struct type *elm) \
{ \
if (RB_RIGHT(elm, field)) { \
elm = RB_RIGHT(elm, field); \
while (RB_LEFT(elm, field)) \
elm = RB_LEFT(elm, field); \
} else { \
if (RB_PARENT(elm, field) && \
(elm == RB_LEFT(RB_PARENT(elm, field), field))) \
elm = RB_PARENT(elm, field); \
else { \
while (RB_PARENT(elm, field) && \
(elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
elm = RB_PARENT(elm, field); \
elm = RB_PARENT(elm, field); \
} \
} \
return (elm); \
} \
\
struct type * \
name##_RB_MINMAX(struct name *head, int val) \
{ \
struct type *tmp = RB_ROOT(head); \
struct type *parent = NULL; \
while (tmp) { \
parent = tmp; \
if (val < 0) \
tmp = RB_LEFT(tmp, field); \
else \
tmp = RB_RIGHT(tmp, field); \
} \
return (parent); \
}
#define RB_NEGINF -1
#define RB_INF 1
#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y)
#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y)
#define RB_FIND(name, x, y) name##_RB_FIND(x, y)
#define RB_NEXT(name, x, y) name##_RB_NEXT(y)
#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF)
#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF)
#define RB_FOREACH(x, name, head) \
for ((x) = RB_MIN(name, head); \
(x) != NULL; \
(x) = name##_RB_NEXT(x))
#endif /* _SYS_TREE_H_ */

47
conf.c
View File

@ -20,6 +20,7 @@
#define CONF_MAX_WINTITLE 256 #define CONF_MAX_WINTITLE 256
#define CONF_IGNORECASE 0x01 #define CONF_IGNORECASE 0x01
/* /*
* Match a window. * Match a window.
*/ */
@ -78,9 +79,9 @@ conf_cmd_add(struct conf *c, char *image, char *label, int flags)
/* "term" and "lock" have special meanings. */ /* "term" and "lock" have special meanings. */
if (strcmp(label, "term") == 0) { if (strcmp(label, "term") == 0) {
strlcpy(G_conf.termpath, image, sizeof(G_conf.termpath)); strlcpy(Conf.termpath, image, sizeof(Conf.termpath));
} else if (strcmp(label, "lock") == 0) { } else if (strcmp(label, "lock") == 0) {
strlcpy(G_conf.lockpath, image, sizeof(G_conf.lockpath)); strlcpy(Conf.lockpath, image, sizeof(Conf.lockpath));
} else { } else {
struct cmd *cmd; struct cmd *cmd;
XMALLOC(cmd, struct cmd); XMALLOC(cmd, struct cmd);
@ -149,6 +150,9 @@ conf_cmd_populate(struct conf *c, char *path)
/* Add a dynamic entry to the command menu */ /* Add a dynamic entry to the command menu */
conf_cmd_add(c, fullname, filename, 0); conf_cmd_add(c, fullname, filename, 0);
} }
closedir(dir);
} }
void void
@ -185,6 +189,8 @@ conf_setup(struct conf *c)
XK_Return, ControlMask|Mod1Mask, 0, NULL); XK_Return, ControlMask|Mod1Mask, 0, NULL);
conf_bindkey(c, kbfunc_lock, conf_bindkey(c, kbfunc_lock,
XK_Delete, ControlMask|Mod1Mask, 0, NULL); XK_Delete, ControlMask|Mod1Mask, 0, NULL);
conf_bindkey(c, kbfunc_exec, XK_question, Mod1Mask, 0, NULL);
conf_bindkey(c, kbfunc_ssh, XK_period, Mod1Mask, 0, NULL);
conf_bindkey(c, kbfunc_client_hide, conf_bindkey(c, kbfunc_client_hide,
XK_Return, Mod1Mask, KBFLAG_NEEDCLIENT, 0); XK_Return, Mod1Mask, KBFLAG_NEEDCLIENT, 0);
conf_bindkey(c, kbfunc_client_lower, conf_bindkey(c, kbfunc_client_lower,
@ -195,9 +201,9 @@ conf_setup(struct conf *c)
conf_bindkey(c, kbfunc_menu_search, conf_bindkey(c, kbfunc_menu_search,
XK_slash, ControlMask, 0, 0); XK_slash, ControlMask, 0, 0);
conf_bindkey(c, kbfunc_client_cycle, conf_bindkey(c, kbfunc_client_cycle,
XK_Tab, Mod1Mask, KBFLAG_NEEDCLIENT, 0); XK_Tab, Mod1Mask, 0, 0);
conf_bindkey(c, kbfunc_client_rcycle, conf_bindkey(c, kbfunc_client_rcycle,
XK_Tab, Mod1Mask|ShiftMask, KBFLAG_NEEDCLIENT, 0); XK_Tab, Mod1Mask|ShiftMask, 0, 0);
conf_bindkey(c, kbfunc_client_label, XK_l, conf_bindkey(c, kbfunc_client_label, XK_l,
ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0); ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0);
conf_bindkey(c, kbfunc_client_delete, XK_x, conf_bindkey(c, kbfunc_client_delete, XK_x,
@ -228,8 +234,30 @@ conf_setup(struct conf *c)
XK_Right, Mod1Mask, 0, 0); XK_Right, Mod1Mask, 0, 0);
conf_bindkey(c, kbfunc_client_prevgroup, conf_bindkey(c, kbfunc_client_prevgroup,
XK_Left, Mod1Mask, 0, 0); XK_Left, Mod1Mask, 0, 0);
conf_bindkey(c, kbfunc_client_maximize,
XK_f, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0);
conf_bindkey(c, kbfunc_client_vmaximize, conf_bindkey(c, kbfunc_client_vmaximize,
XK_equal, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0); XK_equal, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0);
conf_bindkey(c, kbfunc_client_move,
XK_k, Mod1Mask, KBFLAG_NEEDCLIENT, (void *)CWM_UP);
conf_bindkey(c, kbfunc_client_move,
XK_j, Mod1Mask, KBFLAG_NEEDCLIENT, (void *)CWM_DOWN);
conf_bindkey(c, kbfunc_client_move,
XK_l, Mod1Mask, KBFLAG_NEEDCLIENT, (void *)CWM_RIGHT);
conf_bindkey(c, kbfunc_client_move,
XK_h, Mod1Mask, KBFLAG_NEEDCLIENT, (void *)CWM_LEFT);
conf_bindkey(c, kbfunc_client_move,
XK_K, Mod1Mask, KBFLAG_NEEDCLIENT,
(void *)(CWM_UP|CWM_BIGMOVE));
conf_bindkey(c, kbfunc_client_move,
XK_J, Mod1Mask, KBFLAG_NEEDCLIENT,
(void *)(CWM_DOWN|CWM_BIGMOVE));
conf_bindkey(c, kbfunc_client_move,
XK_L, Mod1Mask, KBFLAG_NEEDCLIENT,
(void *)(CWM_RIGHT|CWM_BIGMOVE));
conf_bindkey(c, kbfunc_client_move,
XK_H, Mod1Mask, KBFLAG_NEEDCLIENT,
(void *)(CWM_LEFT|CWM_BIGMOVE));
} }
snprintf(dir_settings, sizeof(dir_settings), snprintf(dir_settings, sizeof(dir_settings),
@ -259,8 +287,8 @@ conf_setup(struct conf *c)
c->flags = 0; c->flags = 0;
/* Default term/lock */ /* Default term/lock */
strlcpy(G_conf.termpath, "xterm", sizeof(G_conf.termpath)); strlcpy(Conf.termpath, "xterm", sizeof(Conf.termpath));
strlcpy(G_conf.lockpath, "xlock", sizeof(G_conf.lockpath)); strlcpy(Conf.lockpath, "xlock", sizeof(Conf.lockpath));
} }
int int
@ -409,7 +437,7 @@ conf_parsekeys(struct conf *c, char *filename)
substring = strchr(ent->d_name, '-') + 1; substring = strchr(ent->d_name, '-') + 1;
// if there is no '-' in name, continue as is /* If there is no '-' in name, continue as is */
if (strchr(ent->d_name, '-') == NULL) if (strchr(ent->d_name, '-') == NULL)
substring = ent->d_name; substring = ent->d_name;
@ -468,7 +496,7 @@ conf_parsesettings(struct conf *c, char *filename)
if (ent->d_name[0] == '.') if (ent->d_name[0] == '.')
continue; continue;
if (strncmp(ent->d_name, "sticky", 7)==0) if (strncmp(ent->d_name, "sticky", 7)==0)
G_conf.flags |= CONF_STICKY_GROUPS; Conf.flags |= CONF_STICKY_GROUPS;
} }
closedir(dir); closedir(dir);
} }
@ -528,4 +556,7 @@ conf_parseautogroups(struct conf *c, char *filename)
TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry); TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry);
} }
closedir(dir);
} }

1463
config.guess vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,129 +0,0 @@
/* config.h.in. Generated from configure.in by autoheader. */
#undef u_int16_t
#undef u_int32_t
#undef u_int64_t
#undef u_int8_t
/* Define to 1 if you have the <err.h> header file. */
#undef HAVE_ERR_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `socket' function. */
#undef HAVE_SOCKET
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strlcat' function. */
#undef HAVE_STRLCAT
/* Define to 1 if you have the `strlcpy' function. */
#undef HAVE_STRLCPY
/* Define to 1 if you have the `strsep' function. */
#undef HAVE_STRSEP
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* Define to 1 if you have the <time.h> header file. */
#undef HAVE_TIME_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Version number of package */
#undef VERSION
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
/* Define to `unsigned short' if <sys/types.h> does not define. */
#undef u_int16_t
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef u_int32_t
/* Define to `unsigned long long' if <sys/types.h> does not define. */
#undef u_int64_t
/* Define to `unsigned char' if <sys/types.h> does not define. */
#undef u_int8_t
/* Prototypes for missing functions */
#ifndef HAVE_STRLCPY
size_t strlcpy(char *, const char *, size_t);
#endif
#ifndef HAVE_STRLCAT
size_t strlcat(char *, const char *, size_t);
#endif
#ifndef HAVE_STRSEP
char *strsep(char **, const char *);
#endif /* HAVE_STRSEP */
#ifndef HAVE_ERR
void err(int, const char *, ...);
void warn(const char *, ...);
void errx(int , const char *, ...);
void warnx(const char *, ...);
#endif

1579
config.sub vendored

File diff suppressed because it is too large Load Diff

7775
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,74 +0,0 @@
dnl $Id$
AC_INIT(calmwm.c)
AC_CANONICAL_SYSTEM
dnl AC_LIBTOOL_DLOPEN
AM_INIT_AUTOMAKE(cwm, 3)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
AC_PROG_CC
AC_PROG_MAKE_SET
dnl intitialization
if test "x$prefix" = "xNONE"; then
prefix="/usr/local"
fi
dnl Checks for programs.
AC_PROG_RANLIB
AC_PROG_INSTALL
dnl ugly ugly hack
AC_CHECK_LIB(c, err, [ ERRO="" ], [ ERRO="err.o" ],)
AC_SUBST(ERRO)
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
dnl X stuff
AC_PATH_X
AC_PATH_XTRA
LIBS="$X_LIBS -lX11 -lXext"
CFLAGS="$CFLAGS $X_CFLAGS"
dnl dnl Check for __progname; from OpenSSHp
dnl AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
dnl AC_TRY_LINK([],
dnl [ extern char *__progname; printf("%s", __progname); ],
dnl [ ac_cv_libc_defines___progname="yes" ],
dnl [ ac_cv_libc_defines___progname="no" ]
dnl )
dnl ])
dnl if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
dnl AC_DEFINE(HAVE___PROGNAME)
dnl fi
AC_CHECK_HEADERS(sys/time.h err.h time.h unistd.h stdint.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_CHECK_TYPE(u_int64_t, unsigned long long)
AC_CHECK_TYPE(u_int32_t, unsigned int)
AC_CHECK_TYPE(u_int16_t, unsigned short)
AC_CHECK_TYPE(u_int8_t, unsigned char)
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(socket)
AC_REPLACE_FUNCS(strlcpy strsep strlcat)
PKG_CHECK_MODULES(XFT, [xft], , )
AC_SUBST(XFT_CFLAGS)
AC_SUBST(XFT_LIBS)
AC_SUBST(LTLIBOBJS)
AC_OUTPUT(Makefile)

View File

@ -48,12 +48,12 @@ _mkcursor(struct cursor_data *c, struct screen_ctx *sc)
{ {
Pixmap f, m; Pixmap f, m;
f = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin, (char *)c->fore, f = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, (char *)c->fore,
c->width, c->width, 1, 0, 1); c->width, c->width, 1, 0, 1);
m = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin, (char *)c->mask, m = XCreatePixmapFromBitmapData(X_Dpy, sc->rootwin, (char *)c->mask,
c->width, c->width, 1, 0, 1); c->width, c->width, 1, 0, 1);
return (XCreatePixmapCursor(G_dpy, f, m, return (XCreatePixmapCursor(X_Dpy, f, m,
&sc->blackcolor, &sc->whitecolor, c->hot[0], c->hot[1])); &sc->blackcolor, &sc->whitecolor, c->hot[0], c->hot[1]));
} }

291
cwm.1
View File

@ -1,7 +1,7 @@
.\" $OpenBSD$ .\" $OpenBSD$
.\" .\"
.\" The following requests are required for all man pages. .\" The following requests are required for all man pages.
.Dd July 10, 2004 .Dd June 29, 2007
.Dt CWM 1 .Dt CWM 1
.Os .Os
.Sh NAME .Sh NAME
@ -10,213 +10,266 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.\" For a program: program [-abc] file ... .\" For a program: program [-abc] file ...
.Nm cwm .Nm cwm
.Op Fl s .Op Fl s
.Op Fl d Ar display
.Op Fl f Ar fontname .Op Fl f Ar fontname
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
is a window manager for X11. It was originally inspired by evilwm, is a window manager for X11.
but was rewritten from scratch due to limitations in the evilwm It was originally inspired by evilwm, but was rewritten from scratch
codebase. The from-scratch rewrite borrowed some code from 9wm. due to limitations in the evilwm codebase.
The from-scratch rewrite borrowed some code from 9wm.
.Nm .Nm
contains many new features which all concentrate on the efficiency and contains many new features which all concentrate on the efficiency and
transparency of window management. transparency of window management.
.Nm .Nm
also aims to maintain the most simplest and pleasant aesthetic. also aims to maintain the most simplest and pleasant aesthetic.
.Pp
.Sh BASIC OPERATION The following notation is used throughout this page:
We will adopt the following notation: .Pp
.Bl -tag -width Ds -offset indent -compact
.Bl -tag -width 10n -offset -indent -compact .It Ic C
.It Fa C
Control Control
.It Fa M .It Ic M
Meta (Alt on PCs) Meta (Alt on PCs)
.It Fa S .It Ic S
Shift Shift
.It Fa M1 .It Ic M1
Left mouse button Left mouse button
.It Fa M2 .It Ic M2
Middle mouse button Middle mouse button
.It Fa M3 .It Ic M3
Right mouse button Right mouse button
.El .El
.Pp
.Nm .Nm
is very simple in its use. Most of the actions are initiated via is very simple in its use.
keybindings. The current keybindings are described below, their Most of the actions are initiated via keybindings.
functionality is described in more detail later. The current keybindings are described below;
their functionality is described in more detail later.
.Bl -tag -width 10n -offset -indent -compact .Pp
.It Fa C-M-Enter .Bl -tag -width "C-M-EscapeXXX" -offset indent -compact
.It Ic C-M-Enter
Spawn a new terminal. Spawn a new terminal.
.It Fa C-M-Delete .It Ic C-M-Delete
Lock the screen. Lock the screen.
.It Fa M-Enter .It Ic M-Enter
Hide current window. Hide current window.
.It Fa M-Down .It Ic M-Down
Lower current window. Lower current window.
.It Fa M-Up .It Ic M-Up
Raise current window. Raise current window.
.It Fa M-/ .It Ic M-/
Search for windows. Search for windows.
.It Fa C-/ .It Ic C-/
Search for applications. Search for applications.
.It Fa C-M-l .It Ic C-M-l
Label current window. Label current window.
.It Fa M-Tab .It Ic M-Tab
Cycle through currently visible windows. Cycle through currently visible windows.
.It Fa M-S-Tab .It Ic M-S-Tab
Reverse cycle through currently visible windows. Reverse cycle through currently visible windows.
.It Fa C-M-x .It Ic C-M-x
Delete current window. Delete current window.
.It Fa C-M-Escape .It Ic C-M-Escape
Enter group edit mode. Enter group edit mode.
.It Fa C-M-[n] .It Ic C-M-[n]
Select group n, where n is 1-9. Select group n, where n is 1-9.
.It Fa C-M-0 .It Ic C-M-0
Select all groups. Select all groups.
.It Fa M-Right .It Ic M-Right
Switch to next group. Switch to next group.
.It Fa M-Left .It Ic M-Left
Switch to previous group. Switch to previous group.
.It Fa C-M-= .It Ic C-M-f
Toggle full-screen size of window.
.It Ic C-M-=
Toggle vertical maximization of window. Toggle vertical maximization of window.
.It Ic M-?
Spawn
.Dq Exec program
dialog.
.It Ic M-.
Spawn
.Dq Ssh to
dialog.
This parses
.Pa $HOME/.ssh/known_hosts
to provide host auto-completion.
.Xr ssh 1
will be executed via the configured terminal emulator.
.El .El
.Pp
The mouse bindings are also important, they are: The mouse bindings are also important, they are:
.Pp
.Bl -tag -width 10n -offset -indent -compact .Bl -tag -width Ds -offset indent -compact
.It Fa M-M1 .It M-M1
Move a window. Move a window.
.It Fa C-M-M1 .It C-M-M1
Toggle a window's membership in the current group. A blue highlight Toggle a window's membership in the current group.
indicates the window has been added to the group, a red highlight A blue highlight indicates the window has been added to the group;
indicates it has been removed. a red highlight indicates it has been removed.
.It Fa M-M2 .It M-M2
Resize a window/Select a window. Resize a window/select a window.
.It Fa M-M3 .It M-M3
Lower a window. Lower a window.
.El .El
.Pp
The options for The options for
.Nm .Nm
are as follows: are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Fl d Ar display
Specify the display to use.
.It Fl f Ar fontname
Makes the
.Xr Xft 3
font string
.Ar fontname
the default font.
.It Fl s .It Fl s
Set sticky group mode on. Set sticky group mode on.
The default behavior for new windows is to not assign any group. The default behavior for new windows is to not assign any group.
This changes the default behavior to assigning the currrently selected This changes the default behavior to assigning the currrently selected
group to any newly created windows. group to any newly created windows.
.It Fl f Ar fontname
Makes the
.Xr Xft 3
font string
.Ar fontname
the default font.
.El .El
.Sh WINDOW MOVEMENT
.Nm
windows can be moved with the use of the keyboard through Vi-like bindings.
M-[hjkl] moves the current window a small amount, while M-shift-[hjkl] moves
the current window a larger amount.
For example, to move the current window to the left a small amount, press M-h.
To move the current window down by a larger amount, press M-shift-j.
.Sh SEARCH .Sh SEARCH
.Nm .Nm
features the ability to search for windows by their current title, old features the ability to search for windows by their current title,
titles and by their label. The priority for the search results are: old titles, and by their label.
Label, current title, old titles in reverse order and finally window The priority for the search results are: label, current title,
class name. old titles in reverse order, and finally window class name.
.Nm .Nm
keeps a history of the 5 previous titles of a window. keeps a history of the 5 previous titles of a window.
.Pp
When searching, the leftmost character of the result list may show a When searching, the leftmost character of the result list may show a
flag: flag:
.Pp
.Bl -tag -width 10n -offset -indent -compact .Bl -tag -width 10n -offset -indent -compact
.It Fa ! .It !
The window is the currently focused window. The window is the currently focused window.
.It Fa & .It &
The window is hidden. The window is hidden.
.El .El
.Pp
The following keybindings may be used to navigate the result list: The following keybindings may be used to navigate the result list:
.Pp
.Bl -tag -width 10n -offset -indent -compact .Bl -tag -width "[Down] or C-sXXX" -offset indent -compact
.It [Down] or C-s .It Ic [Down] No or Ic C-s
Select the next window in the list. Select the next window in the list.
.It [Up] or C-r .It Ic [Up] No or Ic C-r
Select the previous window in the list. Select the previous window in the list.
.It C-u .It Ic C-u
Clear the input. Clear the input.
.It [Enter] .It Ic [Enter]
Focus the selected window. Focus the selected window.
.It [Esc] .It Ic [Esc]
Quit. Quit.
.It C-a .It Ic C-a
Whenever there are no matching windows, list every window. Whenever there are no matching windows, list every window.
.El .El
.Sh GROUPS .Sh GROUPS
.Nm .Nm
has the ability to group windows together, and use the groups to has the ability to group windows together, and use the groups to
perform operations on the entire group instead of just one window. perform operations on the entire group instead of just one window.
Currently, the only operation that is supported is to hide and unhide Currently, the only operation that is supported is to hide and unhide
the grouped windows. Together with the the grouped windows.
Together with the
.Fl s .Fl s
option, this can be used to emulate virtual desktops. option, this can be used to emulate virtual desktops.
.Pp
To edit groups, enter the group edit mode, and select/unselect the To edit groups, enter the group edit mode, and select/unselect the
groups with the group selection mouse click. A blue border will be groups with the group selection mouse click.
shown on the currently selected windows. The group selection keyboard A blue border will be shown on the currently selected windows.
shortcuts can also be used to change which group to edit. The group selection keyboard shortcuts can also be used to change
which group to edit.
.Sh MENUS .Sh MENUS
Menus are recalled by clicking the mouse on the root window: Menus are recalled by clicking the mouse on the root window:
.Pp
.Bl -tag -width 10n -offset -indent -compact .Bl -tag -width 10n -offset -indent -compact
.It Fa M1 .It M1
Show list of currently hidden windows. Clicking on an item will Show list of currently hidden windows.
unhide that window. Clicking on an item will unhide that window.
.It Fa M2 .It M2
Show list of currently defined groups. Clicking on an item will Show list of currently defined groups.
hide/unhide that group. Clicking on an item will hide/unhide that group.
.It Fa M3 .It M3
Show list of applications as defined in Show list of applications as defined in
.Fa ~/.calmwm . .Pa ~/.calmwm .
Clicking on an item will spawn that application. Clicking on an item will spawn that application.
.El .El
.Sh ENVIRONMENT
.Sh ~/.calmwm .Bl -tag -width "DISPLAYXXX"
.It DISPLAY
Any directory entries here are shown in the application menu. When it .Nm
is selected, the image is executed with starts on this display unless the
.Fl d
option is given.
.El
.Sh FILES
.Bl -tag -width Ds
.It Pa ~/.calmwm
Any directory entries here are shown in the application menu.
When it is selected, the image is executed with
.Xr execve 2 . .Xr execve 2 .
One use of this is to create symbolic links for your favorite One use of this is to create symbolic links for your favorite
applications in this directory using applications in this directory using
.Xr ln 1 . .Xr ln 1 .
.Pp
The entries The entries
.Nm term .Nm term
and and
.Nm lock .Nm lock
have special meaning. When they exist they point to the terminal have a special meaning.
program and screen locking programs used by the keybindings specified When they exist they point to the terminal program and screen locking
above. The defaults for these are programs used by the keybindings specified above.
The defaults for these are
.Xr xterm 1 .Xr xterm 1
and and
.Xr xlock 1 , .Xr xlock 1 ,
respectively. respectively.
.It Pa ~/.calmwm/.autogroup
.Sh ACKNOWLEDGEMENTS Symlinks in this directory are read upon startup and control the
automatic grouping feature, which is based on the window name and class
properties.
To obtain the name and class of a window, use
.Ql xprop WM_CLASS ,
then click on the window.
The first quoted string is the window name; the second one is the
window class.
.Pp
The name of a link can be the window class, or the window class and name
separated by a comma.
The link target is a group name (one, two, \&..., nine).
For example, to make all windows in the
.Xr xterm 1
class go to the third group:
.Bd -literal -offset indent
$ ln -s three ~/.calmwm/.autogroup/XTerm
.Ed
.El
.Sh AUTHORS
.An -nosplit
.Pp
.Nm .Nm
contains some code from 9wm. contains some code from 9wm.
.Pp
.Sh AUTHORS
The The
.Nm .Nm
software has been developed by Marius Aamodt Eriksen software has been developed by
.Aq marius@monkey.org .An Marius Aamodt Eriksen Aq marius@monkey.org
with contributions from Andy Adamson with contributions from
.Aq dros@monkey.org , .An Andy Adamson Aq dros@monkey.org ,
Niels Provos .An Niels Provos Aq provos@monkey.org ,
.Aq provos@monkey.org and
and Antti Nyk<EFBFBD>nen .An Antti Nyk<EFBFBD>nen Aq aon@iki.fi .
.Aq aon@iki.fi .
Ideas, discussion with many others. Ideas, discussion with many others.
.\" .Sh HISTORY .\" .Sh HISTORY
.\".Aq marius@monkey.org . .\".Aq marius@monkey.org .

2
draw.c
View File

@ -15,7 +15,7 @@ draw_outline(struct client_ctx *cc)
{ {
struct screen_ctx *sc = CCTOSC(cc); struct screen_ctx *sc = CCTOSC(cc);
XDrawRectangle(G_dpy, sc->rootwin, sc->invgc, XDrawRectangle(X_Dpy, sc->rootwin, sc->invgc,
cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth, cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth,
cc->geom.width + cc->bwidth, cc->geom.height + cc->bwidth); cc->geom.width + cc->bwidth, cc->geom.height + cc->bwidth);
} }

105
err.c
View File

@ -1,105 +0,0 @@
/*
* err.c
*
* Adapted from OpenBSD libc *err* *warn* code.
*
* Copyright (c) 2000 Dug Song <dugsong@monkey.org>
*
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*/
#include <sys/types.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
void
err(int eval, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (fmt != NULL) {
(void)vfprintf(stderr, fmt, ap);
(void)fprintf(stderr, ": ");
}
va_end(ap);
(void)fprintf(stderr, "%s\n", strerror(errno));
exit(eval);
}
void
warn(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (fmt != NULL) {
(void)vfprintf(stderr, fmt, ap);
(void)fprintf(stderr, ": ");
}
va_end(ap);
(void)fprintf(stderr, "%s\n", strerror(errno));
}
void
errx(int eval, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (fmt != NULL)
(void)vfprintf(stderr, fmt, ap);
(void)fprintf(stderr, "\n");
va_end(ap);
exit(eval);
}
void
warnx(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (fmt != NULL)
(void)vfprintf(stderr, fmt, ap);
(void)fprintf(stderr, "\n");
va_end(ap);
}

12
font.c
View File

@ -61,12 +61,12 @@ font_init(struct screen_ctx *sc)
XColor xcolor, tmp; XColor xcolor, tmp;
HASH_INIT(&sc->fonthash, fontdesc_hash); HASH_INIT(&sc->fonthash, fontdesc_hash);
sc->xftdraw = XftDrawCreate(G_dpy, sc->rootwin, sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin,
DefaultVisual(G_dpy, sc->which), DefaultColormap(G_dpy, sc->which)); DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which));
if (sc->xftdraw == NULL) if (sc->xftdraw == NULL)
errx(1, "XftDrawCreate"); errx(1, "XftDrawCreate");
if (!XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, sc->which), if (!XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, sc->which),
"black", &xcolor, &tmp)) "black", &xcolor, &tmp))
errx(1, "XAllocNamedColor"); errx(1, "XAllocNamedColor");
@ -112,7 +112,7 @@ int
font_width(struct fontdesc *fdp, const char *text, int len) font_width(struct fontdesc *fdp, const char *text, int len)
{ {
XGlyphInfo extents; XGlyphInfo extents;
XftTextExtents8(G_dpy, fdp->fn, (const XftChar8*)text, len, &extents); XftTextExtents8(X_Dpy, fdp->fn, (const XftChar8*)text, len, &extents);
return (extents.xOff); return (extents.xOff);
} }
@ -149,8 +149,8 @@ _make_font(struct screen_ctx *sc, struct fontdesc *fdp)
if ((pat = FcNameParse(fdp->name)) == NULL) if ((pat = FcNameParse(fdp->name)) == NULL)
return (NULL); return (NULL);
if ((patx = XftFontMatch(G_dpy, sc->which, pat, &res)) != NULL) if ((patx = XftFontMatch(X_Dpy, sc->which, pat, &res)) != NULL)
fn = XftFontOpenPattern(G_dpy, patx); fn = XftFontOpenPattern(X_Dpy, patx);
FcPatternDestroy(pat); FcPatternDestroy(pat);

View File

@ -33,7 +33,7 @@ _visible(struct client_ctx *this_cc)
if (cc->flags & CLIENT_HIDDEN) if (cc->flags & CLIENT_HIDDEN)
return (0); return (0);
TAILQ_FOREACH(cc, &G_clientq, entry) { TAILQ_FOREACH(cc, &Clientq, entry) {
if (cc->flags & CLIENT_HIDDEN) if (cc->flags & CLIENT_HIDDEN)
continue; continue;

169
grab.c
View File

@ -32,10 +32,10 @@ grab_sweep_draw(struct client_ctx *cc, int dx, int dy)
wide = MAX(wide_size, wide_name); wide = MAX(wide_size, wide_name);
height = font_ascent(font) + font_descent(font) + 1; height = font_ascent(font) + font_descent(font) + 1;
XMoveResizeWindow(G_dpy, sc->menuwin, x0, y0, wide, height * 2); XMoveResizeWindow(X_Dpy, sc->menuwin, x0, y0, wide, height * 2);
XMapWindow(G_dpy, sc->menuwin); XMapWindow(X_Dpy, sc->menuwin);
XReparentWindow(G_dpy, sc->menuwin, cc->win, 0, 0); XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0);
XClearWindow(G_dpy, sc->menuwin); XClearWindow(X_Dpy, sc->menuwin);
font_draw(font, cc->name, strlen(cc->name), sc->menuwin, font_draw(font, cc->name, strlen(cc->name), sc->menuwin,
2, font_ascent(font) + 1); 2, font_ascent(font) + 1);
font_draw(font, asize, strlen(asize), sc->menuwin, font_draw(font, asize, strlen(asize), sc->menuwin,
@ -56,7 +56,7 @@ grab_sweep(struct client_ctx *cc)
client_raise(cc); client_raise(cc);
client_ptrsave(cc); client_ptrsave(cc);
if (xu_ptr_grab(sc->rootwin, MouseMask, G_cursor_resize) < 0) if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_resize) < 0)
return (-1); return (-1);
xu_ptr_setpos(cc->win, cc->geom.width, cc->geom.height); xu_ptr_setpos(cc->win, cc->geom.width, cc->geom.height);
@ -64,27 +64,30 @@ grab_sweep(struct client_ctx *cc)
for (;;) { for (;;) {
/* Look for changes in ptr position. */ /* Look for changes in ptr position. */
XMaskEvent(G_dpy, MouseMask, &ev); XMaskEvent(X_Dpy, MouseMask|ExposureMask, &ev);
switch (ev.type) { switch (ev.type) {
case Expose:
client_draw_border(cc);
break;
case MotionNotify: case MotionNotify:
if (_sweepcalc(cc, x0, y0, ev.xmotion.x, ev.xmotion.y)) if (_sweepcalc(cc, x0, y0, ev.xmotion.x, ev.xmotion.y))
/* Recompute window output */ /* Recompute window output */
grab_sweep_draw(cc, dx, dy); grab_sweep_draw(cc, dx, dy);
XMoveResizeWindow(G_dpy, cc->pwin, XMoveResizeWindow(X_Dpy, cc->pwin,
cc->geom.x - cc->bwidth, cc->geom.x - cc->bwidth,
cc->geom.y - cc->bwidth, cc->geom.y - cc->bwidth,
cc->geom.width + cc->bwidth*2, cc->geom.width + cc->bwidth*2,
cc->geom.height + cc->bwidth*2); cc->geom.height + cc->bwidth*2);
XMoveResizeWindow(G_dpy, cc->win, XMoveResizeWindow(X_Dpy, cc->win,
cc->bwidth, cc->bwidth, cc->bwidth, cc->bwidth,
cc->geom.width, cc->geom.height); cc->geom.width, cc->geom.height);
break; break;
case ButtonRelease: case ButtonRelease:
XUnmapWindow(G_dpy, sc->menuwin); XUnmapWindow(X_Dpy, sc->menuwin);
XReparentWindow(G_dpy, sc->menuwin, sc->rootwin, 0, 0); XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0);
xu_ptr_ungrab(); xu_ptr_ungrab();
client_ptrwarp(cc); client_ptrwarp(cc);
return (0); return (0);
@ -102,20 +105,23 @@ grab_drag(struct client_ctx *cc)
client_raise(cc); client_raise(cc);
if (xu_ptr_grab(sc->rootwin, MouseMask, G_cursor_move) < 0) if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_move) < 0)
return (-1); return (-1);
xu_ptr_getpos(sc->rootwin, &xm, &ym); xu_ptr_getpos(sc->rootwin, &xm, &ym);
for (;;) { for (;;) {
XMaskEvent(G_dpy, MouseMask, &ev); XMaskEvent(X_Dpy, MouseMask|ExposureMask, &ev);
switch (ev.type) { switch (ev.type) {
case Expose:
client_draw_border(cc);
break;
case MotionNotify: case MotionNotify:
cc->geom.x = x0 + (ev.xmotion.x - xm); cc->geom.x = x0 + (ev.xmotion.x - xm);
cc->geom.y = y0 + (ev.xmotion.y - ym); cc->geom.y = y0 + (ev.xmotion.y - ym);
XMoveWindow(G_dpy, cc->pwin, XMoveWindow(X_Dpy, cc->pwin,
cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth); cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth);
break; break;
@ -185,8 +191,8 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq)
y = e->y - cur*high - high/2; y = e->y - cur*high - high/2;
warp = 0; warp = 0;
/* XXX - cache these in sc. */ /* XXX - cache these in sc. */
xmax = DisplayWidth(G_dpy, sc->which); xmax = DisplayWidth(X_Dpy, sc->which);
ymax = DisplayHeight(G_dpy, sc->which); ymax = DisplayHeight(X_Dpy, sc->which);
if (x < 0) { if (x < 0) {
e->x -= x; e->x -= x;
x = 0; x = 0;
@ -210,12 +216,12 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq)
if (warp) if (warp)
xu_ptr_setpos(e->root, e->x, e->y); xu_ptr_setpos(e->root, e->x, e->y);
XMoveResizeWindow(G_dpy, sc->menuwin, x, y, dx, dy); XMoveResizeWindow(X_Dpy, sc->menuwin, x, y, dx, dy);
XSelectInput(G_dpy, sc->menuwin, MenuMask); XSelectInput(X_Dpy, sc->menuwin, MenuMask);
XMapRaised(G_dpy, sc->menuwin); XMapRaised(X_Dpy, sc->menuwin);
status = xu_ptr_grab(sc->menuwin, MenuGrabMask, G_cursor_select); status = xu_ptr_grab(sc->menuwin, MenuGrabMask, Cursor_select);
if (status < 0) { if (status < 0) {
XUnmapWindow(G_dpy, sc->menuwin); XUnmapWindow(X_Dpy, sc->menuwin);
return (NULL); return (NULL);
} }
drawn = 0; drawn = 0;
@ -226,13 +232,13 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq)
cc = grab_menu_getcc(menuq, cur); cc = grab_menu_getcc(menuq, cur);
if (cc != NULL) { if (cc != NULL) {
client_unhide(cc); client_unhide(cc);
XRaiseWindow(G_dpy, sc->menuwin); XRaiseWindow(X_Dpy, sc->menuwin);
} }
} }
#endif #endif
for (;;) { for (;;) {
XMaskEvent(G_dpy, MenuMask, &ev); XMaskEvent(X_Dpy, MenuMask, &ev);
switch (ev.type) { switch (ev.type) {
default: default:
warnx("menuhit: unknown ev.type %d\n", ev.type); warnx("menuhit: unknown ev.type %d\n", ev.type);
@ -259,7 +265,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq)
/* XXX */ /* XXX */
/* ungrab(&ev.xbutton); */ /* ungrab(&ev.xbutton); */
xu_ptr_ungrab(); xu_ptr_ungrab();
XUnmapWindow(G_dpy, sc->menuwin); XUnmapWindow(X_Dpy, sc->menuwin);
n = 0; n = 0;
TAILQ_FOREACH(mi, menuq, entry) TAILQ_FOREACH(mi, menuq, entry)
if (i == n++) if (i == n++)
@ -290,7 +296,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq)
client_hide(cc); client_hide(cc);
} }
#endif #endif
XFillRectangle(G_dpy, sc->menuwin, XFillRectangle(X_Dpy, sc->menuwin,
sc->hlgc, 0, old*high, wide, high); sc->hlgc, 0, old*high, wide, high);
} }
if (cur >= 0 && cur < n) { if (cur >= 0 && cur < n) {
@ -300,19 +306,19 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq)
cc = grab_menu_getcc(menuq, cur); cc = grab_menu_getcc(menuq, cur);
if (cc != NULL) { if (cc != NULL) {
client_unhide(cc); client_unhide(cc);
XRaiseWindow(G_dpy, XRaiseWindow(X_Dpy,
sc->menuwin); sc->menuwin);
} }
} }
#endif #endif
xu_ptr_regrab(MenuGrabMask, G_cursor_select); xu_ptr_regrab(MenuGrabMask, Cursor_select);
XFillRectangle(G_dpy, sc->menuwin, XFillRectangle(X_Dpy, sc->menuwin,
sc->hlgc, 0, cur*high, wide, high); sc->hlgc, 0, cur*high, wide, high);
} else } else
xu_ptr_regrab(MenuGrabMask, G_cursor_default); xu_ptr_regrab(MenuGrabMask, Cursor_default);
break; break;
case Expose: case Expose:
XClearWindow(G_dpy, sc->menuwin); XClearWindow(X_Dpy, sc->menuwin);
i = 0; i = 0;
TAILQ_FOREACH(mi, menuq, entry) { TAILQ_FOREACH(mi, menuq, entry) {
tx = (wide - font_width(font, mi->text, tx = (wide - font_width(font, mi->text,
@ -323,7 +329,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq)
i++; i++;
} }
if (cur >= 0 && cur < n) if (cur >= 0 && cur < n)
XFillRectangle(G_dpy, sc->menuwin, XFillRectangle(X_Dpy, sc->menuwin,
sc->hlgc, 0, cur*high, wide, high); sc->hlgc, 0, cur*high, wide, high);
drawn = 1; drawn = 1;
} }
@ -333,7 +339,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq)
void void
grab_menuinit(struct screen_ctx *sc) grab_menuinit(struct screen_ctx *sc)
{ {
sc->menuwin = XCreateSimpleWindow(G_dpy, sc->rootwin, 0, 0, sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0,
1, 1, 1, sc->blackpixl, sc->whitepixl); 1, 1, 1, sc->blackpixl, sc->whitepixl);
} }
@ -364,21 +370,21 @@ grab_label(struct client_ctx *cc)
dy = fontheight = font_ascent(font) + font_descent(font) + 1; dy = fontheight = font_ascent(font) + font_descent(font) + 1;
dx = font_width(font, "label>", 6); dx = font_width(font, "label>", 6);
XMoveResizeWindow(G_dpy, sc->searchwin, x, y, dx, dy); XMoveResizeWindow(X_Dpy, sc->searchwin, x, y, dx, dy);
XSelectInput(G_dpy, sc->searchwin, LabelMask); XSelectInput(X_Dpy, sc->searchwin, LabelMask);
XMapRaised(G_dpy, sc->searchwin); XMapRaised(X_Dpy, sc->searchwin);
XGetInputFocus(G_dpy, &focuswin, &focusrevert); XGetInputFocus(X_Dpy, &focuswin, &focusrevert);
XSetInputFocus(G_dpy, sc->searchwin, XSetInputFocus(X_Dpy, sc->searchwin,
RevertToPointerRoot, CurrentTime); RevertToPointerRoot, CurrentTime);
for (;;) { for (;;) {
XMaskEvent(G_dpy, LabelMask, &e); XMaskEvent(X_Dpy, LabelMask, &e);
switch (e.type) { switch (e.type) {
case KeyPress: case KeyPress:
if (input_keycodetrans(e.xkey.keycode, e.xkey.state, if (input_keycodetrans(e.xkey.keycode, e.xkey.state,
&ctl, &chr, 1) < 0) &ctl, &chr, 0) < 0)
continue; continue;
switch (ctl) { switch (ctl) {
@ -415,8 +421,8 @@ grab_label(struct client_ctx *cc)
dx = font_width(font, dispstr, strlen(dispstr)); dx = font_width(font, dispstr, strlen(dispstr));
dy = fontheight; dy = fontheight;
XClearWindow(G_dpy, sc->searchwin); XClearWindow(X_Dpy, sc->searchwin);
XResizeWindow(G_dpy, sc->searchwin, dx, dy); XResizeWindow(X_Dpy, sc->searchwin, dx, dy);
font_draw(font, dispstr, strlen(dispstr), font_draw(font, dispstr, strlen(dispstr),
sc->searchwin, 0, font_ascent(font) + 1); sc->searchwin, 0, font_ascent(font) + 1);
@ -425,9 +431,88 @@ grab_label(struct client_ctx *cc)
} }
out: out:
XSetInputFocus(G_dpy, focuswin, XSetInputFocus(X_Dpy, focuswin,
focusrevert, CurrentTime); focusrevert, CurrentTime);
XUnmapWindow(G_dpy, sc->searchwin); XUnmapWindow(X_Dpy, sc->searchwin);
}
#define ExecMask (KeyPressMask|ExposureMask)
void
grab_exec(void)
{
int x, y, dx, dy, fontheight, focusrevert, len;
char cmdstr[MAXPATHLEN];
char dispstr[MAXPATHLEN + sizeof("exec>") - 1];
char chr, str[2];
enum ctltype ctl;
struct fontdesc *font = DefaultFont;
struct screen_ctx *sc = screen_current();
XEvent e;
Window focuswin;
cmdstr[0] = '\0';
xu_ptr_getpos(sc->rootwin, &x, &y);
dy = fontheight = font_ascent(font) + font_descent(font) + 1;
dx = font_width(font, "exec>", 5);
XMoveResizeWindow(X_Dpy, sc->searchwin, x, y, dx, dy);
XSelectInput(X_Dpy, sc->searchwin, ExecMask);
XMapRaised(X_Dpy, sc->searchwin);
XGetInputFocus(X_Dpy, &focuswin, &focusrevert);
XSetInputFocus(X_Dpy, sc->searchwin,
RevertToPointerRoot, CurrentTime);
for (;;) {
XMaskEvent(X_Dpy, ExecMask, &e);
switch (e.type) {
case KeyPress:
if (input_keycodetrans(e.xkey.keycode, e.xkey.state,
&ctl, &chr, 0) < 0)
continue;
switch (ctl) {
case CTL_ERASEONE:
if ((len = strlen(cmdstr)) > 0)
cmdstr[len - 1] = '\0';
break;
case CTL_RETURN:
if (strlen(cmdstr) > 0)
u_spawn(cmdstr);
goto out;
break;
case CTL_ABORT:
goto out;
default:
break;
}
if (chr != '\0') {
str[0] = chr;
str[1] = '\0';
strlcat(cmdstr, str, sizeof(cmdstr));
}
case Expose:
snprintf(dispstr, sizeof(dispstr), "exec>%s", cmdstr);
dx = font_width(font, dispstr, strlen(dispstr));
dy = fontheight;
XClearWindow(X_Dpy, sc->searchwin);
XResizeWindow(X_Dpy, sc->searchwin, dx, dy);
font_draw(font, dispstr, strlen(dispstr),
sc->searchwin, 0, font_ascent(font) + 1);
break;
}
}
out:
XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime);
XUnmapWindow(X_Dpy, sc->searchwin);
} }
int int

148
group.c
View File

@ -13,17 +13,17 @@
#define CALMWM_NGROUPS 9 #define CALMWM_NGROUPS 9
int G_groupmode = 0; int Groupmode = 0;
int G_groupnamemode = 0; int Groupnamemode = 0;
struct group_ctx *G_group_active = NULL; struct group_ctx *Group_active = NULL;
struct group_ctx *G_group_current = NULL; struct group_ctx *Group_current = NULL;
struct group_ctx G_groups[CALMWM_NGROUPS]; struct group_ctx Groups[CALMWM_NGROUPS];
char G_group_name[256]; char Group_name[256];
int G_groupfocusset = 0; int Groupfocusset = 0;
Window G_groupfocuswin; Window Groupfocuswin;
int G_groupfocusrevert; int Groupfocusrevert;
int G_grouphideall = 0; int Grouphideall = 0;
struct group_ctx_q G_groupq; struct group_ctx_q Groupq;
#define GroupMask (KeyPressMask|ExposureMask) #define GroupMask (KeyPressMask|ExposureMask)
@ -137,11 +137,11 @@ _group_show(struct group_ctx *gc)
} }
} }
XRestackWindows(G_dpy, winlist, gc->nhidden); XRestackWindows(X_Dpy, winlist, gc->nhidden);
xfree(winlist); xfree(winlist);
gc->hidden = 0; gc->hidden = 0;
G_group_active = gc; Group_active = gc;
} }
@ -170,16 +170,16 @@ group_init(void)
{ {
int i; int i;
TAILQ_INIT(&G_groupq); TAILQ_INIT(&Groupq);
for (i = 0; i < CALMWM_NGROUPS; i++) { for (i = 0; i < CALMWM_NGROUPS; i++) {
TAILQ_INIT(&G_groups[i].clients); TAILQ_INIT(&Groups[i].clients);
G_groups[i].hidden = 0; Groups[i].hidden = 0;
G_groups[i].shortcut = i + 1; Groups[i].shortcut = i + 1;
TAILQ_INSERT_TAIL(&G_groupq, &G_groups[i], entry); TAILQ_INSERT_TAIL(&Groupq, &Groups[i], entry);
} }
G_group_current = G_group_active = &G_groups[0]; Group_current = Group_active = &Groups[0];
} }
/* /*
@ -196,8 +196,8 @@ group_new(void)
int i; int i;
for (i=0; i < CALMWM_NGROUPS; i++) { for (i=0; i < CALMWM_NGROUPS; i++) {
if (TAILQ_EMPTY(&G_groups[i].clients)) { if (TAILQ_EMPTY(&Groups[i].clients)) {
G_group_current = &G_groups[i]; Group_current = &Groups[i];
return (0); return (0);
} }
@ -211,7 +211,7 @@ group_new(void)
int int
group_select(int idx) group_select(int idx)
{ {
struct group_ctx *gc = G_group_current; struct group_ctx *gc = Group_current;
struct client_ctx *cc; struct client_ctx *cc;
if (idx < 0 || idx >= CALMWM_NGROUPS) if (idx < 0 || idx >= CALMWM_NGROUPS)
@ -223,7 +223,7 @@ group_select(int idx)
} }
_group_commit(gc); _group_commit(gc);
G_group_current = &G_groups[idx]; Group_current = &Groups[idx];
group_display_draw(screen_current()); group_display_draw(screen_current());
return (0); return (0);
@ -233,16 +233,16 @@ group_select(int idx)
void void
group_enter(void) group_enter(void)
{ {
if (G_groupmode != 0) if (Groupmode != 0)
errx(1, "group_enter called twice"); errx(1, "group_enter called twice");
if (G_group_current == NULL) if (Group_current == NULL)
G_group_current = &G_groups[0]; Group_current = &Groups[0];
/* setup input buffer */ /* setup input buffer */
G_group_name[0] = '\0'; Group_name[0] = '\0';
G_groupmode = 1; Groupmode = 1;
group_display_init(screen_current()); group_display_init(screen_current());
group_display_draw(screen_current()); group_display_draw(screen_current());
@ -252,10 +252,10 @@ group_enter(void)
void void
group_exit(int commit) group_exit(int commit)
{ {
struct group_ctx *gc = G_group_current; struct group_ctx *gc = Group_current;
struct client_ctx *cc; struct client_ctx *cc;
if (G_groupmode != 1) if (Groupmode != 1)
errx(1, "group_exit called twice"); errx(1, "group_exit called twice");
TAILQ_FOREACH(cc, &gc->clients, group_entry) { TAILQ_FOREACH(cc, &gc->clients, group_entry) {
@ -272,21 +272,21 @@ group_exit(int commit)
_group_destroy(gc); _group_destroy(gc);
} }
XUnmapWindow(G_dpy, screen_current()->groupwin); XUnmapWindow(X_Dpy, screen_current()->groupwin);
if (G_groupnamemode) { if (Groupnamemode) {
XSetInputFocus(G_dpy, G_groupfocuswin, G_groupfocusrevert, XSetInputFocus(X_Dpy, Groupfocuswin, Groupfocusrevert,
CurrentTime); CurrentTime);
G_groupfocusset = 0; Groupfocusset = 0;
} }
G_groupmode = G_groupnamemode = 0; Groupmode = Groupnamemode = 0;
} }
void void
group_click(struct client_ctx *cc) group_click(struct client_ctx *cc)
{ {
struct group_ctx *gc = G_group_current; struct group_ctx *gc = Group_current;
if (gc == cc->group) if (gc == cc->group)
_group_remove(cc); _group_remove(cc);
@ -301,13 +301,13 @@ group_click(struct client_ctx *cc)
void void
group_sticky(struct client_ctx *cc) group_sticky(struct client_ctx *cc)
{ {
_group_add(G_group_active, cc); _group_add(Group_active, cc);
} }
void void
group_sticky_toggle_enter(struct client_ctx *cc) group_sticky_toggle_enter(struct client_ctx *cc)
{ {
struct group_ctx *gc = G_group_active; struct group_ctx *gc = Group_active;
if (gc == cc->group) { if (gc == cc->group) {
_group_remove(cc); _group_remove(cc);
@ -334,14 +334,14 @@ group_sticky_toggle_exit(struct client_ctx *cc)
void void
group_display_init(struct screen_ctx *sc) group_display_init(struct screen_ctx *sc)
{ {
sc->groupwin = XCreateSimpleWindow(G_dpy, sc->rootwin, 0, 0, sc->groupwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0,
1, 1, 1, sc->blackpixl, sc->whitepixl); 1, 1, 1, sc->blackpixl, sc->whitepixl);
} }
void void
group_display_draw(struct screen_ctx *sc) group_display_draw(struct screen_ctx *sc)
{ {
struct group_ctx *gc = G_group_current; struct group_ctx *gc = Group_current;
int x, y, dx, dy, fontheight, titlelen; int x, y, dx, dy, fontheight, titlelen;
struct client_ctx *cc; struct client_ctx *cc;
char titlebuf[1024]; char titlebuf[1024];
@ -360,13 +360,13 @@ group_display_draw(struct screen_ctx *sc)
client_draw_border(cc); client_draw_border(cc);
} }
XMoveResizeWindow(G_dpy, sc->groupwin, x, y, dx, dy); XMoveResizeWindow(X_Dpy, sc->groupwin, x, y, dx, dy);
/* XXX */ /* XXX */
XSelectInput(G_dpy, sc->groupwin, GroupMask); XSelectInput(X_Dpy, sc->groupwin, GroupMask);
XMapRaised(G_dpy, sc->groupwin); XMapRaised(X_Dpy, sc->groupwin);
XClearWindow(G_dpy, sc->groupwin); XClearWindow(X_Dpy, sc->groupwin);
font_draw(font, titlebuf, strlen(titlebuf), sc->groupwin, font_draw(font, titlebuf, strlen(titlebuf), sc->groupwin,
0, font_ascent(font) + 1); 0, font_ascent(font) + 1);
} }
@ -374,12 +374,12 @@ group_display_draw(struct screen_ctx *sc)
void void
group_display_keypress(KeyCode k) group_display_keypress(KeyCode k)
{ {
struct group_ctx * gc = G_group_current; struct group_ctx * gc = Group_current;
char chr; char chr;
enum ctltype ctl; enum ctltype ctl;
int len; int len;
if (!G_groupnamemode) if (!Groupnamemode)
return; return;
if (input_keycodetrans(k, 0, &ctl, &chr, 1) < 0) if (input_keycodetrans(k, 0, &ctl, &chr, 1) < 0)
@ -387,14 +387,14 @@ group_display_keypress(KeyCode k)
switch (ctl) { switch (ctl) {
case CTL_ERASEONE: case CTL_ERASEONE:
if ((len = strlen(G_group_name)) > 0) if ((len = strlen(Group_name)) > 0)
G_group_name[len - 1] = '\0'; Group_name[len - 1] = '\0';
break; break;
case CTL_RETURN: case CTL_RETURN:
if (gc->name != NULL) if (gc->name != NULL)
xfree(gc->name); xfree(gc->name);
gc->name = xstrdup(G_group_name); gc->name = xstrdup(Group_name);
group_exit(1); group_exit(1);
return; return;
@ -403,8 +403,8 @@ group_display_keypress(KeyCode k)
} }
if (chr != '\0') if (chr != '\0')
snprintf(G_group_name, sizeof(G_group_name), "%s%c", snprintf(Group_name, sizeof(Group_name), "%s%c",
G_group_name, chr); Group_name, chr);
out: out:
group_display_draw(screen_current()); group_display_draw(screen_current());
@ -438,7 +438,7 @@ group_hidetoggle(int idx)
if (idx < 0 || idx >= CALMWM_NGROUPS) if (idx < 0 || idx >= CALMWM_NGROUPS)
err(1, "group_hidetoggle: index out of range (%d)", idx); err(1, "group_hidetoggle: index out of range (%d)", idx);
gc = &G_groups[idx]; gc = &Groups[idx];
_group_fix_hidden_state(gc); _group_fix_hidden_state(gc);
@ -447,7 +447,7 @@ group_hidetoggle(int idx)
else { else {
_group_hide(gc); _group_hide(gc);
if (TAILQ_EMPTY(&gc->clients)) if (TAILQ_EMPTY(&gc->clients))
G_group_active = gc; Group_active = gc;
} }
#ifdef notyet #ifdef notyet
@ -468,15 +468,15 @@ group_slide(int fwd)
{ {
struct group_ctx *gc, *showgroup = NULL; struct group_ctx *gc, *showgroup = NULL;
assert(G_group_active != NULL); assert(Group_active != NULL);
gc = G_group_active; gc = Group_active;
for (;;) { for (;;) {
gc = GROUP_NEXT(gc, fwd); gc = GROUP_NEXT(gc, fwd);
if (gc == NULL) if (gc == NULL)
gc = fwd ? TAILQ_FIRST(&G_groupq) : gc = fwd ? TAILQ_FIRST(&Groupq) :
TAILQ_LAST(&G_groupq, group_ctx_q); TAILQ_LAST(&Groupq, group_ctx_q);
if (gc == G_group_active) if (gc == Group_active)
break; break;
if (!TAILQ_EMPTY(&gc->clients) && showgroup == NULL) if (!TAILQ_EMPTY(&gc->clients) && showgroup == NULL)
@ -488,12 +488,12 @@ group_slide(int fwd)
if (showgroup == NULL) if (showgroup == NULL)
return; return;
_group_hide(G_group_active); _group_hide(Group_active);
if (showgroup->hidden) if (showgroup->hidden)
_group_show(showgroup); _group_show(showgroup);
else else
G_group_active = showgroup; Group_active = showgroup;
} }
/* called when a client is deleted */ /* called when a client is deleted */
@ -519,7 +519,7 @@ group_menu(XButtonEvent *e)
TAILQ_INIT(&menuq); TAILQ_INIT(&menuq);
for (i = 0; i < CALMWM_NGROUPS; i++) { for (i = 0; i < CALMWM_NGROUPS; i++) {
gc = &G_groups[i]; gc = &Groups[i];
if (TAILQ_EMPTY(&gc->clients)) if (TAILQ_EMPTY(&gc->clients))
continue; continue;
@ -563,7 +563,7 @@ group_menu(XButtonEvent *e)
void void
group_namemode(void) group_namemode(void)
{ {
G_groupnamemode = 1; Groupnamemode = 1;
group_display_draw(screen_current()); group_display_draw(screen_current());
} }
@ -574,31 +574,31 @@ group_alltoggle(void)
int i; int i;
for (i=0; i < CALMWM_NGROUPS; i++) { for (i=0; i < CALMWM_NGROUPS; i++) {
if (G_grouphideall) if (Grouphideall)
_group_show(&G_groups[i]); _group_show(&Groups[i]);
else else
_group_hide(&G_groups[i]); _group_hide(&Groups[i]);
} }
if (G_grouphideall) if (Grouphideall)
G_grouphideall = 0; Grouphideall = 0;
else else
G_grouphideall = 1; Grouphideall = 1;
} }
void void
group_deletecurrent(void) group_deletecurrent(void)
{ {
_group_destroy(G_group_current); _group_destroy(Group_current);
XUnmapWindow(G_dpy, screen_current()->groupwin); XUnmapWindow(X_Dpy, screen_current()->groupwin);
G_groupmode = G_groupnamemode = 0; Groupmode = Groupnamemode = 0;
} }
void void
group_done(void) group_done(void)
{ {
struct group_ctx *gc = G_group_current; struct group_ctx *gc = Group_current;
if (gc->name != NULL) if (gc->name != NULL)
xfree(gc->name); xfree(gc->name);
@ -618,7 +618,7 @@ group_autogroup(struct client_ctx *cc)
if (cc->app_class == NULL || cc->app_name == NULL) if (cc->app_class == NULL || cc->app_name == NULL)
return; return;
TAILQ_FOREACH(aw, &G_conf.autogroupq, entry) { TAILQ_FOREACH(aw, &Conf.autogroupq, entry) {
if (strcmp(aw->class, cc->app_class) == 0 && if (strcmp(aw->class, cc->app_class) == 0 &&
(aw->name == NULL || strcmp(aw->name, cc->app_name) == 0)) { (aw->name == NULL || strcmp(aw->name, cc->app_name) == 0)) {
strlcpy(group, aw->group, sizeof(group)); strlcpy(group, aw->group, sizeof(group));
@ -626,7 +626,7 @@ group_autogroup(struct client_ctx *cc)
} }
} }
TAILQ_FOREACH(gc, &G_groupq, entry) { TAILQ_FOREACH(gc, &Groupq, entry) {
if (strcmp(shortcut_to_name[gc->shortcut], group) == 0) if (strcmp(shortcut_to_name[gc->shortcut], group) == 0)
_group_add(gc, cc); _group_add(gc, cc);
} }

View File

@ -12,10 +12,6 @@
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#include <sys/queue.h> #include <sys/queue.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/param.h> #include <sys/param.h>
@ -43,10 +39,6 @@
#include <X11/Xos.h> #include <X11/Xos.h>
#include <X11/Xft/Xft.h> #include <X11/Xft/Xft.h>
#ifdef USE_XOSD
#include <xosd.h>
#endif /* USE_XOSD */
#include <err.h> #include <err.h>
#endif /* _CALMWM_HEADERS_H_ */ #endif /* _CALMWM_HEADERS_H_ */

View File

@ -19,7 +19,10 @@ input_keycodetrans(KeyCode kc, u_int state,
*ctl = CTL_NONE; *ctl = CTL_NONE;
*chr = '\0'; *chr = '\0';
ks = XKeycodeToKeysym(G_dpy, kc, 0); if (state & ShiftMask)
ks = XKeycodeToKeysym(X_Dpy, kc, 1);
else
ks = XKeycodeToKeysym(X_Dpy, kc, 0);
/* Look for control characters. */ /* Look for control characters. */
switch (ks) { switch (ks) {

View File

@ -1,323 +0,0 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2005-05-14.22
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
chmodcmd="$chmodprog 0755"
chowncmd=
chgrpcmd=
stripcmd=
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=
dst=
dir_arg=
dstarg=
no_target_directory=
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
-c (ignored)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
--help display this help and exit.
--version display version info and exit.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
while test -n "$1"; do
case $1 in
-c) shift
continue;;
-d) dir_arg=true
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
--help) echo "$usage"; exit $?;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t) dstarg=$2
shift
shift
continue;;
-T) no_target_directory=true
shift
continue;;
--version) echo "$0 $scriptversion"; exit $?;;
*) # When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
test -n "$dir_arg$dstarg" && break
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
break;;
esac
done
if test -z "$1"; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
esac
if test -n "$dir_arg"; then
dst=$src
src=
if test -d "$dst"; then
mkdircmd=:
chmodcmd=
else
mkdircmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dstarg: Is a directory" >&2
exit 1
fi
dst=$dst/`basename "$src"`
fi
fi
# This sed command emulates the dirname command.
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# Skip lots of stat calls in the usual case.
if test ! -d "$dstdir"; then
defaultIFS='
'
IFS="${IFS-$defaultIFS}"
oIFS=$IFS
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
shift
IFS=$oIFS
pathcomp=
while test $# -ne 0 ; do
pathcomp=$pathcomp$1
shift
if test ! -d "$pathcomp"; then
$mkdirprog "$pathcomp"
# mkdir can fail with a `File exist' error in case several
# install-sh are creating the directory concurrently. This
# is OK.
test -d "$pathcomp" || exit
fi
pathcomp=$pathcomp/
done
fi
if test -n "$dir_arg"; then
$doit $mkdircmd "$dst" \
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
else
dstfile=`basename "$dst"`
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
trap '(exit $?); exit' 1 2 13 15
# Copy the file name to the temp name.
$doit $cpprog "$src" "$dsttmp" &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
# Now rename the file to the real destination.
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|| {
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
if test -f "$dstdir/$dstfile"; then
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|| {
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit 1
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
}
}
fi || { (exit 1); exit 1; }
done
# The final little trick to "correctly" pass the exit status to the exit trap.
{
(exit 0); exit 0
}
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

226
kbfunc.c
View File

@ -7,9 +7,15 @@
* $Id$ * $Id$
*/ */
#include <paths.h>
#include "headers.h" #include "headers.h"
#include "calmwm.h" #include "calmwm.h"
#define KNOWN_HOSTS ".ssh/known_hosts"
#define HASH_MARKER "|1|"
#define MOVE_AMOUNT 10
void void
kbfunc_client_lower(struct client_ctx *cc, void *arg) kbfunc_client_lower(struct client_ctx *cc, void *arg)
{ {
@ -22,6 +28,45 @@ kbfunc_client_raise(struct client_ctx *cc, void *arg)
client_raise(cc); client_raise(cc);
} }
void
kbfunc_client_move(struct client_ctx *cc, void *arg)
{
int x,y,flags,amt;
u_int mx,my;
mx = my = 0;
flags = (int)arg;
amt = MOVE_AMOUNT;
if (flags & CWM_BIGMOVE) {
flags -= CWM_BIGMOVE;
amt = amt*10;
}
switch(flags) {
case CWM_UP:
my -= amt;
break;
case CWM_DOWN:
my += amt;
break;
case CWM_RIGHT:
mx += amt;
break;
case CWM_LEFT:
mx -= amt;
break;
}
cc->geom.y += my;
cc->geom.x += mx;
client_move(cc);
xu_ptr_getpos(cc->pwin, &x, &y);
cc->ptr.y = y + my;
cc->ptr.x = x + mx;
client_ptrwarp(cc);
}
void void
kbfunc_client_search(struct client_ctx *scratch, void *arg) kbfunc_client_search(struct client_ctx *scratch, void *arg)
{ {
@ -31,7 +76,7 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg)
TAILQ_INIT(&menuq); TAILQ_INIT(&menuq);
TAILQ_FOREACH(cc, &G_clientq, entry) { TAILQ_FOREACH(cc, &Clientq, entry) {
struct menu *mi; struct menu *mi;
XCALLOC(mi, struct menu); XCALLOC(mi, struct menu);
strlcpy(mi->text, cc->name, sizeof(mi->text)); strlcpy(mi->text, cc->name, sizeof(mi->text));
@ -41,7 +86,7 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg)
if ((mi = search_start(&menuq, if ((mi = search_start(&menuq,
search_match_client, NULL, search_match_client, NULL,
search_print_client, "window")) != NULL) { search_print_client, "window", 0)) != NULL) {
cc = (struct client_ctx *)mi->ctx; cc = (struct client_ctx *)mi->ctx;
if (cc->flags & CLIENT_HIDDEN) if (cc->flags & CLIENT_HIDDEN)
client_unhide(cc); client_unhide(cc);
@ -66,8 +111,8 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg)
TAILQ_INIT(&menuq); TAILQ_INIT(&menuq);
conf_cmd_refresh(&G_conf); conf_cmd_refresh(&Conf);
TAILQ_FOREACH(cmd, &G_conf.cmdq, entry) { TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
XCALLOC(mi, struct menu); XCALLOC(mi, struct menu);
strlcpy(mi->text, cmd->label, sizeof(mi->text)); strlcpy(mi->text, cmd->label, sizeof(mi->text));
mi->ctx = cmd; mi->ctx = cmd;
@ -75,7 +120,7 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg)
} }
if ((mi = search_start(&menuq, if ((mi = search_start(&menuq,
search_match_text, NULL, NULL, "application")) != NULL) search_match_text, NULL, NULL, "application", 0)) != NULL)
u_spawn(((struct cmd *)mi->ctx)->image); u_spawn(((struct cmd *)mi->ctx)->image);
while ((mi = TAILQ_FIRST(&menuq)) != NULL) { while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
@ -85,15 +130,15 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg)
} }
void void
kbfunc_client_cycle(struct client_ctx *cc, void *arg) kbfunc_client_cycle(struct client_ctx *scratch, void *arg)
{ {
client_cyclenext(cc, 0); client_cyclenext(0);
} }
void void
kbfunc_client_rcycle(struct client_ctx *cc, void *arg) kbfunc_client_rcycle(struct client_ctx *scratch, void *arg)
{ {
client_cyclenext(cc, 1); client_cyclenext(1);
} }
void void
@ -111,15 +156,164 @@ kbfunc_cmdexec(struct client_ctx *cc, void *arg)
void void
kbfunc_term(struct client_ctx *cc, void *arg) kbfunc_term(struct client_ctx *cc, void *arg)
{ {
conf_cmd_refresh(&G_conf); conf_cmd_refresh(&Conf);
u_spawn(G_conf.termpath); u_spawn(Conf.termpath);
} }
void void
kbfunc_lock(struct client_ctx *cc, void *arg) kbfunc_lock(struct client_ctx *cc, void *arg)
{ {
conf_cmd_refresh(&G_conf); conf_cmd_refresh(&Conf);
u_spawn(G_conf.lockpath); u_spawn(Conf.lockpath);
}
void
kbfunc_exec(struct client_ctx *scratch, void *arg)
{
char **ap, *paths[256], *path, tpath[MAXPATHLEN];
int l, i, j, ngroups;
gid_t mygroups[NGROUPS_MAX];
uid_t ruid, euid, suid;
DIR *dirp;
struct dirent *dp;
struct stat sb;
struct menu_q menuq;
struct menu *mi;
if (getgroups(0, mygroups) == -1)
err(1, "getgroups failure");
if ((ngroups = getresuid(&ruid, &euid, &suid)) == -1)
err(1, "getresuid failure");
TAILQ_INIT(&menuq);
/* just use default path until we have config to set this */
path = xstrdup(_PATH_DEFPATH);
for (ap = paths; ap < &paths[sizeof(paths) - 1] &&
(*ap = strsep(&path, ":")) != NULL;) {
if (**ap != '\0')
ap++;
}
*ap = NULL;
for (i = 0; i < sizeof(paths) && paths[i] != NULL; i++) {
if ((dirp = opendir(paths[i])) == NULL)
continue;
while ((dp = readdir(dirp)) != NULL) {
/* skip everything but regular files and symlinks */
if (dp->d_type != DT_REG && dp->d_type != DT_LNK)
continue;
memset(tpath, '\0', sizeof(tpath));
l = snprintf(tpath, sizeof(tpath), "%s/%s", paths[i],
dp->d_name);
/* check for truncation etc */
if (l == -1 || l >= (int)sizeof(tpath))
continue;
/* just ignore on stat failure */
if (stat(tpath, &sb) == -1)
continue;
/* may we execute this file? */
if (euid == sb.st_uid)
if (sb.st_mode & S_IXUSR)
goto executable;
else
continue;
for (j = 0; j < ngroups; j++)
if (mygroups[j] == sb.st_gid)
if (sb.st_mode & S_IXGRP)
goto executable;
else
continue;
if (sb.st_mode & S_IXOTH)
goto executable;
continue;
executable:
/* the thing in tpath, we may execute */
XCALLOC(mi, struct menu);
strlcpy(mi->text, dp->d_name, sizeof(mi->text));
TAILQ_INSERT_TAIL(&menuq, mi, entry);
}
(void) closedir(dirp);
}
if ((mi = search_start(&menuq,
search_match_exec, NULL, NULL, "exec", 1)) != NULL)
u_spawn(mi->text);
if (mi != NULL && mi->dummy)
xfree(mi);
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
TAILQ_REMOVE(&menuq, mi, entry);
xfree(mi);
}
xfree(path);
}
void
kbfunc_ssh(struct client_ctx *scratch, void *arg)
{
struct menu_q menuq;
struct menu *mi;
FILE *fp;
size_t len;
char *buf, *lbuf, *p, *home;
char hostbuf[MAXHOSTNAMELEN], filename[MAXPATHLEN], cmd[256];
int l;
if ((home = getenv("HOME")) == NULL)
return;
l = snprintf(filename, sizeof(filename), "%s/%s", home, KNOWN_HOSTS);
if (l == -1 || l >= sizeof(filename))
return;
if ((fp = fopen(filename, "r")) == NULL)
return;
TAILQ_INIT(&menuq);
lbuf = NULL;
while ((buf = fgetln(fp, &len))) {
if (buf[len - 1] == '\n')
buf[len - 1] = '\0';
else {
/* EOF without EOL, copy and add the NUL */
lbuf = xmalloc(len + 1);
memcpy(lbuf, buf, len);
lbuf[len] = '\0';
buf = lbuf;
}
/* skip hashed hosts */
if (strncmp(buf, HASH_MARKER, strlen(HASH_MARKER)) == 0)
continue;
for (p = buf; *p != ',' && *p != ' ' && p != buf + len; p++) {
/* do nothing */
}
/* ignore badness */
if (p - buf + 1 > sizeof(hostbuf))
continue;
(void) strlcpy(hostbuf, buf, p - buf + 1);
XCALLOC(mi, struct menu);
(void) strlcpy(mi->text, hostbuf, sizeof(mi->text));
TAILQ_INSERT_TAIL(&menuq, mi, entry);
}
xfree(lbuf);
fclose(fp);
if ((mi = search_start(&menuq,
search_match_exec, NULL, NULL, "ssh", 1)) != NULL) {
conf_cmd_refresh(&Conf);
l = snprintf(cmd, sizeof(cmd), "%s -e ssh %s", Conf.termpath,
mi->text);
if (l != -1 && l < sizeof(cmd))
u_spawn(cmd);
}
if (mi != NULL && mi->dummy)
xfree(mi);
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
TAILQ_REMOVE(&menuq, mi, entry);
xfree(mi);
}
} }
void void
@ -137,7 +331,7 @@ kbfunc_client_delete(struct client_ctx *cc, void *arg)
void void
kbfunc_client_groupselect(struct client_ctx *cc, void *arg) kbfunc_client_groupselect(struct client_ctx *cc, void *arg)
{ {
if (G_groupmode) if (Groupmode)
group_done(); group_done();
else else
group_enter(); group_enter();
@ -146,7 +340,7 @@ kbfunc_client_groupselect(struct client_ctx *cc, void *arg)
void void
kbfunc_client_group(struct client_ctx *cc, void *arg) kbfunc_client_group(struct client_ctx *cc, void *arg)
{ {
if (G_groupmode) if (Groupmode)
group_select(KBTOGROUP((int)arg)); group_select(KBTOGROUP((int)arg));
else else
group_hidetoggle(KBTOGROUP((int)arg)); group_hidetoggle(KBTOGROUP((int)arg));
@ -167,7 +361,7 @@ kbfunc_client_prevgroup(struct client_ctx *cc, void *arg)
void void
kbfunc_client_nogroup(struct client_ctx *cc, void *arg) kbfunc_client_nogroup(struct client_ctx *cc, void *arg)
{ {
if (G_groupmode) if (Groupmode)
group_deletecurrent(); group_deletecurrent();
else else
group_alltoggle(); group_alltoggle();

360
missing
View File

@ -1,360 +0,0 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2005-06-08.21
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case "$1" in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
esac
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program).
case "$1" in
lex|yacc)
# Not GNU programs, they don't have --version.
;;
tar)
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
exit 1
fi
;;
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case "$1" in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
fi
if [ -f "$file" ]; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
# If the file does not exist, the user really needs makeinfo;
# let's fail without touching anything.
test -f $file || exit 1
touch $file
;;
tar)
shift
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

View File

@ -10,14 +10,14 @@
#include "headers.h" #include "headers.h"
#include "calmwm.h" #include "calmwm.h"
extern struct screen_ctx_q G_screenq; extern struct screen_ctx_q Screenq;
extern struct screen_ctx *G_curscreen; extern struct screen_ctx *Curscreen;
static void static void
_clearwindow_cb(int sig) _clearwindow_cb(int sig)
{ {
struct screen_ctx *sc = screen_current(); struct screen_ctx *sc = screen_current();
XUnmapWindow(G_dpy, sc->infowin); XUnmapWindow(X_Dpy, sc->infowin);
} }
struct screen_ctx * struct screen_ctx *
@ -25,18 +25,18 @@ screen_fromroot(Window rootwin)
{ {
struct screen_ctx *sc; struct screen_ctx *sc;
TAILQ_FOREACH(sc, &G_screenq, entry) TAILQ_FOREACH(sc, &Screenq, entry)
if (sc->rootwin == rootwin) if (sc->rootwin == rootwin)
return (sc); return (sc);
/* XXX FAIL HERE */ /* XXX FAIL HERE */
return (TAILQ_FIRST(&G_screenq)); return (TAILQ_FIRST(&Screenq));
} }
struct screen_ctx * struct screen_ctx *
screen_current(void) screen_current(void)
{ {
return (G_curscreen); return (Curscreen);
} }
void void
@ -47,7 +47,7 @@ screen_updatestackingorder(void)
u_int nwins, i, s; u_int nwins, i, s;
struct client_ctx *cc; struct client_ctx *cc;
if (!XQueryTree(G_dpy, sc->rootwin, &w0, &w1, &wins, &nwins)) if (!XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins))
return; return;
for (s = 0, i = 0; i < nwins; i++) { for (s = 0, i = 0; i < nwins; i++) {
@ -70,7 +70,7 @@ screen_init(void)
sc->cycle_client = NULL; sc->cycle_client = NULL;
sc->infowin = XCreateSimpleWindow(G_dpy, sc->rootwin, 0, 0, sc->infowin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0,
1, 1, 1, sc->blackpixl, sc->whitepixl); 1, 1, 1, sc->blackpixl, sc->whitepixl);
/* XXX - marius. */ /* XXX - marius. */
@ -86,15 +86,15 @@ screen_infomsg(char *msg)
int dy, dx; int dy, dx;
struct fontdesc *font = DefaultFont; struct fontdesc *font = DefaultFont;
XUnmapWindow(G_dpy, sc->infowin); XUnmapWindow(X_Dpy, sc->infowin);
alarm(0); alarm(0);
snprintf(buf, sizeof(buf), ">%s", msg); snprintf(buf, sizeof(buf), ">%s", msg);
dy = font_ascent(font) + font_descent(font) + 1; dy = font_ascent(font) + font_descent(font) + 1;
dx = font_width(font, buf, strlen(buf)); dx = font_width(font, buf, strlen(buf));
XMoveResizeWindow(G_dpy, sc->infowin, 0, 0, dx, dy); XMoveResizeWindow(X_Dpy, sc->infowin, 0, 0, dx, dy);
XMapRaised(G_dpy, sc->infowin); XMapRaised(X_Dpy, sc->infowin);
font_draw(font, buf, strlen(buf), sc->infowin, font_draw(font, buf, strlen(buf), sc->infowin,
0, font_ascent(font) + 1); 0, font_ascent(font) + 1);

View File

@ -12,12 +12,12 @@
#define SearchMask (KeyPressMask|ExposureMask) #define SearchMask (KeyPressMask|ExposureMask)
static int _strsubmatch(char *, char *); static int _strsubmatch(char *, char *, int);
void void
search_init(struct screen_ctx *sc) search_init(struct screen_ctx *sc)
{ {
sc->searchwin = XCreateSimpleWindow(G_dpy, sc->rootwin, 0, 0, sc->searchwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0,
1, 1, 1, sc->blackpixl, sc->whitepixl); 1, 1, 1, sc->blackpixl, sc->whitepixl);
} }
@ -37,7 +37,7 @@ search_start(struct menu_q *menuq,
void (*match)(struct menu_q *, struct menu_q *, char *), void (*match)(struct menu_q *, struct menu_q *, char *),
void (*rank)(struct menu_q *resultq, char *search), void (*rank)(struct menu_q *resultq, char *search),
void (*print)(struct menu *mi, int print), void (*print)(struct menu *mi, int print),
char *prompt) char *prompt, int dummy)
{ {
struct screen_ctx *sc = screen_current(); struct screen_ctx *sc = screen_current();
int x, y, dx, dy, fontheight, int x, y, dx, dy, fontheight,
@ -47,7 +47,7 @@ search_start(struct menu_q *menuq,
char dispstr[MENU_MAXENTRY*2 + 1]; char dispstr[MENU_MAXENTRY*2 + 1];
char promptstr[MENU_MAXENTRY + 1]; char promptstr[MENU_MAXENTRY + 1];
Window focuswin; Window focuswin;
struct menu *mi = NULL; struct menu *mi = NULL, *dummy_mi = NULL;
struct menu_q resultq; struct menu_q resultq;
char chr; char chr;
enum ctltype ctl; enum ctltype ctl;
@ -63,8 +63,8 @@ search_start(struct menu_q *menuq,
TAILQ_INIT(&resultq); TAILQ_INIT(&resultq);
xmax = DisplayWidth(G_dpy, sc->which); xmax = DisplayWidth(X_Dpy, sc->which);
ymax = DisplayHeight(G_dpy, sc->which); ymax = DisplayHeight(X_Dpy, sc->which);
xu_ptr_getpos(sc->rootwin, &x, &y); xu_ptr_getpos(sc->rootwin, &x, &y);
@ -75,27 +75,27 @@ search_start(struct menu_q *menuq,
snprintf(dispstr, sizeof(dispstr), "%s%c", promptstr, endchar); snprintf(dispstr, sizeof(dispstr), "%s%c", promptstr, endchar);
dx = font_width(font, dispstr, strlen(dispstr)); dx = font_width(font, dispstr, strlen(dispstr));
XMoveResizeWindow(G_dpy, sc->searchwin, x, y, dx, dy); XMoveResizeWindow(X_Dpy, sc->searchwin, x, y, dx, dy);
XSelectInput(G_dpy, sc->searchwin, SearchMask); XSelectInput(X_Dpy, sc->searchwin, SearchMask);
XMapRaised(G_dpy, sc->searchwin); XMapRaised(X_Dpy, sc->searchwin);
/* /*
* TODO: eventually, the mouse should be able to select * TODO: eventually, the mouse should be able to select
* results as well. Right now we grab it only to set a fancy * results as well. Right now we grab it only to set a fancy
* cursor. * cursor.
*/ */
if (xu_ptr_grab(sc->searchwin, 0, G_cursor_question) < 0) { if (xu_ptr_grab(sc->searchwin, 0, Cursor_question) < 0) {
XUnmapWindow(G_dpy, sc->searchwin); XUnmapWindow(X_Dpy, sc->searchwin);
return (NULL); return (NULL);
} }
XGetInputFocus(G_dpy, &focuswin, &focusrevert); XGetInputFocus(X_Dpy, &focuswin, &focusrevert);
XSetInputFocus(G_dpy, sc->searchwin, RevertToPointerRoot, CurrentTime); XSetInputFocus(X_Dpy, sc->searchwin, RevertToPointerRoot, CurrentTime);
for (;;) { for (;;) {
added = mutated = 0; added = mutated = 0;
XMaskEvent(G_dpy, SearchMask, &e); XMaskEvent(X_Dpy, SearchMask, &e);
switch (e.type) { switch (e.type) {
case KeyPress: case KeyPress:
@ -133,16 +133,22 @@ search_start(struct menu_q *menuq,
case CTL_RETURN: case CTL_RETURN:
/* This is just picking the match the /* This is just picking the match the
* cursor is over. */ * cursor is over. */
if ((mi = TAILQ_FIRST(&resultq)) != NULL) if ((mi = TAILQ_FIRST(&resultq)) != NULL) {
goto found; goto found;
else } else if (dummy) {
goto out; dummy_mi = xmalloc(sizeof *dummy_mi);
(void) strlcpy(dummy_mi->text,
searchstr, sizeof(dummy_mi->text));
dummy_mi->dummy = 1;
goto found;
}
goto out;
case CTL_WIPE: case CTL_WIPE:
searchstr[0] = '\0'; searchstr[0] = '\0';
mutated = 1; mutated = 1;
break; break;
case CTL_ALL: case CTL_ALL:
list = !list; list = !list;
break; break;
case CTL_ABORT: case CTL_ABORT:
goto out; goto out;
@ -239,8 +245,8 @@ search_start(struct menu_q *menuq,
if (warp) if (warp)
xu_ptr_setpos(sc->rootwin, x, y); xu_ptr_setpos(sc->rootwin, x, y);
XClearWindow(G_dpy, sc->searchwin); XClearWindow(X_Dpy, sc->searchwin);
XMoveResizeWindow(G_dpy, sc->searchwin, x, y, dx, dy); XMoveResizeWindow(X_Dpy, sc->searchwin, x, y, dx, dy);
font_draw(font, dispstr, strlen(dispstr), sc->searchwin, font_draw(font, dispstr, strlen(dispstr), sc->searchwin,
0, font_ascent(font) + 1); 0, font_ascent(font) + 1);
@ -258,11 +264,11 @@ search_start(struct menu_q *menuq,
} }
if (n > 1) if (n > 1)
XFillRectangle(G_dpy, sc->searchwin, sc->gc, XFillRectangle(X_Dpy, sc->searchwin, sc->gc,
0, fontheight, dx, fontheight); 0, fontheight, dx, fontheight);
if (beobnoxious) if (beobnoxious)
XFillRectangle(G_dpy, sc->searchwin, sc->gc, XFillRectangle(X_Dpy, sc->searchwin, sc->gc,
0, 0, dx, fontheight); 0, 0, dx, fontheight);
break; break;
@ -272,10 +278,13 @@ search_start(struct menu_q *menuq,
out: out:
/* (if no match) */ /* (if no match) */
xu_ptr_ungrab(); xu_ptr_ungrab();
XSetInputFocus(G_dpy, focuswin, focusrevert, CurrentTime); XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime);
found:
XUnmapWindow(G_dpy, sc->searchwin);
found:
XUnmapWindow(X_Dpy, sc->searchwin);
if (dummy && dummy_mi != NULL)
return (dummy_mi);
return (mi); return (mi);
} }
@ -307,7 +316,7 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
struct client_ctx *cc = mi->ctx; struct client_ctx *cc = mi->ctx;
/* First, try to match on labels. */ /* First, try to match on labels. */
if (cc->label != NULL && _strsubmatch(search, cc->label)) { if (cc->label != NULL && _strsubmatch(search, cc->label, 0)) {
cc->matchname = cc->label; cc->matchname = cc->label;
tier = 0; tier = 0;
} }
@ -315,7 +324,7 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
/* Then, on window names. */ /* Then, on window names. */
if (tier < 0) { if (tier < 0) {
TAILQ_FOREACH_REVERSE(wn, &cc->nameq, winname_q, entry) TAILQ_FOREACH_REVERSE(wn, &cc->nameq, winname_q, entry)
if (_strsubmatch(search, wn->name)) { if (_strsubmatch(search, wn->name, 0)) {
cc->matchname = wn->name; cc->matchname = wn->name;
tier = 2; tier = 2;
break; break;
@ -327,7 +336,7 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
* name. * name.
*/ */
if (tier < 0 && _strsubmatch(search, cc->app_class)) { if (tier < 0 && _strsubmatch(search, cc->app_class, 0)) {
cc->matchname = cc->app_class; cc->matchname = cc->app_class;
tier = 3; tier = 3;
} }
@ -417,7 +426,19 @@ search_match_text(struct menu_q *menuq, struct menu_q *resultq, char *search)
TAILQ_INIT(resultq); TAILQ_INIT(resultq);
TAILQ_FOREACH(mi, menuq, entry) TAILQ_FOREACH(mi, menuq, entry)
if (_strsubmatch(search, mi->text)) if (_strsubmatch(search, mi->text, 0))
TAILQ_INSERT_TAIL(resultq, mi, resultentry);
}
void
search_match_exec(struct menu_q *menuq, struct menu_q *resultq, char *search)
{
struct menu *mi;
TAILQ_INIT(resultq);
TAILQ_FOREACH(mi, menuq, entry)
if (_strsubmatch(search, mi->text, 1))
TAILQ_INSERT_TAIL(resultq, mi, resultentry); TAILQ_INSERT_TAIL(resultq, mi, resultentry);
} }
@ -428,10 +449,10 @@ search_rank_text(struct menu_q *resultq, char *search)
} }
static int static int
_strsubmatch(char *sub, char *str) _strsubmatch(char *sub, char *str, int zeroidx)
{ {
size_t len, sublen; size_t len, sublen;
u_int n; u_int n, flen;
if (sub == NULL || str == NULL) if (sub == NULL || str == NULL)
return (0); return (0);
@ -442,7 +463,11 @@ _strsubmatch(char *sub, char *str)
if (sublen > len) if (sublen > len)
return (0); return (0);
for (n = 0; n <= len - sublen; n++) if (!zeroidx)
flen = len - sublen;
else
flen = 0;
for (n = 0; n <= flen; n++)
if (strncasecmp(sub, str + n, sublen) == 0) if (strncasecmp(sub, str + n, sublen) == 0)
return (1); return (1);

View File

@ -1,79 +0,0 @@
/* $OpenBSD$ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
* All rights reserved.
*
* 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.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid = "$OpenBSD$";
#endif /* LIBC_SCCS and not lint */
#if defined(__sun__)
#include <sys/socket.h>
#endif /* __sun__ */
#include <sys/types.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_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)
{
register char *d = dst;
register const char *s = src;
register 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 */
}

View File

@ -1,71 +0,0 @@
/* $OpenBSD$ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
* All rights reserved.
*
* 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.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid = "$OpenBSD$";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_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)
{
register char *d = dst;
register const char *s = src;
register 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 */
}

View File

@ -1,95 +0,0 @@
/* $OpenBSD$ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*/
#if !defined(HAVE_STRSEP)
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)strsep.c 8.1 (Berkeley) 6/4/93";
#else
static char *rcsid = "$OpenBSD$";
#endif
#endif /* LIBC_SCCS and not lint */
/*
* Get next token from string *stringp, where tokens are possibly-empty
* strings separated by characters from delim.
*
* Writes NULs into the string at *stringp to end tokens.
* delim need not remain constant from call to call.
* On return, *stringp points past the last NUL written (if there might
* be further tokens), or is NULL (if there are definitely no more tokens).
*
* If *stringp is NULL, strsep returns NULL.
*/
char *
strsep(char **stringp, const char *delim)
{
register char *s;
register const char *spanp;
register int c, sc;
char *tok;
if ((s = *stringp) == NULL)
return (NULL);
for (tok = s;;) {
c = *s++;
spanp = delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0)
s = NULL;
else
s[-1] = 0;
*stringp = s;
return (tok);
}
} while (sc != 0);
}
/* NOTREACHED */
}
#endif /* !defined(HAVE_STRSEP) */

View File

@ -38,7 +38,7 @@ xev_handle_maprequest(struct xevent *xev, XEvent *ee)
client_ptrsave(old_cc); client_ptrsave(old_cc);
if ((cc = client_find(e->window)) == NULL) { if ((cc = client_find(e->window)) == NULL) {
XGetWindowAttributes(G_dpy, e->window, &xattr); XGetWindowAttributes(X_Dpy, e->window, &xattr);
cc = client_new(e->window, screen_fromroot(xattr.root), 1); cc = client_new(e->window, screen_fromroot(xattr.root), 1);
sc = CCTOSC(cc); sc = CCTOSC(cc);
} else { } else {
@ -113,11 +113,11 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee)
cc->geom.y = e->y; cc->geom.y = e->y;
if (cc->geom.x == 0 && if (cc->geom.x == 0 &&
cc->geom.width >= DisplayWidth(G_dpy, sc->which)) cc->geom.width >= DisplayWidth(X_Dpy, sc->which))
cc->geom.x -= cc->bwidth; cc->geom.x -= cc->bwidth;
if (cc->geom.y == 0 && if (cc->geom.y == 0 &&
cc->geom.height >= DisplayHeight(G_dpy, sc->which)) cc->geom.height >= DisplayHeight(X_Dpy, sc->which))
cc->geom.y -= cc->bwidth; cc->geom.y -= cc->bwidth;
client_gravitate(cc, 1); client_gravitate(cc, 1);
@ -129,7 +129,7 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee)
wc.border_width = 0; wc.border_width = 0;
/* We need to move the parent window, too. */ /* We need to move the parent window, too. */
XConfigureWindow(G_dpy, cc->pwin, e->value_mask, &wc); XConfigureWindow(X_Dpy, cc->pwin, e->value_mask, &wc);
xev_reconfig(cc); xev_reconfig(cc);
} }
@ -142,7 +142,7 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee)
e->value_mask &= ~CWStackMode; e->value_mask &= ~CWStackMode;
e->value_mask |= CWBorderWidth; e->value_mask |= CWBorderWidth;
XConfigureWindow(G_dpy, e->window, e->value_mask, &wc); XConfigureWindow(X_Dpy, e->window, e->value_mask, &wc);
xev_register(xev); xev_register(xev);
} }
@ -157,7 +157,7 @@ xev_handle_propertynotify(struct xevent *xev, XEvent *ee)
if ((cc = client_find(e->window)) != NULL) { if ((cc = client_find(e->window)) != NULL) {
switch(e->atom) { switch(e->atom) {
case XA_WM_NORMAL_HINTS: case XA_WM_NORMAL_HINTS:
XGetWMNormalHints(G_dpy, cc->win, cc->size, &tmp); XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp);
break; break;
case XA_WM_NAME: case XA_WM_NAME:
client_setname(cc); client_setname(cc);
@ -187,7 +187,7 @@ xev_reconfig(struct client_ctx *cc)
ce.above = None; ce.above = None;
ce.override_redirect = 0; ce.override_redirect = 0;
XSendEvent(G_dpy, cc->win, False, StructureNotifyMask, (XEvent *)&ce); XSendEvent(X_Dpy, cc->win, False, StructureNotifyMask, (XEvent *)&ce);
} }
void void
@ -246,7 +246,7 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
switch (e->button) { switch (e->button) {
case Button1: case Button1:
TAILQ_FOREACH(cc, &G_clientq, entry) { TAILQ_FOREACH(cc, &Clientq, entry) {
if (cc->flags & CLIENT_HIDDEN) { if (cc->flags & CLIENT_HIDDEN) {
if (cc->label != NULL) if (cc->label != NULL)
wname = cc->label; wname = cc->label;
@ -266,11 +266,11 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
break; break;
case Button3: { case Button3: {
struct cmd *cmd; struct cmd *cmd;
if (conf_cmd_changed(G_conf.menu_path)) { if (conf_cmd_changed(Conf.menu_path)) {
conf_cmd_clear(&G_conf); conf_cmd_clear(&Conf);
conf_cmd_populate(&G_conf, G_conf.menu_path); conf_cmd_populate(&Conf, Conf.menu_path);
} }
TAILQ_FOREACH(cmd, &G_conf.cmdq, entry) { TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
XCALLOC(mi, struct menu); XCALLOC(mi, struct menu);
strlcpy(mi->text, cmd->label, sizeof(mi->text)); strlcpy(mi->text, cmd->label, sizeof(mi->text));
mi->ctx = cmd; mi->ctx = cmd;
@ -321,7 +321,7 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
switch (e->button) { switch (e->button) {
case Button1: case Button1:
if (altcontrol && !G_groupmode) if (altcontrol && !Groupmode)
group_sticky_toggle_enter(cc); group_sticky_toggle_enter(cc);
else { else {
grab_drag(cc); grab_drag(cc);
@ -330,7 +330,7 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
break; break;
case Button2: case Button2:
/* XXXSIGH!!! */ /* XXXSIGH!!! */
if (G_groupmode) if (Groupmode)
group_click(cc); group_click(cc);
else { else {
grab_sweep(cc); grab_sweep(cc);
@ -351,7 +351,7 @@ xev_handle_buttonrelease(struct xevent *xev, XEvent *ee)
{ {
struct client_ctx *cc = client_current(); struct client_ctx *cc = client_current();
if (cc != NULL && !G_groupmode) if (cc != NULL && !Groupmode)
group_sticky_toggle_exit(cc); group_sticky_toggle_exit(cc);
xev_register(xev); xev_register(xev);
@ -367,10 +367,10 @@ xev_handle_keypress(struct xevent *xev, XEvent *ee)
KeySym keysym, skeysym; KeySym keysym, skeysym;
int modshift; int modshift;
keysym = XKeycodeToKeysym(G_dpy, e->keycode, 0); keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0);
skeysym = XKeycodeToKeysym(G_dpy, e->keycode, 1); skeysym = XKeycodeToKeysym(X_Dpy, e->keycode, 1);
TAILQ_FOREACH(kb, &G_conf.keybindingq, entry) { TAILQ_FOREACH(kb, &Conf.keybindingq, entry) {
if (keysym != kb->keysym && skeysym == kb->keysym) if (keysym != kb->keysym && skeysym == kb->keysym)
modshift = ShiftMask; modshift = ShiftMask;
else else
@ -413,7 +413,7 @@ xev_handle_keyrelease(struct xevent *xev, XEvent *ee)
struct screen_ctx *sc = screen_fromroot(e->root); struct screen_ctx *sc = screen_fromroot(e->root);
int keysym; int keysym;
keysym = XKeycodeToKeysym(G_dpy, e->keycode, 0); keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0);
if (keysym != XK_Alt_L && keysym != XK_Alt_R) if (keysym != XK_Alt_L && keysym != XK_Alt_R)
goto out; goto out;
@ -435,7 +435,7 @@ xev_handle_clientmessage(struct xevent *xev, XEvent *ee)
{ {
XClientMessageEvent *e = &ee->xclient; XClientMessageEvent *e = &ee->xclient;
struct client_ctx *cc = client_find(e->window); struct client_ctx *cc = client_find(e->window);
Atom xa_wm_change_state = XInternAtom(G_dpy, "WM_CHANGE_STATE", False); Atom xa_wm_change_state = XInternAtom(X_Dpy, "WM_CHANGE_STATE", False);
if (cc == NULL) if (cc == NULL)
goto out; goto out;
@ -536,7 +536,7 @@ xev_loop(void)
errx(1, "X event queue empty"); errx(1, "X event queue empty");
#endif #endif
XNextEvent(G_dpy, &e); XNextEvent(X_Dpy, &e);
type = e.type; type = e.type;
win = root = 0; win = root = 0;

36
xutil.c
View File

@ -13,7 +13,7 @@
int int
xu_ptr_grab(Window win, int mask, Cursor curs) xu_ptr_grab(Window win, int mask, Cursor curs)
{ {
return (XGrabPointer(G_dpy, win, False, mask, return (XGrabPointer(X_Dpy, win, False, mask,
GrabModeAsync, GrabModeAsync, GrabModeAsync, GrabModeAsync,
None, curs, CurrentTime) == GrabSuccess ? 0 : -1); None, curs, CurrentTime) == GrabSuccess ? 0 : -1);
} }
@ -21,20 +21,20 @@ xu_ptr_grab(Window win, int mask, Cursor curs)
int int
xu_ptr_regrab(int mask, Cursor curs) xu_ptr_regrab(int mask, Cursor curs)
{ {
return (XChangeActivePointerGrab(G_dpy, mask, return (XChangeActivePointerGrab(X_Dpy, mask,
curs, CurrentTime) == GrabSuccess ? 0 : -1); curs, CurrentTime) == GrabSuccess ? 0 : -1);
} }
void void
xu_ptr_ungrab(void) xu_ptr_ungrab(void)
{ {
XUngrabPointer(G_dpy, CurrentTime); XUngrabPointer(X_Dpy, CurrentTime);
} }
int int
xu_btn_grab(Window win, int mask, u_int btn) xu_btn_grab(Window win, int mask, u_int btn)
{ {
return (XGrabButton(G_dpy, btn, mask, win, return (XGrabButton(X_Dpy, btn, mask, win,
False, ButtonMask, GrabModeAsync, False, ButtonMask, GrabModeAsync,
GrabModeSync, None, None) == GrabSuccess ? 0 : -1); GrabModeSync, None, None) == GrabSuccess ? 0 : -1);
} }
@ -42,7 +42,7 @@ xu_btn_grab(Window win, int mask, u_int btn)
void void
xu_btn_ungrab(Window win, int mask, u_int btn) xu_btn_ungrab(Window win, int mask, u_int btn)
{ {
XUngrabButton(G_dpy, btn, mask, win); XUngrabButton(X_Dpy, btn, mask, win);
} }
void void
@ -52,13 +52,13 @@ xu_ptr_getpos(Window rootwin, int *x, int *y)
u_int tmp2; u_int tmp2;
Window w0, w1; Window w0, w1;
XQueryPointer(G_dpy, rootwin, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2); XQueryPointer(X_Dpy, rootwin, &w0, &w1, &tmp0, &tmp1, x, y, &tmp2);
} }
void void
xu_ptr_setpos(Window win, int x, int y) xu_ptr_setpos(Window win, int x, int y)
{ {
XWarpPointer(G_dpy, None, win, 0, 0, 0, 0, x, y); XWarpPointer(X_Dpy, None, win, 0, 0, 0, 0, x, y);
} }
void void
@ -66,15 +66,15 @@ xu_key_grab(Window win, int mask, int keysym)
{ {
KeyCode code; KeyCode code;
code = XKeysymToKeycode(G_dpy, keysym); code = XKeysymToKeycode(X_Dpy, keysym);
if ((XKeycodeToKeysym(G_dpy, code, 0) != keysym) && if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) &&
(XKeycodeToKeysym(G_dpy, code, 1) == keysym)) (XKeycodeToKeysym(X_Dpy, code, 1) == keysym))
mask |= ShiftMask; mask |= ShiftMask;
XGrabKey(G_dpy, XKeysymToKeycode(G_dpy, keysym), mask, win, True, XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), mask, win, True,
GrabModeAsync, GrabModeAsync); GrabModeAsync, GrabModeAsync);
#if 0 #if 0
XGrabKey(G_dpy, XKeysymToKeycode(G_dpy, keysym), LockMask|mask, XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), LockMask|mask,
win, True, GrabModeAsync, GrabModeAsync); win, True, GrabModeAsync, GrabModeAsync);
#endif #endif
} }
@ -82,7 +82,7 @@ xu_key_grab(Window win, int mask, int keysym)
void void
xu_key_grab_keycode(Window win, int mask, int keycode) xu_key_grab_keycode(Window win, int mask, int keycode)
{ {
XGrabKey(G_dpy, keycode, mask, win, True, GrabModeAsync, GrabModeAsync); XGrabKey(X_Dpy, keycode, mask, win, True, GrabModeAsync, GrabModeAsync);
} }
void void
@ -98,7 +98,7 @@ xu_sendmsg(struct client_ctx *cc, Atom atm, long val)
e.xclient.data.l[0] = val; e.xclient.data.l[0] = val;
e.xclient.data.l[1] = CurrentTime; e.xclient.data.l[1] = CurrentTime;
XSendEvent(G_dpy, cc->win, False, 0, &e); XSendEvent(X_Dpy, cc->win, False, 0, &e);
} }
int int
@ -108,7 +108,7 @@ xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p)
u_long n, extra; u_long n, extra;
int format; int format;
if (XGetWindowProperty(G_dpy, cc->win, atm, 0L, len, False, type, if (XGetWindowProperty(X_Dpy, cc->win, atm, 0L, len, False, type,
&realtype, &format, &n, &extra, p) != Success || *p == NULL) &realtype, &format, &n, &extra, p) != Success || *p == NULL)
return (-1); return (-1);
@ -121,7 +121,7 @@ xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p)
int int
xu_getstate(struct client_ctx *cc, int *state) xu_getstate(struct client_ctx *cc, int *state)
{ {
Atom wm_state = XInternAtom(G_dpy, "WM_STATE", False); Atom wm_state = XInternAtom(X_Dpy, "WM_STATE", False);
long *p = NULL; long *p = NULL;
if (xu_getprop(cc, wm_state, wm_state, 2L, (u_char **)&p) <= 0) if (xu_getprop(cc, wm_state, wm_state, 2L, (u_char **)&p) <= 0)
@ -151,12 +151,12 @@ xu_setstate(struct client_ctx *cc, int state)
Atom wm_state; Atom wm_state;
/* XXX cache */ /* XXX cache */
wm_state = XInternAtom(G_dpy, "WM_STATE", False); wm_state = XInternAtom(X_Dpy, "WM_STATE", False);
dat[0] = (long)state; dat[0] = (long)state;
dat[1] = (long)None; dat[1] = (long)None;
cc->state = state; cc->state = state;
XChangeProperty(G_dpy, cc->win, wm_state, wm_state, 32, XChangeProperty(X_Dpy, cc->win, wm_state, wm_state, 32,
PropModeReplace, (unsigned char *)dat, 2); PropModeReplace, (unsigned char *)dat, 2);
} }