mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Compare commits
56 Commits
cwm
...
OPENBSD_4_
Author | SHA1 | Date | |
---|---|---|---|
d816834954 | |||
de36e6ec2f | |||
7ef6f63557 | |||
3f63e529bf | |||
9cb4f8884e | |||
09dbddac87 | |||
a936ffc470 | |||
de72f62924 | |||
7fb2664f92 | |||
1eed217b1c | |||
e5cabb0f43 | |||
3de5c68888 | |||
160d6aa910 | |||
847191cff3 | |||
f82afee4e2 | |||
381ba77e03 | |||
01a3f493d6 | |||
219f297493 | |||
2e72df662d | |||
8b3cd2243a | |||
f14a3eeebf | |||
19ae2f65de | |||
3341229c74 | |||
ebebed71bd | |||
4b85adbe60 | |||
576d299095 | |||
dc39e11ff9 | |||
6b00b86622 | |||
e64e1709ba | |||
699b048959 | |||
af71fc930a | |||
56994282f0 | |||
0584867396 | |||
964a1e73a7 | |||
365aecd25e | |||
a1d4169eb3 | |||
80d08270b8 | |||
35887fbdf6 | |||
c025dc9089 | |||
15fdb76df9 | |||
9b04f2582b | |||
5a0f777c6f | |||
04248d0ed3 | |||
9006bbf20b | |||
4a498a4c60 | |||
31356d9833 | |||
2742ebe21c | |||
2b75f1ef96 | |||
57da7d7cd8 | |||
c3a569adfb | |||
22329fd6f6 | |||
9d51a8cf84 | |||
8d60503290 | |||
890a32aa33 | |||
fa515a82d0 | |||
d957b53c6f |
18
LICENSE
18
LICENSE
@ -12,21 +12,3 @@
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
Parts derived from 9wm:
|
||||
|
||||
9wm is free software, and is Copyright (c) 1994 by David Hogan.
|
||||
Permission is granted to all sentient beings to use this software,
|
||||
to make copies of it, and to distribute those copies, provided
|
||||
that:
|
||||
|
||||
(1) the copyright and licence notices are left intact
|
||||
(2) the recipients are aware that it is free software
|
||||
(3) any unapproved changes in functionality are either
|
||||
(i) only distributed as patches
|
||||
or (ii) distributed as a new program which is not called 9wm
|
||||
and whose documentation gives credit where it is due
|
||||
(4) the author is not held responsible for any defects
|
||||
or shortcomings in the software, or damages caused by it.
|
||||
|
||||
There is no warranty for this software. Have a nice day.
|
||||
|
25
Makefile
Normal file
25
Makefile
Normal file
@ -0,0 +1,25 @@
|
||||
# $OpenBSD$
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
X11BASE?= /usr/X11R6
|
||||
|
||||
PROG= cwm
|
||||
|
||||
SRCS= calmwm.c screen.c xmalloc.c client.c grab.c search.c \
|
||||
util.c xutil.c conf.c input.c xevents.c group.c \
|
||||
kbfunc.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>
|
19
Makefile.am
19
Makefile.am
@ -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
|
@ -1,3 +0,0 @@
|
||||
AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||
|
||||
DISTCLEANFILES = *~
|
617
Makefile.in
617
Makefile.in
@ -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:
|
5
README
5
README
@ -52,8 +52,7 @@ DOCUMENTATION
|
||||
|
||||
LICENSE
|
||||
|
||||
cwm is distributed under a BSD like license. Feel free to use,
|
||||
modify and distribute in any form. See the LICENSE file for more
|
||||
information.
|
||||
cwm is distributed under a BSD like license. Please see the LICENSE
|
||||
file or the top of any source file for more information.
|
||||
|
||||
[1] http://evilwm.sourceforge.net/
|
||||
|
6
TODO
6
TODO
@ -1,5 +1,3 @@
|
||||
- clean up menu code from 9wm
|
||||
|
||||
- window initial position
|
||||
|
||||
- don't map windows if it's within [some time increment] of active typing,
|
||||
@ -14,8 +12,6 @@
|
||||
- ignoreq, always lower them. perhaps implement by lowering the entire
|
||||
queue on each XLower...
|
||||
|
||||
- kbd shortcut for xlock
|
||||
|
||||
- search window should try to stay inside of the screen boundaries.
|
||||
|
||||
- geographical keyboard navigation (window switching)
|
||||
@ -30,5 +26,3 @@
|
||||
once before moving on.
|
||||
|
||||
- cache all the atoms somewhere.
|
||||
|
||||
- convert globals from G_foo to Foo;
|
||||
|
27
acconfig.h
27
acconfig.h
@ -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
949
aclocal.m4
vendored
@ -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
|
||||
|
207
calmwm.c
207
calmwm.c
@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -10,24 +21,23 @@
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
Display *G_dpy;
|
||||
XFontStruct *G_font;
|
||||
Display *X_Dpy;
|
||||
|
||||
Cursor G_cursor_move;
|
||||
Cursor G_cursor_resize;
|
||||
Cursor G_cursor_select;
|
||||
Cursor G_cursor_default;
|
||||
Cursor G_cursor_question;
|
||||
Cursor Cursor_move;
|
||||
Cursor Cursor_resize;
|
||||
Cursor Cursor_select;
|
||||
Cursor Cursor_default;
|
||||
Cursor Cursor_question;
|
||||
|
||||
struct screen_ctx_q G_screenq;
|
||||
struct screen_ctx *G_curscreen;
|
||||
u_int G_nscreens;
|
||||
struct screen_ctx_q Screenq;
|
||||
struct screen_ctx *Curscreen;
|
||||
u_int Nscreens;
|
||||
|
||||
struct client_ctx_q G_clientq;
|
||||
struct client_ctx_q Clientq;
|
||||
|
||||
int G_doshape, G_shape_ev;
|
||||
int G_starting;
|
||||
struct conf G_conf;
|
||||
int Doshape, Shape_ev;
|
||||
int Starting;
|
||||
struct conf Conf;
|
||||
struct fontdesc *DefaultFont;
|
||||
char *DefaultFontName;
|
||||
|
||||
@ -36,16 +46,6 @@ char *DefaultFontName;
|
||||
#define gray_height 2
|
||||
static char gray_bits[] = {0x02, 0x01};
|
||||
|
||||
/* List borrowed from 9wm/rio */
|
||||
char *tryfonts[] = {
|
||||
"9x15bold",
|
||||
"blit",
|
||||
"*-lucidatypewriter-bold-*-14-*-75-*",
|
||||
"*-lucidatypewriter-medium-*-12-*-75-*",
|
||||
"fixed",
|
||||
"*",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static void _sigchld_cb(int);
|
||||
|
||||
@ -55,10 +55,15 @@ main(int argc, char **argv)
|
||||
int ch;
|
||||
int conf_flags = 0;
|
||||
|
||||
char *display_name = NULL;
|
||||
|
||||
DefaultFontName = "sans-serif:pixelsize=14:bold";
|
||||
|
||||
while ((ch = getopt(argc, argv, "sf:")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "d:sf:")) != -1) {
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
display_name = optarg;
|
||||
break;
|
||||
case 's':
|
||||
conf_flags |= CONF_STICKY_GROUPS;
|
||||
break;
|
||||
@ -66,9 +71,11 @@ main(int argc, char **argv)
|
||||
DefaultFontName = xstrdup(optarg);
|
||||
break;
|
||||
default:
|
||||
errx(1, "Unknown option '%c'", ch);
|
||||
usage();
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
/* Ignore a few signals. */
|
||||
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
|
||||
@ -79,12 +86,12 @@ main(int argc, char **argv)
|
||||
|
||||
group_init();
|
||||
|
||||
G_starting = 1;
|
||||
conf_setup(&G_conf);
|
||||
G_conf.flags |= conf_flags;
|
||||
Starting = 1;
|
||||
conf_setup(&Conf);
|
||||
Conf.flags |= conf_flags;
|
||||
client_setup();
|
||||
x_setup();
|
||||
G_starting = 0;
|
||||
x_setup(display_name);
|
||||
Starting = 0;
|
||||
|
||||
xev_init();
|
||||
XEV_QUICK(NULL, NULL, MapRequest, xev_handle_maprequest, NULL);
|
||||
@ -108,48 +115,37 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
void
|
||||
x_setup(void)
|
||||
x_setup(char *display_name)
|
||||
{
|
||||
int i;
|
||||
struct screen_ctx *sc;
|
||||
char *fontname;
|
||||
|
||||
TAILQ_INIT(&G_screenq);
|
||||
TAILQ_INIT(&Screenq);
|
||||
|
||||
if ((G_dpy = XOpenDisplay("")) == NULL)
|
||||
errx(1, "%s:%d XOpenDisplay()", __FILE__, __LINE__);
|
||||
if ((X_Dpy = XOpenDisplay(display_name)) == NULL)
|
||||
errx(1, "unable to open display \"%s\"",
|
||||
XDisplayName(display_name));
|
||||
|
||||
XSetErrorHandler(x_errorhandler);
|
||||
|
||||
G_doshape = XShapeQueryExtension(G_dpy, &G_shape_ev, &i);
|
||||
Doshape = XShapeQueryExtension(X_Dpy, &Shape_ev, &i);
|
||||
|
||||
i = 0;
|
||||
while ((fontname = tryfonts[i++]) != NULL) {
|
||||
if ((G_font = XLoadQueryFont(G_dpy, fontname)) != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
if (fontname == NULL)
|
||||
errx(1, "Couldn't load any fonts.");
|
||||
|
||||
G_nscreens = ScreenCount(G_dpy);
|
||||
for (i = 0; i < (int)G_nscreens; i++) {
|
||||
Nscreens = ScreenCount(X_Dpy);
|
||||
for (i = 0; i < (int)Nscreens; i++) {
|
||||
XMALLOC(sc, struct screen_ctx);
|
||||
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);
|
||||
G_cursor_resize = XCreateFontCursor(G_dpy, XC_bottom_right_corner);
|
||||
/* (used to be) XCreateFontCursor(G_dpy, XC_hand1); */
|
||||
G_cursor_select = XCreateFontCursor(G_dpy, XC_hand1);
|
||||
/* G_cursor_select = cursor_bigarrow(G_curscreen); */
|
||||
G_cursor_default = XCreateFontCursor(G_dpy, XC_X_cursor);
|
||||
/* G_cursor_default = cursor_bigarrow(G_curscreen); */
|
||||
G_cursor_question = XCreateFontCursor(G_dpy, XC_question_arrow);
|
||||
Cursor_move = XCreateFontCursor(X_Dpy, XC_fleur);
|
||||
Cursor_resize = XCreateFontCursor(X_Dpy, XC_bottom_right_corner);
|
||||
Cursor_select = XCreateFontCursor(X_Dpy, XC_hand1);
|
||||
Cursor_default = XCreateFontCursor(X_Dpy, XC_X_cursor);
|
||||
Cursor_question = XCreateFontCursor(X_Dpy, XC_question_arrow);
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
{
|
||||
XColor tmp;
|
||||
@ -162,78 +158,63 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
|
||||
sc->display = x_screenname(which);
|
||||
sc->which = which;
|
||||
sc->rootwin = RootWindow(G_dpy, which);
|
||||
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which),
|
||||
sc->rootwin = RootWindow(X_Dpy, which);
|
||||
XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which),
|
||||
"black", &sc->fgcolor, &tmp);
|
||||
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which),
|
||||
XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which),
|
||||
"#00cc00", &sc->bgcolor, &tmp);
|
||||
XAllocNamedColor(G_dpy,DefaultColormap(G_dpy, which),
|
||||
XAllocNamedColor(X_Dpy,DefaultColormap(X_Dpy, which),
|
||||
"blue", &sc->fccolor, &tmp);
|
||||
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which),
|
||||
XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which),
|
||||
"red", &sc->redcolor, &tmp);
|
||||
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which),
|
||||
XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which),
|
||||
"#00ccc8", &sc->cyancolor, &tmp);
|
||||
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which),
|
||||
XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which),
|
||||
"white", &sc->whitecolor, &tmp);
|
||||
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which),
|
||||
XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, which),
|
||||
"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);
|
||||
|
||||
/* Special -- for alt state. */
|
||||
/* xu_key_grab(sc->rootwin, 0, XK_Alt_L); */
|
||||
/* xu_key_grab(sc->rootwin, 0, XK_Alt_R); */
|
||||
|
||||
sc->blackpixl = BlackPixel(G_dpy, sc->which);
|
||||
sc->whitepixl = WhitePixel(G_dpy, sc->which);
|
||||
sc->blackpixl = BlackPixel(X_Dpy, sc->which);
|
||||
sc->whitepixl = WhitePixel(X_Dpy, sc->which);
|
||||
sc->bluepixl = sc->fccolor.pixel;
|
||||
sc->redpixl = sc->redcolor.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,
|
||||
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,
|
||||
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,
|
||||
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.background = sc->whitepixl;
|
||||
gv.function = GXxor;
|
||||
gv.line_width = 1;
|
||||
gv.subwindow_mode = IncludeInferiors;
|
||||
gv.font = G_font->fid;
|
||||
|
||||
sc->gc = XCreateGC(G_dpy, sc->rootwin,
|
||||
sc->gc = XCreateGC(X_Dpy, sc->rootwin,
|
||||
GCForeground|GCBackground|GCFunction|
|
||||
GCLineWidth|GCSubwindowMode|GCFont, &gv);
|
||||
GCLineWidth|GCSubwindowMode, &gv);
|
||||
|
||||
#ifdef notyet
|
||||
gv2.foreground = sc->blackpixl^sc->cyanpixl;
|
||||
gv2.background = sc->cyanpixl;
|
||||
gv2.function = GXxor;
|
||||
gv2.line_width = 1;
|
||||
gv2.subwindow_mode = IncludeInferiors;
|
||||
gv2.font = G_font->fid;
|
||||
#endif
|
||||
|
||||
sc->hlgc = XCreateGC(G_dpy, sc->rootwin,
|
||||
sc->hlgc = XCreateGC(X_Dpy, sc->rootwin,
|
||||
GCForeground|GCBackground|GCFunction|
|
||||
GCLineWidth|GCSubwindowMode|GCFont, &gv);
|
||||
GCLineWidth|GCSubwindowMode, &gv);
|
||||
|
||||
gv1.function = GXinvert;
|
||||
gv1.subwindow_mode = IncludeInferiors;
|
||||
gv1.line_width = 1;
|
||||
gv1.font = G_font->fid;
|
||||
|
||||
sc->invgc = XCreateGC(G_dpy, sc->rootwin,
|
||||
GCFunction|GCSubwindowMode|GCLineWidth|GCFont, &gv1);
|
||||
sc->invgc = XCreateGC(X_Dpy, sc->rootwin,
|
||||
GCFunction|GCSubwindowMode|GCLineWidth, &gv1);
|
||||
|
||||
font_init(sc);
|
||||
DefaultFont = font_getx(sc, DefaultFontName);
|
||||
@ -249,36 +230,33 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||
search_init(sc);
|
||||
|
||||
/* 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++) {
|
||||
XGetWindowAttributes(G_dpy, wins[i], &winattr);
|
||||
XGetWindowAttributes(X_Dpy, wins[i], &winattr);
|
||||
if (winattr.override_redirect ||
|
||||
winattr.map_state != IsViewable) {
|
||||
char *name;
|
||||
XFetchName(G_dpy, wins[i], &name);
|
||||
XFetchName(X_Dpy, wins[i], &name);
|
||||
continue;
|
||||
}
|
||||
client_new(wins[i], sc, winattr.map_state != IsUnmapped);
|
||||
}
|
||||
XFree(wins);
|
||||
|
||||
G_curscreen = sc; /* XXX */
|
||||
Curscreen = sc; /* XXX */
|
||||
screen_init();
|
||||
screen_updatestackingorder();
|
||||
|
||||
rootattr.event_mask = ChildMask|PropertyChangeMask|EnterWindowMask|
|
||||
LeaveWindowMask|ColormapChangeMask|ButtonMask;
|
||||
|
||||
/* Set the root cursor to a nice obnoxious arrow :-) */
|
||||
/* rootattr.cursor = cursor_bigarrow(sc); */
|
||||
|
||||
XChangeWindowAttributes(G_dpy, sc->rootwin,
|
||||
XChangeWindowAttributes(X_Dpy, sc->rootwin,
|
||||
/* CWCursor| */CWEventMask, &rootattr);
|
||||
|
||||
XSync(G_dpy, False);
|
||||
XSync(X_Dpy, False);
|
||||
|
||||
return (0);
|
||||
return;
|
||||
}
|
||||
|
||||
char *
|
||||
@ -291,7 +269,7 @@ x_screenname(int which)
|
||||
errx(1, "Can't handle more than 9 screens. If you need it, "
|
||||
"tell <marius@monkey.org>. It's a trivial fix.");
|
||||
|
||||
dstr = xstrdup(DisplayString(G_dpy));
|
||||
dstr = xstrdup(DisplayString(X_Dpy));
|
||||
|
||||
if ((cp = rindex(dstr, ':')) == NULL)
|
||||
return (NULL);
|
||||
@ -314,16 +292,16 @@ x_errorhandler(Display *dpy, XErrorEvent *e)
|
||||
{
|
||||
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);
|
||||
XGetErrorDatabaseText(G_dpy, "XRequest", number,
|
||||
XGetErrorDatabaseText(X_Dpy, "XRequest", number,
|
||||
"<unknown>", req, sizeof(req));
|
||||
|
||||
warnx("%s(0x%x): %s", req, (u_int)e->resourceid, msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (G_starting &&
|
||||
if (Starting &&
|
||||
e->error_code == BadAccess &&
|
||||
e->request_code == X_GrabKey)
|
||||
errx(1, "root window unavailable - perhaps another "
|
||||
@ -343,3 +321,12 @@ _sigchld_cb(int which)
|
||||
(pid < 0 && errno == EINTR))
|
||||
;
|
||||
}
|
||||
|
||||
__dead void
|
||||
usage(void)
|
||||
{
|
||||
extern char *__progname;
|
||||
|
||||
fprintf(stderr, "usage: %s [-s] [-d display] [-f fontname] \n", __progname);
|
||||
exit(1);
|
||||
}
|
||||
|
89
calmwm.h
89
calmwm.h
@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -68,6 +79,10 @@ struct screen_ctx {
|
||||
|
||||
int altpersist;
|
||||
|
||||
int maxinitialised;
|
||||
int xmax;
|
||||
int ymax;
|
||||
|
||||
FILE *notifier;
|
||||
|
||||
struct cycle_entry_q mruq;
|
||||
@ -192,7 +207,7 @@ TAILQ_HEAD(xevent_q, xevent);
|
||||
enum kbtype {
|
||||
KB_DELETE, KB_NEWTERM0, KB_NEWTERM1, KB_HIDE,
|
||||
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. */
|
||||
KB_GROUP_1, KB_GROUP_2, KB_GROUP_3, KB_GROUP_4, KB_GROUP_5,
|
||||
@ -204,6 +219,15 @@ enum kbtype {
|
||||
KB__LAST
|
||||
};
|
||||
|
||||
#define CWM_BIGMOVE 0x1000
|
||||
enum directions {
|
||||
CWM_UP=0, CWM_DOWN, CWM_LEFT, CWM_RIGHT,
|
||||
};
|
||||
|
||||
/* for cwm_exec */
|
||||
#define CWM_EXEC_PROGRAM 0x1
|
||||
#define CWM_EXEC_WM 0x2
|
||||
|
||||
#define KBFLAG_NEEDCLIENT 0x01
|
||||
#define KBFLAG_FINDCLIENT 0x02
|
||||
|
||||
@ -256,7 +280,7 @@ struct menu {
|
||||
char text[MENU_MAXENTRY + 1];
|
||||
char print[MENU_MAXENTRY + 1];
|
||||
void *ctx;
|
||||
short lasthit;
|
||||
short dummy;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(menu_q, menu);
|
||||
@ -285,10 +309,10 @@ struct mwm_hints {
|
||||
int input_keycodetrans(KeyCode, u_int, enum ctltype *, char *, int);
|
||||
|
||||
int x_errorhandler(Display *, XErrorEvent *);
|
||||
void x_setup(void);
|
||||
void x_setup(char *display_name);
|
||||
char *x_screenname(int);
|
||||
void x_loop(void);
|
||||
int x_setupscreen(struct screen_ctx *, u_int);
|
||||
void x_setupscreen(struct screen_ctx *, u_int);
|
||||
__dead void usage(void);
|
||||
|
||||
struct client_ctx *client_find(Window);
|
||||
void client_setup(void);
|
||||
@ -320,7 +344,7 @@ u_long client_bg_pixel(struct client_ctx *);
|
||||
Pixmap client_bg_pixmap(struct client_ctx *);
|
||||
void client_map(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_altrelease();
|
||||
struct client_ctx *client_mrunext(struct client_ctx *cc);
|
||||
@ -372,9 +396,10 @@ int dirent_exists(char *);
|
||||
int dirent_isdir(char *);
|
||||
int dirent_islink(char *);
|
||||
int u_spawn(char *);
|
||||
void exec_wm(char *);
|
||||
|
||||
int grab_sweep(struct client_ctx *);
|
||||
int grab_drag(struct client_ctx *);
|
||||
void grab_sweep(struct client_ctx *);
|
||||
void grab_drag(struct client_ctx *);
|
||||
void grab_menuinit(struct screen_ctx *);
|
||||
void *grab_menu(XButtonEvent *, struct menu_q *);
|
||||
void grab_label(struct client_ctx *);
|
||||
@ -398,6 +423,8 @@ int conf_get_int(struct client_ctx *, enum conftype);
|
||||
void conf_client(struct client_ctx *);
|
||||
void conf_bindkey(struct conf *, void (*)(struct client_ctx *, void *),
|
||||
int, int, int, void *);
|
||||
void conf_bindname(struct conf *, char *, char *);
|
||||
void conf_unbind(struct conf *, struct keybinding *);
|
||||
void conf_parsekeys(struct conf *, char *);
|
||||
void conf_parsesettings(struct conf *, char *);
|
||||
void conf_parseignores(struct conf *, char *);
|
||||
@ -424,26 +451,29 @@ void kbfunc_client_prevgroup(struct client_ctx *, void *);
|
||||
void kbfunc_client_nogroup(struct client_ctx *, void *);
|
||||
void kbfunc_client_maximize(struct client_ctx *, void *);
|
||||
void kbfunc_client_vmaximize(struct client_ctx *, void *);
|
||||
void kbfunc_client_move(struct client_ctx *, void *);
|
||||
void kbfunc_client_resize(struct client_ctx *, void *);
|
||||
void kbfunc_menu_search(struct client_ctx *, void *);
|
||||
void kbfunc_exec(struct client_ctx *, void *);
|
||||
void kbfunc_ptrmove(struct client_ctx *, void *);
|
||||
void kbfunc_ssh(struct client_ctx *, void *);
|
||||
void kbfunc_term(struct client_ctx *cc, void *arg);
|
||||
void kbfunc_lock(struct client_ctx *cc, void *arg);
|
||||
|
||||
void draw_outline(struct client_ctx *);
|
||||
|
||||
void search_init(struct screen_ctx *);
|
||||
struct menu *search_start(struct menu_q *menuq,
|
||||
void (*match)(struct menu_q *, struct menu_q *, char *),
|
||||
void (*rank)(struct menu_q *, char *),
|
||||
void (*print)(struct menu *mi, int),
|
||||
char *);
|
||||
char *, int);
|
||||
void search_match_client(struct menu_q *, struct menu_q *, char *);
|
||||
void search_print_client(struct menu *mi, int list);
|
||||
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 group_init(void);
|
||||
int group_new(void);
|
||||
int group_select(int);
|
||||
void group_select(int);
|
||||
void group_enter(void);
|
||||
void group_exit(int);
|
||||
void group_click(struct client_ctx *);
|
||||
@ -465,10 +495,6 @@ void group_autogroup(struct client_ctx *);
|
||||
|
||||
void notification_init(struct screen_ctx *);
|
||||
|
||||
struct client_ctx *geographic_west(struct client_ctx *);
|
||||
|
||||
Cursor cursor_bigarrow();
|
||||
|
||||
void font_init(struct screen_ctx *sc);
|
||||
struct fontdesc *font_get(struct screen_ctx *sc, const char *name);
|
||||
int font_width(struct fontdesc *fdp, const char *text, int len);
|
||||
@ -482,25 +508,24 @@ struct fontdesc *font_getx(struct screen_ctx *sc, const char *name);
|
||||
|
||||
/* Externs */
|
||||
|
||||
extern Display *G_dpy;
|
||||
extern XFontStruct *G_font;
|
||||
extern Display *X_Dpy;
|
||||
|
||||
extern Cursor G_cursor_move;
|
||||
extern Cursor G_cursor_resize;
|
||||
extern Cursor G_cursor_select;
|
||||
extern Cursor G_cursor_default;
|
||||
extern Cursor G_cursor_question;
|
||||
extern Cursor Cursor_move;
|
||||
extern Cursor Cursor_resize;
|
||||
extern Cursor Cursor_select;
|
||||
extern Cursor Cursor_default;
|
||||
extern Cursor Cursor_question;
|
||||
|
||||
extern struct screen_ctx_q G_screenq;
|
||||
extern struct screen_ctx *G_curscreen;
|
||||
extern u_int G_nscreens;
|
||||
extern struct screen_ctx_q Screenq;
|
||||
extern struct screen_ctx *curscreen;
|
||||
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 struct conf G_conf;
|
||||
extern int Doshape, Shape_ev;
|
||||
extern struct conf Conf;
|
||||
|
||||
extern int G_groupmode;
|
||||
extern int Groupmode;
|
||||
extern struct fontdesc *DefaultFont;
|
||||
|
||||
|
||||
|
232
client.c
232
client.c
@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -21,7 +32,7 @@ struct client_ctx *_curcc = NULL;
|
||||
void
|
||||
client_setup(void)
|
||||
{
|
||||
TAILQ_INIT(&G_clientq);
|
||||
TAILQ_INIT(&Clientq);
|
||||
}
|
||||
|
||||
struct client_ctx *
|
||||
@ -29,7 +40,7 @@ client_find(Window win)
|
||||
{
|
||||
struct client_ctx *cc;
|
||||
|
||||
TAILQ_FOREACH(cc, &G_clientq, entry)
|
||||
TAILQ_FOREACH(cc, &Clientq, entry)
|
||||
if (cc->pwin == win || cc->win == win)
|
||||
return (cc);
|
||||
|
||||
@ -51,7 +62,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
|
||||
XCALLOC(cc, struct client_ctx);
|
||||
|
||||
XGrabServer(G_dpy);
|
||||
XGrabServer(X_Dpy);
|
||||
|
||||
cc->state = mapped ? NormalState : IconicState;
|
||||
cc->sc = sc;
|
||||
@ -70,8 +81,8 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
*/
|
||||
conf_client(cc);
|
||||
|
||||
XGetWMNormalHints(G_dpy, cc->win, cc->size, &tmp);
|
||||
XGetWindowAttributes(G_dpy, cc->win, &wattr);
|
||||
XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp);
|
||||
XGetWindowAttributes(X_Dpy, cc->win, &wattr);
|
||||
|
||||
if (cc->size->flags & PBaseSize) {
|
||||
cc->geom.min_dx = cc->size->base_width;
|
||||
@ -91,12 +102,11 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
cc->geom.y = wattr.y;
|
||||
cc->geom.width = wattr.width;
|
||||
cc->geom.height = wattr.height;
|
||||
cc->geom.height = wattr.height;
|
||||
cc->cmap = wattr.colormap;
|
||||
|
||||
if (wattr.map_state != IsViewable) {
|
||||
client_placecalc(cc);
|
||||
if ((wmhints = XGetWMHints(G_dpy, cc->win)) != NULL) {
|
||||
if ((wmhints = XGetWMHints(X_Dpy, cc->win)) != NULL) {
|
||||
if (wmhints->flags & StateHint)
|
||||
xu_setstate(cc, wmhints->initial_state);
|
||||
|
||||
@ -107,7 +117,7 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
if (xu_getstate(cc, &state) < 0)
|
||||
state = NormalState;
|
||||
|
||||
XSelectInput(G_dpy, cc->win,
|
||||
XSelectInput(X_Dpy, cc->win,
|
||||
ColormapChangeMask|EnterWindowMask|PropertyChangeMask|KeyReleaseMask);
|
||||
|
||||
x = cc->geom.x - cc->bwidth;
|
||||
@ -129,24 +139,24 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
/* 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); */
|
||||
|
||||
cc->pwin = XCreateWindow(G_dpy, sc->rootwin, x, y,
|
||||
cc->pwin = XCreateWindow(X_Dpy, sc->rootwin, x, y,
|
||||
width, height, 0, /* XXX */
|
||||
DefaultDepth(G_dpy, sc->which), CopyFromParent,
|
||||
DefaultVisual(G_dpy, sc->which),
|
||||
DefaultDepth(X_Dpy, sc->which), CopyFromParent,
|
||||
DefaultVisual(X_Dpy, sc->which),
|
||||
CWOverrideRedirect | CWBackPixel | CWEventMask, &pxattr);
|
||||
|
||||
if (G_doshape) {
|
||||
if (Doshape) {
|
||||
XRectangle *r;
|
||||
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)
|
||||
XShapeCombineShape(G_dpy, cc->pwin, ShapeBounding,
|
||||
XShapeCombineShape(X_Dpy, cc->pwin, ShapeBounding,
|
||||
0, 0, /* XXX border */
|
||||
cc->win, ShapeBounding, ShapeSet);
|
||||
XFree(r);
|
||||
@ -155,28 +165,33 @@ client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||
cc->active = 0;
|
||||
client_draw_border(cc);
|
||||
|
||||
XAddToSaveSet(G_dpy, cc->win);
|
||||
XSetWindowBorderWidth(G_dpy, cc->win, 0);
|
||||
XReparentWindow(G_dpy, cc->win, cc->pwin, cc->bwidth, cc->bwidth);
|
||||
XAddToSaveSet(X_Dpy, cc->win);
|
||||
XSetWindowBorderWidth(X_Dpy, cc->win, 0);
|
||||
XReparentWindow(X_Dpy, cc->win, cc->pwin, cc->bwidth, cc->bwidth);
|
||||
|
||||
/* Notify client of its configuration. */
|
||||
xev_reconfig(cc);
|
||||
|
||||
XMapRaised(G_dpy, cc->pwin);
|
||||
XMapWindow(G_dpy, cc->win);
|
||||
if (state == IconicState)
|
||||
client_hide(cc);
|
||||
else {
|
||||
XMapRaised(X_Dpy, cc->pwin);
|
||||
XMapWindow(X_Dpy, cc->win);
|
||||
}
|
||||
|
||||
xu_setstate(cc, cc->state);
|
||||
|
||||
XSync(G_dpy, False);
|
||||
XUngrabServer(G_dpy);
|
||||
XSync(X_Dpy, False);
|
||||
XUngrabServer(X_Dpy);
|
||||
|
||||
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_update(cc);
|
||||
|
||||
if (mapped) {
|
||||
if (G_conf.flags & CONF_STICKY_GROUPS)
|
||||
if (Conf.flags & CONF_STICKY_GROUPS)
|
||||
group_sticky(cc);
|
||||
else
|
||||
group_autogroup(cc);
|
||||
@ -195,25 +210,25 @@ client_delete(struct client_ctx *cc, int sendevent, int ignorewindow)
|
||||
return (1);
|
||||
|
||||
group_client_delete(cc);
|
||||
XGrabServer(G_dpy);
|
||||
XGrabServer(X_Dpy);
|
||||
|
||||
xu_setstate(cc, WithdrawnState);
|
||||
XRemoveFromSaveSet(G_dpy, cc->win);
|
||||
XRemoveFromSaveSet(X_Dpy, cc->win);
|
||||
|
||||
if (!ignorewindow) {
|
||||
client_gravitate(cc, 0);
|
||||
XSetWindowBorderWidth(G_dpy, cc->win, 1); /* XXX */
|
||||
XReparentWindow(G_dpy, cc->win,
|
||||
XSetWindowBorderWidth(X_Dpy, cc->win, 1); /* XXX */
|
||||
XReparentWindow(X_Dpy, cc->win,
|
||||
sc->rootwin, cc->geom.x, cc->geom.y);
|
||||
}
|
||||
if (cc->pwin)
|
||||
XDestroyWindow(G_dpy, cc->pwin);
|
||||
XDestroyWindow(X_Dpy, cc->pwin);
|
||||
|
||||
XSync(G_dpy, False);
|
||||
XUngrabServer(G_dpy);
|
||||
XSync(X_Dpy, False);
|
||||
XUngrabServer(X_Dpy);
|
||||
|
||||
TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
|
||||
TAILQ_REMOVE(&G_clientq, cc, entry);
|
||||
TAILQ_REMOVE(&Clientq, cc, entry);
|
||||
|
||||
if (_curcc == cc)
|
||||
_curcc = NULL;
|
||||
@ -251,15 +266,6 @@ client_leave(struct client_ctx *cc)
|
||||
xu_btn_ungrab(sc->rootwin, AnyModifier, Button1);
|
||||
}
|
||||
|
||||
void
|
||||
client_nocurrent(void)
|
||||
{
|
||||
if (_curcc != NULL)
|
||||
client_setactive(_curcc, 0);
|
||||
|
||||
_curcc = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
client_setactive(struct client_ctx *cc, int fg)
|
||||
{
|
||||
@ -273,8 +279,8 @@ client_setactive(struct client_ctx *cc, int fg)
|
||||
sc = CCTOSC(cc);
|
||||
|
||||
if (fg) {
|
||||
XInstallColormap(G_dpy, cc->cmap);
|
||||
XSetInputFocus(G_dpy, cc->win,
|
||||
XInstallColormap(X_Dpy, cc->cmap);
|
||||
XSetInputFocus(X_Dpy, cc->win,
|
||||
RevertToPointerRoot, CurrentTime);
|
||||
xu_btn_grab(cc->pwin, Mod1Mask, AnyButton);
|
||||
xu_btn_grab(cc->pwin, ControlMask|Mod1Mask, Button1);
|
||||
@ -334,7 +340,7 @@ client_maximize(struct client_ctx *cc)
|
||||
XWindowAttributes rootwin_geom;
|
||||
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->geom.x = 0;
|
||||
cc->geom.y = 0;
|
||||
@ -346,26 +352,13 @@ client_maximize(struct client_ctx *cc)
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
void
|
||||
client_push_geometry(struct client_ctx *cc)
|
||||
{
|
||||
cc->savegeom = cc->geom;
|
||||
}
|
||||
|
||||
void
|
||||
client_restore_geometry(struct client_ctx *cc)
|
||||
{
|
||||
cc->geom = cc->savegeom;
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
void
|
||||
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.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);
|
||||
xev_reconfig(cc);
|
||||
client_draw_border(cc);
|
||||
@ -374,7 +367,7 @@ client_resize(struct client_ctx *cc)
|
||||
void
|
||||
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);
|
||||
xev_reconfig(cc);
|
||||
}
|
||||
@ -382,23 +375,16 @@ client_move(struct client_ctx *cc)
|
||||
void
|
||||
client_lower(struct client_ctx *cc)
|
||||
{
|
||||
XLowerWindow(G_dpy, cc->pwin);
|
||||
XLowerWindow(X_Dpy, cc->pwin);
|
||||
}
|
||||
|
||||
void
|
||||
client_raise(struct client_ctx *cc)
|
||||
{
|
||||
XRaiseWindow(G_dpy, cc->pwin);
|
||||
XRaiseWindow(X_Dpy, cc->pwin);
|
||||
client_draw_border(cc);
|
||||
}
|
||||
|
||||
void
|
||||
client_warp(struct client_ctx *cc)
|
||||
{
|
||||
client_raise(cc);
|
||||
xu_ptr_setpos(cc->pwin, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
client_ptrwarp(struct client_ctx *cc)
|
||||
{
|
||||
@ -409,7 +395,11 @@ client_ptrwarp(struct client_ctx *cc)
|
||||
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);
|
||||
}
|
||||
|
||||
@ -429,8 +419,8 @@ void
|
||||
client_hide(struct client_ctx *cc)
|
||||
{
|
||||
/* XXX - add wm_state stuff */
|
||||
XUnmapWindow(G_dpy, cc->pwin);
|
||||
XUnmapWindow(G_dpy, cc->win);
|
||||
XUnmapWindow(X_Dpy, cc->pwin);
|
||||
XUnmapWindow(X_Dpy, cc->win);
|
||||
|
||||
cc->active = 0;
|
||||
cc->flags |= CLIENT_HIDDEN;
|
||||
@ -443,8 +433,8 @@ client_hide(struct client_ctx *cc)
|
||||
void
|
||||
client_unhide(struct client_ctx *cc)
|
||||
{
|
||||
XMapWindow(G_dpy, cc->win);
|
||||
XMapRaised(G_dpy, cc->pwin);
|
||||
XMapWindow(X_Dpy, cc->win);
|
||||
XMapRaised(X_Dpy, cc->pwin);
|
||||
|
||||
cc->flags &= ~CLIENT_HIDDEN;
|
||||
xu_setstate(cc, NormalState);
|
||||
@ -456,21 +446,19 @@ client_draw_border(struct client_ctx *cc)
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
|
||||
if (cc->active) {
|
||||
XSetWindowBackground(G_dpy, cc->pwin, client_bg_pixel(cc));
|
||||
XClearWindow(G_dpy, cc->pwin);
|
||||
XSetWindowBackground(X_Dpy, cc->pwin, client_bg_pixel(cc));
|
||||
XClearWindow(X_Dpy, cc->pwin);
|
||||
|
||||
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.height + cc->bwidth);
|
||||
} else {
|
||||
XSetWindowBackgroundPixmap(G_dpy, cc->pwin,
|
||||
client_bg_pixmap(cc));
|
||||
if (cc->bwidth > 1)
|
||||
XSetWindowBackgroundPixmap(G_dpy,
|
||||
XSetWindowBackgroundPixmap(X_Dpy,
|
||||
cc->pwin, client_bg_pixmap(cc));
|
||||
|
||||
XClearWindow(G_dpy, cc->pwin);
|
||||
XClearWindow(X_Dpy, cc->pwin);
|
||||
}
|
||||
}
|
||||
|
||||
@ -524,9 +512,9 @@ client_update(struct client_ctx *cc)
|
||||
long n;
|
||||
|
||||
/* XXX cache these. */
|
||||
wm_delete = XInternAtom(G_dpy, "WM_DELETE_WINDOW", False);
|
||||
wm_protocols = XInternAtom(G_dpy, "WM_PROTOCOLS", False);
|
||||
wm_take_focus = XInternAtom(G_dpy, "WM_TAKE_FOCUS", False);
|
||||
wm_delete = XInternAtom(X_Dpy, "WM_DELETE_WINDOW", False);
|
||||
wm_protocols = XInternAtom(X_Dpy, "WM_PROTOCOLS", False);
|
||||
wm_take_focus = XInternAtom(X_Dpy, "WM_TAKE_FOCUS", False);
|
||||
|
||||
if ((n = xu_getprop(cc, wm_protocols,
|
||||
XA_ATOM, 20L, (u_char **)&p)) <= 0)
|
||||
@ -547,13 +535,13 @@ client_send_delete(struct client_ctx *cc)
|
||||
Atom wm_delete, wm_protocols;
|
||||
|
||||
/* XXX - cache */
|
||||
wm_delete = XInternAtom(G_dpy, "WM_DELETE_WINDOW", False);
|
||||
wm_protocols = XInternAtom(G_dpy, "WM_PROTOCOLS", False);
|
||||
wm_delete = XInternAtom(X_Dpy, "WM_DELETE_WINDOW", False);
|
||||
wm_protocols = XInternAtom(X_Dpy, "WM_PROTOCOLS", False);
|
||||
|
||||
if (cc->xproto & CLIENT_PROTO_DELETE)
|
||||
xu_sendmsg(cc, wm_protocols, wm_delete);
|
||||
else
|
||||
XKillClient(G_dpy, cc->win);
|
||||
XKillClient(X_Dpy, cc->win);
|
||||
}
|
||||
|
||||
void
|
||||
@ -562,7 +550,7 @@ client_setname(struct client_ctx *cc)
|
||||
char *newname;
|
||||
struct winname *wn;
|
||||
|
||||
XFetchName(G_dpy, cc->win, &newname);
|
||||
XFetchName(X_Dpy, cc->win, &newname);
|
||||
if (newname == NULL)
|
||||
newname = emptystring;
|
||||
|
||||
@ -602,14 +590,23 @@ match:
|
||||
*/
|
||||
|
||||
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 *) =
|
||||
reverse ? &client_mruprev : &client_mrunext;
|
||||
|
||||
/* 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 (!sc->altpersist || sc->cycle_client == NULL)
|
||||
sc->cycle_client = TAILQ_FIRST(&sc->mruq);
|
||||
@ -689,10 +686,14 @@ client_cycleinfo(struct client_ctx *cc)
|
||||
if ((diff = cc->geom.height - (y + h)) < 0)
|
||||
y += diff;
|
||||
|
||||
XReparentWindow(G_dpy, sc->infowin, cc->win, 0, 0);
|
||||
XMoveResizeWindow(G_dpy, sc->infowin, x, y, w, h);
|
||||
XMapRaised(G_dpy, sc->infowin);
|
||||
XClearWindow(G_dpy, sc->infowin);
|
||||
/* Don't hide the beginning of the window names */
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
|
||||
XReparentWindow(X_Dpy, sc->infowin, cc->win, 0, 0);
|
||||
XMoveResizeWindow(X_Dpy, sc->infowin, x, y, w, h);
|
||||
XMapRaised(X_Dpy, sc->infowin);
|
||||
XClearWindow(X_Dpy, sc->infowin);
|
||||
|
||||
for (i = 0, n = 0; i < sizeof(list)/sizeof(list[0]); i++) {
|
||||
if ((ccc = list[i]) == NULL)
|
||||
@ -707,7 +708,7 @@ client_cycleinfo(struct client_ctx *cc)
|
||||
assert(curn != -1);
|
||||
|
||||
/* 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 *
|
||||
@ -754,8 +755,8 @@ client_altrelease()
|
||||
return;
|
||||
sc = CCTOSC(cc);
|
||||
|
||||
XUnmapWindow(G_dpy, sc->infowin);
|
||||
XReparentWindow(G_dpy, sc->infowin, sc->rootwin, 0, 0);
|
||||
XUnmapWindow(X_Dpy, sc->infowin);
|
||||
XReparentWindow(X_Dpy, sc->infowin, sc->rootwin, 0, 0);
|
||||
}
|
||||
|
||||
void
|
||||
@ -771,8 +772,8 @@ client_placecalc(struct client_ctx *cc)
|
||||
height = cc->geom.height;
|
||||
width = cc->geom.width;
|
||||
|
||||
ymax = DisplayHeight(G_dpy, sc->which) - cc->bwidth;
|
||||
xmax = DisplayWidth(G_dpy, sc->which) - cc->bwidth;
|
||||
ymax = DisplayHeight(X_Dpy, sc->which) - cc->bwidth;
|
||||
xmax = DisplayWidth(X_Dpy, sc->which) - cc->bwidth;
|
||||
|
||||
yslack = ymax - cc->geom.height;
|
||||
xslack = xmax - cc->geom.width;
|
||||
@ -786,12 +787,18 @@ client_placecalc(struct client_ctx *cc)
|
||||
mousey = MAX(mousey, (int)cc->bwidth);
|
||||
|
||||
if (cc->size->flags & USPosition) {
|
||||
x = cc->size->x;
|
||||
if (x <= 0 || x >= xmax)
|
||||
if (cc->size->x > 0)
|
||||
x = cc->size->x;
|
||||
if (x < cc->bwidth)
|
||||
x = cc->bwidth;
|
||||
y = cc->size->y;
|
||||
if (y <= 0 || y >= ymax)
|
||||
else if (x > xslack)
|
||||
x = xslack;
|
||||
if (cc->size->y > 0)
|
||||
y = cc->size->y;
|
||||
if (y < cc->bwidth)
|
||||
y = cc->bwidth;
|
||||
else if (y > yslack)
|
||||
y = yslack;
|
||||
} else {
|
||||
if (yslack < 0) {
|
||||
y = cc->bwidth;
|
||||
@ -827,7 +834,7 @@ client_vertmaximize(struct client_ctx *cc)
|
||||
cc->geom = cc->savegeom;
|
||||
} else {
|
||||
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->savegeom = cc->geom;
|
||||
@ -843,13 +850,6 @@ client_vertmaximize(struct client_ctx *cc)
|
||||
client_resize(cc);
|
||||
}
|
||||
|
||||
void
|
||||
client_map(struct client_ctx *cc)
|
||||
{
|
||||
/* mtf? */
|
||||
client_ptrwarp(cc);
|
||||
}
|
||||
|
||||
void
|
||||
client_mtf(struct client_ctx *cc)
|
||||
{
|
||||
@ -876,21 +876,21 @@ client_gethints(struct client_ctx *cc)
|
||||
Atom mha;
|
||||
struct mwm_hints *mwmh;
|
||||
|
||||
if (XGetClassHint(G_dpy, cc->win, &xch)) {
|
||||
if (XGetClassHint(X_Dpy, cc->win, &xch)) {
|
||||
if (xch.res_name != NULL)
|
||||
cc->app_name = xch.res_name;
|
||||
if (xch.res_class != NULL)
|
||||
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,
|
||||
(u_char **)&mwmh) == MWM_NUMHINTS)
|
||||
if (mwmh->flags & MWM_HINTS_DECORATIONS &&
|
||||
!(mwmh->decorations & MWM_DECOR_ALL) &&
|
||||
!(mwmh->decorations & MWM_DECOR_BORDER))
|
||||
cc->bwidth = 0;
|
||||
if (XGetCommand(G_dpy, cc->win, &argv, &argc)) {
|
||||
if (XGetCommand(X_Dpy, cc->win, &argv, &argc)) {
|
||||
#define MAX_ARGLEN 512
|
||||
#define ARG_SEP_ " "
|
||||
int len = MAX_ARGLEN;
|
||||
|
@ -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_ */
|
@ -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_ */
|
383
conf.c
383
conf.c
@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -20,6 +31,7 @@
|
||||
#define CONF_MAX_WINTITLE 256
|
||||
#define CONF_IGNORECASE 0x01
|
||||
|
||||
|
||||
/*
|
||||
* Match a window.
|
||||
*/
|
||||
@ -78,9 +90,9 @@ conf_cmd_add(struct conf *c, char *image, char *label, int flags)
|
||||
/* "term" and "lock" have special meanings. */
|
||||
|
||||
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) {
|
||||
strlcpy(G_conf.lockpath, image, sizeof(G_conf.lockpath));
|
||||
strlcpy(Conf.lockpath, image, sizeof(Conf.lockpath));
|
||||
} else {
|
||||
struct cmd *cmd;
|
||||
XMALLOC(cmd, struct cmd);
|
||||
@ -149,6 +161,9 @@ conf_cmd_populate(struct conf *c, char *path)
|
||||
/* Add a dynamic entry to the command menu */
|
||||
conf_cmd_add(c, fullname, filename, 0);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@ -177,60 +192,67 @@ conf_setup(struct conf *c)
|
||||
conf_cmd_init(c);
|
||||
|
||||
TAILQ_INIT(&c->keybindingq);
|
||||
|
||||
conf_bindname(c, "CM-Return", "terminal");
|
||||
conf_bindname(c, "CM-Delete", "lock");
|
||||
conf_bindname(c, "M-question", "exec");
|
||||
conf_bindname(c, "CM-q", "exec_wm");
|
||||
conf_bindname(c, "M-period", "ssh");
|
||||
conf_bindname(c, "M-Return", "hide");
|
||||
conf_bindname(c, "M-Down", "lower");
|
||||
conf_bindname(c, "M-Up", "raise");
|
||||
conf_bindname(c, "M-slash", "search");
|
||||
conf_bindname(c, "C-slash", "menusearch");
|
||||
conf_bindname(c, "M-Tab", "cycle");
|
||||
conf_bindname(c, "MS-Tab", "rcycle");
|
||||
conf_bindname(c, "CM-n", "label");
|
||||
conf_bindname(c, "CM-x", "delete");
|
||||
conf_bindname(c, "CM-Escape", "groupselect");
|
||||
conf_bindname(c, "CM-0", "nogroup");
|
||||
conf_bindname(c, "CM-1", "group1");
|
||||
conf_bindname(c, "CM-2", "group2");
|
||||
conf_bindname(c, "CM-3", "group3");
|
||||
conf_bindname(c, "CM-4", "group4");
|
||||
conf_bindname(c, "CM-5", "group5");
|
||||
conf_bindname(c, "CM-6", "group6");
|
||||
conf_bindname(c, "CM-7", "group7");
|
||||
conf_bindname(c, "CM-8", "group8");
|
||||
conf_bindname(c, "CM-9", "group9");
|
||||
conf_bindname(c, "M-Right", "nextgroup");
|
||||
conf_bindname(c, "M-Left", "prevgroup");
|
||||
conf_bindname(c, "CM-f", "maximize");
|
||||
conf_bindname(c, "CM-equal", "vmaximize");
|
||||
|
||||
conf_bindname(c, "M-h", "moveleft");
|
||||
conf_bindname(c, "M-j", "movedown");
|
||||
conf_bindname(c, "M-k", "moveup");
|
||||
conf_bindname(c, "M-l", "moveright");
|
||||
conf_bindname(c, "M-H", "bigmoveleft");
|
||||
conf_bindname(c, "M-J", "bigmovedown");
|
||||
conf_bindname(c, "M-K", "bigmoveup");
|
||||
conf_bindname(c, "M-L", "bigmoveright");
|
||||
|
||||
conf_bindname(c, "CM-h", "resizeleft");
|
||||
conf_bindname(c, "CM-j", "resizedown");
|
||||
conf_bindname(c, "CM-k", "resizeup");
|
||||
conf_bindname(c, "CM-l", "resizeright");
|
||||
conf_bindname(c, "CM-H", "bigresizeleft");
|
||||
conf_bindname(c, "CM-J", "bigresizedown");
|
||||
conf_bindname(c, "CM-K", "bigresizeup");
|
||||
conf_bindname(c, "CM-L", "bigresizeright");
|
||||
|
||||
conf_bindname(c, "C-Left", "ptrmoveleft");
|
||||
conf_bindname(c, "C-Down", "ptrmovedown");
|
||||
conf_bindname(c, "C-Up", "ptrmoveup");
|
||||
conf_bindname(c, "C-Right", "ptrmoveright");
|
||||
conf_bindname(c, "CS-Left", "bigptrmoveleft");
|
||||
conf_bindname(c, "CS-Down", "bigptrmovedown");
|
||||
conf_bindname(c, "CS-Up", "bigptrmoveup");
|
||||
conf_bindname(c, "CS-Right", "bigptrmoveright");
|
||||
|
||||
snprintf(dir_keydefs, sizeof(dir_keydefs), "%s/.calmwm/.keys", home);
|
||||
if (dirent_isdir(dir_keydefs)) {
|
||||
if (dirent_isdir(dir_keydefs))
|
||||
conf_parsekeys(c, dir_keydefs);
|
||||
} else {
|
||||
conf_bindkey(c, kbfunc_term,
|
||||
XK_Return, ControlMask|Mod1Mask, 0, NULL);
|
||||
conf_bindkey(c, kbfunc_lock,
|
||||
XK_Delete, ControlMask|Mod1Mask, 0, NULL);
|
||||
conf_bindkey(c, kbfunc_client_hide,
|
||||
XK_Return, Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_lower,
|
||||
XK_Down, Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_raise,
|
||||
XK_Up, Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_search, XK_slash, Mod1Mask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_menu_search,
|
||||
XK_slash, ControlMask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_client_cycle,
|
||||
XK_Tab, Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_rcycle,
|
||||
XK_Tab, Mod1Mask|ShiftMask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_label, XK_l,
|
||||
ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_delete, XK_x,
|
||||
ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
conf_bindkey(c, kbfunc_client_groupselect,
|
||||
XK_Escape, ControlMask|Mod1Mask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_1, ControlMask|Mod1Mask, 0, (void *) 1);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_2, ControlMask|Mod1Mask, 0, (void *) 2);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_3, ControlMask|Mod1Mask, 0, (void *) 3);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_4, ControlMask|Mod1Mask, 0, (void *) 4);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_5, ControlMask|Mod1Mask, 0, (void *) 5);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_6, ControlMask|Mod1Mask, 0, (void *) 6);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_7, ControlMask|Mod1Mask, 0, (void *) 7);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_8, ControlMask|Mod1Mask, 0, (void *) 8);
|
||||
conf_bindkey(c, kbfunc_client_group,
|
||||
XK_9, ControlMask|Mod1Mask, 0, (void *) 9);
|
||||
conf_bindkey(c, kbfunc_client_nogroup,
|
||||
XK_0, ControlMask|Mod1Mask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_client_nextgroup,
|
||||
XK_Right, Mod1Mask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_client_prevgroup,
|
||||
XK_Left, Mod1Mask, 0, 0);
|
||||
conf_bindkey(c, kbfunc_client_vmaximize,
|
||||
XK_equal, ControlMask|Mod1Mask, KBFLAG_NEEDCLIENT, 0);
|
||||
}
|
||||
|
||||
snprintf(dir_settings, sizeof(dir_settings),
|
||||
"%s/.calmwm/.settings", home);
|
||||
@ -259,8 +281,8 @@ conf_setup(struct conf *c)
|
||||
c->flags = 0;
|
||||
|
||||
/* Default term/lock */
|
||||
strlcpy(G_conf.termpath, "xterm", sizeof(G_conf.termpath));
|
||||
strlcpy(G_conf.lockpath, "xlock", sizeof(G_conf.lockpath));
|
||||
strlcpy(Conf.termpath, "xterm", sizeof(Conf.termpath));
|
||||
strlcpy(Conf.lockpath, "xlock", sizeof(Conf.lockpath));
|
||||
}
|
||||
|
||||
int
|
||||
@ -305,19 +327,6 @@ conf_get_int(struct client_ctx *cc, enum conftype ctype)
|
||||
return (val);
|
||||
}
|
||||
|
||||
char *
|
||||
conf_get_str(struct client_ctx *cc, enum conftype ctype)
|
||||
{
|
||||
switch (ctype) {
|
||||
case CONF_NOTIFIER:
|
||||
return xstrdup("./notifier.py"); /* XXX */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
conf_client(struct client_ctx *cc)
|
||||
{
|
||||
@ -333,60 +342,70 @@ struct {
|
||||
} name_to_kbfunc[] = {
|
||||
{ "lower", kbfunc_client_lower, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "raise", kbfunc_client_raise, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "search", kbfunc_client_search, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "search", kbfunc_client_search, 0, 0 },
|
||||
{ "menusearch", kbfunc_menu_search, 0, 0 },
|
||||
{ "hide", kbfunc_client_hide, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "cycle", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "rcycle", kbfunc_client_rcycle, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "label", kbfunc_client_label, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "delete", kbfunc_client_delete, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "ptrmoveup", kbfunc_ptrmove, 0, (void *)CWM_UP },
|
||||
{ "ptrmovedown", kbfunc_ptrmove, 0, (void *)CWM_DOWN },
|
||||
{ "ptrmoveleft", kbfunc_ptrmove, 0, (void *)CWM_LEFT },
|
||||
{ "ptrmoveright", kbfunc_ptrmove, 0, (void *)CWM_RIGHT },
|
||||
{ "bigptrmoveup", kbfunc_ptrmove, 0, (void *)(CWM_UP|CWM_BIGMOVE) },
|
||||
{ "bigptrmovedown", kbfunc_ptrmove, 0, (void *)(CWM_DOWN|CWM_BIGMOVE) },
|
||||
{ "bigptrmoveleft", kbfunc_ptrmove, 0, (void *)(CWM_LEFT|CWM_BIGMOVE) },
|
||||
{ "bigptrmoveright", kbfunc_ptrmove, 0, (void *)(CWM_RIGHT|CWM_BIGMOVE) },
|
||||
{ "groupselect", kbfunc_client_groupselect, 0, 0 },
|
||||
{ "group1", kbfunc_client_group, 0, (void *) 1 },
|
||||
{ "group2", kbfunc_client_group, 0, (void *) 2 },
|
||||
{ "group3", kbfunc_client_group, 0, (void *) 3 },
|
||||
{ "group4", kbfunc_client_group, 0, (void *) 4 },
|
||||
{ "group5", kbfunc_client_group, 0, (void *) 5 },
|
||||
{ "group6", kbfunc_client_group, 0, (void *) 6 },
|
||||
{ "group7", kbfunc_client_group, 0, (void *) 7 },
|
||||
{ "group8", kbfunc_client_group, 0, (void *) 8 },
|
||||
{ "group9", kbfunc_client_group, 0, (void *) 9 },
|
||||
{ "nogroup", kbfunc_client_nogroup, 0, 0},
|
||||
{ "nextgroup", kbfunc_client_nextgroup, 0, 0},
|
||||
{ "prevgroup", kbfunc_client_prevgroup, 0, 0},
|
||||
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, 0},
|
||||
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, 0},
|
||||
{ "group1", kbfunc_client_group, 0, (void *)1 },
|
||||
{ "group2", kbfunc_client_group, 0, (void *)2 },
|
||||
{ "group3", kbfunc_client_group, 0, (void *)3 },
|
||||
{ "group4", kbfunc_client_group, 0, (void *)4 },
|
||||
{ "group5", kbfunc_client_group, 0, (void *)5 },
|
||||
{ "group6", kbfunc_client_group, 0, (void *)6 },
|
||||
{ "group7", kbfunc_client_group, 0, (void *)7 },
|
||||
{ "group8", kbfunc_client_group, 0, (void *)8 },
|
||||
{ "group9", kbfunc_client_group, 0, (void *)9 },
|
||||
{ "nogroup", kbfunc_client_nogroup, 0, 0 },
|
||||
{ "nextgroup", kbfunc_client_nextgroup, 0, 0 },
|
||||
{ "prevgroup", kbfunc_client_prevgroup, 0, 0 },
|
||||
{ "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, 0 },
|
||||
{ "exec", kbfunc_exec, 0, (void *)CWM_EXEC_PROGRAM },
|
||||
{ "exec_wm", kbfunc_exec, 0, (void *)CWM_EXEC_WM },
|
||||
{ "ssh", kbfunc_ssh, 0, 0 },
|
||||
{ "terminal", kbfunc_term, 0, 0 },
|
||||
{ "lock", kbfunc_lock, 0, 0 },
|
||||
{ "moveup", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_UP },
|
||||
{ "movedown", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_DOWN },
|
||||
{ "moveright", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_RIGHT },
|
||||
{ "moveleft", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)CWM_LEFT },
|
||||
{ "bigmoveup", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)(CWM_UP|CWM_BIGMOVE) },
|
||||
{ "bigmovedown", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)(CWM_DOWN|CWM_BIGMOVE) },
|
||||
{ "bigmoveright", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)(CWM_RIGHT|CWM_BIGMOVE) },
|
||||
{ "bigmoveleft", kbfunc_client_move, KBFLAG_NEEDCLIENT, (void *)(CWM_LEFT|CWM_BIGMOVE) },
|
||||
{ "resizeup", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_UP) },
|
||||
{ "resizedown", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)CWM_DOWN },
|
||||
{ "resizeright", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)CWM_RIGHT },
|
||||
{ "resizeleft", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)CWM_LEFT },
|
||||
{ "bigresizeup", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_UP|CWM_BIGMOVE) },
|
||||
{ "bigresizedown", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_DOWN|CWM_BIGMOVE) },
|
||||
{ "bigresizeright", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_RIGHT|CWM_BIGMOVE) },
|
||||
{ "bigresizeleft", kbfunc_client_resize, KBFLAG_NEEDCLIENT, (void *)(CWM_LEFT|CWM_BIGMOVE) },
|
||||
{ NULL, NULL, 0, 0},
|
||||
};
|
||||
|
||||
void
|
||||
conf_bindkey(struct conf *c, void (*arg_callback)(struct client_ctx *, void *),
|
||||
int arg_keysym, int arg_modmask, int arg_flags, void * arg_arg)
|
||||
{
|
||||
struct keybinding *kb;
|
||||
|
||||
XMALLOC(kb, struct keybinding);
|
||||
|
||||
kb->modmask = arg_modmask;
|
||||
kb->keysym = arg_keysym;
|
||||
kb->keycode = 0;
|
||||
kb->flags = arg_flags;
|
||||
kb->callback = arg_callback;
|
||||
kb->argument = arg_arg;
|
||||
TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
|
||||
}
|
||||
|
||||
void
|
||||
conf_parsekeys(struct conf *c, char *filename)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
struct keybinding *current_binding;
|
||||
int iter;
|
||||
char buffer[MAXPATHLEN];
|
||||
char current_file[MAXPATHLEN];
|
||||
|
||||
dir = opendir(filename);
|
||||
while ((ent = readdir(dir)) != NULL) {
|
||||
char *substring;
|
||||
if (ent->d_name[0] == '.')
|
||||
continue;
|
||||
|
||||
@ -397,66 +416,113 @@ conf_parsekeys(struct conf *c, char *filename)
|
||||
if (!dirent_islink(current_file))
|
||||
continue;
|
||||
|
||||
XCALLOC(current_binding, struct keybinding);
|
||||
|
||||
if (strchr(ent->d_name, 'C') != NULL &&
|
||||
strchr(ent->d_name, 'C') < strchr(ent->d_name, '-'))
|
||||
current_binding->modmask |= ControlMask;
|
||||
|
||||
if (strchr(ent->d_name, 'M') != NULL &&
|
||||
strchr(ent->d_name, 'M') < strchr(ent->d_name, '-'))
|
||||
current_binding->modmask |= Mod1Mask;
|
||||
|
||||
substring = strchr(ent->d_name, '-') + 1;
|
||||
|
||||
// if there is no '-' in name, continue as is
|
||||
if (strchr(ent->d_name, '-') == NULL)
|
||||
substring = ent->d_name;
|
||||
|
||||
if (substring[0] == '[' &&
|
||||
substring[strlen(substring)-1] == ']') {
|
||||
sscanf(substring, "[%d]", ¤t_binding->keycode);
|
||||
current_binding->keysym = NoSymbol;
|
||||
} else {
|
||||
current_binding->keycode = 0;
|
||||
current_binding->keysym = XStringToKeysym(substring);
|
||||
}
|
||||
|
||||
if (current_binding->keysym == NoSymbol &&
|
||||
current_binding->keycode == 0 ) {
|
||||
xfree(current_binding);
|
||||
continue;
|
||||
}
|
||||
|
||||
memset(buffer, 0, MAXPATHLEN);
|
||||
if (readlink(current_file, buffer, MAXPATHLEN) < 0) {
|
||||
free(current_binding);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (iter = 0; name_to_kbfunc[iter].tag != NULL; iter++) {
|
||||
if (strcmp(name_to_kbfunc[iter].tag, buffer) != 0)
|
||||
continue;
|
||||
|
||||
current_binding->callback = name_to_kbfunc[iter].handler;
|
||||
current_binding->flags = name_to_kbfunc[iter].flags;
|
||||
current_binding->argument = name_to_kbfunc[iter].argument;
|
||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||
break;
|
||||
}
|
||||
|
||||
if (name_to_kbfunc[iter].tag != NULL)
|
||||
if (readlink(current_file, buffer, MAXPATHLEN) < 0)
|
||||
continue;
|
||||
|
||||
current_binding->callback = kbfunc_cmdexec;
|
||||
current_binding->argument = strdup(buffer);
|
||||
current_binding->flags = 0;
|
||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||
conf_bindname(c, ent->d_name, buffer);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
void
|
||||
conf_bindname(struct conf *c, char *name, char *binding)
|
||||
{
|
||||
int iter;
|
||||
struct keybinding *current_binding;
|
||||
char *substring;
|
||||
|
||||
XCALLOC(current_binding, struct keybinding);
|
||||
|
||||
if (strchr(name, 'C') != NULL &&
|
||||
strchr(name, 'C') < strchr(name, '-'))
|
||||
current_binding->modmask |= ControlMask;
|
||||
|
||||
if (strchr(name, 'M') != NULL &&
|
||||
strchr(name, 'M') < strchr(name, '-'))
|
||||
current_binding->modmask |= Mod1Mask;
|
||||
|
||||
if (strchr(name, '2') != NULL &&
|
||||
strchr(name, '2') < strchr(name, '-'))
|
||||
current_binding->modmask |= Mod2Mask;
|
||||
|
||||
if (strchr(name, '3') != NULL &&
|
||||
strchr(name, '3') < strchr(name, '-'))
|
||||
current_binding->modmask |= Mod3Mask;
|
||||
|
||||
if (strchr(name, '4') != NULL &&
|
||||
strchr(name, '4') < strchr(name, '-'))
|
||||
current_binding->modmask |= Mod4Mask;
|
||||
|
||||
if (strchr(name, 'S') != NULL &&
|
||||
strchr(name, 'S') < strchr(name, '-'))
|
||||
current_binding->modmask |= ShiftMask;
|
||||
|
||||
substring = strchr(name, '-') + 1;
|
||||
|
||||
/* If there is no '-' in name, continue as is */
|
||||
if (strchr(name, '-') == NULL)
|
||||
substring = name;
|
||||
|
||||
if (substring[0] == '[' &&
|
||||
substring[strlen(substring)-1] == ']') {
|
||||
sscanf(substring, "[%d]", ¤t_binding->keycode);
|
||||
current_binding->keysym = NoSymbol;
|
||||
} else {
|
||||
current_binding->keycode = 0;
|
||||
current_binding->keysym = XStringToKeysym(substring);
|
||||
}
|
||||
|
||||
if (current_binding->keysym == NoSymbol &&
|
||||
current_binding->keycode == 0 ) {
|
||||
xfree(current_binding);
|
||||
return;
|
||||
}
|
||||
|
||||
/* We now have the correct binding, remove duplicates. */
|
||||
conf_unbind(c, current_binding);
|
||||
|
||||
if (strcmp("unmap",binding) == 0)
|
||||
return;
|
||||
|
||||
for (iter = 0; name_to_kbfunc[iter].tag != NULL; iter++) {
|
||||
if (strcmp(name_to_kbfunc[iter].tag, binding) != 0)
|
||||
continue;
|
||||
|
||||
current_binding->callback = name_to_kbfunc[iter].handler;
|
||||
current_binding->flags = name_to_kbfunc[iter].flags;
|
||||
current_binding->argument = name_to_kbfunc[iter].argument;
|
||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||
break;
|
||||
}
|
||||
|
||||
if (name_to_kbfunc[iter].tag != NULL)
|
||||
return;
|
||||
|
||||
current_binding->callback = kbfunc_cmdexec;
|
||||
current_binding->argument = strdup(binding);
|
||||
current_binding->flags = 0;
|
||||
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||
return;
|
||||
}
|
||||
|
||||
void conf_unbind(struct conf *c, struct keybinding *unbind)
|
||||
{
|
||||
struct keybinding *key = NULL;
|
||||
|
||||
TAILQ_FOREACH(key, &c->keybindingq, entry) {
|
||||
if (key->modmask != unbind->modmask)
|
||||
continue;
|
||||
|
||||
if ((key->keycode != 0 && key->keysym == NoSymbol &&
|
||||
key->keycode == unbind->keycode) ||
|
||||
key->keysym == unbind->keysym)
|
||||
TAILQ_REMOVE(&c->keybindingq, key, entry);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
conf_parsesettings(struct conf *c, char *filename)
|
||||
{
|
||||
@ -468,7 +534,7 @@ conf_parsesettings(struct conf *c, char *filename)
|
||||
if (ent->d_name[0] == '.')
|
||||
continue;
|
||||
if (strncmp(ent->d_name, "sticky", 7)==0)
|
||||
G_conf.flags |= CONF_STICKY_GROUPS;
|
||||
Conf.flags |= CONF_STICKY_GROUPS;
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
@ -528,4 +594,7 @@ conf_parseautogroups(struct conf *c, char *filename)
|
||||
|
||||
TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
}
|
||||
|
1463
config.guess
vendored
1463
config.guess
vendored
File diff suppressed because it is too large
Load Diff
129
config.h.in
129
config.h.in
@ -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
1579
config.sub
vendored
File diff suppressed because it is too large
Load Diff
74
configure.in
74
configure.in
@ -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)
|
65
cursor.c
65
cursor.c
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* cursor.c
|
||||
*
|
||||
* Copyright (c) 2005 Marius Eriksen <marius@monkey.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
/* Pretty much straight out of 9wm... */
|
||||
|
||||
struct cursor_data {
|
||||
int width;
|
||||
int hot[2];
|
||||
u_char mask[64];
|
||||
u_char fore[64];
|
||||
};
|
||||
|
||||
static struct cursor_data Bigarrow = {
|
||||
16,
|
||||
{0, 0},
|
||||
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0x3F,
|
||||
0xFF, 0x0F, 0xFF, 0x0F, 0xFF, 0x1F, 0xFF, 0x3F,
|
||||
0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0xFF, 0x3F,
|
||||
0xCF, 0x1F, 0x8F, 0x0F, 0x07, 0x07, 0x03, 0x02,
|
||||
},
|
||||
{ 0x00, 0x00, 0xFE, 0x7F, 0xFE, 0x3F, 0xFE, 0x0F,
|
||||
0xFE, 0x07, 0xFE, 0x07, 0xFE, 0x0F, 0xFE, 0x1F,
|
||||
0xFE, 0x3F, 0xFE, 0x7F, 0xFE, 0x3F, 0xCE, 0x1F,
|
||||
0x86, 0x0F, 0x06, 0x07, 0x02, 0x02, 0x00, 0x00,
|
||||
},
|
||||
};
|
||||
|
||||
static Cursor
|
||||
_mkcursor(struct cursor_data *c, struct screen_ctx *sc)
|
||||
{
|
||||
Pixmap f, m;
|
||||
|
||||
f = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin, (char *)c->fore,
|
||||
c->width, c->width, 1, 0, 1);
|
||||
m = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin, (char *)c->mask,
|
||||
c->width, c->width, 1, 0, 1);
|
||||
|
||||
return (XCreatePixmapCursor(G_dpy, f, m,
|
||||
&sc->blackcolor, &sc->whitecolor, c->hot[0], c->hot[1]));
|
||||
}
|
||||
|
||||
Cursor
|
||||
cursor_bigarrow(struct screen_ctx *sc)
|
||||
{
|
||||
return _mkcursor(&Bigarrow, sc);
|
||||
}
|
||||
|
400
cwm.1
400
cwm.1
@ -1,7 +1,21 @@
|
||||
.\" $OpenBSD$
|
||||
.\"
|
||||
.\" Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
.\"
|
||||
.\" Permission to use, copy, modify, and distribute this software for any
|
||||
.\" purpose with or without fee is hereby granted, provided that the above
|
||||
.\" copyright notice and this permission notice appear in all copies.
|
||||
.\"
|
||||
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
.\"
|
||||
.\" The following requests are required for all man pages.
|
||||
.Dd July 10, 2004
|
||||
.Dd June 29, 2007
|
||||
.Dt CWM 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -10,214 +24,348 @@
|
||||
.Sh SYNOPSIS
|
||||
.\" For a program: program [-abc] file ...
|
||||
.Nm cwm
|
||||
.Op Fl s
|
||||
.Op Fl s
|
||||
.Op Fl d Ar display
|
||||
.Op Fl f Ar fontname
|
||||
.Sh DESCRIPTION
|
||||
.Nm
|
||||
is a window manager for X11. It was originally inspired by evilwm,
|
||||
but was rewritten from scratch due to limitations in the evilwm
|
||||
codebase. The from-scratch rewrite borrowed some code from 9wm.
|
||||
is a window manager for X11 which contains many features that
|
||||
concentrate on the efficiency and transparency of window management.
|
||||
.Nm
|
||||
contains many new features which all concentrate on the efficiency and
|
||||
transparency of window management.
|
||||
.Nm
|
||||
also aims to maintain the most simplest and pleasant aesthetic.
|
||||
|
||||
.Sh BASIC OPERATION
|
||||
We will adopt the following notation:
|
||||
|
||||
.Bl -tag -width 10n -offset -indent -compact
|
||||
.It Fa C
|
||||
also aims to maintain the simplest and most pleasant aesthetic.
|
||||
.Pp
|
||||
The following notation is used throughout this page:
|
||||
.Pp
|
||||
.Bl -tag -width Ds -offset indent -compact
|
||||
.It Ic C
|
||||
Control
|
||||
.It Fa M
|
||||
.It Ic M
|
||||
Meta (Alt on PCs)
|
||||
.It Fa S
|
||||
.It Ic S
|
||||
Shift
|
||||
.It Fa M1
|
||||
.It Ic M1
|
||||
Left mouse button
|
||||
.It Fa M2
|
||||
.It Ic M2
|
||||
Middle mouse button
|
||||
.It Fa M3
|
||||
.It Ic M3
|
||||
Right mouse button
|
||||
.El
|
||||
|
||||
.Pp
|
||||
.Nm
|
||||
is very simple in its use. Most of the actions are initiated via
|
||||
keybindings. The current keybindings are described below, their
|
||||
functionality is described in more detail later.
|
||||
|
||||
.Bl -tag -width 10n -offset -indent -compact
|
||||
.It Fa C-M-Enter
|
||||
is very simple in its use.
|
||||
Most of the actions are initiated via keybindings.
|
||||
The current keybindings are described below;
|
||||
their functionality is described in more detail later.
|
||||
.Pp
|
||||
.Bl -tag -width "C-M-EscapeXXX" -offset indent -compact
|
||||
.It Ic C-M-Enter
|
||||
Spawn a new terminal.
|
||||
.It Fa C-M-Delete
|
||||
.It Ic C-M-Delete
|
||||
Lock the screen.
|
||||
.It Fa M-Enter
|
||||
.It Ic M-Enter
|
||||
Hide current window.
|
||||
.It Fa M-Down
|
||||
.It Ic M-Down
|
||||
Lower current window.
|
||||
.It Fa M-Up
|
||||
.It Ic M-Up
|
||||
Raise current window.
|
||||
.It Fa M-/
|
||||
.It Ic M-/
|
||||
Search for windows.
|
||||
.It Fa C-/
|
||||
.It Ic C-/
|
||||
Search for applications.
|
||||
.It Fa C-M-l
|
||||
.It Ic C-M-n
|
||||
Label current window.
|
||||
.It Fa M-Tab
|
||||
.It Ic M-Tab
|
||||
Cycle through currently visible windows.
|
||||
.It Fa M-S-Tab
|
||||
.It Ic M-S-Tab
|
||||
Reverse cycle through currently visible windows.
|
||||
.It Fa C-M-x
|
||||
.It Ic C-M-x
|
||||
Delete current window.
|
||||
.It Fa C-M-Escape
|
||||
.It Ic C-M-Escape
|
||||
Enter group edit mode.
|
||||
.It Fa C-M-[n]
|
||||
.It Ic C-M-[n]
|
||||
Select group n, where n is 1-9.
|
||||
.It Fa C-M-0
|
||||
.It Ic C-M-0
|
||||
Select all groups.
|
||||
.It Fa M-Right
|
||||
.It Ic M-Right
|
||||
Switch to next group.
|
||||
.It Fa M-Left
|
||||
.It Ic M-Left
|
||||
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.
|
||||
.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.
|
||||
.It Ic C-M-q
|
||||
Spawn
|
||||
.Dq Exec WindowManager
|
||||
dialog; allows you to switch from
|
||||
.Nm
|
||||
to another window manager without restarting the X server.
|
||||
.El
|
||||
|
||||
.Pp
|
||||
The mouse bindings are also important, they are:
|
||||
|
||||
.Bl -tag -width 10n -offset -indent -compact
|
||||
.It Fa M-M1
|
||||
.Pp
|
||||
.Bl -tag -width Ds -offset indent -compact
|
||||
.It M-M1
|
||||
Move a window.
|
||||
.It Fa C-M-M1
|
||||
Toggle a window's membership in the current group. A blue highlight
|
||||
indicates the window has been added to the group, a red highlight
|
||||
indicates it has been removed.
|
||||
.It Fa M-M2
|
||||
Resize a window/Select a window.
|
||||
.It Fa M-M3
|
||||
.It C-M-M1
|
||||
Toggle a window's membership in the current group.
|
||||
A blue highlight indicates the window has been added to the group;
|
||||
a red highlight indicates it has been removed.
|
||||
.It M-M2
|
||||
Resize a window/select a window.
|
||||
.It M-M3
|
||||
Lower a window.
|
||||
.El
|
||||
|
||||
.Pp
|
||||
The options for
|
||||
.Nm
|
||||
are as follows:
|
||||
.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
|
||||
Set sticky group mode on.
|
||||
The default behavior for new windows is to not assign any group.
|
||||
This changes the default behavior to assigning the currrently selected
|
||||
group to any newly created windows.
|
||||
.It Fl f Ar fontname
|
||||
Makes the
|
||||
.Xr Xft 3
|
||||
font string
|
||||
.Ar fontname
|
||||
the default font.
|
||||
.El
|
||||
|
||||
.Sh POINTER MOVEMENT
|
||||
The pointer can be moved with the use of the keyboard through bindings.
|
||||
C-[UP|DOWN|LEFT|RIGHT] moves the pointer a small amount, while
|
||||
C-shift-[UP|DOWN|LEFT|RIGHT] moves the pointer a larger amount.
|
||||
For example, to move the pointer to the left by a small amount,
|
||||
press C-LEFT.
|
||||
To move the pointer down by a larger amount, press C-shift-DOWN.
|
||||
.Sh WINDOW MOVEMENT AND RESIZING
|
||||
.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.
|
||||
.Pp
|
||||
Similarly, windows may be resized with the same keybindings with the addition
|
||||
of the Control key.
|
||||
C-M-[hjkl] resizes the window a small amount and C-M-shift-[hjkl]
|
||||
resizes by a larger increment.
|
||||
.Sh SEARCH
|
||||
.Nm
|
||||
features the ability to search for windows by their current title, old
|
||||
titles and by their label. The priority for the search results are:
|
||||
Label, current title, old titles in reverse order and finally window
|
||||
class name.
|
||||
.Nm
|
||||
features the ability to search for windows by their current title,
|
||||
old titles, and by their label.
|
||||
The priority for the search results are: label, current title,
|
||||
old titles in reverse order, and finally window class name.
|
||||
.Nm
|
||||
keeps a history of the 5 previous titles of a window.
|
||||
|
||||
.Pp
|
||||
When searching, the leftmost character of the result list may show a
|
||||
flag:
|
||||
|
||||
.Pp
|
||||
.Bl -tag -width 10n -offset -indent -compact
|
||||
.It Fa !
|
||||
.It !
|
||||
The window is the currently focused window.
|
||||
.It Fa &
|
||||
.It &
|
||||
The window is hidden.
|
||||
.El
|
||||
|
||||
.Pp
|
||||
The following keybindings may be used to navigate the result list:
|
||||
|
||||
.Bl -tag -width 10n -offset -indent -compact
|
||||
.It [Down] or C-s
|
||||
.Pp
|
||||
.Bl -tag -width "[Down] or C-sXXX" -offset indent -compact
|
||||
.It Ic [Down] No or Ic C-s
|
||||
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.
|
||||
.It C-u
|
||||
.It Ic C-u
|
||||
Clear the input.
|
||||
.It [Enter]
|
||||
.It Ic [Enter]
|
||||
Focus the selected window.
|
||||
.It [Esc]
|
||||
.It Ic [Esc]
|
||||
Quit.
|
||||
.It C-a
|
||||
.It Ic C-a
|
||||
Whenever there are no matching windows, list every window.
|
||||
.El
|
||||
|
||||
.Sh GROUPS
|
||||
.Nm
|
||||
has the ability to group windows together, and use the groups to
|
||||
perform operations on the entire group instead of just one window.
|
||||
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
|
||||
option, this can be used to emulate virtual desktops.
|
||||
|
||||
.Pp
|
||||
To edit groups, enter the group edit mode, and select/unselect the
|
||||
groups with the group selection mouse click. A blue border will be
|
||||
shown on the currently selected windows. The group selection keyboard
|
||||
shortcuts can also be used to change which group to edit.
|
||||
|
||||
groups with the group selection mouse click.
|
||||
A blue border will be shown on the currently selected windows.
|
||||
The group selection keyboard shortcuts can also be used to change
|
||||
which group to edit.
|
||||
.Sh MENUS
|
||||
Menus are recalled by clicking the mouse on the root window:
|
||||
|
||||
.Pp
|
||||
.Bl -tag -width 10n -offset -indent -compact
|
||||
.It Fa M1
|
||||
Show list of currently hidden windows. Clicking on an item will
|
||||
unhide that window.
|
||||
.It Fa M2
|
||||
Show list of currently defined groups. Clicking on an item will
|
||||
hide/unhide that group.
|
||||
.It Fa M3
|
||||
Show list of applications as defined in
|
||||
.Fa ~/.calmwm .
|
||||
Clicking on an item will spawn that application.
|
||||
.It M1
|
||||
Show list of currently hidden windows.
|
||||
Clicking on an item will unhide that window.
|
||||
.It M2
|
||||
Show list of currently defined groups.
|
||||
Clicking on an item will hide/unhide that group.
|
||||
.It M3
|
||||
Show list of applications as defined in
|
||||
.Pa ~/.calmwm .
|
||||
Clicking on an item will spawn that application.
|
||||
.El
|
||||
|
||||
.Sh ~/.calmwm
|
||||
|
||||
Any directory entries here are shown in the application menu. When it
|
||||
is selected, the image is executed with
|
||||
.Sh ENVIRONMENT
|
||||
.Bl -tag -width "DISPLAYXXX"
|
||||
.It DISPLAY
|
||||
.Nm
|
||||
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 .
|
||||
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 .
|
||||
|
||||
.Pp
|
||||
The entries
|
||||
.Nm term
|
||||
and
|
||||
and
|
||||
.Nm lock
|
||||
have special meaning. When they exist they point to the terminal
|
||||
program and screen locking programs used by the keybindings specified
|
||||
above. The defaults for these are
|
||||
have a special meaning.
|
||||
When they exist they point to the terminal program and screen locking
|
||||
programs used by the keybindings specified above.
|
||||
The defaults for these are
|
||||
.Xr xterm 1
|
||||
and
|
||||
and
|
||||
.Xr xlock 1 ,
|
||||
respectively.
|
||||
|
||||
.Sh ACKNOWLEDGEMENTS
|
||||
.It Pa ~/.calmwm/.autogroup
|
||||
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
|
||||
.It Pa ~/.calmwm/.settings
|
||||
Files in this directory cause various configuration options to be
|
||||
set or unset.
|
||||
Currently the only setting availiable is whether or not sticky groups
|
||||
are activated.
|
||||
To activate sticky groups create a file in this directory with the name
|
||||
``sticky''.
|
||||
.It Pa ~/.calmwm/.ignore
|
||||
Any files in this directory cause
|
||||
.Nm
|
||||
contains some code from 9wm.
|
||||
|
||||
to ignore programs by that name by not drawing borders around them.
|
||||
For example the command
|
||||
.Bd -literal -offset indent
|
||||
$ ln -s three ~/.calmwm/.ignore/xclock
|
||||
.Ed
|
||||
will cause any instances of
|
||||
.Xr xclock 1
|
||||
to not have borders.
|
||||
.It Pa ~/.calmwm/.keys
|
||||
Symlinks in this directory cause the creation of keyboard shortcuts.
|
||||
The default shortcuts will always be created. In case of conflict,
|
||||
user-defined shortcuts take precidence.
|
||||
The name of a link here is first the modifier keys, followed by a ``-''.
|
||||
The following modifiers are recognised:
|
||||
.Bl -tag -width Ds
|
||||
.It Pa C
|
||||
The Control key.
|
||||
.It Pa M
|
||||
The Meta key.
|
||||
.It Pa S
|
||||
The Shift key.
|
||||
.It Pa 2
|
||||
The Mod2 key.
|
||||
.It Pa 3
|
||||
The Mod3 key.
|
||||
.It Pa 4
|
||||
The Mod4 key (normally the windows key).
|
||||
.El
|
||||
The ``-'' should be followed by either a keysym name, taken from
|
||||
.Pa /usr/X11R6/include/X11/keysymdef.h ,
|
||||
or a numerical keycode value enclosed in ``[]''.
|
||||
The target of the link should be either the name of a task from the
|
||||
``name_to_kbfunc''
|
||||
structure in
|
||||
.Pa conf.c ,
|
||||
or, alternatively it should be the commandline that is wished to be executed.
|
||||
A special case is the ``unmap'' keyword, which causes any bindings using the
|
||||
named shortcut to be removed. This can be used to remove a binding which conflicts
|
||||
with an application.
|
||||
For example, to cause
|
||||
.Ic C-M-r
|
||||
to add a label to a window:
|
||||
.Bd -literal -offset indent
|
||||
$ ln -s "label" ~/.calmwm/.keys/CM-r
|
||||
.Ed
|
||||
Launch an xterm running
|
||||
.Xr top 1
|
||||
with C-S-Enter:
|
||||
.Bd -literal -offset indent
|
||||
$ ln -s "/usr/X11R6/bin/xterm -e top" ~/.calmwm/.keys/CS-Return
|
||||
.Ed
|
||||
Remove a keybinding for Mod4-o
|
||||
.Bd -literal -offset indent
|
||||
$ ln -s "unmap" 4-o
|
||||
.Ed
|
||||
.El
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.An -nosplit
|
||||
.Pp
|
||||
.Nm
|
||||
software has been developed by Marius Aamodt Eriksen
|
||||
.Aq marius@monkey.org
|
||||
with contributions from Andy Adamson
|
||||
.Aq dros@monkey.org ,
|
||||
Niels Provos
|
||||
.Aq provos@monkey.org
|
||||
and Antti Nyk<EFBFBD>nen
|
||||
.Aq aon@iki.fi .
|
||||
was developed by
|
||||
.An Marius Aamodt Eriksen Aq marius@monkey.org
|
||||
with contributions from
|
||||
.An Andy Adamson Aq dros@monkey.org ,
|
||||
.An Niels Provos Aq provos@monkey.org ,
|
||||
and
|
||||
.An Antti Nyk<EFBFBD>nen Aq aon@iki.fi .
|
||||
Ideas, discussion with many others.
|
||||
.\" .Sh HISTORY
|
||||
.\".Aq marius@monkey.org .
|
||||
.\" .Sh CAVEATS
|
||||
.Sh HISTORY
|
||||
.Nm
|
||||
was originally inspired by evilwm, but was rewritten from scratch
|
||||
due to limitations in the evilwm codebase.
|
||||
The from-scratch rewrite borrowed some code from 9wm, however that code
|
||||
has since been removed or rewritten.
|
||||
.Pp
|
||||
.Nm
|
||||
first appeared in
|
||||
.Ox 4.2 .
|
||||
|
21
draw.c
21
draw.c
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
void
|
||||
draw_outline(struct client_ctx *cc)
|
||||
{
|
||||
struct screen_ctx *sc = CCTOSC(cc);
|
||||
|
||||
XDrawRectangle(G_dpy, sc->rootwin, sc->invgc,
|
||||
cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth,
|
||||
cc->geom.width + cc->bwidth, cc->geom.height + cc->bwidth);
|
||||
}
|
105
err.c
105
err.c
@ -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
12
font.c
@ -61,12 +61,12 @@ font_init(struct screen_ctx *sc)
|
||||
XColor xcolor, tmp;
|
||||
|
||||
HASH_INIT(&sc->fonthash, fontdesc_hash);
|
||||
sc->xftdraw = XftDrawCreate(G_dpy, sc->rootwin,
|
||||
DefaultVisual(G_dpy, sc->which), DefaultColormap(G_dpy, sc->which));
|
||||
sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin,
|
||||
DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which));
|
||||
if (sc->xftdraw == NULL)
|
||||
errx(1, "XftDrawCreate");
|
||||
|
||||
if (!XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, sc->which),
|
||||
if (!XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, sc->which),
|
||||
"black", &xcolor, &tmp))
|
||||
errx(1, "XAllocNamedColor");
|
||||
|
||||
@ -112,7 +112,7 @@ int
|
||||
font_width(struct fontdesc *fdp, const char *text, int len)
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -149,8 +149,8 @@ _make_font(struct screen_ctx *sc, struct fontdesc *fdp)
|
||||
if ((pat = FcNameParse(fdp->name)) == NULL)
|
||||
return (NULL);
|
||||
|
||||
if ((patx = XftFontMatch(G_dpy, sc->which, pat, &res)) != NULL)
|
||||
fn = XftFontOpenPattern(G_dpy, patx);
|
||||
if ((patx = XftFontMatch(X_Dpy, sc->which, pat, &res)) != NULL)
|
||||
fn = XftFontOpenPattern(X_Dpy, patx);
|
||||
|
||||
FcPatternDestroy(pat);
|
||||
|
||||
|
53
geographic.c
53
geographic.c
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
struct client_ctx *
|
||||
geographic_west(struct client_ctx *from_cc)
|
||||
{
|
||||
/* Window *wins, w0, w1; */
|
||||
/* struct screen_ctx *sc = screen_current(); */
|
||||
/* u_int nwins, i; */
|
||||
/* struct client_ctx *cc; */
|
||||
|
||||
screen_updatestackingorder();
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int
|
||||
_visible(struct client_ctx *this_cc)
|
||||
{
|
||||
int stacking = cc->stackingorder;
|
||||
struct client_ctx *cc;
|
||||
|
||||
if (cc->flags & CLIENT_HIDDEN)
|
||||
return (0);
|
||||
|
||||
TAILQ_FOREACH(cc, &G_clientq, entry) {
|
||||
if (cc->flags & CLIENT_HIDDEN)
|
||||
continue;
|
||||
|
||||
if (cc->stackingorder > stacking &&
|
||||
cc->geom.x <= this_cc->geom.x &&
|
||||
cc->geom.y <= this_cc->geom.y &&
|
||||
cc->geom.width > (this_cc->geom.width +
|
||||
(this_cc->geom.x - cc->geom.x) &&
|
||||
|
||||
|
||||
cc->geom.height > (this_cc->geom.height - cc->geom.height))
|
||||
return (0);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
#endif
|
346
grab.c
346
grab.c
@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -10,8 +21,8 @@
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
int _sweepcalc(struct client_ctx *, int, int, int, int);
|
||||
int _nobuttons(XButtonEvent *);
|
||||
static int _sweepcalc(struct client_ctx *, int, int, int, int);
|
||||
static int menu_calc_entry(int, int, int, int, int);
|
||||
|
||||
#define ADJUST_HEIGHT(cc, dy) ((cc->geom.height - cc->geom.min_dy)/ dy)
|
||||
#define ADJUST_WIDTH(cc, dx) ((cc->geom.width - cc->geom.min_dx)/ dx)
|
||||
@ -32,17 +43,17 @@ grab_sweep_draw(struct client_ctx *cc, int dx, int dy)
|
||||
wide = MAX(wide_size, wide_name);
|
||||
height = font_ascent(font) + font_descent(font) + 1;
|
||||
|
||||
XMoveResizeWindow(G_dpy, sc->menuwin, x0, y0, wide, height * 2);
|
||||
XMapWindow(G_dpy, sc->menuwin);
|
||||
XReparentWindow(G_dpy, sc->menuwin, cc->win, 0, 0);
|
||||
XClearWindow(G_dpy, sc->menuwin);
|
||||
XMoveResizeWindow(X_Dpy, sc->menuwin, x0, y0, wide, height * 2);
|
||||
XMapWindow(X_Dpy, sc->menuwin);
|
||||
XReparentWindow(X_Dpy, sc->menuwin, cc->win, 0, 0);
|
||||
XClearWindow(X_Dpy, sc->menuwin);
|
||||
font_draw(font, cc->name, strlen(cc->name), sc->menuwin,
|
||||
2, font_ascent(font) + 1);
|
||||
font_draw(font, asize, strlen(asize), sc->menuwin,
|
||||
wide/2 - wide_size/2, height + font_ascent(font) + 1);
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
grab_sweep(struct client_ctx *cc)
|
||||
{
|
||||
XEvent ev;
|
||||
@ -56,44 +67,47 @@ grab_sweep(struct client_ctx *cc)
|
||||
client_raise(cc);
|
||||
client_ptrsave(cc);
|
||||
|
||||
if (xu_ptr_grab(sc->rootwin, MouseMask, G_cursor_resize) < 0)
|
||||
return (-1);
|
||||
if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_resize) < 0)
|
||||
return;
|
||||
|
||||
xu_ptr_setpos(cc->win, cc->geom.width, cc->geom.height);
|
||||
grab_sweep_draw(cc, dx, dy);
|
||||
|
||||
for (;;) {
|
||||
/* Look for changes in ptr position. */
|
||||
XMaskEvent(G_dpy, MouseMask, &ev);
|
||||
XMaskEvent(X_Dpy, MouseMask|ExposureMask, &ev);
|
||||
|
||||
switch (ev.type) {
|
||||
case Expose:
|
||||
client_draw_border(cc);
|
||||
break;
|
||||
case MotionNotify:
|
||||
if (_sweepcalc(cc, x0, y0, ev.xmotion.x, ev.xmotion.y))
|
||||
/* Recompute window output */
|
||||
grab_sweep_draw(cc, dx, dy);
|
||||
|
||||
XMoveResizeWindow(G_dpy, cc->pwin,
|
||||
XMoveResizeWindow(X_Dpy, cc->pwin,
|
||||
cc->geom.x - cc->bwidth,
|
||||
cc->geom.y - cc->bwidth,
|
||||
cc->geom.width + cc->bwidth*2,
|
||||
cc->geom.height + cc->bwidth*2);
|
||||
XMoveResizeWindow(G_dpy, cc->win,
|
||||
XMoveResizeWindow(X_Dpy, cc->win,
|
||||
cc->bwidth, cc->bwidth,
|
||||
cc->geom.width, cc->geom.height);
|
||||
|
||||
break;
|
||||
case ButtonRelease:
|
||||
XUnmapWindow(G_dpy, sc->menuwin);
|
||||
XReparentWindow(G_dpy, sc->menuwin, sc->rootwin, 0, 0);
|
||||
XUnmapWindow(X_Dpy, sc->menuwin);
|
||||
XReparentWindow(X_Dpy, sc->menuwin, sc->rootwin, 0, 0);
|
||||
xu_ptr_ungrab();
|
||||
client_ptrwarp(cc);
|
||||
return (0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
grab_drag(struct client_ctx *cc)
|
||||
{
|
||||
int x0 = cc->geom.x, y0 = cc->geom.y, xm, ym;
|
||||
@ -102,230 +116,139 @@ grab_drag(struct client_ctx *cc)
|
||||
|
||||
client_raise(cc);
|
||||
|
||||
if (xu_ptr_grab(sc->rootwin, MouseMask, G_cursor_move) < 0)
|
||||
return (-1);
|
||||
if (xu_ptr_grab(sc->rootwin, MouseMask, Cursor_move) < 0)
|
||||
return;
|
||||
|
||||
xu_ptr_getpos(sc->rootwin, &xm, &ym);
|
||||
|
||||
for (;;) {
|
||||
XMaskEvent(G_dpy, MouseMask, &ev);
|
||||
XMaskEvent(X_Dpy, MouseMask|ExposureMask, &ev);
|
||||
|
||||
switch (ev.type) {
|
||||
case Expose:
|
||||
client_draw_border(cc);
|
||||
break;
|
||||
case MotionNotify:
|
||||
cc->geom.x = x0 + (ev.xmotion.x - xm);
|
||||
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);
|
||||
|
||||
break;
|
||||
case ButtonRelease:
|
||||
xu_ptr_ungrab();
|
||||
return (0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/*
|
||||
* Adapted from 9wm.
|
||||
*/
|
||||
|
||||
/* XXX - this REALLY needs to be cleaned up. */
|
||||
|
||||
#define MenuMask (ButtonMask|ButtonMotionMask|ExposureMask)
|
||||
#define MenuGrabMask (ButtonMask|ButtonMotionMask|StructureNotifyMask)
|
||||
#define AllButtonMask (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
|
||||
|
||||
#ifdef notyet
|
||||
struct client_ctx *
|
||||
grab_menu_getcc(struct menu_q *menuq, int off)
|
||||
{
|
||||
int where = 0;
|
||||
struct menu *mi;
|
||||
|
||||
TAILQ_FOREACH(mi, menuq, entry)
|
||||
if (off == where++)
|
||||
return mi->ctx;
|
||||
return (NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
void *
|
||||
grab_menu(XButtonEvent *e, struct menu_q *menuq)
|
||||
{
|
||||
struct screen_ctx *sc;
|
||||
struct menu *mi;
|
||||
XEvent ev;
|
||||
int i, n, cur = 0, old, wide, high, status, drawn, warp;
|
||||
int x, y, dx, dy, xmax, ymax;
|
||||
int tx, ty;
|
||||
XEvent event;
|
||||
struct fontdesc *font = DefaultFont;
|
||||
int x, y, width, height, tothigh, i, no, entry, prev;
|
||||
int fx, fy;
|
||||
|
||||
no = i = width = 0;
|
||||
|
||||
if ((sc = screen_fromroot(e->root)) == NULL || e->window == sc->menuwin)
|
||||
return (NULL);
|
||||
|
||||
dx = 0;
|
||||
i = 0;
|
||||
TAILQ_FOREACH(mi, menuq, entry) {
|
||||
wide = font_width(font, mi->text, strlen(mi->text)) + 4;
|
||||
if (wide > dx)
|
||||
dx = wide;
|
||||
if (mi->lasthit)
|
||||
cur = i;
|
||||
i++;
|
||||
i = font_width(font, mi->text, strlen(mi->text)) + 4;
|
||||
if (i > width)
|
||||
width = i;
|
||||
no++;
|
||||
}
|
||||
|
||||
n = i;
|
||||
if (!sc->maxinitialised) {
|
||||
sc->xmax = DisplayWidth(X_Dpy, sc->which);
|
||||
sc->ymax = DisplayHeight(X_Dpy, sc->which);
|
||||
}
|
||||
|
||||
wide = dx;
|
||||
high = font_ascent(font) + font_descent(font) + 1;
|
||||
dy = n*high;
|
||||
x = e->x - wide/2;
|
||||
y = e->y - cur*high - high/2;
|
||||
warp = 0;
|
||||
/* XXX - cache these in sc. */
|
||||
xmax = DisplayWidth(G_dpy, sc->which);
|
||||
ymax = DisplayHeight(G_dpy, sc->which);
|
||||
if (x < 0) {
|
||||
e->x -= x;
|
||||
height = font_ascent(font) + font_descent(font) + 1;
|
||||
tothigh = height * no;
|
||||
|
||||
x = e->x - width/2;
|
||||
y = e->y - height/2;
|
||||
|
||||
/* does it fit on the screen? */
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
warp++;
|
||||
}
|
||||
if (x+wide >= xmax) {
|
||||
e->x -= x+wide-xmax;
|
||||
x = xmax-wide;
|
||||
warp++;
|
||||
}
|
||||
if (y < 0) {
|
||||
e->y -= y;
|
||||
y = 0;
|
||||
warp++;
|
||||
}
|
||||
if (y+dy >= ymax) {
|
||||
e->y -= y+dy-ymax;
|
||||
y = ymax-dy;
|
||||
warp++;
|
||||
}
|
||||
if (warp)
|
||||
xu_ptr_setpos(e->root, e->x, e->y);
|
||||
else if (x+width >= sc->xmax)
|
||||
x = sc->xmax - width;
|
||||
|
||||
XMoveResizeWindow(G_dpy, sc->menuwin, x, y, dx, dy);
|
||||
XSelectInput(G_dpy, sc->menuwin, MenuMask);
|
||||
XMapRaised(G_dpy, sc->menuwin);
|
||||
status = xu_ptr_grab(sc->menuwin, MenuGrabMask, G_cursor_select);
|
||||
if (status < 0) {
|
||||
XUnmapWindow(G_dpy, sc->menuwin);
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y+tothigh >= sc->ymax)
|
||||
y = sc->ymax - tothigh;
|
||||
|
||||
xu_ptr_setpos(e->root, x + width/2, y + height/2);
|
||||
|
||||
XMoveResizeWindow(X_Dpy, sc->menuwin, x, y, width, tothigh);
|
||||
XSelectInput(X_Dpy, sc->menuwin, MenuMask);
|
||||
XMapRaised(X_Dpy, sc->menuwin);
|
||||
|
||||
if (xu_ptr_grab(sc->menuwin, MenuGrabMask, Cursor_select) < 0) {
|
||||
XUnmapWindow(X_Dpy, sc->menuwin);
|
||||
return (NULL);
|
||||
}
|
||||
drawn = 0;
|
||||
|
||||
#ifdef notyet
|
||||
if (e->button == Button1) {
|
||||
struct client_ctx *cc;
|
||||
cc = grab_menu_getcc(menuq, cur);
|
||||
if (cc != NULL) {
|
||||
client_unhide(cc);
|
||||
XRaiseWindow(G_dpy, sc->menuwin);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
entry = prev = -1;
|
||||
|
||||
for (;;) {
|
||||
XMaskEvent(G_dpy, MenuMask, &ev);
|
||||
switch (ev.type) {
|
||||
default:
|
||||
warnx("menuhit: unknown ev.type %d\n", ev.type);
|
||||
break;
|
||||
case ButtonPress:
|
||||
break;
|
||||
case ButtonRelease:
|
||||
if (ev.xbutton.button != e->button)
|
||||
break;
|
||||
x = ev.xbutton.x;
|
||||
y = ev.xbutton.y;
|
||||
i = y/high;
|
||||
if (cur >= 0 && y >= cur*high-3 && y < (cur+1)*high+3)
|
||||
i = cur;
|
||||
if (x < 0 || x > wide || y < -3)
|
||||
i = -1;
|
||||
else if (i < 0 || i >= n)
|
||||
i = -1;
|
||||
/* else */
|
||||
/* m->lasthit = i; */
|
||||
if (!_nobuttons(&ev.xbutton))
|
||||
i = -1;
|
||||
|
||||
/* XXX */
|
||||
/* ungrab(&ev.xbutton); */
|
||||
xu_ptr_ungrab();
|
||||
XUnmapWindow(G_dpy, sc->menuwin);
|
||||
n = 0;
|
||||
TAILQ_FOREACH(mi, menuq, entry)
|
||||
if (i == n++)
|
||||
break;
|
||||
|
||||
return (mi);
|
||||
case MotionNotify:
|
||||
if (!drawn)
|
||||
break;
|
||||
x = ev.xbutton.x;
|
||||
y = ev.xbutton.y;
|
||||
old = cur;
|
||||
cur = y/high;
|
||||
if (old >= 0 && y >= old*high-3 && y < (old+1)*high+3)
|
||||
cur = old;
|
||||
if (x < 0 || x > wide || y < -3)
|
||||
cur = -1;
|
||||
else if (cur < 0 || cur >= n)
|
||||
cur = -1;
|
||||
if (cur == old)
|
||||
break;
|
||||
if (old >= 0 && old < n) {
|
||||
#ifdef notyet
|
||||
if (e->button == Button1) {
|
||||
struct client_ctx *cc;
|
||||
cc = grab_menu_getcc(menuq, old);
|
||||
if (cc != NULL)
|
||||
client_hide(cc);
|
||||
}
|
||||
#endif
|
||||
XFillRectangle(G_dpy, sc->menuwin,
|
||||
sc->hlgc, 0, old*high, wide, high);
|
||||
}
|
||||
if (cur >= 0 && cur < n) {
|
||||
#ifdef notyet
|
||||
if (e->button == Button1) {
|
||||
struct client_ctx *cc;
|
||||
cc = grab_menu_getcc(menuq, cur);
|
||||
if (cc != NULL) {
|
||||
client_unhide(cc);
|
||||
XRaiseWindow(G_dpy,
|
||||
sc->menuwin);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
xu_ptr_regrab(MenuGrabMask, G_cursor_select);
|
||||
XFillRectangle(G_dpy, sc->menuwin,
|
||||
sc->hlgc, 0, cur*high, wide, high);
|
||||
} else
|
||||
xu_ptr_regrab(MenuGrabMask, G_cursor_default);
|
||||
break;
|
||||
XMaskEvent(X_Dpy, MenuMask, &event);
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
XClearWindow(G_dpy, sc->menuwin);
|
||||
XClearWindow(X_Dpy, sc->menuwin);
|
||||
i = 0;
|
||||
TAILQ_FOREACH(mi, menuq, entry) {
|
||||
tx = (wide - font_width(font, mi->text,
|
||||
strlen(mi->text)))/2;
|
||||
ty = i*high + font_ascent(font) + 1;
|
||||
fx = (width - font_width(font, mi->text,
|
||||
strlen(mi->text)))/2;
|
||||
fy = height*i + font_ascent(font) + 1;
|
||||
font_draw(font, mi->text, strlen(mi->text),
|
||||
sc->menuwin, tx, ty);
|
||||
sc->menuwin, fx, fy);
|
||||
i++;
|
||||
}
|
||||
if (cur >= 0 && cur < n)
|
||||
XFillRectangle(G_dpy, sc->menuwin,
|
||||
sc->hlgc, 0, cur*high, wide, high);
|
||||
drawn = 1;
|
||||
/* FALLTHROUGH */
|
||||
case MotionNotify:
|
||||
prev = entry;
|
||||
entry = menu_calc_entry(event.xbutton.x,
|
||||
event.xbutton.y, width, height, no);
|
||||
if (prev != -1)
|
||||
XFillRectangle(X_Dpy, sc->menuwin, sc->hlgc,
|
||||
0, height*prev, width, height);
|
||||
if (entry != -1) {
|
||||
xu_ptr_regrab(MenuGrabMask, Cursor_select);
|
||||
XFillRectangle(X_Dpy, sc->menuwin, sc->hlgc,
|
||||
0, height*entry, width, height);
|
||||
} else
|
||||
xu_ptr_regrab(MenuGrabMask, Cursor_default);
|
||||
break;
|
||||
case ButtonRelease:
|
||||
if (event.xbutton.button != e->button)
|
||||
break;
|
||||
entry = menu_calc_entry(event.xbutton.x,
|
||||
event.xbutton.y, width, height, no);
|
||||
xu_ptr_ungrab();
|
||||
XUnmapWindow(X_Dpy, sc->menuwin);
|
||||
|
||||
i = 0;
|
||||
TAILQ_FOREACH(mi, menuq, entry)
|
||||
if (entry == i++)
|
||||
break;
|
||||
return (mi);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -333,7 +256,7 @@ grab_menu(XButtonEvent *e, struct menu_q *menuq)
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
@ -364,21 +287,21 @@ grab_label(struct client_ctx *cc)
|
||||
dy = fontheight = font_ascent(font) + font_descent(font) + 1;
|
||||
dx = font_width(font, "label>", 6);
|
||||
|
||||
XMoveResizeWindow(G_dpy, sc->searchwin, x, y, dx, dy);
|
||||
XSelectInput(G_dpy, sc->searchwin, LabelMask);
|
||||
XMapRaised(G_dpy, sc->searchwin);
|
||||
XMoveResizeWindow(X_Dpy, sc->searchwin, x, y, dx, dy);
|
||||
XSelectInput(X_Dpy, sc->searchwin, LabelMask);
|
||||
XMapRaised(X_Dpy, sc->searchwin);
|
||||
|
||||
XGetInputFocus(G_dpy, &focuswin, &focusrevert);
|
||||
XSetInputFocus(G_dpy, sc->searchwin,
|
||||
XGetInputFocus(X_Dpy, &focuswin, &focusrevert);
|
||||
XSetInputFocus(X_Dpy, sc->searchwin,
|
||||
RevertToPointerRoot, CurrentTime);
|
||||
|
||||
for (;;) {
|
||||
XMaskEvent(G_dpy, LabelMask, &e);
|
||||
XMaskEvent(X_Dpy, LabelMask, &e);
|
||||
|
||||
switch (e.type) {
|
||||
case KeyPress:
|
||||
if (input_keycodetrans(e.xkey.keycode, e.xkey.state,
|
||||
&ctl, &chr, 1) < 0)
|
||||
&ctl, &chr, 0) < 0)
|
||||
continue;
|
||||
|
||||
switch (ctl) {
|
||||
@ -395,7 +318,7 @@ grab_label(struct client_ctx *cc)
|
||||
xfree(cc->label);
|
||||
|
||||
cc->label = xstrdup(labelstr);
|
||||
|
||||
/* FALLTHROUGH */
|
||||
case CTL_ABORT:
|
||||
goto out;
|
||||
default:
|
||||
@ -415,8 +338,8 @@ grab_label(struct client_ctx *cc)
|
||||
dx = font_width(font, dispstr, strlen(dispstr));
|
||||
dy = fontheight;
|
||||
|
||||
XClearWindow(G_dpy, sc->searchwin);
|
||||
XResizeWindow(G_dpy, sc->searchwin, dx, dy);
|
||||
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);
|
||||
@ -425,12 +348,12 @@ grab_label(struct client_ctx *cc)
|
||||
}
|
||||
|
||||
out:
|
||||
XSetInputFocus(G_dpy, focuswin,
|
||||
XSetInputFocus(X_Dpy, focuswin,
|
||||
focusrevert, CurrentTime);
|
||||
XUnmapWindow(G_dpy, sc->searchwin);
|
||||
XUnmapWindow(X_Dpy, sc->searchwin);
|
||||
}
|
||||
|
||||
int
|
||||
static int
|
||||
_sweepcalc(struct client_ctx *cc, int x0, int y0, int motionx, int motiony)
|
||||
{
|
||||
int width, height;
|
||||
@ -464,12 +387,15 @@ _sweepcalc(struct client_ctx *cc, int x0, int y0, int motionx, int motiony)
|
||||
return (width != cc->geom.width || height != cc->geom.height);
|
||||
}
|
||||
|
||||
/* XXX */
|
||||
int
|
||||
_nobuttons(XButtonEvent *e) /* Einstuerzende */
|
||||
static int
|
||||
menu_calc_entry(int x, int y, int width, int height, int noentries)
|
||||
{
|
||||
int state;
|
||||
int entry = y/height;
|
||||
|
||||
state = (e->state & AllButtonMask);
|
||||
return (e->type == ButtonRelease) && (state & (state - 1)) == 0;
|
||||
/* in bounds? */
|
||||
if (x < 0 || x > width || y < 0 || y > height*noentries ||
|
||||
entry < 0 || entry >= noentries)
|
||||
entry = -1;
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
190
group.c
190
group.c
@ -3,7 +3,18 @@
|
||||
*
|
||||
* Copyright (c) 2004 Andy Adamson <dros@monkey.org>
|
||||
* Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -13,17 +24,17 @@
|
||||
|
||||
#define CALMWM_NGROUPS 9
|
||||
|
||||
int G_groupmode = 0;
|
||||
int G_groupnamemode = 0;
|
||||
struct group_ctx *G_group_active = NULL;
|
||||
struct group_ctx *G_group_current = NULL;
|
||||
struct group_ctx G_groups[CALMWM_NGROUPS];
|
||||
char G_group_name[256];
|
||||
int G_groupfocusset = 0;
|
||||
Window G_groupfocuswin;
|
||||
int G_groupfocusrevert;
|
||||
int G_grouphideall = 0;
|
||||
struct group_ctx_q G_groupq;
|
||||
int Groupmode = 0;
|
||||
int Groupnamemode = 0;
|
||||
struct group_ctx *Group_active = NULL;
|
||||
struct group_ctx *Group_current = NULL;
|
||||
struct group_ctx Groups[CALMWM_NGROUPS];
|
||||
char Group_name[256];
|
||||
int Groupfocusset = 0;
|
||||
Window Groupfocuswin;
|
||||
int Groupfocusrevert;
|
||||
int Grouphideall = 0;
|
||||
struct group_ctx_q Groupq;
|
||||
|
||||
#define GroupMask (KeyPressMask|ExposureMask)
|
||||
|
||||
@ -81,7 +92,7 @@ _group_purge(struct group_ctx *gc)
|
||||
struct client_ctx *cc;
|
||||
|
||||
if (gc == NULL)
|
||||
errx(1, "_group_commit: ctx is null");
|
||||
errx(1, "_group_purge: ctx is null");
|
||||
|
||||
TAILQ_FOREACH(cc, &gc->clients, group_entry)
|
||||
if (cc->groupcommit == 0)
|
||||
@ -137,11 +148,11 @@ _group_show(struct group_ctx *gc)
|
||||
}
|
||||
}
|
||||
|
||||
XRestackWindows(G_dpy, winlist, gc->nhidden);
|
||||
XRestackWindows(X_Dpy, winlist, gc->nhidden);
|
||||
xfree(winlist);
|
||||
|
||||
gc->hidden = 0;
|
||||
G_group_active = gc;
|
||||
Group_active = gc;
|
||||
}
|
||||
|
||||
|
||||
@ -170,52 +181,31 @@ group_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
TAILQ_INIT(&G_groupq);
|
||||
TAILQ_INIT(&Groupq);
|
||||
|
||||
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
||||
TAILQ_INIT(&G_groups[i].clients);
|
||||
G_groups[i].hidden = 0;
|
||||
G_groups[i].shortcut = i + 1;
|
||||
TAILQ_INSERT_TAIL(&G_groupq, &G_groups[i], entry);
|
||||
TAILQ_INIT(&Groups[i].clients);
|
||||
Groups[i].hidden = 0;
|
||||
Groups[i].shortcut = i + 1;
|
||||
TAILQ_INSERT_TAIL(&Groupq, &Groups[i], entry);
|
||||
}
|
||||
|
||||
G_group_current = G_group_active = &G_groups[0];
|
||||
Group_current = Group_active = &Groups[0];
|
||||
}
|
||||
|
||||
/*
|
||||
* manipulate the 'current group'
|
||||
*/
|
||||
|
||||
#if 0
|
||||
/* set current group to the first empty group
|
||||
* returns 0 on success, -1 if there are no empty groups
|
||||
*/
|
||||
int
|
||||
group_new(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0; i < CALMWM_NGROUPS; i++) {
|
||||
if (TAILQ_EMPTY(&G_groups[i].clients)) {
|
||||
G_group_current = &G_groups[i];
|
||||
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* change the current group */
|
||||
int
|
||||
void
|
||||
group_select(int idx)
|
||||
{
|
||||
struct group_ctx *gc = G_group_current;
|
||||
struct group_ctx *gc = Group_current;
|
||||
struct client_ctx *cc;
|
||||
|
||||
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
||||
return (-1);
|
||||
return;
|
||||
|
||||
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
|
||||
cc->highlight = 0;
|
||||
@ -223,26 +213,26 @@ group_select(int idx)
|
||||
}
|
||||
|
||||
_group_commit(gc);
|
||||
G_group_current = &G_groups[idx];
|
||||
Group_current = &Groups[idx];
|
||||
|
||||
group_display_draw(screen_current());
|
||||
return (0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* enter group mode */
|
||||
void
|
||||
group_enter(void)
|
||||
{
|
||||
if (G_groupmode != 0)
|
||||
if (Groupmode != 0)
|
||||
errx(1, "group_enter called twice");
|
||||
|
||||
if (G_group_current == NULL)
|
||||
G_group_current = &G_groups[0];
|
||||
if (Group_current == NULL)
|
||||
Group_current = &Groups[0];
|
||||
|
||||
/* setup input buffer */
|
||||
G_group_name[0] = '\0';
|
||||
Group_name[0] = '\0';
|
||||
|
||||
G_groupmode = 1;
|
||||
Groupmode = 1;
|
||||
|
||||
group_display_init(screen_current());
|
||||
group_display_draw(screen_current());
|
||||
@ -252,10 +242,10 @@ group_enter(void)
|
||||
void
|
||||
group_exit(int commit)
|
||||
{
|
||||
struct group_ctx *gc = G_group_current;
|
||||
struct group_ctx *gc = Group_current;
|
||||
struct client_ctx *cc;
|
||||
|
||||
if (G_groupmode != 1)
|
||||
if (Groupmode != 1)
|
||||
errx(1, "group_exit called twice");
|
||||
|
||||
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
|
||||
@ -272,21 +262,21 @@ group_exit(int commit)
|
||||
_group_destroy(gc);
|
||||
}
|
||||
|
||||
XUnmapWindow(G_dpy, screen_current()->groupwin);
|
||||
XUnmapWindow(X_Dpy, screen_current()->groupwin);
|
||||
|
||||
if (G_groupnamemode) {
|
||||
XSetInputFocus(G_dpy, G_groupfocuswin, G_groupfocusrevert,
|
||||
if (Groupnamemode) {
|
||||
XSetInputFocus(X_Dpy, Groupfocuswin, Groupfocusrevert,
|
||||
CurrentTime);
|
||||
G_groupfocusset = 0;
|
||||
Groupfocusset = 0;
|
||||
}
|
||||
|
||||
G_groupmode = G_groupnamemode = 0;
|
||||
Groupmode = Groupnamemode = 0;
|
||||
}
|
||||
|
||||
void
|
||||
group_click(struct client_ctx *cc)
|
||||
{
|
||||
struct group_ctx *gc = G_group_current;
|
||||
struct group_ctx *gc = Group_current;
|
||||
|
||||
if (gc == cc->group)
|
||||
_group_remove(cc);
|
||||
@ -301,13 +291,13 @@ group_click(struct client_ctx *cc)
|
||||
void
|
||||
group_sticky(struct client_ctx *cc)
|
||||
{
|
||||
_group_add(G_group_active, cc);
|
||||
_group_add(Group_active, cc);
|
||||
}
|
||||
|
||||
void
|
||||
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) {
|
||||
_group_remove(cc);
|
||||
@ -334,15 +324,15 @@ group_sticky_toggle_exit(struct client_ctx *cc)
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
group_display_draw(struct screen_ctx *sc)
|
||||
{
|
||||
struct group_ctx *gc = G_group_current;
|
||||
int x, y, dx, dy, fontheight, titlelen;
|
||||
struct group_ctx *gc = Group_current;
|
||||
int x, y, dx, dy, fontheight;
|
||||
struct client_ctx *cc;
|
||||
char titlebuf[1024];
|
||||
struct fontdesc *font = DefaultFont;
|
||||
@ -352,7 +342,7 @@ group_display_draw(struct screen_ctx *sc)
|
||||
x = y = 0;
|
||||
|
||||
fontheight = font_ascent(font) + font_descent(font) + 1;
|
||||
dx = titlelen = font_width(font, titlebuf, strlen(titlebuf));
|
||||
dx = font_width(font, titlebuf, strlen(titlebuf));
|
||||
dy = fontheight;
|
||||
|
||||
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
|
||||
@ -360,13 +350,13 @@ group_display_draw(struct screen_ctx *sc)
|
||||
client_draw_border(cc);
|
||||
}
|
||||
|
||||
XMoveResizeWindow(G_dpy, sc->groupwin, x, y, dx, dy);
|
||||
XMoveResizeWindow(X_Dpy, sc->groupwin, x, y, dx, dy);
|
||||
|
||||
/* XXX */
|
||||
XSelectInput(G_dpy, sc->groupwin, GroupMask);
|
||||
XSelectInput(X_Dpy, sc->groupwin, GroupMask);
|
||||
|
||||
XMapRaised(G_dpy, sc->groupwin);
|
||||
XClearWindow(G_dpy, sc->groupwin);
|
||||
XMapRaised(X_Dpy, sc->groupwin);
|
||||
XClearWindow(X_Dpy, sc->groupwin);
|
||||
font_draw(font, titlebuf, strlen(titlebuf), sc->groupwin,
|
||||
0, font_ascent(font) + 1);
|
||||
}
|
||||
@ -374,12 +364,12 @@ group_display_draw(struct screen_ctx *sc)
|
||||
void
|
||||
group_display_keypress(KeyCode k)
|
||||
{
|
||||
struct group_ctx * gc = G_group_current;
|
||||
struct group_ctx * gc = Group_current;
|
||||
char chr;
|
||||
enum ctltype ctl;
|
||||
int len;
|
||||
|
||||
if (!G_groupnamemode)
|
||||
if (!Groupnamemode)
|
||||
return;
|
||||
|
||||
if (input_keycodetrans(k, 0, &ctl, &chr, 1) < 0)
|
||||
@ -387,14 +377,14 @@ group_display_keypress(KeyCode k)
|
||||
|
||||
switch (ctl) {
|
||||
case CTL_ERASEONE:
|
||||
if ((len = strlen(G_group_name)) > 0)
|
||||
G_group_name[len - 1] = '\0';
|
||||
if ((len = strlen(Group_name)) > 0)
|
||||
Group_name[len - 1] = '\0';
|
||||
break;
|
||||
case CTL_RETURN:
|
||||
if (gc->name != NULL)
|
||||
xfree(gc->name);
|
||||
|
||||
gc->name = xstrdup(G_group_name);
|
||||
gc->name = xstrdup(Group_name);
|
||||
|
||||
group_exit(1);
|
||||
return;
|
||||
@ -403,8 +393,8 @@ group_display_keypress(KeyCode k)
|
||||
}
|
||||
|
||||
if (chr != '\0')
|
||||
snprintf(G_group_name, sizeof(G_group_name), "%s%c",
|
||||
G_group_name, chr);
|
||||
snprintf(Group_name, sizeof(Group_name), "%s%c",
|
||||
Group_name, chr);
|
||||
|
||||
out:
|
||||
group_display_draw(screen_current());
|
||||
@ -438,7 +428,7 @@ group_hidetoggle(int idx)
|
||||
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
||||
err(1, "group_hidetoggle: index out of range (%d)", idx);
|
||||
|
||||
gc = &G_groups[idx];
|
||||
gc = &Groups[idx];
|
||||
|
||||
_group_fix_hidden_state(gc);
|
||||
|
||||
@ -447,7 +437,7 @@ group_hidetoggle(int idx)
|
||||
else {
|
||||
_group_hide(gc);
|
||||
if (TAILQ_EMPTY(&gc->clients))
|
||||
G_group_active = gc;
|
||||
Group_active = gc;
|
||||
}
|
||||
|
||||
#ifdef notyet
|
||||
@ -468,15 +458,15 @@ group_slide(int fwd)
|
||||
{
|
||||
struct group_ctx *gc, *showgroup = NULL;
|
||||
|
||||
assert(G_group_active != NULL);
|
||||
assert(Group_active != NULL);
|
||||
|
||||
gc = G_group_active;
|
||||
gc = Group_active;
|
||||
for (;;) {
|
||||
gc = GROUP_NEXT(gc, fwd);
|
||||
if (gc == NULL)
|
||||
gc = fwd ? TAILQ_FIRST(&G_groupq) :
|
||||
TAILQ_LAST(&G_groupq, group_ctx_q);
|
||||
if (gc == G_group_active)
|
||||
gc = fwd ? TAILQ_FIRST(&Groupq) :
|
||||
TAILQ_LAST(&Groupq, group_ctx_q);
|
||||
if (gc == Group_active)
|
||||
break;
|
||||
|
||||
if (!TAILQ_EMPTY(&gc->clients) && showgroup == NULL)
|
||||
@ -488,12 +478,12 @@ group_slide(int fwd)
|
||||
if (showgroup == NULL)
|
||||
return;
|
||||
|
||||
_group_hide(G_group_active);
|
||||
_group_hide(Group_active);
|
||||
|
||||
if (showgroup->hidden)
|
||||
_group_show(showgroup);
|
||||
else
|
||||
G_group_active = showgroup;
|
||||
Group_active = showgroup;
|
||||
}
|
||||
|
||||
/* called when a client is deleted */
|
||||
@ -519,7 +509,7 @@ group_menu(XButtonEvent *e)
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
||||
gc = &G_groups[i];
|
||||
gc = &Groups[i];
|
||||
|
||||
if (TAILQ_EMPTY(&gc->clients))
|
||||
continue;
|
||||
@ -563,7 +553,7 @@ group_menu(XButtonEvent *e)
|
||||
void
|
||||
group_namemode(void)
|
||||
{
|
||||
G_groupnamemode = 1;
|
||||
Groupnamemode = 1;
|
||||
|
||||
group_display_draw(screen_current());
|
||||
}
|
||||
@ -574,31 +564,31 @@ group_alltoggle(void)
|
||||
int i;
|
||||
|
||||
for (i=0; i < CALMWM_NGROUPS; i++) {
|
||||
if (G_grouphideall)
|
||||
_group_show(&G_groups[i]);
|
||||
if (Grouphideall)
|
||||
_group_show(&Groups[i]);
|
||||
else
|
||||
_group_hide(&G_groups[i]);
|
||||
_group_hide(&Groups[i]);
|
||||
}
|
||||
|
||||
if (G_grouphideall)
|
||||
G_grouphideall = 0;
|
||||
if (Grouphideall)
|
||||
Grouphideall = 0;
|
||||
else
|
||||
G_grouphideall = 1;
|
||||
Grouphideall = 1;
|
||||
}
|
||||
|
||||
void
|
||||
group_deletecurrent(void)
|
||||
{
|
||||
_group_destroy(G_group_current);
|
||||
XUnmapWindow(G_dpy, screen_current()->groupwin);
|
||||
_group_destroy(Group_current);
|
||||
XUnmapWindow(X_Dpy, screen_current()->groupwin);
|
||||
|
||||
G_groupmode = G_groupnamemode = 0;
|
||||
Groupmode = Groupnamemode = 0;
|
||||
}
|
||||
|
||||
void
|
||||
group_done(void)
|
||||
{
|
||||
struct group_ctx *gc = G_group_current;
|
||||
struct group_ctx *gc = Group_current;
|
||||
|
||||
if (gc->name != NULL)
|
||||
xfree(gc->name);
|
||||
@ -618,7 +608,7 @@ group_autogroup(struct client_ctx *cc)
|
||||
if (cc->app_class == NULL || cc->app_name == NULL)
|
||||
return;
|
||||
|
||||
TAILQ_FOREACH(aw, &G_conf.autogroupq, entry) {
|
||||
TAILQ_FOREACH(aw, &Conf.autogroupq, entry) {
|
||||
if (strcmp(aw->class, cc->app_class) == 0 &&
|
||||
(aw->name == NULL || strcmp(aw->name, cc->app_name) == 0)) {
|
||||
strlcpy(group, aw->group, sizeof(group));
|
||||
@ -626,7 +616,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)
|
||||
_group_add(gc, cc);
|
||||
}
|
||||
|
21
headers.h
21
headers.h
@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -12,10 +23,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif /* HAVE_CONFIG_H */
|
||||
|
||||
#include <sys/queue.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/param.h>
|
||||
@ -43,10 +50,6 @@
|
||||
#include <X11/Xos.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
#ifdef USE_XOSD
|
||||
#include <xosd.h>
|
||||
#endif /* USE_XOSD */
|
||||
|
||||
#include <err.h>
|
||||
|
||||
#endif /* _CALMWM_HEADERS_H_ */
|
||||
|
18
input.c
18
input.c
@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -19,7 +30,10 @@ input_keycodetrans(KeyCode kc, u_int state,
|
||||
*ctl = CTL_NONE;
|
||||
*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. */
|
||||
switch (ks) {
|
||||
|
323
install-sh
323
install-sh
@ -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:
|
349
kbfunc.c
349
kbfunc.c
@ -2,14 +2,31 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Martin Murray <mmurray@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <paths.h>
|
||||
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
#define KNOWN_HOSTS ".ssh/known_hosts"
|
||||
#define HASH_MARKER "|1|"
|
||||
#define MOVE_AMOUNT 1
|
||||
|
||||
void
|
||||
kbfunc_client_lower(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
@ -22,6 +39,128 @@ kbfunc_client_raise(struct client_ctx *cc, void *arg)
|
||||
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
|
||||
kbfunc_client_resize(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
int flags,mx,my;
|
||||
u_int amt;
|
||||
|
||||
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.height += my;
|
||||
cc->geom.width += mx;
|
||||
client_resize(cc);
|
||||
|
||||
/*
|
||||
* Moving the cursor while resizing is problematic. Just place
|
||||
* it in the middle of the window.
|
||||
*/
|
||||
cc->ptr.x = -1;
|
||||
cc->ptr.y = -1;
|
||||
client_ptrwarp(cc);
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_ptrmove(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
int px,py,mx,my,flags,amt;
|
||||
struct screen_ctx *sc = screen_current();
|
||||
my = mx = 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;
|
||||
}
|
||||
|
||||
if (cc) {
|
||||
xu_ptr_getpos(cc->pwin, &px, &py);
|
||||
xu_ptr_setpos(cc->pwin, px + mx, py + my);
|
||||
} else {
|
||||
xu_ptr_getpos(sc->rootwin, &px, &py);
|
||||
xu_ptr_setpos(sc->rootwin, px + mx, py + my);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_client_search(struct client_ctx *scratch, void *arg)
|
||||
{
|
||||
@ -31,8 +170,7 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg)
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
TAILQ_FOREACH(cc, &G_clientq, entry) {
|
||||
struct menu *mi;
|
||||
TAILQ_FOREACH(cc, &Clientq, entry) {
|
||||
XCALLOC(mi, struct menu);
|
||||
strlcpy(mi->text, cc->name, sizeof(mi->text));
|
||||
mi->ctx = cc;
|
||||
@ -41,7 +179,7 @@ kbfunc_client_search(struct client_ctx *scratch, void *arg)
|
||||
|
||||
if ((mi = search_start(&menuq,
|
||||
search_match_client, NULL,
|
||||
search_print_client, "window")) != NULL) {
|
||||
search_print_client, "window", 0)) != NULL) {
|
||||
cc = (struct client_ctx *)mi->ctx;
|
||||
if (cc->flags & CLIENT_HIDDEN)
|
||||
client_unhide(cc);
|
||||
@ -66,8 +204,8 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg)
|
||||
|
||||
TAILQ_INIT(&menuq);
|
||||
|
||||
conf_cmd_refresh(&G_conf);
|
||||
TAILQ_FOREACH(cmd, &G_conf.cmdq, entry) {
|
||||
conf_cmd_refresh(&Conf);
|
||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
||||
XCALLOC(mi, struct menu);
|
||||
strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
||||
mi->ctx = cmd;
|
||||
@ -75,7 +213,7 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg)
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||
@ -85,15 +223,15 @@ kbfunc_menu_search(struct client_ctx *scratch, void *arg)
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
@ -111,15 +249,190 @@ kbfunc_cmdexec(struct client_ctx *cc, void *arg)
|
||||
void
|
||||
kbfunc_term(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
conf_cmd_refresh(&G_conf);
|
||||
u_spawn(G_conf.termpath);
|
||||
conf_cmd_refresh(&Conf);
|
||||
u_spawn(Conf.termpath);
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_lock(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
conf_cmd_refresh(&G_conf);
|
||||
u_spawn(G_conf.lockpath);
|
||||
conf_cmd_refresh(&Conf);
|
||||
u_spawn(Conf.lockpath);
|
||||
}
|
||||
|
||||
void
|
||||
kbfunc_exec(struct client_ctx *scratch, void *arg)
|
||||
{
|
||||
#define NPATHS 256
|
||||
char **ap, *paths[NPATHS], *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;
|
||||
char *label;
|
||||
|
||||
int cmd = (int)arg;
|
||||
switch(cmd) {
|
||||
case CWM_EXEC_PROGRAM:
|
||||
label = "exec";
|
||||
break;
|
||||
case CWM_EXEC_WM:
|
||||
label = "wm";
|
||||
break;
|
||||
default:
|
||||
err(1, "kbfunc_exec: invalid cmd %d", cmd);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
|
||||
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[NPATHS - 1] &&
|
||||
(*ap = strsep(&path, ":")) != NULL;) {
|
||||
if (**ap != '\0')
|
||||
ap++;
|
||||
}
|
||||
*ap = NULL;
|
||||
for (i = 0; i < NPATHS && 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, label, 1)) != NULL) {
|
||||
switch (cmd) {
|
||||
case CWM_EXEC_PROGRAM:
|
||||
u_spawn(mi->text);
|
||||
break;
|
||||
case CWM_EXEC_WM:
|
||||
exec_wm(mi->text);
|
||||
break;
|
||||
default:
|
||||
err(1, "kb_func: egad, cmd changed value!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
@ -137,7 +450,7 @@ kbfunc_client_delete(struct client_ctx *cc, void *arg)
|
||||
void
|
||||
kbfunc_client_groupselect(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
if (G_groupmode)
|
||||
if (Groupmode)
|
||||
group_done();
|
||||
else
|
||||
group_enter();
|
||||
@ -146,7 +459,7 @@ kbfunc_client_groupselect(struct client_ctx *cc, void *arg)
|
||||
void
|
||||
kbfunc_client_group(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
if (G_groupmode)
|
||||
if (Groupmode)
|
||||
group_select(KBTOGROUP((int)arg));
|
||||
else
|
||||
group_hidetoggle(KBTOGROUP((int)arg));
|
||||
@ -167,7 +480,7 @@ kbfunc_client_prevgroup(struct client_ctx *cc, void *arg)
|
||||
void
|
||||
kbfunc_client_nogroup(struct client_ctx *cc, void *arg)
|
||||
{
|
||||
if (G_groupmode)
|
||||
if (Groupmode)
|
||||
group_deletecurrent();
|
||||
else
|
||||
group_alltoggle();
|
||||
|
360
missing
360
missing
@ -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:
|
35
screen.c
35
screen.c
@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -10,14 +21,14 @@
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
extern struct screen_ctx_q G_screenq;
|
||||
extern struct screen_ctx *G_curscreen;
|
||||
extern struct screen_ctx_q Screenq;
|
||||
extern struct screen_ctx *Curscreen;
|
||||
|
||||
static void
|
||||
_clearwindow_cb(int sig)
|
||||
{
|
||||
struct screen_ctx *sc = screen_current();
|
||||
XUnmapWindow(G_dpy, sc->infowin);
|
||||
XUnmapWindow(X_Dpy, sc->infowin);
|
||||
}
|
||||
|
||||
struct screen_ctx *
|
||||
@ -25,18 +36,18 @@ screen_fromroot(Window rootwin)
|
||||
{
|
||||
struct screen_ctx *sc;
|
||||
|
||||
TAILQ_FOREACH(sc, &G_screenq, entry)
|
||||
TAILQ_FOREACH(sc, &Screenq, entry)
|
||||
if (sc->rootwin == rootwin)
|
||||
return (sc);
|
||||
|
||||
/* XXX FAIL HERE */
|
||||
return (TAILQ_FIRST(&G_screenq));
|
||||
return (TAILQ_FIRST(&Screenq));
|
||||
}
|
||||
|
||||
struct screen_ctx *
|
||||
screen_current(void)
|
||||
{
|
||||
return (G_curscreen);
|
||||
return (Curscreen);
|
||||
}
|
||||
|
||||
void
|
||||
@ -47,7 +58,7 @@ screen_updatestackingorder(void)
|
||||
u_int nwins, i, s;
|
||||
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;
|
||||
|
||||
for (s = 0, i = 0; i < nwins; i++) {
|
||||
@ -70,7 +81,7 @@ screen_init(void)
|
||||
|
||||
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);
|
||||
|
||||
/* XXX - marius. */
|
||||
@ -86,15 +97,15 @@ screen_infomsg(char *msg)
|
||||
int dy, dx;
|
||||
struct fontdesc *font = DefaultFont;
|
||||
|
||||
XUnmapWindow(G_dpy, sc->infowin);
|
||||
XUnmapWindow(X_Dpy, sc->infowin);
|
||||
alarm(0);
|
||||
|
||||
snprintf(buf, sizeof(buf), ">%s", msg);
|
||||
dy = font_ascent(font) + font_descent(font) + 1;
|
||||
dx = font_width(font, buf, strlen(buf));
|
||||
|
||||
XMoveResizeWindow(G_dpy, sc->infowin, 0, 0, dx, dy);
|
||||
XMapRaised(G_dpy, sc->infowin);
|
||||
XMoveResizeWindow(X_Dpy, sc->infowin, 0, 0, dx, dy);
|
||||
XMapRaised(X_Dpy, sc->infowin);
|
||||
|
||||
font_draw(font, buf, strlen(buf), sc->infowin,
|
||||
0, font_ascent(font) + 1);
|
||||
|
104
search.c
104
search.c
@ -2,7 +2,17 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -12,12 +22,12 @@
|
||||
|
||||
#define SearchMask (KeyPressMask|ExposureMask)
|
||||
|
||||
static int _strsubmatch(char *, char *);
|
||||
static int _strsubmatch(char *, char *, int);
|
||||
|
||||
void
|
||||
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);
|
||||
}
|
||||
|
||||
@ -37,7 +47,7 @@ search_start(struct menu_q *menuq,
|
||||
void (*match)(struct menu_q *, struct menu_q *, char *),
|
||||
void (*rank)(struct menu_q *resultq, char *search),
|
||||
void (*print)(struct menu *mi, int print),
|
||||
char *prompt)
|
||||
char *prompt, int dummy)
|
||||
{
|
||||
struct screen_ctx *sc = screen_current();
|
||||
int x, y, dx, dy, fontheight,
|
||||
@ -47,7 +57,7 @@ search_start(struct menu_q *menuq,
|
||||
char dispstr[MENU_MAXENTRY*2 + 1];
|
||||
char promptstr[MENU_MAXENTRY + 1];
|
||||
Window focuswin;
|
||||
struct menu *mi = NULL;
|
||||
struct menu *mi = NULL, *dummy_mi = NULL;
|
||||
struct menu_q resultq;
|
||||
char chr;
|
||||
enum ctltype ctl;
|
||||
@ -63,8 +73,8 @@ search_start(struct menu_q *menuq,
|
||||
|
||||
TAILQ_INIT(&resultq);
|
||||
|
||||
xmax = DisplayWidth(G_dpy, sc->which);
|
||||
ymax = DisplayHeight(G_dpy, sc->which);
|
||||
xmax = DisplayWidth(X_Dpy, sc->which);
|
||||
ymax = DisplayHeight(X_Dpy, sc->which);
|
||||
|
||||
xu_ptr_getpos(sc->rootwin, &x, &y);
|
||||
|
||||
@ -75,27 +85,27 @@ search_start(struct menu_q *menuq,
|
||||
snprintf(dispstr, sizeof(dispstr), "%s%c", promptstr, endchar);
|
||||
dx = font_width(font, dispstr, strlen(dispstr));
|
||||
|
||||
XMoveResizeWindow(G_dpy, sc->searchwin, x, y, dx, dy);
|
||||
XSelectInput(G_dpy, sc->searchwin, SearchMask);
|
||||
XMapRaised(G_dpy, sc->searchwin);
|
||||
XMoveResizeWindow(X_Dpy, sc->searchwin, x, y, dx, dy);
|
||||
XSelectInput(X_Dpy, sc->searchwin, SearchMask);
|
||||
XMapRaised(X_Dpy, sc->searchwin);
|
||||
|
||||
/*
|
||||
* TODO: eventually, the mouse should be able to select
|
||||
* results as well. Right now we grab it only to set a fancy
|
||||
* cursor.
|
||||
*/
|
||||
if (xu_ptr_grab(sc->searchwin, 0, G_cursor_question) < 0) {
|
||||
XUnmapWindow(G_dpy, sc->searchwin);
|
||||
if (xu_ptr_grab(sc->searchwin, 0, Cursor_question) < 0) {
|
||||
XUnmapWindow(X_Dpy, sc->searchwin);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
XGetInputFocus(G_dpy, &focuswin, &focusrevert);
|
||||
XSetInputFocus(G_dpy, sc->searchwin, RevertToPointerRoot, CurrentTime);
|
||||
XGetInputFocus(X_Dpy, &focuswin, &focusrevert);
|
||||
XSetInputFocus(X_Dpy, sc->searchwin, RevertToPointerRoot, CurrentTime);
|
||||
|
||||
for (;;) {
|
||||
added = mutated = 0;
|
||||
|
||||
XMaskEvent(G_dpy, SearchMask, &e);
|
||||
XMaskEvent(X_Dpy, SearchMask, &e);
|
||||
|
||||
switch (e.type) {
|
||||
case KeyPress:
|
||||
@ -133,16 +143,22 @@ search_start(struct menu_q *menuq,
|
||||
case CTL_RETURN:
|
||||
/* This is just picking the match the
|
||||
* cursor is over. */
|
||||
if ((mi = TAILQ_FIRST(&resultq)) != NULL)
|
||||
if ((mi = TAILQ_FIRST(&resultq)) != NULL) {
|
||||
goto found;
|
||||
else
|
||||
goto out;
|
||||
} else if (dummy) {
|
||||
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:
|
||||
searchstr[0] = '\0';
|
||||
mutated = 1;
|
||||
break;
|
||||
case CTL_ALL:
|
||||
list = !list;
|
||||
list = !list;
|
||||
break;
|
||||
case CTL_ABORT:
|
||||
goto out;
|
||||
@ -233,14 +249,19 @@ search_start(struct menu_q *menuq,
|
||||
}
|
||||
if (y + dy >= ymax) {
|
||||
y = ymax - dy;
|
||||
/* If the menu is too high, never hide the
|
||||
* top of the menu.
|
||||
*/
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
warp = 1;
|
||||
}
|
||||
|
||||
if (warp)
|
||||
xu_ptr_setpos(sc->rootwin, x, y);
|
||||
|
||||
XClearWindow(G_dpy, sc->searchwin);
|
||||
XMoveResizeWindow(G_dpy, sc->searchwin, x, y, dx, dy);
|
||||
XClearWindow(X_Dpy, sc->searchwin);
|
||||
XMoveResizeWindow(X_Dpy, sc->searchwin, x, y, dx, dy);
|
||||
|
||||
font_draw(font, dispstr, strlen(dispstr), sc->searchwin,
|
||||
0, font_ascent(font) + 1);
|
||||
@ -258,11 +279,11 @@ search_start(struct menu_q *menuq,
|
||||
}
|
||||
|
||||
if (n > 1)
|
||||
XFillRectangle(G_dpy, sc->searchwin, sc->gc,
|
||||
XFillRectangle(X_Dpy, sc->searchwin, sc->gc,
|
||||
0, fontheight, dx, fontheight);
|
||||
|
||||
if (beobnoxious)
|
||||
XFillRectangle(G_dpy, sc->searchwin, sc->gc,
|
||||
XFillRectangle(X_Dpy, sc->searchwin, sc->gc,
|
||||
0, 0, dx, fontheight);
|
||||
|
||||
break;
|
||||
@ -272,10 +293,13 @@ search_start(struct menu_q *menuq,
|
||||
out:
|
||||
/* (if no match) */
|
||||
xu_ptr_ungrab();
|
||||
XSetInputFocus(G_dpy, focuswin, focusrevert, CurrentTime);
|
||||
found:
|
||||
XUnmapWindow(G_dpy, sc->searchwin);
|
||||
XSetInputFocus(X_Dpy, focuswin, focusrevert, CurrentTime);
|
||||
|
||||
found:
|
||||
XUnmapWindow(X_Dpy, sc->searchwin);
|
||||
|
||||
if (dummy && dummy_mi != NULL)
|
||||
return (dummy_mi);
|
||||
return (mi);
|
||||
}
|
||||
|
||||
@ -307,7 +331,7 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||
struct client_ctx *cc = mi->ctx;
|
||||
|
||||
/* 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;
|
||||
tier = 0;
|
||||
}
|
||||
@ -315,7 +339,7 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||
/* Then, on window names. */
|
||||
if (tier < 0) {
|
||||
TAILQ_FOREACH_REVERSE(wn, &cc->nameq, winname_q, entry)
|
||||
if (_strsubmatch(search, wn->name)) {
|
||||
if (_strsubmatch(search, wn->name, 0)) {
|
||||
cc->matchname = wn->name;
|
||||
tier = 2;
|
||||
break;
|
||||
@ -327,7 +351,7 @@ search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||
* name.
|
||||
*/
|
||||
|
||||
if (tier < 0 && _strsubmatch(search, cc->app_class)) {
|
||||
if (tier < 0 && _strsubmatch(search, cc->app_class, 0)) {
|
||||
cc->matchname = cc->app_class;
|
||||
tier = 3;
|
||||
}
|
||||
@ -417,21 +441,27 @@ search_match_text(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||
TAILQ_INIT(resultq);
|
||||
|
||||
TAILQ_FOREACH(mi, menuq, entry)
|
||||
if (_strsubmatch(search, mi->text))
|
||||
if (_strsubmatch(search, mi->text, 0))
|
||||
TAILQ_INSERT_TAIL(resultq, mi, resultentry);
|
||||
}
|
||||
|
||||
void
|
||||
search_rank_text(struct menu_q *resultq, char *search)
|
||||
search_match_exec(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||
{
|
||||
return;
|
||||
struct menu *mi;
|
||||
|
||||
TAILQ_INIT(resultq);
|
||||
|
||||
TAILQ_FOREACH(mi, menuq, entry)
|
||||
if (_strsubmatch(search, mi->text, 1))
|
||||
TAILQ_INSERT_TAIL(resultq, mi, resultentry);
|
||||
}
|
||||
|
||||
static int
|
||||
_strsubmatch(char *sub, char *str)
|
||||
_strsubmatch(char *sub, char *str, int zeroidx)
|
||||
{
|
||||
size_t len, sublen;
|
||||
u_int n;
|
||||
u_int n, flen;
|
||||
|
||||
if (sub == NULL || str == NULL)
|
||||
return (0);
|
||||
@ -442,7 +472,11 @@ _strsubmatch(char *sub, char *str)
|
||||
if (sublen > len)
|
||||
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)
|
||||
return (1);
|
||||
|
||||
|
79
strlcat.c
79
strlcat.c
@ -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 */
|
||||
}
|
71
strlcpy.c
71
strlcpy.c
@ -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 */
|
||||
}
|
95
strsep.c
95
strsep.c
@ -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) */
|
28
util.c
28
util.c
@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -39,10 +50,19 @@ u_spawn(char *argstr)
|
||||
return (0);
|
||||
}
|
||||
|
||||
int dirent_exists(char *filename) {
|
||||
struct stat buffer;
|
||||
void
|
||||
exec_wm(char *argstr)
|
||||
{
|
||||
char *args[MAXARGLEN], **ap = args;
|
||||
char **end = &args[MAXARGLEN - 1];
|
||||
|
||||
return stat(filename, &buffer);
|
||||
while (ap < end && (*ap = strsep(&argstr, " \t")) != NULL)
|
||||
ap++;
|
||||
|
||||
*ap = NULL;
|
||||
setsid();
|
||||
execvp(args[0], args);
|
||||
warn(args[0]);
|
||||
}
|
||||
|
||||
int dirent_isdir(char *filename) {
|
||||
|
59
xevents.c
59
xevents.c
@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -16,8 +27,6 @@
|
||||
#include "headers.h"
|
||||
#include "calmwm.h"
|
||||
|
||||
void _sendxmsg(Window, Atom, long);
|
||||
|
||||
/*
|
||||
* NOTE: in reality, many of these should move to client.c now that
|
||||
* we've got this nice event layer.
|
||||
@ -38,7 +47,7 @@ xev_handle_maprequest(struct xevent *xev, XEvent *ee)
|
||||
client_ptrsave(old_cc);
|
||||
|
||||
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);
|
||||
sc = CCTOSC(cc);
|
||||
} else {
|
||||
@ -113,11 +122,11 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee)
|
||||
cc->geom.y = e->y;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
client_gravitate(cc, 1);
|
||||
@ -129,7 +138,7 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee)
|
||||
wc.border_width = 0;
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
@ -142,7 +151,7 @@ xev_handle_configurerequest(struct xevent *xev, XEvent *ee)
|
||||
e->value_mask &= ~CWStackMode;
|
||||
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);
|
||||
}
|
||||
@ -157,7 +166,7 @@ xev_handle_propertynotify(struct xevent *xev, XEvent *ee)
|
||||
if ((cc = client_find(e->window)) != NULL) {
|
||||
switch(e->atom) {
|
||||
case XA_WM_NORMAL_HINTS:
|
||||
XGetWMNormalHints(G_dpy, cc->win, cc->size, &tmp);
|
||||
XGetWMNormalHints(X_Dpy, cc->win, cc->size, &tmp);
|
||||
break;
|
||||
case XA_WM_NAME:
|
||||
client_setname(cc);
|
||||
@ -187,7 +196,7 @@ xev_reconfig(struct client_ctx *cc)
|
||||
ce.above = None;
|
||||
ce.override_redirect = 0;
|
||||
|
||||
XSendEvent(G_dpy, cc->win, False, StructureNotifyMask, (XEvent *)&ce);
|
||||
XSendEvent(X_Dpy, cc->win, False, StructureNotifyMask, (XEvent *)&ce);
|
||||
}
|
||||
|
||||
void
|
||||
@ -246,7 +255,7 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
|
||||
|
||||
switch (e->button) {
|
||||
case Button1:
|
||||
TAILQ_FOREACH(cc, &G_clientq, entry) {
|
||||
TAILQ_FOREACH(cc, &Clientq, entry) {
|
||||
if (cc->flags & CLIENT_HIDDEN) {
|
||||
if (cc->label != NULL)
|
||||
wname = cc->label;
|
||||
@ -266,11 +275,11 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
|
||||
break;
|
||||
case Button3: {
|
||||
struct cmd *cmd;
|
||||
if (conf_cmd_changed(G_conf.menu_path)) {
|
||||
conf_cmd_clear(&G_conf);
|
||||
conf_cmd_populate(&G_conf, G_conf.menu_path);
|
||||
if (conf_cmd_changed(Conf.menu_path)) {
|
||||
conf_cmd_clear(&Conf);
|
||||
conf_cmd_populate(&Conf, Conf.menu_path);
|
||||
}
|
||||
TAILQ_FOREACH(cmd, &G_conf.cmdq, entry) {
|
||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
||||
XCALLOC(mi, struct menu);
|
||||
strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
||||
mi->ctx = cmd;
|
||||
@ -321,7 +330,7 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
|
||||
|
||||
switch (e->button) {
|
||||
case Button1:
|
||||
if (altcontrol && !G_groupmode)
|
||||
if (altcontrol && !Groupmode)
|
||||
group_sticky_toggle_enter(cc);
|
||||
else {
|
||||
grab_drag(cc);
|
||||
@ -330,7 +339,7 @@ xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
|
||||
break;
|
||||
case Button2:
|
||||
/* XXXSIGH!!! */
|
||||
if (G_groupmode)
|
||||
if (Groupmode)
|
||||
group_click(cc);
|
||||
else {
|
||||
grab_sweep(cc);
|
||||
@ -351,7 +360,7 @@ xev_handle_buttonrelease(struct xevent *xev, XEvent *ee)
|
||||
{
|
||||
struct client_ctx *cc = client_current();
|
||||
|
||||
if (cc != NULL && !G_groupmode)
|
||||
if (cc != NULL && !Groupmode)
|
||||
group_sticky_toggle_exit(cc);
|
||||
|
||||
xev_register(xev);
|
||||
@ -367,10 +376,10 @@ xev_handle_keypress(struct xevent *xev, XEvent *ee)
|
||||
KeySym keysym, skeysym;
|
||||
int modshift;
|
||||
|
||||
keysym = XKeycodeToKeysym(G_dpy, e->keycode, 0);
|
||||
skeysym = XKeycodeToKeysym(G_dpy, e->keycode, 1);
|
||||
keysym = XKeycodeToKeysym(X_Dpy, e->keycode, 0);
|
||||
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)
|
||||
modshift = ShiftMask;
|
||||
else
|
||||
@ -404,7 +413,7 @@ out:
|
||||
}
|
||||
|
||||
/*
|
||||
* This is only used for the alt supression detection.
|
||||
* This is only used for the alt suppression detection.
|
||||
*/
|
||||
void
|
||||
xev_handle_keyrelease(struct xevent *xev, XEvent *ee)
|
||||
@ -413,7 +422,7 @@ xev_handle_keyrelease(struct xevent *xev, XEvent *ee)
|
||||
struct screen_ctx *sc = screen_fromroot(e->root);
|
||||
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)
|
||||
goto out;
|
||||
|
||||
@ -435,7 +444,7 @@ xev_handle_clientmessage(struct xevent *xev, XEvent *ee)
|
||||
{
|
||||
XClientMessageEvent *e = &ee->xclient;
|
||||
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)
|
||||
goto out;
|
||||
@ -536,7 +545,7 @@ xev_loop(void)
|
||||
errx(1, "X event queue empty");
|
||||
#endif
|
||||
|
||||
XNextEvent(G_dpy, &e);
|
||||
XNextEvent(X_Dpy, &e);
|
||||
type = e.type;
|
||||
|
||||
win = root = 0;
|
||||
|
13
xmalloc.c
13
xmalloc.c
@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
66
xutil.c
66
xutil.c
@ -2,7 +2,18 @@
|
||||
* calmwm - the calm window manager
|
||||
*
|
||||
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
@ -13,7 +24,7 @@
|
||||
int
|
||||
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,
|
||||
None, curs, CurrentTime) == GrabSuccess ? 0 : -1);
|
||||
}
|
||||
@ -21,20 +32,20 @@ xu_ptr_grab(Window win, int mask, Cursor curs)
|
||||
int
|
||||
xu_ptr_regrab(int mask, Cursor curs)
|
||||
{
|
||||
return (XChangeActivePointerGrab(G_dpy, mask,
|
||||
return (XChangeActivePointerGrab(X_Dpy, mask,
|
||||
curs, CurrentTime) == GrabSuccess ? 0 : -1);
|
||||
}
|
||||
|
||||
void
|
||||
xu_ptr_ungrab(void)
|
||||
{
|
||||
XUngrabPointer(G_dpy, CurrentTime);
|
||||
XUngrabPointer(X_Dpy, CurrentTime);
|
||||
}
|
||||
|
||||
int
|
||||
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,
|
||||
GrabModeSync, None, None) == GrabSuccess ? 0 : -1);
|
||||
}
|
||||
@ -42,7 +53,7 @@ xu_btn_grab(Window win, int mask, u_int btn)
|
||||
void
|
||||
xu_btn_ungrab(Window win, int mask, u_int btn)
|
||||
{
|
||||
XUngrabButton(G_dpy, btn, mask, win);
|
||||
XUngrabButton(X_Dpy, btn, mask, win);
|
||||
}
|
||||
|
||||
void
|
||||
@ -52,13 +63,13 @@ xu_ptr_getpos(Window rootwin, int *x, int *y)
|
||||
u_int tmp2;
|
||||
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
|
||||
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
|
||||
@ -66,23 +77,13 @@ xu_key_grab(Window win, int mask, int keysym)
|
||||
{
|
||||
KeyCode code;
|
||||
|
||||
code = XKeysymToKeycode(G_dpy, keysym);
|
||||
if ((XKeycodeToKeysym(G_dpy, code, 0) != keysym) &&
|
||||
(XKeycodeToKeysym(G_dpy, code, 1) == keysym))
|
||||
code = XKeysymToKeycode(X_Dpy, keysym);
|
||||
if ((XKeycodeToKeysym(X_Dpy, code, 0) != keysym) &&
|
||||
(XKeycodeToKeysym(X_Dpy, code, 1) == keysym))
|
||||
mask |= ShiftMask;
|
||||
|
||||
XGrabKey(G_dpy, XKeysymToKeycode(G_dpy, keysym), mask, win, True,
|
||||
XGrabKey(X_Dpy, XKeysymToKeycode(X_Dpy, keysym), mask, win, True,
|
||||
GrabModeAsync, GrabModeAsync);
|
||||
#if 0
|
||||
XGrabKey(G_dpy, XKeysymToKeycode(G_dpy, keysym), LockMask|mask,
|
||||
win, True, GrabModeAsync, GrabModeAsync);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
xu_key_grab_keycode(Window win, int mask, int keycode)
|
||||
{
|
||||
XGrabKey(G_dpy, keycode, mask, win, True, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
|
||||
void
|
||||
@ -98,7 +99,7 @@ xu_sendmsg(struct client_ctx *cc, Atom atm, long val)
|
||||
e.xclient.data.l[0] = val;
|
||||
e.xclient.data.l[1] = CurrentTime;
|
||||
|
||||
XSendEvent(G_dpy, cc->win, False, 0, &e);
|
||||
XSendEvent(X_Dpy, cc->win, False, 0, &e);
|
||||
}
|
||||
|
||||
int
|
||||
@ -108,7 +109,7 @@ xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p)
|
||||
u_long n, extra;
|
||||
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)
|
||||
return (-1);
|
||||
|
||||
@ -121,7 +122,7 @@ xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p)
|
||||
int
|
||||
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;
|
||||
|
||||
if (xu_getprop(cc, wm_state, wm_state, 2L, (u_char **)&p) <= 0)
|
||||
@ -133,17 +134,6 @@ xu_getstate(struct client_ctx *cc, int *state)
|
||||
return (0);
|
||||
}
|
||||
|
||||
char *
|
||||
xu_getstrprop(struct client_ctx *cc, Atom atm)
|
||||
{
|
||||
u_char *cp;
|
||||
|
||||
if (xu_getprop(cc, atm, XA_STRING, 100L, &cp) <= 0)
|
||||
return (NULL);
|
||||
|
||||
return ((char *)cp);
|
||||
}
|
||||
|
||||
void
|
||||
xu_setstate(struct client_ctx *cc, int state)
|
||||
{
|
||||
@ -151,12 +141,12 @@ xu_setstate(struct client_ctx *cc, int state)
|
||||
Atom wm_state;
|
||||
|
||||
/* XXX cache */
|
||||
wm_state = XInternAtom(G_dpy, "WM_STATE", False);
|
||||
wm_state = XInternAtom(X_Dpy, "WM_STATE", False);
|
||||
|
||||
dat[0] = (long)state;
|
||||
dat[1] = (long)None;
|
||||
|
||||
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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user