mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Initial revision
This commit is contained in:
commit
3d12c94f42
32
LICENSE
Normal file
32
LICENSE
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
Copyright (c) 2004 Andy Adamson <dros@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.
|
||||||
|
|
||||||
|
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.
|
19
Makefile.am
Normal file
19
Makefile.am
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
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
|
3
Makefile.am.inc
Normal file
3
Makefile.am.inc
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
AUTOMAKE_OPTIONS = foreign no-dependencies
|
||||||
|
|
||||||
|
DISTCLEANFILES = *~
|
617
Makefile.in
Normal file
617
Makefile.in
Normal file
@ -0,0 +1,617 @@
|
|||||||
|
# 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:
|
59
README
Normal file
59
README
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
--------------------------------------------------------------------------------
|
||||||
|
cwm release three
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
by Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
contributions by Andy Adamson <dros@monkey.org>,
|
||||||
|
Niels Provos <provos@monkey.org>,
|
||||||
|
Martin Murray <mmurray@monkey.org>,
|
||||||
|
Dimitris Economou <dimeco@stanford.edu> &
|
||||||
|
Antti Nykänen <aon@iki.fi>.
|
||||||
|
|
||||||
|
http://monkey.org/~marius/cwm
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
|
||||||
|
cwm is a window manager initially inspired by evilwm[1]. It
|
||||||
|
developed out of modifications to evilwm, but eventually the code
|
||||||
|
base of evilwm did not accomodate well for the new features added.
|
||||||
|
So calmwm was written from scratch.
|
||||||
|
|
||||||
|
Its main goal is to be as efficient as possible, while providing
|
||||||
|
a very clean, simple & attractive aesthetic.
|
||||||
|
|
||||||
|
cwm has several novel features, including the ability to search
|
||||||
|
for windows.
|
||||||
|
|
||||||
|
HIGHLIGHTS IN RELEASE TWO
|
||||||
|
|
||||||
|
* Improved alt-tabbing, including the ability to reverse cycle.
|
||||||
|
* Display of a context menu when alt-tabbing, showing the previous,
|
||||||
|
current and next window in the cycle order.
|
||||||
|
* Much improved ranking in search.
|
||||||
|
* In search-menus, the ability to list every item.
|
||||||
|
|
||||||
|
HIGHLIGHTS IN RELEASE THREE
|
||||||
|
|
||||||
|
* More search ranking improvements
|
||||||
|
* Many contributions by Antti Nykänen: keyboard binding "i18n",
|
||||||
|
show window labels in minimized window menu, automatic window
|
||||||
|
grouping, MWM hints support & some bug fixes.
|
||||||
|
* Xft support & the addition of the -f flag (see manpage).
|
||||||
|
|
||||||
|
INSTALL
|
||||||
|
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
su
|
||||||
|
make install
|
||||||
|
|
||||||
|
DOCUMENTATION
|
||||||
|
|
||||||
|
See the manpage cwm(1).
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
[1] http://evilwm.sourceforge.net/
|
34
TODO
Normal file
34
TODO
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
- clean up menu code from 9wm
|
||||||
|
|
||||||
|
- window initial position
|
||||||
|
|
||||||
|
- don't map windows if it's within [some time increment] of active typing,
|
||||||
|
this is part of the "calm" goal. also, it helps if you're mindlessly
|
||||||
|
typing in a password and the keyboard input ends up in some other window,
|
||||||
|
bad...
|
||||||
|
|
||||||
|
- integrate everything into /ONE/ event loop.
|
||||||
|
register handlers, with the ability to select, for example,
|
||||||
|
a window, or an event, etc. (no, maybe not...)
|
||||||
|
|
||||||
|
- 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)
|
||||||
|
|
||||||
|
- search should ignore the current window. (not add to match list).
|
||||||
|
|
||||||
|
- make kbd shortcuts/events more general. the ability to associate an
|
||||||
|
event with a mode (i.e. prioritize). gets rid of hacky-ness in
|
||||||
|
groups, etc.
|
||||||
|
|
||||||
|
- figure out what's up when alt-tab goes back to the current window
|
||||||
|
once before moving on.
|
||||||
|
|
||||||
|
- cache all the atoms somewhere.
|
||||||
|
|
||||||
|
- convert globals from G_foo to Foo;
|
27
acconfig.h
Normal file
27
acconfig.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#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
Normal file
949
aclocal.m4
vendored
Normal file
@ -0,0 +1,949 @@
|
|||||||
|
# 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
|
||||||
|
|
345
calmwm.c
Normal file
345
calmwm.c
Normal file
@ -0,0 +1,345 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "headers.h"
|
||||||
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
Display *G_dpy;
|
||||||
|
XFontStruct *G_font;
|
||||||
|
|
||||||
|
Cursor G_cursor_move;
|
||||||
|
Cursor G_cursor_resize;
|
||||||
|
Cursor G_cursor_select;
|
||||||
|
Cursor G_cursor_default;
|
||||||
|
Cursor G_cursor_question;
|
||||||
|
|
||||||
|
struct screen_ctx_q G_screenq;
|
||||||
|
struct screen_ctx *G_curscreen;
|
||||||
|
u_int G_nscreens;
|
||||||
|
|
||||||
|
struct client_ctx_q G_clientq;
|
||||||
|
|
||||||
|
int G_doshape, G_shape_ev;
|
||||||
|
int G_starting;
|
||||||
|
struct conf G_conf;
|
||||||
|
struct fontdesc *DefaultFont;
|
||||||
|
char *DefaultFontName;
|
||||||
|
|
||||||
|
/* From TWM */
|
||||||
|
#define gray_width 2
|
||||||
|
#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);
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
int conf_flags = 0;
|
||||||
|
|
||||||
|
DefaultFontName = "sans-serif:pixelsize=14:bold";
|
||||||
|
|
||||||
|
while ((ch = getopt(argc, argv, "sf:")) != -1) {
|
||||||
|
switch (ch) {
|
||||||
|
case 's':
|
||||||
|
conf_flags |= CONF_STICKY_GROUPS;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
DefaultFontName = xstrdup(optarg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errx(1, "Unknown option '%c'", ch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ignore a few signals. */
|
||||||
|
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
|
||||||
|
err(1, "signal");
|
||||||
|
|
||||||
|
if (signal(SIGCHLD, _sigchld_cb) == SIG_ERR)
|
||||||
|
err(1, "signal");
|
||||||
|
|
||||||
|
group_init();
|
||||||
|
|
||||||
|
G_starting = 1;
|
||||||
|
conf_setup(&G_conf);
|
||||||
|
G_conf.flags |= conf_flags;
|
||||||
|
client_setup();
|
||||||
|
x_setup();
|
||||||
|
G_starting = 0;
|
||||||
|
|
||||||
|
xev_init();
|
||||||
|
XEV_QUICK(NULL, NULL, MapRequest, xev_handle_maprequest, NULL);
|
||||||
|
XEV_QUICK(NULL, NULL, UnmapNotify, xev_handle_unmapnotify, NULL);
|
||||||
|
XEV_QUICK(NULL, NULL, ConfigureRequest,
|
||||||
|
xev_handle_configurerequest, NULL);
|
||||||
|
XEV_QUICK(NULL, NULL, PropertyNotify, xev_handle_propertynotify, NULL);
|
||||||
|
XEV_QUICK(NULL, NULL, EnterNotify, xev_handle_enternotify, NULL);
|
||||||
|
XEV_QUICK(NULL, NULL, LeaveNotify, xev_handle_leavenotify, NULL);
|
||||||
|
XEV_QUICK(NULL, NULL, ButtonPress, xev_handle_buttonpress, NULL);
|
||||||
|
XEV_QUICK(NULL, NULL, ButtonRelease, xev_handle_buttonrelease, NULL);
|
||||||
|
XEV_QUICK(NULL, NULL, KeyPress, xev_handle_keypress, NULL);
|
||||||
|
XEV_QUICK(NULL, NULL, KeyRelease, xev_handle_keyrelease, NULL);
|
||||||
|
XEV_QUICK(NULL, NULL, Expose, xev_handle_expose, NULL);
|
||||||
|
XEV_QUICK(NULL, NULL, DestroyNotify, xev_handle_destroynotify, NULL);
|
||||||
|
XEV_QUICK(NULL, NULL, ClientMessage, xev_handle_clientmessage, NULL);
|
||||||
|
|
||||||
|
xev_loop();
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
x_setup(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct screen_ctx *sc;
|
||||||
|
char *fontname;
|
||||||
|
|
||||||
|
TAILQ_INIT(&G_screenq);
|
||||||
|
|
||||||
|
if ((G_dpy = XOpenDisplay("")) == NULL)
|
||||||
|
errx(1, "%s:%d XOpenDisplay()", __FILE__, __LINE__);
|
||||||
|
|
||||||
|
XSetErrorHandler(x_errorhandler);
|
||||||
|
|
||||||
|
G_doshape = XShapeQueryExtension(G_dpy, &G_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++) {
|
||||||
|
XMALLOC(sc, struct screen_ctx);
|
||||||
|
x_setupscreen(sc, i);
|
||||||
|
TAILQ_INSERT_TAIL(&G_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
x_setupscreen(struct screen_ctx *sc, u_int which)
|
||||||
|
{
|
||||||
|
XColor tmp;
|
||||||
|
XGCValues gv, gv1/* , gv2 */;
|
||||||
|
Window *wins, w0, w1;
|
||||||
|
u_int nwins, i = 0;
|
||||||
|
XWindowAttributes winattr;
|
||||||
|
XSetWindowAttributes rootattr;
|
||||||
|
struct keybinding *kb;
|
||||||
|
|
||||||
|
sc->display = x_screenname(which);
|
||||||
|
sc->which = which;
|
||||||
|
sc->rootwin = RootWindow(G_dpy, which);
|
||||||
|
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which),
|
||||||
|
"black", &sc->fgcolor, &tmp);
|
||||||
|
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which),
|
||||||
|
"#00cc00", &sc->bgcolor, &tmp);
|
||||||
|
XAllocNamedColor(G_dpy,DefaultColormap(G_dpy, which),
|
||||||
|
"blue", &sc->fccolor, &tmp);
|
||||||
|
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which),
|
||||||
|
"red", &sc->redcolor, &tmp);
|
||||||
|
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which),
|
||||||
|
"#00ccc8", &sc->cyancolor, &tmp);
|
||||||
|
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which),
|
||||||
|
"white", &sc->whitecolor, &tmp);
|
||||||
|
XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, which),
|
||||||
|
"black", &sc->blackcolor, &tmp);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(kb, &G_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->bluepixl = sc->fccolor.pixel;
|
||||||
|
sc->redpixl = sc->redcolor.pixel;
|
||||||
|
sc->cyanpixl = sc->cyancolor.pixel;
|
||||||
|
|
||||||
|
sc->gray = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin,
|
||||||
|
gray_bits, gray_width, gray_height,
|
||||||
|
sc->blackpixl, sc->whitepixl, DefaultDepth(G_dpy, sc->which));
|
||||||
|
|
||||||
|
sc->blue = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin,
|
||||||
|
gray_bits, gray_width, gray_height,
|
||||||
|
sc->bluepixl, sc->whitepixl, DefaultDepth(G_dpy, sc->which));
|
||||||
|
|
||||||
|
sc->red = XCreatePixmapFromBitmapData(G_dpy, sc->rootwin,
|
||||||
|
gray_bits, gray_width, gray_height,
|
||||||
|
sc->redpixl, sc->whitepixl, DefaultDepth(G_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,
|
||||||
|
GCForeground|GCBackground|GCFunction|
|
||||||
|
GCLineWidth|GCSubwindowMode|GCFont, &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,
|
||||||
|
GCForeground|GCBackground|GCFunction|
|
||||||
|
GCLineWidth|GCSubwindowMode|GCFont, &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);
|
||||||
|
|
||||||
|
font_init(sc);
|
||||||
|
DefaultFont = font_getx(sc, DefaultFontName);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX - this should *really* be in screen_init(). ordering
|
||||||
|
* problem.
|
||||||
|
*/
|
||||||
|
TAILQ_INIT(&sc->mruq);
|
||||||
|
|
||||||
|
/* Initialize menu window. */
|
||||||
|
grab_menuinit(sc);
|
||||||
|
search_init(sc);
|
||||||
|
|
||||||
|
/* Deal with existing clients. */
|
||||||
|
XQueryTree(G_dpy, sc->rootwin, &w0, &w1, &wins, &nwins);
|
||||||
|
|
||||||
|
for (i = 0; i < nwins; i++) {
|
||||||
|
XGetWindowAttributes(G_dpy, wins[i], &winattr);
|
||||||
|
if (winattr.override_redirect ||
|
||||||
|
winattr.map_state != IsViewable) {
|
||||||
|
char *name;
|
||||||
|
XFetchName(G_dpy, wins[i], &name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
client_new(wins[i], sc, winattr.map_state != IsUnmapped);
|
||||||
|
}
|
||||||
|
XFree(wins);
|
||||||
|
|
||||||
|
G_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,
|
||||||
|
/* CWCursor| */CWEventMask, &rootattr);
|
||||||
|
|
||||||
|
XSync(G_dpy, False);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
x_screenname(int which)
|
||||||
|
{
|
||||||
|
char *cp, *dstr, *sn;
|
||||||
|
size_t snlen;
|
||||||
|
|
||||||
|
if (which > 9)
|
||||||
|
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));
|
||||||
|
|
||||||
|
if ((cp = rindex(dstr, ':')) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
if ((cp = index(cp, '.')) != NULL)
|
||||||
|
*cp = '\0';
|
||||||
|
|
||||||
|
snlen = strlen(dstr) + 3; /* string, dot, number, null */
|
||||||
|
sn = (char *)xmalloc(snlen);
|
||||||
|
snprintf(sn, snlen, "%s.%d", dstr, which);
|
||||||
|
free(dstr);
|
||||||
|
|
||||||
|
return (sn);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
x_errorhandler(Display *dpy, XErrorEvent *e)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
{
|
||||||
|
char msg[80], number[80], req[80];
|
||||||
|
|
||||||
|
XGetErrorText(G_dpy, e->error_code, msg, sizeof(msg));
|
||||||
|
snprintf(number, sizeof(number), "%d", e->request_code);
|
||||||
|
XGetErrorDatabaseText(G_dpy, "XRequest", number,
|
||||||
|
"<unknown>", req, sizeof(req));
|
||||||
|
|
||||||
|
warnx("%s(0x%x): %s", req, (u_int)e->resourceid, msg);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (G_starting &&
|
||||||
|
e->error_code == BadAccess &&
|
||||||
|
e->request_code == X_GrabKey)
|
||||||
|
errx(1, "root window unavailable - perhaps another "
|
||||||
|
"wm is running?");
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_sigchld_cb(int which)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
/* Collect dead children. */
|
||||||
|
while ((pid = waitpid(-1, &status, WNOHANG)) > 0 ||
|
||||||
|
(pid < 0 && errno == EINTR))
|
||||||
|
;
|
||||||
|
}
|
507
calmwm.h
Normal file
507
calmwm.h
Normal file
@ -0,0 +1,507 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CALMWM_H_
|
||||||
|
#define _CALMWM_H_
|
||||||
|
|
||||||
|
#define CALMWM_MAXNAMELEN 256
|
||||||
|
|
||||||
|
#include "hash.h"
|
||||||
|
|
||||||
|
#undef MIN
|
||||||
|
#undef MAX
|
||||||
|
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||||
|
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
||||||
|
|
||||||
|
enum conftype {
|
||||||
|
CONF_BWIDTH, CONF_IGNORE, CONF_NOTIFIER,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ChildMask (SubstructureRedirectMask|SubstructureNotifyMask)
|
||||||
|
#define ButtonMask (ButtonPressMask|ButtonReleaseMask)
|
||||||
|
#define MouseMask (ButtonMask|PointerMotionMask)
|
||||||
|
|
||||||
|
struct client_ctx;
|
||||||
|
|
||||||
|
TAILQ_HEAD(cycle_entry_q, client_ctx);
|
||||||
|
|
||||||
|
/* #define CYCLE_FOREACH_MRU(cy, ctx) TAILQ_FOREACH((ctx), */
|
||||||
|
|
||||||
|
struct screen_ctx;
|
||||||
|
|
||||||
|
struct fontdesc {
|
||||||
|
const char *name;
|
||||||
|
XftFont *fn;
|
||||||
|
struct screen_ctx *sc;
|
||||||
|
HASH_ENTRY(fontdesc) node;
|
||||||
|
};
|
||||||
|
|
||||||
|
int fontdesc_cmp(struct fontdesc *a, struct fontdesc *b);
|
||||||
|
|
||||||
|
HASH_HEAD(fonthash, fontdesc, 16);
|
||||||
|
HASH_PROTOTYPE(fonthash, fontdesc, node, fontdesc_cmp);
|
||||||
|
|
||||||
|
struct screen_ctx {
|
||||||
|
TAILQ_ENTRY(screen_ctx) entry;
|
||||||
|
|
||||||
|
u_int which;
|
||||||
|
Window rootwin;
|
||||||
|
Window menuwin;
|
||||||
|
Window searchwin;
|
||||||
|
Window groupwin;
|
||||||
|
Window infowin;
|
||||||
|
Colormap colormap;
|
||||||
|
GC invcg;
|
||||||
|
XColor bgcolor, fgcolor, fccolor, redcolor, cyancolor,
|
||||||
|
whitecolor, blackcolor;
|
||||||
|
char *display;
|
||||||
|
unsigned long blackpixl, whitepixl, redpixl, bluepixl, cyanpixl;
|
||||||
|
GC gc, invgc, hlgc;
|
||||||
|
|
||||||
|
Pixmap gray, blue, red;
|
||||||
|
|
||||||
|
int altpersist;
|
||||||
|
|
||||||
|
FILE *notifier;
|
||||||
|
|
||||||
|
struct cycle_entry_q mruq;
|
||||||
|
|
||||||
|
struct client_ctx* cycle_client;
|
||||||
|
|
||||||
|
struct fonthash fonthash;
|
||||||
|
XftDraw *xftdraw;
|
||||||
|
XftColor xftcolor;
|
||||||
|
};
|
||||||
|
|
||||||
|
TAILQ_HEAD(screen_ctx_q, screen_ctx);
|
||||||
|
|
||||||
|
#define CLIENT_PROTO_DELETE 0x01
|
||||||
|
#define CLIENT_PROTO_TAKEFOCUS 0x02
|
||||||
|
|
||||||
|
#define CLIENT_MAXNAMEQLEN 5
|
||||||
|
|
||||||
|
#define CLIENT_HIDDEN 0x01
|
||||||
|
#define CLIENT_IGNORE 0x02
|
||||||
|
#define CLIENT_INQUEUE 0x04 /* tmp used by search code */
|
||||||
|
#define CLIENT_MAXIMIZED 0x08
|
||||||
|
|
||||||
|
#define CLIENT_HIGHLIGHT_BLUE 1
|
||||||
|
#define CLIENT_HIGHLIGHT_RED 2
|
||||||
|
|
||||||
|
|
||||||
|
struct winname {
|
||||||
|
TAILQ_ENTRY(winname) entry;
|
||||||
|
char *name;
|
||||||
|
};
|
||||||
|
|
||||||
|
TAILQ_HEAD(winname_q, winname);
|
||||||
|
|
||||||
|
struct client_ctx {
|
||||||
|
TAILQ_ENTRY(client_ctx) entry;
|
||||||
|
TAILQ_ENTRY(client_ctx) searchentry;
|
||||||
|
TAILQ_ENTRY(client_ctx) group_entry;
|
||||||
|
TAILQ_ENTRY(client_ctx) mru_entry;
|
||||||
|
|
||||||
|
struct screen_ctx *sc;
|
||||||
|
Window win;
|
||||||
|
XSizeHints *size;
|
||||||
|
|
||||||
|
Colormap cmap;
|
||||||
|
|
||||||
|
Window pwin;
|
||||||
|
|
||||||
|
u_int bwidth;
|
||||||
|
struct {
|
||||||
|
int x, y, width, height;
|
||||||
|
int min_dx, min_dy;
|
||||||
|
} geom, savegeom;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int x,y;
|
||||||
|
} ptr;
|
||||||
|
|
||||||
|
int beepbeep;
|
||||||
|
|
||||||
|
int xproto;
|
||||||
|
|
||||||
|
int flags;
|
||||||
|
int state;
|
||||||
|
char *name;
|
||||||
|
struct winname_q nameq;
|
||||||
|
size_t nameqlen;
|
||||||
|
|
||||||
|
char *label;
|
||||||
|
int active;
|
||||||
|
int highlight;
|
||||||
|
|
||||||
|
char *matchname;
|
||||||
|
struct group_ctx *group;
|
||||||
|
int groupcommit;
|
||||||
|
|
||||||
|
int stackingorder;
|
||||||
|
|
||||||
|
char *app_class;
|
||||||
|
char *app_name;
|
||||||
|
char *app_cliarg;
|
||||||
|
};
|
||||||
|
|
||||||
|
TAILQ_HEAD(client_ctx_q, client_ctx);
|
||||||
|
|
||||||
|
struct group_ctx {
|
||||||
|
TAILQ_ENTRY(group_ctx) entry;
|
||||||
|
struct client_ctx_q clients;
|
||||||
|
char *name;
|
||||||
|
int shortcut;
|
||||||
|
int hidden;
|
||||||
|
int nhidden;
|
||||||
|
int highstack;
|
||||||
|
};
|
||||||
|
|
||||||
|
TAILQ_HEAD(group_ctx_q, group_ctx);
|
||||||
|
|
||||||
|
/* Autogroups */
|
||||||
|
struct autogroupwin {
|
||||||
|
TAILQ_ENTRY(autogroupwin) entry;
|
||||||
|
|
||||||
|
char *class;
|
||||||
|
char *name;
|
||||||
|
char *group;
|
||||||
|
};
|
||||||
|
|
||||||
|
TAILQ_HEAD(autogroupwin_q, autogroupwin);
|
||||||
|
|
||||||
|
/* NULL/0 values indicate match any. */
|
||||||
|
struct xevent {
|
||||||
|
TAILQ_ENTRY(xevent) entry;
|
||||||
|
Window *xev_win;
|
||||||
|
Window *xev_root;
|
||||||
|
int xev_type;
|
||||||
|
void (*xev_cb)(struct xevent *, XEvent *);
|
||||||
|
void *xev_arg;
|
||||||
|
};
|
||||||
|
|
||||||
|
TAILQ_HEAD(xevent_q, xevent);
|
||||||
|
|
||||||
|
/* Keybindings */
|
||||||
|
enum kbtype {
|
||||||
|
KB_DELETE, KB_NEWTERM0, KB_NEWTERM1, KB_HIDE,
|
||||||
|
KB_LOWER, KB_RAISE, KB_SEARCH, KB_CYCLE, KB_LABEL,
|
||||||
|
KB_GROUPSELECT, KB_VERTMAXIMIZE,
|
||||||
|
|
||||||
|
/* Group numbers need to be in order. */
|
||||||
|
KB_GROUP_1, KB_GROUP_2, KB_GROUP_3, KB_GROUP_4, KB_GROUP_5,
|
||||||
|
KB_GROUP_6, KB_GROUP_7, KB_GROUP_8, KB_GROUP_9, KB_NOGROUP,
|
||||||
|
KB_NEXTGROUP, KB_PREVGROUP,
|
||||||
|
|
||||||
|
KB_MOVE_WEST, KB_MOVE_EAST, KB_MOVE_NORTH, KB_MOVE_SOUTH,
|
||||||
|
|
||||||
|
KB__LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
#define KBFLAG_NEEDCLIENT 0x01
|
||||||
|
#define KBFLAG_FINDCLIENT 0x02
|
||||||
|
|
||||||
|
#define KBTOGROUP(X) ((X) - 1)
|
||||||
|
|
||||||
|
struct keybinding {
|
||||||
|
int modmask;
|
||||||
|
int keysym;
|
||||||
|
int keycode;
|
||||||
|
int flags;
|
||||||
|
void (*callback)(struct client_ctx *, void *);
|
||||||
|
void *argument;
|
||||||
|
TAILQ_ENTRY(keybinding) entry;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cmd {
|
||||||
|
TAILQ_ENTRY(cmd) entry;
|
||||||
|
int flags;
|
||||||
|
#define CMD_STATIC 0x01 /* static configuration in conf.c */
|
||||||
|
char image[MAXPATHLEN];
|
||||||
|
char label[256];
|
||||||
|
/* (argv) */
|
||||||
|
};
|
||||||
|
|
||||||
|
TAILQ_HEAD(keybinding_q, keybinding);
|
||||||
|
TAILQ_HEAD(cmd_q, cmd);
|
||||||
|
|
||||||
|
/* Global configuration */
|
||||||
|
struct conf {
|
||||||
|
struct keybinding_q keybindingq;
|
||||||
|
struct autogroupwin_q autogroupq;
|
||||||
|
char menu_path[MAXPATHLEN];
|
||||||
|
struct cmd_q cmdq;
|
||||||
|
|
||||||
|
int flags;
|
||||||
|
#define CONF_STICKY_GROUPS 0x0001
|
||||||
|
|
||||||
|
char termpath[MAXPATHLEN];
|
||||||
|
char lockpath[MAXPATHLEN];
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Menu stuff */
|
||||||
|
|
||||||
|
#define MENU_MAXENTRY 50
|
||||||
|
|
||||||
|
struct menu {
|
||||||
|
TAILQ_ENTRY(menu) entry;
|
||||||
|
TAILQ_ENTRY(menu) resultentry;
|
||||||
|
|
||||||
|
char text[MENU_MAXENTRY + 1];
|
||||||
|
char print[MENU_MAXENTRY + 1];
|
||||||
|
void *ctx;
|
||||||
|
short lasthit;
|
||||||
|
};
|
||||||
|
|
||||||
|
TAILQ_HEAD(menu_q, menu);
|
||||||
|
|
||||||
|
enum ctltype {
|
||||||
|
CTL_NONE = -1,
|
||||||
|
CTL_ERASEONE = 0, CTL_WIPE, CTL_UP, CTL_DOWN, CTL_RETURN,
|
||||||
|
CTL_ABORT, CTL_ALL
|
||||||
|
};
|
||||||
|
|
||||||
|
/* MWM hints */
|
||||||
|
|
||||||
|
struct mwm_hints {
|
||||||
|
u_long flags;
|
||||||
|
u_long functions;
|
||||||
|
u_long decorations;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MWM_NUMHINTS 3
|
||||||
|
|
||||||
|
#define PROP_MWM_HINTS_ELEMENTS 3
|
||||||
|
#define MWM_HINTS_DECORATIONS (1 << 1)
|
||||||
|
#define MWM_DECOR_ALL (1 << 0)
|
||||||
|
#define MWM_DECOR_BORDER (1 << 1)
|
||||||
|
|
||||||
|
int input_keycodetrans(KeyCode, u_int, enum ctltype *, char *, int);
|
||||||
|
|
||||||
|
int x_errorhandler(Display *, XErrorEvent *);
|
||||||
|
void x_setup(void);
|
||||||
|
char *x_screenname(int);
|
||||||
|
void x_loop(void);
|
||||||
|
int x_setupscreen(struct screen_ctx *, u_int);
|
||||||
|
|
||||||
|
struct client_ctx *client_find(Window);
|
||||||
|
void client_setup(void);
|
||||||
|
struct client_ctx *client_new(Window, struct screen_ctx *, int);
|
||||||
|
int client_delete(struct client_ctx *, int, int);
|
||||||
|
void client_setactive(struct client_ctx *, int);
|
||||||
|
void client_gravitate(struct client_ctx *, int);
|
||||||
|
void client_resize(struct client_ctx *);
|
||||||
|
void client_lower(struct client_ctx *);
|
||||||
|
void client_raise(struct client_ctx *);
|
||||||
|
void client_move(struct client_ctx *);
|
||||||
|
void client_leave(struct client_ctx *);
|
||||||
|
void client_send_delete(struct client_ctx *);
|
||||||
|
struct client_ctx *client_current(void);
|
||||||
|
void client_hide(struct client_ctx *);
|
||||||
|
void client_unhide(struct client_ctx *);
|
||||||
|
void client_nocurrent(void);
|
||||||
|
void client_setname(struct client_ctx *);
|
||||||
|
void client_warp(struct client_ctx *);
|
||||||
|
void client_ptrwarp(struct client_ctx *);
|
||||||
|
void client_ptrsave(struct client_ctx *);
|
||||||
|
void client_draw_border(struct client_ctx *);
|
||||||
|
void client_update(struct client_ctx *);
|
||||||
|
void client_cycle(struct client_ctx *);
|
||||||
|
void client_placecalc(struct client_ctx *);
|
||||||
|
void client_maximize(struct client_ctx *);
|
||||||
|
void client_vertmaximize(struct client_ctx *);
|
||||||
|
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);
|
||||||
|
void client_cycleinfo(struct client_ctx *cc);
|
||||||
|
void client_altrelease();
|
||||||
|
struct client_ctx *client_mrunext(struct client_ctx *cc);
|
||||||
|
struct client_ctx *client_mruprev(struct client_ctx *cc);
|
||||||
|
void client_gethints(struct client_ctx *cc);
|
||||||
|
void client_freehints(struct client_ctx *cc);
|
||||||
|
|
||||||
|
void xev_handle_maprequest(struct xevent *, XEvent *);
|
||||||
|
void xev_handle_unmapnotify(struct xevent *, XEvent *);
|
||||||
|
void xev_handle_destroynotify(struct xevent *, XEvent *);
|
||||||
|
void xev_handle_configurerequest(struct xevent *, XEvent *);
|
||||||
|
void xev_handle_propertynotify(struct xevent *, XEvent *);
|
||||||
|
void xev_handle_enternotify(struct xevent *, XEvent *);
|
||||||
|
void xev_handle_leavenotify(struct xevent *, XEvent *);
|
||||||
|
void xev_handle_buttonpress(struct xevent *, XEvent *);
|
||||||
|
void xev_handle_buttonrelease(struct xevent *, XEvent *);
|
||||||
|
void xev_handle_keypress(struct xevent *, XEvent *);
|
||||||
|
void xev_handle_keyrelease(struct xevent *, XEvent *);
|
||||||
|
void xev_handle_expose(struct xevent *, XEvent *);
|
||||||
|
void xev_handle_clientmessage(struct xevent *, XEvent *);
|
||||||
|
|
||||||
|
#define XEV_QUICK(a, b, c, d, e) do { \
|
||||||
|
xev_register(xev_new(a, b, c, d, e)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
void xev_reconfig(struct client_ctx *); /* XXX should be xu_ */
|
||||||
|
|
||||||
|
void xev_init(void);
|
||||||
|
struct xevent *xev_new(Window *, Window *, int, void (*)(struct xevent *, XEvent *), void *);
|
||||||
|
void xev_register(struct xevent *);
|
||||||
|
void xev_loop(void);
|
||||||
|
|
||||||
|
int xu_ptr_grab(Window, int, Cursor);
|
||||||
|
int xu_btn_grab(Window, int, u_int);
|
||||||
|
int xu_ptr_regrab(int, Cursor);
|
||||||
|
void xu_btn_ungrab(Window, int, u_int);
|
||||||
|
void xu_ptr_ungrab(void);
|
||||||
|
void xu_ptr_setpos(Window, int, int);
|
||||||
|
void xu_ptr_getpos(Window, int *, int *);
|
||||||
|
void xu_key_grab(Window, int, int);
|
||||||
|
void xu_sendmsg(struct client_ctx *, Atom, long);
|
||||||
|
int xu_getprop(struct client_ctx *, Atom, Atom, long, u_char **);
|
||||||
|
char *xu_getstrprop(struct client_ctx *, Atom atm);
|
||||||
|
void xu_setstate(struct client_ctx *, int);
|
||||||
|
int xu_getstate(struct client_ctx *, int *);
|
||||||
|
void xu_key_grab_keycode(Window, int, int);
|
||||||
|
|
||||||
|
int dirent_exists(char *);
|
||||||
|
int dirent_isdir(char *);
|
||||||
|
int dirent_islink(char *);
|
||||||
|
int u_spawn(char *);
|
||||||
|
|
||||||
|
int grab_sweep(struct client_ctx *);
|
||||||
|
int grab_drag(struct client_ctx *);
|
||||||
|
void grab_menuinit(struct screen_ctx *);
|
||||||
|
void *grab_menu(XButtonEvent *, struct menu_q *);
|
||||||
|
void grab_label(struct client_ctx *);
|
||||||
|
|
||||||
|
void xfree(void *);
|
||||||
|
void *xmalloc(size_t);
|
||||||
|
void *xcalloc(size_t);
|
||||||
|
char *xstrdup(const char *);
|
||||||
|
|
||||||
|
#define XMALLOC(p, t) ((p) = (t *)xmalloc(sizeof * (p)))
|
||||||
|
#define XCALLOC(p, t) ((p) = (t *)xcalloc(sizeof * (p)))
|
||||||
|
|
||||||
|
void screen_init(void);
|
||||||
|
struct screen_ctx *screen_fromroot(Window);
|
||||||
|
struct screen_ctx *screen_current(void);
|
||||||
|
void screen_updatestackingorder(void);
|
||||||
|
void screen_infomsg(char *);
|
||||||
|
|
||||||
|
void conf_setup(struct conf *);
|
||||||
|
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_parsekeys(struct conf *, char *);
|
||||||
|
void conf_parsesettings(struct conf *, char *);
|
||||||
|
void conf_parseignores(struct conf *, char *);
|
||||||
|
void conf_parseautogroups(struct conf *, char *);
|
||||||
|
void conf_cmd_clear(struct conf *);
|
||||||
|
int conf_cmd_changed(char *);
|
||||||
|
void conf_cmd_populate(struct conf *, char *);
|
||||||
|
void conf_cmd_refresh(struct conf *c);
|
||||||
|
char *conf_get_str(struct client_ctx *, enum conftype);
|
||||||
|
|
||||||
|
void kbfunc_client_lower(struct client_ctx *, void *);
|
||||||
|
void kbfunc_client_raise(struct client_ctx *, void *);
|
||||||
|
void kbfunc_client_search(struct client_ctx *, void *);
|
||||||
|
void kbfunc_client_hide(struct client_ctx *, void *);
|
||||||
|
void kbfunc_client_cycle(struct client_ctx *, void *);
|
||||||
|
void kbfunc_client_rcycle(struct client_ctx *cc, void *arg);
|
||||||
|
void kbfunc_cmdexec(struct client_ctx *, void *);
|
||||||
|
void kbfunc_client_label(struct client_ctx *, void *);
|
||||||
|
void kbfunc_client_delete(struct client_ctx *, void *);
|
||||||
|
void kbfunc_client_groupselect(struct client_ctx *, void *);
|
||||||
|
void kbfunc_client_group(struct client_ctx *, void *);
|
||||||
|
void kbfunc_client_nextgroup(struct client_ctx *, void *);
|
||||||
|
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_menu_search(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 *);
|
||||||
|
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_rank_text(struct menu_q *, char *);
|
||||||
|
|
||||||
|
void group_init(void);
|
||||||
|
int group_new(void);
|
||||||
|
int group_select(int);
|
||||||
|
void group_enter(void);
|
||||||
|
void group_exit(int);
|
||||||
|
void group_click(struct client_ctx *);
|
||||||
|
void group_display_init(struct screen_ctx *);
|
||||||
|
void group_display_draw(struct screen_ctx *);
|
||||||
|
void group_display_keypress(KeyCode);
|
||||||
|
void group_hidetoggle(int);
|
||||||
|
void group_slide(int);
|
||||||
|
void group_sticky(struct client_ctx *);
|
||||||
|
void group_client_delete(struct client_ctx *);
|
||||||
|
void group_menu(XButtonEvent *);
|
||||||
|
void group_namemode(void);
|
||||||
|
void group_alltoggle(void);
|
||||||
|
void group_deletecurrent(void);
|
||||||
|
void group_done(void);
|
||||||
|
void group_sticky_toggle_enter(struct client_ctx *);
|
||||||
|
void group_sticky_toggle_exit(struct client_ctx *);
|
||||||
|
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);
|
||||||
|
void font_draw(struct fontdesc *fdp, const char *text, int len,
|
||||||
|
Drawable d, int x, int y);
|
||||||
|
int font_ascent(struct fontdesc *fdp);
|
||||||
|
int font_descent(struct fontdesc *fdp);
|
||||||
|
struct fontdesc *font_getx(struct screen_ctx *sc, const char *name);
|
||||||
|
|
||||||
|
#define CCTOSC(cc) (cc->sc)
|
||||||
|
|
||||||
|
/* Externs */
|
||||||
|
|
||||||
|
extern Display *G_dpy;
|
||||||
|
extern XFontStruct *G_font;
|
||||||
|
|
||||||
|
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 struct screen_ctx_q G_screenq;
|
||||||
|
extern struct screen_ctx *G_curscreen;
|
||||||
|
extern u_int G_nscreens;
|
||||||
|
|
||||||
|
extern struct client_ctx_q G_clientq;
|
||||||
|
|
||||||
|
extern int G_doshape, G_shape_ev;
|
||||||
|
extern struct conf G_conf;
|
||||||
|
|
||||||
|
extern int G_groupmode;
|
||||||
|
extern struct fontdesc *DefaultFont;
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _CALMWM_H_ */
|
935
client.c
Normal file
935
client.c
Normal file
@ -0,0 +1,935 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "headers.h"
|
||||||
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
static struct client_ctx *client__cycle(struct client_ctx *cc,
|
||||||
|
struct client_ctx *(*iter)(struct client_ctx *));
|
||||||
|
int _inwindowbounds(struct client_ctx *, int, int);
|
||||||
|
|
||||||
|
static char emptystring[] = "";
|
||||||
|
|
||||||
|
struct client_ctx *_curcc = NULL;
|
||||||
|
|
||||||
|
void
|
||||||
|
client_setup(void)
|
||||||
|
{
|
||||||
|
TAILQ_INIT(&G_clientq);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct client_ctx *
|
||||||
|
client_find(Window win)
|
||||||
|
{
|
||||||
|
struct client_ctx *cc;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cc, &G_clientq, entry)
|
||||||
|
if (cc->pwin == win || cc->win == win)
|
||||||
|
return (cc);
|
||||||
|
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct client_ctx *
|
||||||
|
client_new(Window win, struct screen_ctx *sc, int mapped)
|
||||||
|
{
|
||||||
|
struct client_ctx *cc;
|
||||||
|
long tmp;
|
||||||
|
XSetWindowAttributes pxattr;
|
||||||
|
XWindowAttributes wattr;
|
||||||
|
int x, y, height, width, state;
|
||||||
|
XWMHints *wmhints;
|
||||||
|
|
||||||
|
if (win == None)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
XCALLOC(cc, struct client_ctx);
|
||||||
|
|
||||||
|
XGrabServer(G_dpy);
|
||||||
|
|
||||||
|
cc->state = mapped ? NormalState : IconicState;
|
||||||
|
cc->sc = sc;
|
||||||
|
cc->win = win;
|
||||||
|
cc->size= XAllocSizeHints();
|
||||||
|
if (cc->size->width_inc == 0)
|
||||||
|
cc->size->width_inc = 1;
|
||||||
|
if (cc->size->height_inc == 0)
|
||||||
|
cc->size->height_inc = 1;
|
||||||
|
|
||||||
|
TAILQ_INIT(&cc->nameq);
|
||||||
|
client_setname(cc);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* conf_client() needs at least cc->win and cc->name
|
||||||
|
*/
|
||||||
|
conf_client(cc);
|
||||||
|
|
||||||
|
XGetWMNormalHints(G_dpy, cc->win, cc->size, &tmp);
|
||||||
|
XGetWindowAttributes(G_dpy, cc->win, &wattr);
|
||||||
|
|
||||||
|
if (cc->size->flags & PBaseSize) {
|
||||||
|
cc->geom.min_dx = cc->size->base_width;
|
||||||
|
cc->geom.min_dy = cc->size->base_height;
|
||||||
|
} else if (cc->size->flags & PMinSize) {
|
||||||
|
cc->geom.min_dx = cc->size->min_width;
|
||||||
|
cc->geom.min_dy = cc->size->min_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Saved pointer position */
|
||||||
|
cc->ptr.x = -1;
|
||||||
|
cc->ptr.y = -1;
|
||||||
|
|
||||||
|
client_gravitate(cc, 1);
|
||||||
|
|
||||||
|
cc->geom.x = wattr.x;
|
||||||
|
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->flags & StateHint)
|
||||||
|
xu_setstate(cc, wmhints->initial_state);
|
||||||
|
|
||||||
|
XFree(wmhints);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xu_getstate(cc, &state) < 0)
|
||||||
|
state = NormalState;
|
||||||
|
|
||||||
|
XSelectInput(G_dpy, cc->win,
|
||||||
|
ColormapChangeMask|EnterWindowMask|PropertyChangeMask|KeyReleaseMask);
|
||||||
|
|
||||||
|
x = cc->geom.x - cc->bwidth;
|
||||||
|
y = cc->geom.y - cc->bwidth;
|
||||||
|
|
||||||
|
width = cc->geom.width;
|
||||||
|
height = cc->geom.height;
|
||||||
|
if (cc->bwidth > 1) {
|
||||||
|
width += (cc->bwidth)*2;
|
||||||
|
height += (cc->bwidth)*2;
|
||||||
|
}
|
||||||
|
|
||||||
|
pxattr.override_redirect = True;
|
||||||
|
pxattr.background_pixel = sc->bgcolor.pixel;
|
||||||
|
pxattr.event_mask =
|
||||||
|
ChildMask|ButtonPressMask|ButtonReleaseMask|
|
||||||
|
ExposureMask|EnterWindowMask;
|
||||||
|
/* pxattr.border_pixel = sc->blackpix; */
|
||||||
|
/* pxattr.background_pixel = sc->whitepix; */
|
||||||
|
|
||||||
|
|
||||||
|
/* cc->pwin = XCreateSimpleWindow(G_dpy, sc->rootwin, */
|
||||||
|
/* x, y, width, height, 1, sc->blackpix, sc->whitepix); */
|
||||||
|
|
||||||
|
cc->pwin = XCreateWindow(G_dpy, sc->rootwin, x, y,
|
||||||
|
width, height, 0, /* XXX */
|
||||||
|
DefaultDepth(G_dpy, sc->which), CopyFromParent,
|
||||||
|
DefaultVisual(G_dpy, sc->which),
|
||||||
|
CWOverrideRedirect | CWBackPixel | CWEventMask, &pxattr);
|
||||||
|
|
||||||
|
if (G_doshape) {
|
||||||
|
XRectangle *r;
|
||||||
|
int n, tmp;
|
||||||
|
|
||||||
|
XShapeSelectInput(G_dpy, cc->win, ShapeNotifyMask);
|
||||||
|
|
||||||
|
r = XShapeGetRectangles(G_dpy, cc->win, ShapeBounding, &n, &tmp);
|
||||||
|
if (n > 1)
|
||||||
|
XShapeCombineShape(G_dpy, cc->pwin, ShapeBounding,
|
||||||
|
0, 0, /* XXX border */
|
||||||
|
cc->win, ShapeBounding, ShapeSet);
|
||||||
|
XFree(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* Notify client of its configuration. */
|
||||||
|
xev_reconfig(cc);
|
||||||
|
|
||||||
|
XMapRaised(G_dpy, cc->pwin);
|
||||||
|
XMapWindow(G_dpy, cc->win);
|
||||||
|
xu_setstate(cc, cc->state);
|
||||||
|
|
||||||
|
XSync(G_dpy, False);
|
||||||
|
XUngrabServer(G_dpy);
|
||||||
|
|
||||||
|
TAILQ_INSERT_TAIL(&sc->mruq, cc, mru_entry);
|
||||||
|
TAILQ_INSERT_TAIL(&G_clientq, cc, entry);
|
||||||
|
|
||||||
|
client_gethints(cc);
|
||||||
|
client_update(cc);
|
||||||
|
|
||||||
|
if (mapped) {
|
||||||
|
if (G_conf.flags & CONF_STICKY_GROUPS)
|
||||||
|
group_sticky(cc);
|
||||||
|
else
|
||||||
|
group_autogroup(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
client_delete(struct client_ctx *cc, int sendevent, int ignorewindow)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
struct winname *wn;
|
||||||
|
|
||||||
|
if (cc->state == IconicState && !sendevent)
|
||||||
|
return (1);
|
||||||
|
|
||||||
|
group_client_delete(cc);
|
||||||
|
XGrabServer(G_dpy);
|
||||||
|
|
||||||
|
xu_setstate(cc, WithdrawnState);
|
||||||
|
XRemoveFromSaveSet(G_dpy, cc->win);
|
||||||
|
|
||||||
|
if (!ignorewindow) {
|
||||||
|
client_gravitate(cc, 0);
|
||||||
|
XSetWindowBorderWidth(G_dpy, cc->win, 1); /* XXX */
|
||||||
|
XReparentWindow(G_dpy, cc->win,
|
||||||
|
sc->rootwin, cc->geom.x, cc->geom.y);
|
||||||
|
}
|
||||||
|
if (cc->pwin)
|
||||||
|
XDestroyWindow(G_dpy, cc->pwin);
|
||||||
|
|
||||||
|
XSync(G_dpy, False);
|
||||||
|
XUngrabServer(G_dpy);
|
||||||
|
|
||||||
|
TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
|
||||||
|
TAILQ_REMOVE(&G_clientq, cc, entry);
|
||||||
|
|
||||||
|
if (_curcc == cc)
|
||||||
|
_curcc = NULL;
|
||||||
|
|
||||||
|
if (sc->cycle_client == cc)
|
||||||
|
sc->cycle_client = NULL;
|
||||||
|
|
||||||
|
XFree(cc->size);
|
||||||
|
|
||||||
|
while ((wn = TAILQ_FIRST(&cc->nameq)) != NULL) {
|
||||||
|
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
||||||
|
if (wn->name != emptystring)
|
||||||
|
XFree(wn->name);
|
||||||
|
xfree(wn);
|
||||||
|
}
|
||||||
|
|
||||||
|
client_freehints(cc);
|
||||||
|
|
||||||
|
xfree(cc);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_leave(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc;
|
||||||
|
|
||||||
|
if (cc == NULL)
|
||||||
|
cc = _curcc;
|
||||||
|
if (cc == NULL)
|
||||||
|
return;
|
||||||
|
sc = CCTOSC(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)
|
||||||
|
{
|
||||||
|
struct screen_ctx* sc;
|
||||||
|
|
||||||
|
if (cc == NULL)
|
||||||
|
cc = _curcc;
|
||||||
|
if (cc == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sc = CCTOSC(cc);
|
||||||
|
|
||||||
|
if (fg) {
|
||||||
|
XInstallColormap(G_dpy, cc->cmap);
|
||||||
|
XSetInputFocus(G_dpy, cc->win,
|
||||||
|
RevertToPointerRoot, CurrentTime);
|
||||||
|
xu_btn_grab(cc->pwin, Mod1Mask, AnyButton);
|
||||||
|
xu_btn_grab(cc->pwin, ControlMask|Mod1Mask, Button1);
|
||||||
|
/*
|
||||||
|
* If we're in the middle of alt-tabbing, don't change
|
||||||
|
* the order please.
|
||||||
|
*/
|
||||||
|
if (!sc->altpersist)
|
||||||
|
client_mtf(cc);
|
||||||
|
} else
|
||||||
|
client_leave(cc);
|
||||||
|
|
||||||
|
if (fg && _curcc != cc) {
|
||||||
|
client_setactive(NULL, 0);
|
||||||
|
_curcc = cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
cc->active = fg;
|
||||||
|
client_draw_border(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct client_ctx *
|
||||||
|
client_current(void)
|
||||||
|
{
|
||||||
|
return (_curcc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_gravitate(struct client_ctx *cc, int yes)
|
||||||
|
{
|
||||||
|
int dx = 0, dy = 0, mult = yes ? 1 : -1;
|
||||||
|
int gravity = (cc->size->flags & PWinGravity) ?
|
||||||
|
cc->size->win_gravity : NorthWestGravity;
|
||||||
|
|
||||||
|
switch (gravity) {
|
||||||
|
case NorthWestGravity:
|
||||||
|
case SouthWestGravity:
|
||||||
|
case NorthEastGravity:
|
||||||
|
case StaticGravity:
|
||||||
|
dx = cc->bwidth;
|
||||||
|
case NorthGravity:
|
||||||
|
dy = cc->bwidth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cc->geom.x += mult*dx;
|
||||||
|
cc->geom.y += mult*dy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_maximize(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
if (cc->flags & CLIENT_MAXIMIZED) {
|
||||||
|
cc->flags &= ~CLIENT_MAXIMIZED;
|
||||||
|
cc->geom = cc->savegeom;
|
||||||
|
} else {
|
||||||
|
XWindowAttributes rootwin_geom;
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
|
||||||
|
XGetWindowAttributes(G_dpy, sc->rootwin, &rootwin_geom);
|
||||||
|
cc->savegeom = cc->geom;
|
||||||
|
cc->geom.x = 0;
|
||||||
|
cc->geom.y = 0;
|
||||||
|
cc->geom.height = rootwin_geom.height;
|
||||||
|
cc->geom.width = rootwin_geom.width;
|
||||||
|
cc->flags |= CLIENT_MAXIMIZED;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
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,
|
||||||
|
cc->geom.width, cc->geom.height);
|
||||||
|
xev_reconfig(cc);
|
||||||
|
client_draw_border(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_move(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
XMoveWindow(G_dpy, cc->pwin,
|
||||||
|
cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth);
|
||||||
|
xev_reconfig(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_lower(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
XLowerWindow(G_dpy, cc->pwin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_raise(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
XRaiseWindow(G_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)
|
||||||
|
{
|
||||||
|
int x = cc->ptr.x, y = cc->ptr.y;
|
||||||
|
|
||||||
|
if (x == -1 || y == -1) {
|
||||||
|
x = cc->geom.width / 2;
|
||||||
|
y = cc->geom.height / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
client_raise(cc);
|
||||||
|
xu_ptr_setpos(cc->pwin, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_ptrsave(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
xu_ptr_getpos(cc->pwin, &x, &y);
|
||||||
|
if (_inwindowbounds(cc, x, y)) {
|
||||||
|
cc->ptr.x = x;
|
||||||
|
cc->ptr.y = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_hide(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
/* XXX - add wm_state stuff */
|
||||||
|
XUnmapWindow(G_dpy, cc->pwin);
|
||||||
|
XUnmapWindow(G_dpy, cc->win);
|
||||||
|
|
||||||
|
cc->active = 0;
|
||||||
|
cc->flags |= CLIENT_HIDDEN;
|
||||||
|
xu_setstate(cc, IconicState);
|
||||||
|
|
||||||
|
if (cc == _curcc)
|
||||||
|
_curcc = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_unhide(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
XMapWindow(G_dpy, cc->win);
|
||||||
|
XMapRaised(G_dpy, cc->pwin);
|
||||||
|
|
||||||
|
cc->flags &= ~CLIENT_HIDDEN;
|
||||||
|
xu_setstate(cc, NormalState);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (!cc->highlight && cc->bwidth > 1)
|
||||||
|
XDrawRectangle(G_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,
|
||||||
|
cc->pwin, client_bg_pixmap(cc));
|
||||||
|
|
||||||
|
XClearWindow(G_dpy, cc->pwin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u_long
|
||||||
|
client_bg_pixel(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
u_long pixl;
|
||||||
|
|
||||||
|
switch (cc->highlight) {
|
||||||
|
case CLIENT_HIGHLIGHT_BLUE:
|
||||||
|
pixl = sc->bluepixl;
|
||||||
|
break;
|
||||||
|
case CLIENT_HIGHLIGHT_RED:
|
||||||
|
pixl = sc->redpixl;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pixl = sc->blackpixl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (pixl);
|
||||||
|
}
|
||||||
|
|
||||||
|
Pixmap
|
||||||
|
client_bg_pixmap(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
Pixmap pix;
|
||||||
|
|
||||||
|
switch (cc->highlight) {
|
||||||
|
case CLIENT_HIGHLIGHT_BLUE:
|
||||||
|
pix = sc->blue;
|
||||||
|
break;
|
||||||
|
case CLIENT_HIGHLIGHT_RED:
|
||||||
|
pix = sc->red;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
pix = sc->gray;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (pix);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_update(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
Atom *p, wm_delete, wm_protocols, wm_take_focus;
|
||||||
|
int i;
|
||||||
|
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);
|
||||||
|
|
||||||
|
if ((n = xu_getprop(cc, wm_protocols,
|
||||||
|
XA_ATOM, 20L, (u_char **)&p)) <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
if (p[i] == wm_delete)
|
||||||
|
cc->xproto |= CLIENT_PROTO_DELETE;
|
||||||
|
else if (p[i] == wm_take_focus)
|
||||||
|
cc->xproto |= CLIENT_PROTO_TAKEFOCUS;
|
||||||
|
|
||||||
|
XFree(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (cc->xproto & CLIENT_PROTO_DELETE)
|
||||||
|
xu_sendmsg(cc, wm_protocols, wm_delete);
|
||||||
|
else
|
||||||
|
XKillClient(G_dpy, cc->win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_setname(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
char *newname;
|
||||||
|
struct winname *wn;
|
||||||
|
|
||||||
|
XFetchName(G_dpy, cc->win, &newname);
|
||||||
|
if (newname == NULL)
|
||||||
|
newname = emptystring;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(wn, &cc->nameq, entry)
|
||||||
|
if (strcmp(wn->name, newname) == 0) {
|
||||||
|
/* Move to the last since we got a hit. */
|
||||||
|
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
||||||
|
TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
|
||||||
|
goto match;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMALLOC(wn, struct winname);
|
||||||
|
wn->name = newname;
|
||||||
|
TAILQ_INSERT_TAIL(&cc->nameq, wn, entry);
|
||||||
|
cc->nameqlen++;
|
||||||
|
|
||||||
|
match:
|
||||||
|
cc->name = wn->name;
|
||||||
|
|
||||||
|
/* Now, do some garbage collection. */
|
||||||
|
if (cc->nameqlen > CLIENT_MAXNAMEQLEN) {
|
||||||
|
wn = TAILQ_FIRST(&cc->nameq);
|
||||||
|
assert(wn != NULL);
|
||||||
|
TAILQ_REMOVE(&cc->nameq, wn, entry);
|
||||||
|
if (wn->name != emptystring)
|
||||||
|
XFree(wn->name);
|
||||||
|
xfree(wn);
|
||||||
|
cc->nameqlen--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: seems to have some issues still on the first invocation
|
||||||
|
* (globally the first)
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct client_ctx *
|
||||||
|
client_cyclenext(struct client_ctx *cc, int reverse)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
struct client_ctx *(*iter)(struct client_ctx *) =
|
||||||
|
reverse ? &client_mruprev : &client_mrunext;
|
||||||
|
|
||||||
|
/* TODO: maybe this should just be a CIRCLEQ. */
|
||||||
|
|
||||||
|
/* if altheld; then reset the iterator to the beginning */
|
||||||
|
if (!sc->altpersist || sc->cycle_client == NULL)
|
||||||
|
sc->cycle_client = TAILQ_FIRST(&sc->mruq);
|
||||||
|
|
||||||
|
if (sc->cycle_client == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* INVARIANT: as long as sc->cycle_client != NULL here, we
|
||||||
|
* won't exit with sc->cycle_client == NULL
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ((sc->cycle_client = client__cycle(cc, iter)) == NULL)
|
||||||
|
sc->cycle_client = cc;
|
||||||
|
|
||||||
|
/* Do the actual warp. */
|
||||||
|
client_ptrsave(cc);
|
||||||
|
client_ptrwarp(sc->cycle_client);
|
||||||
|
sc->altpersist = 1; /* This is reset when alt is let go... */
|
||||||
|
|
||||||
|
/* Draw window. */
|
||||||
|
client_cycleinfo(sc->cycle_client);
|
||||||
|
|
||||||
|
return (sc->cycle_client);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX - have to have proper exposure handling here. we will probably
|
||||||
|
* have to do this by registering with the event loop a function to
|
||||||
|
* redraw, then match that on windows.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
client_cycleinfo(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
int w, h, nlines, i, n, oneh, curn = -1, x, y, diff;
|
||||||
|
struct client_ctx *ccc, *list[3];
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
struct fontdesc *font = DefaultFont;
|
||||||
|
|
||||||
|
memset(list, 0, sizeof(list));
|
||||||
|
|
||||||
|
nlines = 0;
|
||||||
|
TAILQ_FOREACH(ccc, &sc->mruq, mru_entry)
|
||||||
|
nlines++;
|
||||||
|
nlines = MIN(nlines, 3);
|
||||||
|
|
||||||
|
oneh = font_ascent(font) + font_descent(font) + 1;
|
||||||
|
h = nlines*oneh;
|
||||||
|
|
||||||
|
list[1] = cc;
|
||||||
|
|
||||||
|
if (nlines > 1)
|
||||||
|
list[2] = client__cycle(cc, &client_mrunext);
|
||||||
|
if (nlines > 2)
|
||||||
|
list[0] = client__cycle(cc, &client_mruprev);
|
||||||
|
|
||||||
|
w = 0;
|
||||||
|
for (i = 0; i < sizeof(list)/sizeof(list[0]); i++) {
|
||||||
|
if ((ccc = list[i]) == NULL)
|
||||||
|
continue;
|
||||||
|
w = MAX(w, font_width(font, ccc->name, strlen(ccc->name)));
|
||||||
|
}
|
||||||
|
|
||||||
|
w += 4;
|
||||||
|
|
||||||
|
/* try to fit. */
|
||||||
|
|
||||||
|
if ((x = cc->ptr.x) < 0 || (y = cc->ptr.y) < 0) {
|
||||||
|
x = cc->geom.width / 2;
|
||||||
|
y = cc->geom.height / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((diff = cc->geom.width - (x + w)) < 0)
|
||||||
|
x += diff;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
for (i = 0, n = 0; i < sizeof(list)/sizeof(list[0]); i++) {
|
||||||
|
if ((ccc = list[i]) == NULL)
|
||||||
|
continue;
|
||||||
|
font_draw(font, ccc->name, strlen(ccc->name), sc->infowin,
|
||||||
|
2, n*oneh + font_ascent(font) + 1);
|
||||||
|
if (i == 1)
|
||||||
|
curn = n;
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(curn != -1);
|
||||||
|
|
||||||
|
/* Highlight the current entry. */
|
||||||
|
XFillRectangle(G_dpy, sc->infowin, sc->hlgc, 0, curn*oneh, w, oneh);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct client_ctx *
|
||||||
|
client_mrunext(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
struct client_ctx *ccc;
|
||||||
|
|
||||||
|
return ((ccc = TAILQ_NEXT(cc, mru_entry)) != NULL ?
|
||||||
|
ccc : TAILQ_FIRST(&sc->mruq));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct client_ctx *
|
||||||
|
client_mruprev(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
struct client_ctx *ccc;
|
||||||
|
|
||||||
|
return ((ccc = TAILQ_PREV(cc, cycle_entry_q, mru_entry)) != NULL ?
|
||||||
|
ccc : TAILQ_LAST(&sc->mruq, cycle_entry_q));
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct client_ctx *
|
||||||
|
client__cycle(struct client_ctx *cc,
|
||||||
|
struct client_ctx *(*iter)(struct client_ctx *))
|
||||||
|
{
|
||||||
|
struct client_ctx *save = cc;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (!((cc = (*iter)(cc))->flags & CLIENT_HIDDEN))
|
||||||
|
break;
|
||||||
|
} while (cc != save);
|
||||||
|
|
||||||
|
return cc != save ? cc : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_altrelease()
|
||||||
|
{
|
||||||
|
struct client_ctx *cc = _curcc;
|
||||||
|
struct screen_ctx *sc;
|
||||||
|
|
||||||
|
if (cc == NULL)
|
||||||
|
return;
|
||||||
|
sc = CCTOSC(cc);
|
||||||
|
|
||||||
|
XUnmapWindow(G_dpy, sc->infowin);
|
||||||
|
XReparentWindow(G_dpy, sc->infowin, sc->rootwin, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_placecalc(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
int yslack, xslack;
|
||||||
|
int x, y, height, width, ymax, xmax, mousex, mousey;
|
||||||
|
|
||||||
|
y = cc->geom.y;
|
||||||
|
x = cc->geom.x;
|
||||||
|
|
||||||
|
height = cc->geom.height;
|
||||||
|
width = cc->geom.width;
|
||||||
|
|
||||||
|
ymax = DisplayHeight(G_dpy, sc->which) - cc->bwidth;
|
||||||
|
xmax = DisplayWidth(G_dpy, sc->which) - cc->bwidth;
|
||||||
|
|
||||||
|
yslack = ymax - cc->geom.height;
|
||||||
|
xslack = xmax - cc->geom.width;
|
||||||
|
|
||||||
|
xu_ptr_getpos(sc->rootwin, &mousex, &mousey);
|
||||||
|
|
||||||
|
mousex = MAX(mousex, cc->bwidth) - cc->geom.width/2;
|
||||||
|
mousey = MAX(mousey, cc->bwidth) - cc->geom.height/2;
|
||||||
|
|
||||||
|
mousex = MAX(mousex, (int)cc->bwidth);
|
||||||
|
mousey = MAX(mousey, (int)cc->bwidth);
|
||||||
|
|
||||||
|
if (cc->size->flags & USPosition) {
|
||||||
|
x = cc->size->x;
|
||||||
|
if (x <= 0 || x >= xmax)
|
||||||
|
x = cc->bwidth;
|
||||||
|
y = cc->size->y;
|
||||||
|
if (y <= 0 || y >= ymax)
|
||||||
|
y = cc->bwidth;
|
||||||
|
} else {
|
||||||
|
if (yslack < 0) {
|
||||||
|
y = cc->bwidth;
|
||||||
|
height = ymax;
|
||||||
|
} else {
|
||||||
|
if (y == 0 || y > yslack)
|
||||||
|
y = MIN(mousey, yslack);
|
||||||
|
height = cc->geom.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xslack < 0) {
|
||||||
|
x = cc->bwidth;
|
||||||
|
width = xmax;
|
||||||
|
} else {
|
||||||
|
if (x == 0 || x > xslack)
|
||||||
|
x = MIN(mousex, xslack);
|
||||||
|
width = cc->geom.width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cc->geom.y = y;
|
||||||
|
cc->geom.x = x;
|
||||||
|
|
||||||
|
cc->geom.height = height;
|
||||||
|
cc->geom.width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_vertmaximize(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
if (cc->flags & CLIENT_MAXIMIZED) {
|
||||||
|
cc->flags &= ~CLIENT_MAXIMIZED;
|
||||||
|
cc->geom = cc->savegeom;
|
||||||
|
} else {
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
int display_height = DisplayHeight(G_dpy, sc->which) -
|
||||||
|
cc->bwidth*2;
|
||||||
|
|
||||||
|
cc->savegeom = cc->geom;
|
||||||
|
cc->geom.y = cc->bwidth;
|
||||||
|
if (cc->geom.min_dx == 0)
|
||||||
|
cc->geom.height = display_height;
|
||||||
|
else
|
||||||
|
cc->geom.height = display_height -
|
||||||
|
(display_height % cc->geom.min_dx);
|
||||||
|
cc->flags |= CLIENT_MAXIMIZED;
|
||||||
|
}
|
||||||
|
|
||||||
|
client_resize(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_map(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
/* mtf? */
|
||||||
|
client_ptrwarp(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_mtf(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc;
|
||||||
|
|
||||||
|
if (cc == NULL)
|
||||||
|
cc = _curcc;
|
||||||
|
if (cc == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sc = CCTOSC(cc);
|
||||||
|
|
||||||
|
/* Move to front. */
|
||||||
|
TAILQ_REMOVE(&sc->mruq, cc, mru_entry);
|
||||||
|
TAILQ_INSERT_HEAD(&sc->mruq, cc, mru_entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_gethints(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
XClassHint xch;
|
||||||
|
int argc;
|
||||||
|
char **argv;
|
||||||
|
Atom mha;
|
||||||
|
struct mwm_hints *mwmh;
|
||||||
|
|
||||||
|
if (XGetClassHint(G_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);
|
||||||
|
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)) {
|
||||||
|
#define MAX_ARGLEN 512
|
||||||
|
#define ARG_SEP_ " "
|
||||||
|
int len = MAX_ARGLEN;
|
||||||
|
int i, o;
|
||||||
|
char *buf;
|
||||||
|
|
||||||
|
buf = xmalloc(len);
|
||||||
|
buf[0] = '\0';
|
||||||
|
|
||||||
|
for (o = 0, i = 0; o < len && i < argc; i++) {
|
||||||
|
if (argv[i] == NULL)
|
||||||
|
break;
|
||||||
|
strlcat(buf, argv[i], len);
|
||||||
|
o += strlen(buf);
|
||||||
|
strlcat(buf, ARG_SEP_, len);
|
||||||
|
o += strlen(ARG_SEP_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(buf) > 0)
|
||||||
|
cc->app_cliarg = buf;
|
||||||
|
|
||||||
|
XFreeStringList(argv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
client_freehints(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
if (cc->app_name != NULL)
|
||||||
|
XFree(cc->app_name);
|
||||||
|
if (cc->app_class != NULL)
|
||||||
|
XFree(cc->app_class);
|
||||||
|
if (cc->app_cliarg != NULL)
|
||||||
|
xfree(cc->app_cliarg);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_inwindowbounds(struct client_ctx *cc, int x, int y)
|
||||||
|
{
|
||||||
|
return (x < cc->geom.width && x >= 0 &&
|
||||||
|
y < cc->geom.height && y >= 0);
|
||||||
|
}
|
508
compat/sys/queue.h
Normal file
508
compat/sys/queue.h
Normal file
@ -0,0 +1,508 @@
|
|||||||
|
/* $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_ */
|
677
compat/sys/tree.h
Normal file
677
compat/sys/tree.h
Normal file
@ -0,0 +1,677 @@
|
|||||||
|
/* $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_ */
|
531
conf.c
Normal file
531
conf.c
Normal file
@ -0,0 +1,531 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "headers.h"
|
||||||
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
#ifndef timespeccmp
|
||||||
|
#define timespeccmp(tsp, usp, cmp) \
|
||||||
|
(((tsp)->tv_sec == (usp)->tv_sec) ? \
|
||||||
|
((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
|
||||||
|
((tsp)->tv_sec cmp (usp)->tv_sec))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define CONF_MAX_WINTITLE 256
|
||||||
|
#define CONF_IGNORECASE 0x01
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Match a window.
|
||||||
|
*/
|
||||||
|
struct winmatch {
|
||||||
|
TAILQ_ENTRY(winmatch) entry;
|
||||||
|
|
||||||
|
char title[CONF_MAX_WINTITLE];
|
||||||
|
int opts;
|
||||||
|
};
|
||||||
|
|
||||||
|
TAILQ_HEAD(winmatch_q, winmatch);
|
||||||
|
struct winmatch_q ignoreq;
|
||||||
|
|
||||||
|
/* XXX - until we get a real configuration parser. */
|
||||||
|
#define WINMATCH_ADD(queue, str) do { \
|
||||||
|
struct winmatch *wm; \
|
||||||
|
XCALLOC(wm, struct winmatch); \
|
||||||
|
strlcpy(wm->title, str, sizeof(wm->title)); \
|
||||||
|
wm->opts |= CONF_IGNORECASE; \
|
||||||
|
TAILQ_INSERT_TAIL(queue, wm, entry); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/* #define SYSTR_PRE "systrace -C -g /usr/local/bin/notification -d /usr/home/marius/policy/X11 " */
|
||||||
|
|
||||||
|
/* Initializes the command menu */
|
||||||
|
|
||||||
|
void
|
||||||
|
conf_cmd_init(struct conf *c)
|
||||||
|
{
|
||||||
|
TAILQ_INIT(&c->cmdq);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Removes all static entries */
|
||||||
|
|
||||||
|
void
|
||||||
|
conf_cmd_clear(struct conf *c)
|
||||||
|
{
|
||||||
|
struct cmd *cmd, *next;
|
||||||
|
|
||||||
|
for (cmd = TAILQ_FIRST(&c->cmdq); cmd != NULL; cmd = next) {
|
||||||
|
next = TAILQ_NEXT(cmd, entry);
|
||||||
|
|
||||||
|
/* Do not remove static entries */
|
||||||
|
if (cmd->flags & CMD_STATIC)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
TAILQ_REMOVE(&c->cmdq, cmd, entry);
|
||||||
|
free(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add an command menu entry to the end of the menu */
|
||||||
|
void
|
||||||
|
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));
|
||||||
|
} else if (strcmp(label, "lock") == 0) {
|
||||||
|
strlcpy(G_conf.lockpath, image, sizeof(G_conf.lockpath));
|
||||||
|
} else {
|
||||||
|
struct cmd *cmd;
|
||||||
|
XMALLOC(cmd, struct cmd);
|
||||||
|
cmd->flags = flags;
|
||||||
|
strlcpy(cmd->image, image, sizeof(cmd->image));
|
||||||
|
strlcpy(cmd->label, label, sizeof(cmd->label));
|
||||||
|
TAILQ_INSERT_TAIL(&c->cmdq, cmd, entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
conf_cmd_changed(char *path)
|
||||||
|
{
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
static struct timespec old_ts;
|
||||||
|
#else
|
||||||
|
static time_t old_time;
|
||||||
|
#endif
|
||||||
|
struct stat sb;
|
||||||
|
int changed;
|
||||||
|
|
||||||
|
/* If the directory does not exist we pretend that nothing changed */
|
||||||
|
if (stat(path, &sb) == -1 || !(sb.st_mode & S_IFDIR))
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
changed = !timespeccmp(&sb.st_mtimespec, &old_ts, ==);
|
||||||
|
old_ts = sb.st_mtimespec;
|
||||||
|
#else
|
||||||
|
changed = old_time != sb.st_mtime;
|
||||||
|
old_time = sb.st_mtime;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (changed);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
conf_cmd_populate(struct conf *c, char *path)
|
||||||
|
{
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent *file;
|
||||||
|
char fullname[PATH_MAX];
|
||||||
|
int off;
|
||||||
|
|
||||||
|
if (strlen(path) >= sizeof (fullname) - 2)
|
||||||
|
errx(1, "directory name too long");
|
||||||
|
|
||||||
|
dir = opendir(path);
|
||||||
|
if (dir == NULL)
|
||||||
|
err(1, "opendir");
|
||||||
|
|
||||||
|
strlcpy(fullname, path, sizeof (fullname));
|
||||||
|
off = strlen(fullname);
|
||||||
|
if (fullname[off - 1] != '/') {
|
||||||
|
strlcat(fullname, "/", sizeof(fullname));
|
||||||
|
off++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((file = readdir(dir)) != NULL) {
|
||||||
|
char *filename = file->d_name;
|
||||||
|
if (filename[0] == '.')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
strlcpy(fullname + off, filename, sizeof(fullname) - off);
|
||||||
|
|
||||||
|
/* Add a dynamic entry to the command menu */
|
||||||
|
conf_cmd_add(c, fullname, filename, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
conf_cmd_refresh(struct conf *c)
|
||||||
|
{
|
||||||
|
if (!conf_cmd_changed(c->menu_path))
|
||||||
|
return;
|
||||||
|
|
||||||
|
conf_cmd_clear(c);
|
||||||
|
conf_cmd_populate(c, c->menu_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
conf_setup(struct conf *c)
|
||||||
|
{
|
||||||
|
char dir_keydefs[MAXPATHLEN];
|
||||||
|
char dir_settings[MAXPATHLEN];
|
||||||
|
char dir_ignored[MAXPATHLEN];
|
||||||
|
char dir_autogroup[MAXPATHLEN];
|
||||||
|
char *home = getenv("HOME");
|
||||||
|
|
||||||
|
if (home == NULL)
|
||||||
|
errx(1, "No HOME directory.");
|
||||||
|
snprintf(c->menu_path, sizeof(c->menu_path), "%s/.calmwm", home);
|
||||||
|
|
||||||
|
conf_cmd_init(c);
|
||||||
|
|
||||||
|
TAILQ_INIT(&c->keybindingq);
|
||||||
|
snprintf(dir_keydefs, sizeof(dir_keydefs), "%s/.calmwm/.keys", home);
|
||||||
|
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);
|
||||||
|
if (dirent_isdir(dir_settings))
|
||||||
|
conf_parsesettings(c, dir_settings);
|
||||||
|
|
||||||
|
TAILQ_INIT(&ignoreq);
|
||||||
|
|
||||||
|
snprintf(dir_ignored, sizeof(dir_ignored), "%s/.calmwm/.ignore", home);
|
||||||
|
if (dirent_isdir(dir_ignored))
|
||||||
|
conf_parseignores(c, dir_ignored);
|
||||||
|
else {
|
||||||
|
WINMATCH_ADD(&ignoreq, "XMMS");
|
||||||
|
WINMATCH_ADD(&ignoreq, "xwi");
|
||||||
|
WINMATCH_ADD(&ignoreq, "xapm");
|
||||||
|
WINMATCH_ADD(&ignoreq, "xclock");
|
||||||
|
}
|
||||||
|
|
||||||
|
TAILQ_INIT(&c->autogroupq);
|
||||||
|
|
||||||
|
snprintf(dir_autogroup, sizeof(dir_autogroup),
|
||||||
|
"%s/.calmwm/.autogroup", home);
|
||||||
|
if (dirent_isdir(dir_autogroup))
|
||||||
|
conf_parseautogroups(c, dir_autogroup);
|
||||||
|
|
||||||
|
c->flags = 0;
|
||||||
|
|
||||||
|
/* Default term/lock */
|
||||||
|
strlcpy(G_conf.termpath, "xterm", sizeof(G_conf.termpath));
|
||||||
|
strlcpy(G_conf.lockpath, "xlock", sizeof(G_conf.lockpath));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
conf_get_int(struct client_ctx *cc, enum conftype ctype)
|
||||||
|
{
|
||||||
|
int val = -1, ignore = 0;
|
||||||
|
char *wname;
|
||||||
|
struct winmatch *wm;
|
||||||
|
|
||||||
|
wname = cc->name;
|
||||||
|
|
||||||
|
/* Can wname be NULL? */
|
||||||
|
|
||||||
|
if (wname != NULL) {
|
||||||
|
TAILQ_FOREACH(wm, &ignoreq, entry) {
|
||||||
|
int (*cmpfun)(const char *, const char *, size_t) =
|
||||||
|
wm->opts & CONF_IGNORECASE ? strncasecmp : strncmp;
|
||||||
|
if ((*cmpfun)(wm->title, wname, strlen(wm->title)) == 0) {
|
||||||
|
ignore = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else
|
||||||
|
ignore = 1;
|
||||||
|
|
||||||
|
switch (ctype) {
|
||||||
|
case CONF_BWIDTH:
|
||||||
|
/*
|
||||||
|
* XXX this will be a list, specified in the
|
||||||
|
* configuration file.
|
||||||
|
*/
|
||||||
|
val = ignore ? 0 : 3;
|
||||||
|
break;
|
||||||
|
case CONF_IGNORE:
|
||||||
|
val = ignore;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
cc->bwidth = conf_get_int(cc, CONF_BWIDTH);
|
||||||
|
cc->flags |= conf_get_int(cc, CONF_IGNORE) ? CLIENT_IGNORE : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct {
|
||||||
|
char *tag;
|
||||||
|
void (*handler)(struct client_ctx *, void *);
|
||||||
|
int flags;
|
||||||
|
void *argument;
|
||||||
|
} name_to_kbfunc[] = {
|
||||||
|
{ "lower", kbfunc_client_lower, KBFLAG_NEEDCLIENT, 0 },
|
||||||
|
{ "raise", kbfunc_client_raise, KBFLAG_NEEDCLIENT, 0 },
|
||||||
|
{ "search", kbfunc_client_search, KBFLAG_NEEDCLIENT, 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 },
|
||||||
|
{ "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},
|
||||||
|
{ 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;
|
||||||
|
|
||||||
|
snprintf(current_file, sizeof(current_file),
|
||||||
|
"%s/%s", filename, ent->d_name);
|
||||||
|
if (strchr(ent->d_name, '-') == NULL && ent->d_name[0] != '[')
|
||||||
|
continue;
|
||||||
|
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)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
current_binding->callback = kbfunc_cmdexec;
|
||||||
|
current_binding->argument = strdup(buffer);
|
||||||
|
current_binding->flags = 0;
|
||||||
|
TAILQ_INSERT_TAIL(&c->keybindingq, current_binding, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
conf_parsesettings(struct conf *c, char *filename)
|
||||||
|
{
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent *ent;
|
||||||
|
|
||||||
|
dir = opendir(filename);
|
||||||
|
while ((ent = readdir(dir)) != NULL) {
|
||||||
|
if (ent->d_name[0] == '.')
|
||||||
|
continue;
|
||||||
|
if (strncmp(ent->d_name, "sticky", 7)==0)
|
||||||
|
G_conf.flags |= CONF_STICKY_GROUPS;
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
conf_parseignores(struct conf *c, char *filename)
|
||||||
|
{
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent *ent;
|
||||||
|
|
||||||
|
dir = opendir(filename);
|
||||||
|
while ((ent = readdir(dir)) != NULL) {
|
||||||
|
if (ent->d_name[0] == '.')
|
||||||
|
continue;
|
||||||
|
WINMATCH_ADD(&ignoreq, ent->d_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
conf_parseautogroups(struct conf *c, char *filename)
|
||||||
|
{
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent *ent;
|
||||||
|
struct autogroupwin *aw;
|
||||||
|
char current_file[MAXPATHLEN], *p;
|
||||||
|
char group[CALMWM_MAXNAMELEN];
|
||||||
|
int len;
|
||||||
|
|
||||||
|
dir = opendir(filename);
|
||||||
|
while ((ent = readdir(dir)) != NULL) {
|
||||||
|
if (ent->d_name[0] == '.')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
snprintf(current_file, sizeof(current_file),
|
||||||
|
"%s/%s", filename, ent->d_name);
|
||||||
|
if (!dirent_islink(current_file))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((len = readlink(current_file,
|
||||||
|
group, sizeof(group) - 1)) < 0)
|
||||||
|
continue;
|
||||||
|
group[len] = '\0';
|
||||||
|
|
||||||
|
XCALLOC(aw, struct autogroupwin);
|
||||||
|
|
||||||
|
if ((p = strchr(ent->d_name, ',')) == NULL) {
|
||||||
|
aw->name = NULL;
|
||||||
|
aw->class = xstrdup(ent->d_name);
|
||||||
|
} else {
|
||||||
|
*(p++) = '\0';
|
||||||
|
aw->name = xstrdup(ent->d_name);
|
||||||
|
aw->class = xstrdup(p);
|
||||||
|
}
|
||||||
|
aw->group = xstrdup(group);
|
||||||
|
|
||||||
|
TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry);
|
||||||
|
}
|
||||||
|
}
|
1463
config.guess
vendored
Executable file
1463
config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
129
config.h.in
Normal file
129
config.h.in
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/* 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
Executable file
1579
config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
74
configure.in
Normal file
74
configure.in
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
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
Normal file
65
cursor.c
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
223
cwm.1
Normal file
223
cwm.1
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
.\" $OpenBSD$
|
||||||
|
.\"
|
||||||
|
.\" The following requests are required for all man pages.
|
||||||
|
.Dd July 10, 2004
|
||||||
|
.Dt CWM 1
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm cwm
|
||||||
|
.Nd a lightweight and efficient window manager for X11
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.\" For a program: program [-abc] file ...
|
||||||
|
.Nm cwm
|
||||||
|
.Op Fl s
|
||||||
|
.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.
|
||||||
|
.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
|
||||||
|
Control
|
||||||
|
.It Fa M
|
||||||
|
Meta (Alt on PCs)
|
||||||
|
.It Fa S
|
||||||
|
Shift
|
||||||
|
.It Fa M1
|
||||||
|
Left mouse button
|
||||||
|
.It Fa M2
|
||||||
|
Middle mouse button
|
||||||
|
.It Fa M3
|
||||||
|
Right mouse button
|
||||||
|
.El
|
||||||
|
|
||||||
|
.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
|
||||||
|
Spawn a new terminal.
|
||||||
|
.It Fa C-M-Delete
|
||||||
|
Lock the screen.
|
||||||
|
.It Fa M-Enter
|
||||||
|
Hide current window.
|
||||||
|
.It Fa M-Down
|
||||||
|
Lower current window.
|
||||||
|
.It Fa M-Up
|
||||||
|
Raise current window.
|
||||||
|
.It Fa M-/
|
||||||
|
Search for windows.
|
||||||
|
.It Fa C-/
|
||||||
|
Search for applications.
|
||||||
|
.It Fa C-M-l
|
||||||
|
Label current window.
|
||||||
|
.It Fa M-Tab
|
||||||
|
Cycle through currently visible windows.
|
||||||
|
.It Fa M-S-Tab
|
||||||
|
Reverse cycle through currently visible windows.
|
||||||
|
.It Fa C-M-x
|
||||||
|
Delete current window.
|
||||||
|
.It Fa C-M-Escape
|
||||||
|
Enter group edit mode.
|
||||||
|
.It Fa C-M-[n]
|
||||||
|
Select group n, where n is 1-9.
|
||||||
|
.It Fa C-M-0
|
||||||
|
Select all groups.
|
||||||
|
.It Fa M-Right
|
||||||
|
Switch to next group.
|
||||||
|
.It Fa M-Left
|
||||||
|
Switch to previous group.
|
||||||
|
.It Fa C-M-=
|
||||||
|
Toggle vertical maximization of window.
|
||||||
|
.El
|
||||||
|
|
||||||
|
The mouse bindings are also important, they are:
|
||||||
|
|
||||||
|
.Bl -tag -width 10n -offset -indent -compact
|
||||||
|
.It Fa 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
|
||||||
|
Lower a window.
|
||||||
|
.El
|
||||||
|
|
||||||
|
The options for
|
||||||
|
.Nm
|
||||||
|
are as follows:
|
||||||
|
.Bl -tag -width Ds
|
||||||
|
.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 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
|
||||||
|
keeps a history of the 5 previous titles of a window.
|
||||||
|
|
||||||
|
When searching, the leftmost character of the result list may show a
|
||||||
|
flag:
|
||||||
|
|
||||||
|
.Bl -tag -width 10n -offset -indent -compact
|
||||||
|
.It Fa !
|
||||||
|
The window is the currently focused window.
|
||||||
|
.It Fa &
|
||||||
|
The window is hidden.
|
||||||
|
.El
|
||||||
|
|
||||||
|
The following keybindings may be used to navigate the result list:
|
||||||
|
|
||||||
|
.Bl -tag -width 10n -offset -indent -compact
|
||||||
|
.It [Down] or C-s
|
||||||
|
Select the next window in the list.
|
||||||
|
.It [Up] or C-r
|
||||||
|
Select the previous window in the list.
|
||||||
|
.It C-u
|
||||||
|
Clear the input.
|
||||||
|
.It [Enter]
|
||||||
|
Focus the selected window.
|
||||||
|
.It [Esc]
|
||||||
|
Quit.
|
||||||
|
.It 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
|
||||||
|
.Fl s
|
||||||
|
option, this can be used to emulate virtual desktops.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
.Sh MENUS
|
||||||
|
Menus are recalled by clicking the mouse on the root window:
|
||||||
|
|
||||||
|
.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.
|
||||||
|
.El
|
||||||
|
|
||||||
|
.Sh ~/.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
|
||||||
|
.Xr ln 1 .
|
||||||
|
|
||||||
|
The entries
|
||||||
|
.Nm term
|
||||||
|
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
|
||||||
|
.Xr xterm 1
|
||||||
|
and
|
||||||
|
.Xr xlock 1 ,
|
||||||
|
respectively.
|
||||||
|
|
||||||
|
.Sh ACKNOWLEDGEMENTS
|
||||||
|
.Nm
|
||||||
|
contains some code from 9wm.
|
||||||
|
|
||||||
|
.Sh AUTHORS
|
||||||
|
The
|
||||||
|
.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änen
|
||||||
|
.Aq aon@iki.fi .
|
||||||
|
Ideas, discussion with many others.
|
||||||
|
.\" .Sh HISTORY
|
||||||
|
.\".Aq marius@monkey.org .
|
||||||
|
.\" .Sh CAVEATS
|
21
draw.c
Normal file
21
draw.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* 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
Normal file
105
err.c
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
159
font.c
Normal file
159
font.c
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
/*
|
||||||
|
* font.c - cwm font abstraction
|
||||||
|
*
|
||||||
|
* 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 "hash.h"
|
||||||
|
#include "headers.h"
|
||||||
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
static XftFont *_make_font(struct screen_ctx *sc, struct fontdesc *fdp);
|
||||||
|
|
||||||
|
HASH_GENERATE(fonthash, fontdesc, node, fontdesc_cmp);
|
||||||
|
|
||||||
|
int
|
||||||
|
fontdesc_cmp(struct fontdesc *a, struct fontdesc *b)
|
||||||
|
{
|
||||||
|
return strcmp(a->name, b->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fowler/Noll/Vo hash
|
||||||
|
* http://www.isthe.com/chongo/tech/comp/fnv/
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define FNV_P_32 ((unsigned int)0x01000193) /* 16777619 */
|
||||||
|
#define FNV_1_32 ((unsigned int)0x811c9dc5) /* 2166136261 */
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
fontdesc_hash(struct fontdesc *fdp)
|
||||||
|
{
|
||||||
|
const unsigned char *p, *end, *start;
|
||||||
|
unsigned int hash = FNV_1_32;
|
||||||
|
|
||||||
|
start = fdp->name;
|
||||||
|
end = (const unsigned char *)fdp->name + strlen(fdp->name);
|
||||||
|
|
||||||
|
for (p = start; p < end; p++) {
|
||||||
|
hash *= FNV_P_32;
|
||||||
|
hash ^= (unsigned int)*p;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
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));
|
||||||
|
if (sc->xftdraw == NULL)
|
||||||
|
errx(1, "XftDrawCreate");
|
||||||
|
|
||||||
|
if (!XAllocNamedColor(G_dpy, DefaultColormap(G_dpy, sc->which),
|
||||||
|
"black", &xcolor, &tmp))
|
||||||
|
errx(1, "XAllocNamedColor");
|
||||||
|
|
||||||
|
sc->xftcolor.color.red = xcolor.red;
|
||||||
|
sc->xftcolor.color.green = xcolor.green;
|
||||||
|
sc->xftcolor.color.blue = xcolor.blue;
|
||||||
|
sc->xftcolor.color.alpha = 0x00ff00;
|
||||||
|
sc->xftcolor.pixel = xcolor.pixel;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct fontdesc *
|
||||||
|
font_getx(struct screen_ctx *sc, const char *name)
|
||||||
|
{
|
||||||
|
struct fontdesc *fdp;
|
||||||
|
|
||||||
|
if ((fdp = font_get(sc, name)) == NULL)
|
||||||
|
errx(1, "font_get()");
|
||||||
|
|
||||||
|
return (fdp);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct fontdesc *
|
||||||
|
font_get(struct screen_ctx *sc, const char *name)
|
||||||
|
{
|
||||||
|
struct fontdesc fd, *fdp;
|
||||||
|
XftFont *fn;
|
||||||
|
|
||||||
|
fd.name = name;
|
||||||
|
|
||||||
|
if ((fdp = HASH_FIND(fonthash, &sc->fonthash, &fd)) == NULL
|
||||||
|
&& (fn = _make_font(sc, &fd)) != NULL) {
|
||||||
|
fdp = xmalloc(sizeof(*fdp));
|
||||||
|
fdp->name = xstrdup(fd.name);
|
||||||
|
fdp->fn = fn;
|
||||||
|
fdp->sc = sc;
|
||||||
|
HASH_INSERT(fonthash, &sc->fonthash, fdp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (fdp);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
font_width(struct fontdesc *fdp, const char *text, int len)
|
||||||
|
{
|
||||||
|
XGlyphInfo extents;
|
||||||
|
XftTextExtents8(G_dpy, fdp->fn, (const XftChar8*)text, len, &extents);
|
||||||
|
|
||||||
|
return (extents.xOff);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
font_draw(struct fontdesc *fdp, const char *text, int len,
|
||||||
|
Drawable d, int x, int y)
|
||||||
|
{
|
||||||
|
XftDrawChange(fdp->sc->xftdraw, d);
|
||||||
|
/* Really needs to be UTF8'd. */
|
||||||
|
XftDrawString8(fdp->sc->xftdraw, &fdp->sc->xftcolor, fdp->fn, x, y,
|
||||||
|
(const FcChar8*)text, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
font_ascent(struct fontdesc *fdp)
|
||||||
|
{
|
||||||
|
return fdp->fn->ascent;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
font_descent(struct fontdesc *fdp)
|
||||||
|
{
|
||||||
|
return fdp->fn->descent;
|
||||||
|
}
|
||||||
|
|
||||||
|
static XftFont *
|
||||||
|
_make_font(struct screen_ctx *sc, struct fontdesc *fdp)
|
||||||
|
{
|
||||||
|
XftFont *fn = NULL;
|
||||||
|
FcPattern *pat, *patx;
|
||||||
|
XftResult res;
|
||||||
|
|
||||||
|
if ((pat = FcNameParse(fdp->name)) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
if ((patx = XftFontMatch(G_dpy, sc->which, pat, &res)) != NULL)
|
||||||
|
fn = XftFontOpenPattern(G_dpy, patx);
|
||||||
|
|
||||||
|
FcPatternDestroy(pat);
|
||||||
|
|
||||||
|
return (fn);
|
||||||
|
}
|
||||||
|
|
53
geographic.c
Normal file
53
geographic.c
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
475
grab.c
Normal file
475
grab.c
Normal file
@ -0,0 +1,475 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "headers.h"
|
||||||
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
int _sweepcalc(struct client_ctx *, int, int, int, int);
|
||||||
|
int _nobuttons(XButtonEvent *);
|
||||||
|
|
||||||
|
#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)
|
||||||
|
|
||||||
|
void
|
||||||
|
grab_sweep_draw(struct client_ctx *cc, int dx, int dy)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
int x0 = cc->geom.x, y0 = cc->geom.y;
|
||||||
|
char asize[10]; /* fits "nnnnxnnnn\0" */
|
||||||
|
int wide, height, wide_size, wide_name;
|
||||||
|
struct fontdesc *font = DefaultFont;
|
||||||
|
|
||||||
|
snprintf(asize, sizeof(asize), "%dx%d",
|
||||||
|
ADJUST_WIDTH(cc, dx), ADJUST_HEIGHT(cc, dy));
|
||||||
|
wide_size = font_width(font, asize, strlen(asize)) + 4;
|
||||||
|
wide_name = font_width(font, cc->name, strlen(cc->name)) + 4;
|
||||||
|
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);
|
||||||
|
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
|
||||||
|
grab_sweep(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
XEvent ev;
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
int x0 = cc->geom.x, y0 = cc->geom.y;
|
||||||
|
int dx, dy;
|
||||||
|
|
||||||
|
dx = MAX(1, cc->size->width_inc);
|
||||||
|
dy = MAX(1, cc->size->height_inc);
|
||||||
|
|
||||||
|
client_raise(cc);
|
||||||
|
client_ptrsave(cc);
|
||||||
|
|
||||||
|
if (xu_ptr_grab(sc->rootwin, MouseMask, G_cursor_resize) < 0)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
switch (ev.type) {
|
||||||
|
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,
|
||||||
|
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,
|
||||||
|
cc->geom.width, cc->geom.height);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ButtonRelease:
|
||||||
|
XUnmapWindow(G_dpy, sc->menuwin);
|
||||||
|
XReparentWindow(G_dpy, sc->menuwin, sc->rootwin, 0, 0);
|
||||||
|
xu_ptr_ungrab();
|
||||||
|
client_ptrwarp(cc);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* NOTREACHED */
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
grab_drag(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
int x0 = cc->geom.x, y0 = cc->geom.y, xm, ym;
|
||||||
|
struct screen_ctx *sc = CCTOSC(cc);
|
||||||
|
XEvent ev;
|
||||||
|
|
||||||
|
client_raise(cc);
|
||||||
|
|
||||||
|
if (xu_ptr_grab(sc->rootwin, MouseMask, G_cursor_move) < 0)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
xu_ptr_getpos(sc->rootwin, &xm, &ym);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
XMaskEvent(G_dpy, MouseMask, &ev);
|
||||||
|
|
||||||
|
switch (ev.type) {
|
||||||
|
case MotionNotify:
|
||||||
|
cc->geom.x = x0 + (ev.xmotion.x - xm);
|
||||||
|
cc->geom.y = y0 + (ev.xmotion.y - ym);
|
||||||
|
|
||||||
|
XMoveWindow(G_dpy, cc->pwin,
|
||||||
|
cc->geom.x - cc->bwidth, cc->geom.y - cc->bwidth);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ButtonRelease:
|
||||||
|
xu_ptr_ungrab();
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* 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;
|
||||||
|
struct fontdesc *font = DefaultFont;
|
||||||
|
|
||||||
|
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++;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = i;
|
||||||
|
|
||||||
|
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;
|
||||||
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
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
|
||||||
|
|
||||||
|
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;
|
||||||
|
case Expose:
|
||||||
|
XClearWindow(G_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;
|
||||||
|
font_draw(font, mi->text, strlen(mi->text),
|
||||||
|
sc->menuwin, tx, ty);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
if (cur >= 0 && cur < n)
|
||||||
|
XFillRectangle(G_dpy, sc->menuwin,
|
||||||
|
sc->hlgc, 0, cur*high, wide, high);
|
||||||
|
drawn = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
grab_menuinit(struct screen_ctx *sc)
|
||||||
|
{
|
||||||
|
sc->menuwin = XCreateSimpleWindow(G_dpy, sc->rootwin, 0, 0,
|
||||||
|
1, 1, 1, sc->blackpixl, sc->whitepixl);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define LABEL_MAXLEN 256
|
||||||
|
#define LabelMask (KeyPressMask|ExposureMask)
|
||||||
|
|
||||||
|
void
|
||||||
|
grab_label(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = screen_current();
|
||||||
|
int x, y, dx, dy, fontheight, focusrevert;
|
||||||
|
XEvent e;
|
||||||
|
char labelstr[LABEL_MAXLEN];
|
||||||
|
char dispstr[LABEL_MAXLEN + sizeof("label>") - 1];
|
||||||
|
Window focuswin;
|
||||||
|
char chr;
|
||||||
|
enum ctltype ctl;
|
||||||
|
size_t len;
|
||||||
|
struct fontdesc *font = DefaultFont;
|
||||||
|
|
||||||
|
if (cc->label != NULL)
|
||||||
|
strlcpy(labelstr, cc->label, sizeof(labelstr));
|
||||||
|
else
|
||||||
|
labelstr[0] = '\0';
|
||||||
|
|
||||||
|
xu_ptr_getpos(sc->rootwin, &x, &y);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
XGetInputFocus(G_dpy, &focuswin, &focusrevert);
|
||||||
|
XSetInputFocus(G_dpy, sc->searchwin,
|
||||||
|
RevertToPointerRoot, CurrentTime);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
XMaskEvent(G_dpy, LabelMask, &e);
|
||||||
|
|
||||||
|
switch (e.type) {
|
||||||
|
case KeyPress:
|
||||||
|
if (input_keycodetrans(e.xkey.keycode, e.xkey.state,
|
||||||
|
&ctl, &chr, 1) < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch (ctl) {
|
||||||
|
case CTL_ERASEONE:
|
||||||
|
if ((len = strlen(labelstr)) > 0)
|
||||||
|
labelstr[len - 1] = '\0';
|
||||||
|
break;
|
||||||
|
case CTL_RETURN:
|
||||||
|
/* Done */
|
||||||
|
if (strlen(labelstr) == 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (cc->label != NULL)
|
||||||
|
xfree(cc->label);
|
||||||
|
|
||||||
|
cc->label = xstrdup(labelstr);
|
||||||
|
|
||||||
|
case CTL_ABORT:
|
||||||
|
goto out;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chr != '\0') {
|
||||||
|
char str[2];
|
||||||
|
|
||||||
|
str[0] = chr;
|
||||||
|
str[1] = '\0';
|
||||||
|
strlcat(labelstr, str, sizeof(labelstr));
|
||||||
|
}
|
||||||
|
|
||||||
|
case Expose:
|
||||||
|
snprintf(dispstr, sizeof(dispstr), "label>%s", labelstr);
|
||||||
|
dx = font_width(font, dispstr, strlen(dispstr));
|
||||||
|
dy = fontheight;
|
||||||
|
|
||||||
|
XClearWindow(G_dpy, sc->searchwin);
|
||||||
|
XResizeWindow(G_dpy, sc->searchwin, dx, dy);
|
||||||
|
|
||||||
|
font_draw(font, dispstr, strlen(dispstr),
|
||||||
|
sc->searchwin, 0, font_ascent(font) + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
XSetInputFocus(G_dpy, focuswin,
|
||||||
|
focusrevert, CurrentTime);
|
||||||
|
XUnmapWindow(G_dpy, sc->searchwin);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
_sweepcalc(struct client_ctx *cc, int x0, int y0, int motionx, int motiony)
|
||||||
|
{
|
||||||
|
int width, height;
|
||||||
|
|
||||||
|
width = cc->geom.width;
|
||||||
|
height = cc->geom.height;
|
||||||
|
|
||||||
|
cc->geom.width = abs(x0 - motionx);
|
||||||
|
cc->geom.height = abs(y0 - motiony);
|
||||||
|
|
||||||
|
if (cc->size->flags & PResizeInc) {
|
||||||
|
cc->geom.width -=
|
||||||
|
(cc->geom.width - cc->geom.min_dx) % cc->size->width_inc;
|
||||||
|
cc->geom.height -=
|
||||||
|
(cc->geom.height - cc->geom.min_dy) % cc->size->height_inc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cc->size->flags & PMinSize) {
|
||||||
|
cc->geom.width = MAX(cc->geom.width, cc->size->min_width);
|
||||||
|
cc->geom.height = MAX(cc->geom.height, cc->size->min_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cc->size->flags & PMaxSize) {
|
||||||
|
cc->geom.width = MIN(cc->geom.width, cc->size->max_width);
|
||||||
|
cc->geom.height = MIN(cc->geom.height, cc->size->max_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
cc->geom.x = x0 <= motionx ? x0 : x0 - cc->geom.width;
|
||||||
|
cc->geom.y = y0 <= motiony ? y0 : y0 - cc->geom.height;
|
||||||
|
|
||||||
|
return (width != cc->geom.width || height != cc->geom.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
int
|
||||||
|
_nobuttons(XButtonEvent *e) /* Einstuerzende */
|
||||||
|
{
|
||||||
|
int state;
|
||||||
|
|
||||||
|
state = (e->state & AllButtonMask);
|
||||||
|
return (e->type == ButtonRelease) && (state & (state - 1)) == 0;
|
||||||
|
}
|
634
group.c
Normal file
634
group.c
Normal file
@ -0,0 +1,634 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Andy Adamson <dros@monkey.org>
|
||||||
|
* Copyright (c) 2004,2005 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "headers.h"
|
||||||
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
#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;
|
||||||
|
|
||||||
|
#define GroupMask (KeyPressMask|ExposureMask)
|
||||||
|
|
||||||
|
static char *shortcut_to_name[] = {
|
||||||
|
"XXX", "one", "two", "three",
|
||||||
|
"four", "five", "six", "seven",
|
||||||
|
"eight", "nine",
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
_group_add(struct group_ctx *gc, struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
if (cc == NULL || gc == NULL)
|
||||||
|
errx(1, "_group_add: a ctx is NULL");
|
||||||
|
|
||||||
|
if (cc->group == gc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cc->group != NULL)
|
||||||
|
TAILQ_REMOVE(&cc->group->clients, cc, group_entry);
|
||||||
|
|
||||||
|
TAILQ_INSERT_TAIL(&gc->clients, cc, group_entry);
|
||||||
|
cc->group = gc;
|
||||||
|
cc->groupcommit = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_group_remove(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
if (cc == NULL || cc->group == NULL)
|
||||||
|
errx(1, "_group_remove: a ctx is NULL");
|
||||||
|
|
||||||
|
TAILQ_REMOVE(&cc->group->clients, cc, group_entry);
|
||||||
|
cc->group = NULL;
|
||||||
|
cc->groupcommit = 0;
|
||||||
|
cc->highlight = 0;
|
||||||
|
client_draw_border(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_group_commit(struct group_ctx *gc)
|
||||||
|
{
|
||||||
|
struct client_ctx *cc;
|
||||||
|
|
||||||
|
if (gc == NULL)
|
||||||
|
errx(1, "_group_commit: ctx is null");
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cc, &gc->clients, group_entry)
|
||||||
|
cc->groupcommit = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_group_purge(struct group_ctx *gc)
|
||||||
|
{
|
||||||
|
struct client_ctx *cc;
|
||||||
|
|
||||||
|
if (gc == NULL)
|
||||||
|
errx(1, "_group_commit: ctx is null");
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cc, &gc->clients, group_entry)
|
||||||
|
if (cc->groupcommit == 0)
|
||||||
|
_group_remove(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
_group_hide(struct group_ctx *gc)
|
||||||
|
{
|
||||||
|
struct client_ctx *cc;
|
||||||
|
|
||||||
|
screen_updatestackingorder();
|
||||||
|
|
||||||
|
gc->nhidden = 0;
|
||||||
|
gc->highstack = 0;
|
||||||
|
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
|
||||||
|
client_hide(cc);
|
||||||
|
gc->nhidden++;
|
||||||
|
if (cc->stackingorder > gc->highstack)
|
||||||
|
gc->highstack = cc->stackingorder;
|
||||||
|
}
|
||||||
|
gc->hidden = 1; /* XXX: equivalent to gc->nhidden > 0 */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_group_show(struct group_ctx *gc)
|
||||||
|
{
|
||||||
|
struct client_ctx *cc;
|
||||||
|
Window *winlist;
|
||||||
|
u_int i;
|
||||||
|
int lastempty = -1;
|
||||||
|
|
||||||
|
winlist = (Window *) xcalloc(sizeof(*winlist) * (gc->highstack + 1));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Invert the stacking order as XRestackWindows() expects them
|
||||||
|
* top-to-bottom.
|
||||||
|
*/
|
||||||
|
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
|
||||||
|
winlist[gc->highstack - cc->stackingorder] = cc->pwin;
|
||||||
|
client_unhide(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Un-sparseify */
|
||||||
|
for (i = 0; i <= gc->highstack; i++) {
|
||||||
|
if (!winlist[i] && lastempty == -1)
|
||||||
|
lastempty = i;
|
||||||
|
else if (winlist[i] && lastempty != -1) {
|
||||||
|
winlist[lastempty] = winlist[i];
|
||||||
|
if (++lastempty == i)
|
||||||
|
lastempty = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XRestackWindows(G_dpy, winlist, gc->nhidden);
|
||||||
|
xfree(winlist);
|
||||||
|
|
||||||
|
gc->hidden = 0;
|
||||||
|
G_group_active = gc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
_group_destroy(struct group_ctx *gc)
|
||||||
|
{
|
||||||
|
struct client_ctx *cc;
|
||||||
|
|
||||||
|
if (gc->name != NULL) {
|
||||||
|
xfree(gc->name);
|
||||||
|
gc->name = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((cc = TAILQ_FIRST(&gc->clients)) != NULL) {
|
||||||
|
TAILQ_REMOVE(&gc->clients, cc, group_entry);
|
||||||
|
cc->group = NULL;
|
||||||
|
cc->groupcommit = 0;
|
||||||
|
cc->highlight = 0;
|
||||||
|
client_draw_border(cc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
group_init(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
TAILQ_INIT(&G_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
G_group_current = G_group_active = &G_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
|
||||||
|
group_select(int idx)
|
||||||
|
{
|
||||||
|
struct group_ctx *gc = G_group_current;
|
||||||
|
struct client_ctx *cc;
|
||||||
|
|
||||||
|
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
|
||||||
|
cc->highlight = 0;
|
||||||
|
client_draw_border(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
_group_commit(gc);
|
||||||
|
G_group_current = &G_groups[idx];
|
||||||
|
|
||||||
|
group_display_draw(screen_current());
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* enter group mode */
|
||||||
|
void
|
||||||
|
group_enter(void)
|
||||||
|
{
|
||||||
|
if (G_groupmode != 0)
|
||||||
|
errx(1, "group_enter called twice");
|
||||||
|
|
||||||
|
if (G_group_current == NULL)
|
||||||
|
G_group_current = &G_groups[0];
|
||||||
|
|
||||||
|
/* setup input buffer */
|
||||||
|
G_group_name[0] = '\0';
|
||||||
|
|
||||||
|
G_groupmode = 1;
|
||||||
|
|
||||||
|
group_display_init(screen_current());
|
||||||
|
group_display_draw(screen_current());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* exit group mode */
|
||||||
|
void
|
||||||
|
group_exit(int commit)
|
||||||
|
{
|
||||||
|
struct group_ctx *gc = G_group_current;
|
||||||
|
struct client_ctx *cc;
|
||||||
|
|
||||||
|
if (G_groupmode != 1)
|
||||||
|
errx(1, "group_exit called twice");
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
|
||||||
|
cc->highlight = 0;
|
||||||
|
client_draw_border(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commit) {
|
||||||
|
_group_commit(gc);
|
||||||
|
} else {
|
||||||
|
/* abort */
|
||||||
|
_group_purge(gc);
|
||||||
|
if (!TAILQ_EMPTY(&gc->clients))
|
||||||
|
_group_destroy(gc);
|
||||||
|
}
|
||||||
|
|
||||||
|
XUnmapWindow(G_dpy, screen_current()->groupwin);
|
||||||
|
|
||||||
|
if (G_groupnamemode) {
|
||||||
|
XSetInputFocus(G_dpy, G_groupfocuswin, G_groupfocusrevert,
|
||||||
|
CurrentTime);
|
||||||
|
G_groupfocusset = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
G_groupmode = G_groupnamemode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
group_click(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
struct group_ctx *gc = G_group_current;
|
||||||
|
|
||||||
|
if (gc == cc->group)
|
||||||
|
_group_remove(cc);
|
||||||
|
else
|
||||||
|
_group_add(gc, cc);
|
||||||
|
group_display_draw(screen_current());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Used to add a newly mapped window to the active group */
|
||||||
|
|
||||||
|
void
|
||||||
|
group_sticky(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
_group_add(G_group_active, cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
group_sticky_toggle_enter(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
struct group_ctx *gc = G_group_active;
|
||||||
|
|
||||||
|
if (gc == cc->group) {
|
||||||
|
_group_remove(cc);
|
||||||
|
cc->highlight = CLIENT_HIGHLIGHT_RED;
|
||||||
|
} else {
|
||||||
|
_group_add(gc, cc);
|
||||||
|
cc->highlight = CLIENT_HIGHLIGHT_BLUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
client_draw_border(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
group_sticky_toggle_exit(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
cc->highlight = 0;
|
||||||
|
client_draw_border(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* selection list display
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
group_display_init(struct screen_ctx *sc)
|
||||||
|
{
|
||||||
|
sc->groupwin = XCreateSimpleWindow(G_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 client_ctx *cc;
|
||||||
|
char titlebuf[1024];
|
||||||
|
struct fontdesc *font = DefaultFont;
|
||||||
|
|
||||||
|
snprintf(titlebuf, sizeof(titlebuf), "Editing group %d", gc->shortcut);
|
||||||
|
|
||||||
|
x = y = 0;
|
||||||
|
|
||||||
|
fontheight = font_ascent(font) + font_descent(font) + 1;
|
||||||
|
dx = titlelen = font_width(font, titlebuf, strlen(titlebuf));
|
||||||
|
dy = fontheight;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
|
||||||
|
cc->highlight = CLIENT_HIGHLIGHT_BLUE;
|
||||||
|
client_draw_border(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
XMoveResizeWindow(G_dpy, sc->groupwin, x, y, dx, dy);
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
XSelectInput(G_dpy, sc->groupwin, GroupMask);
|
||||||
|
|
||||||
|
XMapRaised(G_dpy, sc->groupwin);
|
||||||
|
XClearWindow(G_dpy, sc->groupwin);
|
||||||
|
font_draw(font, titlebuf, strlen(titlebuf), sc->groupwin,
|
||||||
|
0, font_ascent(font) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
group_display_keypress(KeyCode k)
|
||||||
|
{
|
||||||
|
struct group_ctx * gc = G_group_current;
|
||||||
|
char chr;
|
||||||
|
enum ctltype ctl;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
if (!G_groupnamemode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (input_keycodetrans(k, 0, &ctl, &chr, 1) < 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
switch (ctl) {
|
||||||
|
case CTL_ERASEONE:
|
||||||
|
if ((len = strlen(G_group_name)) > 0)
|
||||||
|
G_group_name[len - 1] = '\0';
|
||||||
|
break;
|
||||||
|
case CTL_RETURN:
|
||||||
|
if (gc->name != NULL)
|
||||||
|
xfree(gc->name);
|
||||||
|
|
||||||
|
gc->name = xstrdup(G_group_name);
|
||||||
|
|
||||||
|
group_exit(1);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chr != '\0')
|
||||||
|
snprintf(G_group_name, sizeof(G_group_name), "%s%c",
|
||||||
|
G_group_name, chr);
|
||||||
|
|
||||||
|
out:
|
||||||
|
group_display_draw(screen_current());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if group_hidetoggle would produce no effect, toggle the group's hidden state
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
_group_fix_hidden_state(struct group_ctx *gc)
|
||||||
|
{
|
||||||
|
struct client_ctx *cc;
|
||||||
|
int same = 0;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cc, &gc->clients, group_entry) {
|
||||||
|
if (gc->hidden == ((cc->flags & CLIENT_HIDDEN) ? 1 : 0))
|
||||||
|
same++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (same == 0)
|
||||||
|
gc->hidden = !gc->hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
group_hidetoggle(int idx)
|
||||||
|
{
|
||||||
|
struct group_ctx *gc;
|
||||||
|
#ifdef notyet
|
||||||
|
char buf[128];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (idx < 0 || idx >= CALMWM_NGROUPS)
|
||||||
|
err(1, "group_hidetoggle: index out of range (%d)", idx);
|
||||||
|
|
||||||
|
gc = &G_groups[idx];
|
||||||
|
|
||||||
|
_group_fix_hidden_state(gc);
|
||||||
|
|
||||||
|
if (gc->hidden)
|
||||||
|
_group_show(gc);
|
||||||
|
else {
|
||||||
|
_group_hide(gc);
|
||||||
|
if (TAILQ_EMPTY(&gc->clients))
|
||||||
|
G_group_active = gc;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef notyet
|
||||||
|
snprintf(buf, sizeof(buf), "Group %d", idx + 1);
|
||||||
|
screen_infomsg(buf);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GROUP_NEXT(gc, fwd) (fwd) ? \
|
||||||
|
TAILQ_NEXT(gc, entry) : TAILQ_PREV(gc, group_ctx_q, entry)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Jump to the next/previous active group. If none exist, then just
|
||||||
|
* stay put.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
group_slide(int fwd)
|
||||||
|
{
|
||||||
|
struct group_ctx *gc, *showgroup = NULL;
|
||||||
|
|
||||||
|
assert(G_group_active != NULL);
|
||||||
|
|
||||||
|
gc = G_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)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!TAILQ_EMPTY(&gc->clients) && showgroup == NULL)
|
||||||
|
showgroup = gc;
|
||||||
|
else if (!gc->hidden)
|
||||||
|
_group_hide(gc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showgroup == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_group_hide(G_group_active);
|
||||||
|
|
||||||
|
if (showgroup->hidden)
|
||||||
|
_group_show(showgroup);
|
||||||
|
else
|
||||||
|
G_group_active = showgroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* called when a client is deleted */
|
||||||
|
void
|
||||||
|
group_client_delete(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
if (cc->group == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TAILQ_REMOVE(&cc->group->clients, cc, group_entry);
|
||||||
|
cc->group = NULL; /* he he */
|
||||||
|
cc->groupcommit = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
group_menu(XButtonEvent *e)
|
||||||
|
{
|
||||||
|
struct menu_q menuq;
|
||||||
|
struct menu *mi;
|
||||||
|
int i;
|
||||||
|
struct group_ctx *gc;
|
||||||
|
|
||||||
|
TAILQ_INIT(&menuq);
|
||||||
|
|
||||||
|
for (i = 0; i < CALMWM_NGROUPS; i++) {
|
||||||
|
gc = &G_groups[i];
|
||||||
|
|
||||||
|
if (TAILQ_EMPTY(&gc->clients))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (gc->name == NULL)
|
||||||
|
gc->name = xstrdup(shortcut_to_name[gc->shortcut]);
|
||||||
|
|
||||||
|
XCALLOC(mi, struct menu);
|
||||||
|
if (gc->hidden)
|
||||||
|
snprintf(mi->text, sizeof(mi->text), "%d: [%s]",
|
||||||
|
gc->shortcut, gc->name);
|
||||||
|
else
|
||||||
|
snprintf(mi->text, sizeof(mi->text), "%d: %s",
|
||||||
|
gc->shortcut, gc->name);
|
||||||
|
mi->ctx = gc;
|
||||||
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TAILQ_EMPTY(&menuq))
|
||||||
|
return;
|
||||||
|
|
||||||
|
mi = (struct menu *)grab_menu(e, &menuq);
|
||||||
|
|
||||||
|
if (mi == NULL || mi->ctx == NULL)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
gc = (struct group_ctx *)mi->ctx;
|
||||||
|
|
||||||
|
if (gc->hidden)
|
||||||
|
_group_show(gc);
|
||||||
|
else
|
||||||
|
_group_hide(gc);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||||
|
TAILQ_REMOVE(&menuq, mi, entry);
|
||||||
|
xfree(mi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
group_namemode(void)
|
||||||
|
{
|
||||||
|
G_groupnamemode = 1;
|
||||||
|
|
||||||
|
group_display_draw(screen_current());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
group_alltoggle(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i < CALMWM_NGROUPS; i++) {
|
||||||
|
if (G_grouphideall)
|
||||||
|
_group_show(&G_groups[i]);
|
||||||
|
else
|
||||||
|
_group_hide(&G_groups[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (G_grouphideall)
|
||||||
|
G_grouphideall = 0;
|
||||||
|
else
|
||||||
|
G_grouphideall = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
group_deletecurrent(void)
|
||||||
|
{
|
||||||
|
_group_destroy(G_group_current);
|
||||||
|
XUnmapWindow(G_dpy, screen_current()->groupwin);
|
||||||
|
|
||||||
|
G_groupmode = G_groupnamemode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
group_done(void)
|
||||||
|
{
|
||||||
|
struct group_ctx *gc = G_group_current;
|
||||||
|
|
||||||
|
if (gc->name != NULL)
|
||||||
|
xfree(gc->name);
|
||||||
|
|
||||||
|
gc->name = xstrdup(shortcut_to_name[gc->shortcut]);
|
||||||
|
|
||||||
|
group_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
group_autogroup(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
struct autogroupwin *aw;
|
||||||
|
struct group_ctx *gc;
|
||||||
|
char group[CALMWM_MAXNAMELEN];
|
||||||
|
|
||||||
|
if (cc->app_class == NULL || cc->app_name == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(aw, &G_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));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TAILQ_FOREACH(gc, &G_groupq, entry) {
|
||||||
|
if (strcmp(shortcut_to_name[gc->shortcut], group) == 0)
|
||||||
|
_group_add(gc, cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
68
hash.h
Normal file
68
hash.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* hash.h - generic hash template, akin to queue.h & tree.h
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _HASH_H_ /* Possibly this is too generic. */
|
||||||
|
#define _HASH_H_
|
||||||
|
|
||||||
|
#include <sys/tree.h>
|
||||||
|
|
||||||
|
#define HASH_ENTRY SPLAY_ENTRY
|
||||||
|
|
||||||
|
#define HASH_HEAD(name, type, nbuckets) \
|
||||||
|
SPLAY_HEAD(name##_HASH_TREE, type); \
|
||||||
|
struct name { \
|
||||||
|
struct name##_HASH_TREE buckets[nbuckets]; \
|
||||||
|
unsigned int (*hashfn)(struct type *elm); \
|
||||||
|
};
|
||||||
|
|
||||||
|
#define HASH_NBUCKETS(head) \
|
||||||
|
(sizeof((head)->buckets)/sizeof((head)->buckets[0]))
|
||||||
|
|
||||||
|
#define HASH_INIT(head, fn) do { \
|
||||||
|
int i; \
|
||||||
|
for (i = 0; i < HASH_NBUCKETS(head); i++) { \
|
||||||
|
SPLAY_INIT(&(head)->buckets[i]); \
|
||||||
|
} \
|
||||||
|
(head)->hashfn = fn; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define HASH_PROTOTYPE(name, type, field, cmp) \
|
||||||
|
SPLAY_PROTOTYPE(name##_HASH_TREE, type, field, cmp) \
|
||||||
|
struct type *name##_HASH_TREE_FIND(struct name *head, struct type *find); \
|
||||||
|
void name##_HASH_TREE_INSERT(struct name *head, struct type *insert);
|
||||||
|
|
||||||
|
#define HASH_GENERATE(name, type, field, cmp) \
|
||||||
|
SPLAY_GENERATE(name##_HASH_TREE, type, field, cmp) \
|
||||||
|
struct type *name##_HASH_TREE_FIND(struct name *head, struct type *find) \
|
||||||
|
{ \
|
||||||
|
struct name##_HASH_TREE *bucket = \
|
||||||
|
&head->buckets[(*head->hashfn)(find) % HASH_NBUCKETS(head)]; \
|
||||||
|
return SPLAY_FIND(name##_HASH_TREE, bucket, find); \
|
||||||
|
} \
|
||||||
|
void name##_HASH_TREE_INSERT(struct name *head, struct type *insert) \
|
||||||
|
{ \
|
||||||
|
struct name##_HASH_TREE *bucket = \
|
||||||
|
&head->buckets[(*head->hashfn)(insert) % HASH_NBUCKETS(head)]; \
|
||||||
|
\
|
||||||
|
SPLAY_INSERT(name##_HASH_TREE, bucket, insert); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define HASH_FIND(name, head, find) name##_HASH_TREE_FIND((head), (find))
|
||||||
|
#define HASH_INSERT(name, head, insert) name##_HASH_TREE_INSERT((head), (insert))
|
||||||
|
|
||||||
|
#endif /* _HASH_H_ */
|
52
headers.h
Normal file
52
headers.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CALMWM_HEADERS_H_
|
||||||
|
#define _CALMWM_HEADERS_H_
|
||||||
|
|
||||||
|
#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>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <X11/cursorfont.h>
|
||||||
|
#include <X11/extensions/shape.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
#include <X11/Xproto.h>
|
||||||
|
#include <X11/Intrinsic.h>
|
||||||
|
#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_ */
|
81
input.c
Normal file
81
input.c
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "headers.h"
|
||||||
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
input_keycodetrans(KeyCode kc, u_int state,
|
||||||
|
enum ctltype *ctl, char *chr, int normalize)
|
||||||
|
{
|
||||||
|
int ks;
|
||||||
|
|
||||||
|
*ctl = CTL_NONE;
|
||||||
|
*chr = '\0';
|
||||||
|
|
||||||
|
ks = XKeycodeToKeysym(G_dpy, kc, 0);
|
||||||
|
|
||||||
|
/* Look for control characters. */
|
||||||
|
switch (ks) {
|
||||||
|
case XK_BackSpace:
|
||||||
|
*ctl = CTL_ERASEONE;
|
||||||
|
break;
|
||||||
|
case XK_Return:
|
||||||
|
*ctl = CTL_RETURN;
|
||||||
|
break;
|
||||||
|
case XK_Up:
|
||||||
|
*ctl = CTL_UP;
|
||||||
|
break;
|
||||||
|
case XK_Down:
|
||||||
|
*ctl = CTL_DOWN;
|
||||||
|
break;
|
||||||
|
case XK_Escape:
|
||||||
|
*ctl = CTL_ABORT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*ctl == CTL_NONE && (state & ControlMask)) {
|
||||||
|
switch (ks) {
|
||||||
|
case XK_s:
|
||||||
|
case XK_S:
|
||||||
|
/* Emacs "next" */
|
||||||
|
*ctl = CTL_DOWN;
|
||||||
|
break;
|
||||||
|
case XK_r:
|
||||||
|
case XK_R:
|
||||||
|
/* Emacs "previous" */
|
||||||
|
*ctl = CTL_UP;
|
||||||
|
break;
|
||||||
|
case XK_u:
|
||||||
|
case XK_U:
|
||||||
|
*ctl = CTL_WIPE;
|
||||||
|
break;
|
||||||
|
case XK_a:
|
||||||
|
case XK_A:
|
||||||
|
*ctl = CTL_ALL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*ctl != CTL_NONE)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For regular characters, only (part of, actually) Latin 1
|
||||||
|
* for now.
|
||||||
|
*/
|
||||||
|
if (ks < 0x20 || ks > 0x07e)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
*chr = (char)ks;
|
||||||
|
if (normalize)
|
||||||
|
*chr = tolower(*chr);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
323
install-sh
Executable file
323
install-sh
Executable file
@ -0,0 +1,323 @@
|
|||||||
|
#!/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:
|
186
kbfunc.c
Normal file
186
kbfunc.c
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Martin Murray <mmurray@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "headers.h"
|
||||||
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_lower(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
client_lower(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_raise(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
client_raise(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_search(struct client_ctx *scratch, void *arg)
|
||||||
|
{
|
||||||
|
struct menu_q menuq;
|
||||||
|
struct client_ctx *cc, *old_cc = client_current();
|
||||||
|
struct menu *mi;
|
||||||
|
|
||||||
|
TAILQ_INIT(&menuq);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(cc, &G_clientq, entry) {
|
||||||
|
struct menu *mi;
|
||||||
|
XCALLOC(mi, struct menu);
|
||||||
|
strlcpy(mi->text, cc->name, sizeof(mi->text));
|
||||||
|
mi->ctx = cc;
|
||||||
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((mi = search_start(&menuq,
|
||||||
|
search_match_client, NULL,
|
||||||
|
search_print_client, "window")) != NULL) {
|
||||||
|
cc = (struct client_ctx *)mi->ctx;
|
||||||
|
if (cc->flags & CLIENT_HIDDEN)
|
||||||
|
client_unhide(cc);
|
||||||
|
|
||||||
|
if (old_cc)
|
||||||
|
client_ptrsave(old_cc);
|
||||||
|
client_ptrwarp(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||||
|
TAILQ_REMOVE(&menuq, mi, entry);
|
||||||
|
xfree(mi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_menu_search(struct client_ctx *scratch, void *arg)
|
||||||
|
{
|
||||||
|
struct menu_q menuq;
|
||||||
|
struct menu *mi;
|
||||||
|
struct cmd *cmd;
|
||||||
|
|
||||||
|
TAILQ_INIT(&menuq);
|
||||||
|
|
||||||
|
conf_cmd_refresh(&G_conf);
|
||||||
|
TAILQ_FOREACH(cmd, &G_conf.cmdq, entry) {
|
||||||
|
XCALLOC(mi, struct menu);
|
||||||
|
strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
||||||
|
mi->ctx = cmd;
|
||||||
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((mi = search_start(&menuq,
|
||||||
|
search_match_text, NULL, NULL, "application")) != NULL)
|
||||||
|
u_spawn(((struct cmd *)mi->ctx)->image);
|
||||||
|
|
||||||
|
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||||
|
TAILQ_REMOVE(&menuq, mi, entry);
|
||||||
|
xfree(mi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_cycle(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
client_cyclenext(cc, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_rcycle(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
client_cyclenext(cc, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_hide(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
client_hide(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_cmdexec(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
u_spawn((char *)arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_term(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
conf_cmd_refresh(&G_conf);
|
||||||
|
u_spawn(G_conf.termpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_lock(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
conf_cmd_refresh(&G_conf);
|
||||||
|
u_spawn(G_conf.lockpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_label(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
grab_label(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_delete(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
client_send_delete(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_groupselect(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
if (G_groupmode)
|
||||||
|
group_done();
|
||||||
|
else
|
||||||
|
group_enter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_group(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
if (G_groupmode)
|
||||||
|
group_select(KBTOGROUP((int)arg));
|
||||||
|
else
|
||||||
|
group_hidetoggle(KBTOGROUP((int)arg));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_nextgroup(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
group_slide(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_prevgroup(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
group_slide(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_nogroup(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
if (G_groupmode)
|
||||||
|
group_deletecurrent();
|
||||||
|
else
|
||||||
|
group_alltoggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_maximize(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
client_maximize(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kbfunc_client_vmaximize(struct client_ctx *cc, void *arg)
|
||||||
|
{
|
||||||
|
client_vertmaximize(cc);
|
||||||
|
}
|
360
missing
Executable file
360
missing
Executable file
@ -0,0 +1,360 @@
|
|||||||
|
#! /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:
|
103
screen.c
Normal file
103
screen.c
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "headers.h"
|
||||||
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
extern struct screen_ctx_q G_screenq;
|
||||||
|
extern struct screen_ctx *G_curscreen;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_clearwindow_cb(int sig)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = screen_current();
|
||||||
|
XUnmapWindow(G_dpy, sc->infowin);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct screen_ctx *
|
||||||
|
screen_fromroot(Window rootwin)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(sc, &G_screenq, entry)
|
||||||
|
if (sc->rootwin == rootwin)
|
||||||
|
return (sc);
|
||||||
|
|
||||||
|
/* XXX FAIL HERE */
|
||||||
|
return (TAILQ_FIRST(&G_screenq));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct screen_ctx *
|
||||||
|
screen_current(void)
|
||||||
|
{
|
||||||
|
return (G_curscreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
screen_updatestackingorder(void)
|
||||||
|
{
|
||||||
|
Window *wins, w0, w1;
|
||||||
|
struct screen_ctx *sc = screen_current();
|
||||||
|
u_int nwins, i, s;
|
||||||
|
struct client_ctx *cc;
|
||||||
|
|
||||||
|
if (!XQueryTree(G_dpy, sc->rootwin, &w0, &w1, &wins, &nwins))
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (s = 0, i = 0; i < nwins; i++) {
|
||||||
|
/* Skip hidden windows */
|
||||||
|
if ((cc = client_find(wins[i])) == NULL ||
|
||||||
|
cc->flags & CLIENT_HIDDEN)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
cc->stackingorder = s++;
|
||||||
|
}
|
||||||
|
|
||||||
|
XFree(wins);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
screen_init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
struct screen_ctx *sc = screen_current();
|
||||||
|
|
||||||
|
sc->cycle_client = NULL;
|
||||||
|
|
||||||
|
sc->infowin = XCreateSimpleWindow(G_dpy, sc->rootwin, 0, 0,
|
||||||
|
1, 1, 1, sc->blackpixl, sc->whitepixl);
|
||||||
|
|
||||||
|
/* XXX - marius. */
|
||||||
|
if (signal(SIGALRM, _clearwindow_cb) == SIG_ERR)
|
||||||
|
err(1, "signal");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
screen_infomsg(char *msg)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = screen_current();
|
||||||
|
char buf[1024];
|
||||||
|
int dy, dx;
|
||||||
|
struct fontdesc *font = DefaultFont;
|
||||||
|
|
||||||
|
XUnmapWindow(G_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);
|
||||||
|
|
||||||
|
font_draw(font, buf, strlen(buf), sc->infowin,
|
||||||
|
0, font_ascent(font) + 1);
|
||||||
|
|
||||||
|
alarm(1);
|
||||||
|
}
|
450
search.c
Normal file
450
search.c
Normal file
@ -0,0 +1,450 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "headers.h"
|
||||||
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
#define SearchMask (KeyPressMask|ExposureMask)
|
||||||
|
|
||||||
|
static int _strsubmatch(char *, char *);
|
||||||
|
|
||||||
|
void
|
||||||
|
search_init(struct screen_ctx *sc)
|
||||||
|
{
|
||||||
|
sc->searchwin = XCreateSimpleWindow(G_dpy, sc->rootwin, 0, 0,
|
||||||
|
1, 1, 1, sc->blackpixl, sc->whitepixl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ranking. each rank type is assigned a weight. multiply this by
|
||||||
|
* the rank given. add them up. simple linear combination.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Input: list of items,
|
||||||
|
* Output: choose one
|
||||||
|
* so, exactly like menus
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct menu *
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = screen_current();
|
||||||
|
int x, y, dx, dy, fontheight,
|
||||||
|
focusrevert, mutated, xmax, ymax, warp, added, beobnoxious = 0;
|
||||||
|
XEvent e;
|
||||||
|
char searchstr[MENU_MAXENTRY + 1];
|
||||||
|
char dispstr[MENU_MAXENTRY*2 + 1];
|
||||||
|
char promptstr[MENU_MAXENTRY + 1];
|
||||||
|
Window focuswin;
|
||||||
|
struct menu *mi = NULL;
|
||||||
|
struct menu_q resultq;
|
||||||
|
char chr;
|
||||||
|
enum ctltype ctl;
|
||||||
|
size_t len;
|
||||||
|
u_int n;
|
||||||
|
static int list = 0;
|
||||||
|
int listing = 0;
|
||||||
|
char endchar = '«';
|
||||||
|
struct fontdesc *font = DefaultFont;
|
||||||
|
|
||||||
|
if (prompt == NULL)
|
||||||
|
prompt = "search";
|
||||||
|
|
||||||
|
TAILQ_INIT(&resultq);
|
||||||
|
|
||||||
|
xmax = DisplayWidth(G_dpy, sc->which);
|
||||||
|
ymax = DisplayHeight(G_dpy, sc->which);
|
||||||
|
|
||||||
|
xu_ptr_getpos(sc->rootwin, &x, &y);
|
||||||
|
|
||||||
|
searchstr[0] = '\0';
|
||||||
|
|
||||||
|
snprintf(promptstr, sizeof(promptstr), "%s »", prompt);
|
||||||
|
dy = fontheight = font_ascent(font) + font_descent(font) + 1;
|
||||||
|
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);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
XGetInputFocus(G_dpy, &focuswin, &focusrevert);
|
||||||
|
XSetInputFocus(G_dpy, sc->searchwin, RevertToPointerRoot, CurrentTime);
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
added = mutated = 0;
|
||||||
|
|
||||||
|
XMaskEvent(G_dpy, SearchMask, &e);
|
||||||
|
|
||||||
|
switch (e.type) {
|
||||||
|
case KeyPress:
|
||||||
|
/*
|
||||||
|
* XXX - C-s & C-r for next and prev.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (input_keycodetrans(e.xkey.keycode, e.xkey.state,
|
||||||
|
&ctl, &chr, 1) < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch (ctl) {
|
||||||
|
case CTL_ERASEONE:
|
||||||
|
if ((len = strlen(searchstr)) > 0) {
|
||||||
|
searchstr[len - 1] = '\0';
|
||||||
|
mutated = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CTL_UP:
|
||||||
|
mi = TAILQ_LAST(&resultq, menu_q);
|
||||||
|
if (mi == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
TAILQ_REMOVE(&resultq, mi, resultentry);
|
||||||
|
TAILQ_INSERT_HEAD(&resultq, mi, resultentry);
|
||||||
|
break;
|
||||||
|
case CTL_DOWN:
|
||||||
|
mi = TAILQ_FIRST(&resultq);
|
||||||
|
if (mi == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
TAILQ_REMOVE(&resultq, mi, resultentry);
|
||||||
|
TAILQ_INSERT_TAIL(&resultq, mi, resultentry);
|
||||||
|
break;
|
||||||
|
case CTL_RETURN:
|
||||||
|
/* This is just picking the match the
|
||||||
|
* cursor is over. */
|
||||||
|
if ((mi = TAILQ_FIRST(&resultq)) != NULL)
|
||||||
|
goto found;
|
||||||
|
else
|
||||||
|
goto out;
|
||||||
|
case CTL_WIPE:
|
||||||
|
searchstr[0] = '\0';
|
||||||
|
mutated = 1;
|
||||||
|
break;
|
||||||
|
case CTL_ALL:
|
||||||
|
list = !list;
|
||||||
|
break;
|
||||||
|
case CTL_ABORT:
|
||||||
|
goto out;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chr != '\0') {
|
||||||
|
char str[2];
|
||||||
|
|
||||||
|
str[0] = chr;
|
||||||
|
str[1] = '\0';
|
||||||
|
mutated = 1;
|
||||||
|
added =
|
||||||
|
strlcat(searchstr, str, sizeof(searchstr));
|
||||||
|
}
|
||||||
|
|
||||||
|
beobnoxious = 0;
|
||||||
|
if (mutated && strlen(searchstr) > 0) {
|
||||||
|
(*match)(menuq, &resultq, searchstr);
|
||||||
|
beobnoxious = TAILQ_EMPTY(&resultq);
|
||||||
|
if (!beobnoxious && rank != NULL)
|
||||||
|
(*rank)(&resultq, searchstr);
|
||||||
|
} else if (mutated)
|
||||||
|
TAILQ_INIT(&resultq);
|
||||||
|
|
||||||
|
|
||||||
|
if (!list && listing && !mutated) {
|
||||||
|
TAILQ_INIT(&resultq);
|
||||||
|
listing = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case Expose:
|
||||||
|
if (list) {
|
||||||
|
if (TAILQ_EMPTY(&resultq) && list) {
|
||||||
|
/* Copy them over and rank them. */
|
||||||
|
TAILQ_FOREACH(mi, menuq, entry)
|
||||||
|
TAILQ_INSERT_TAIL(&resultq, mi,
|
||||||
|
resultentry);
|
||||||
|
if (rank != NULL)
|
||||||
|
(*rank)(&resultq, searchstr);
|
||||||
|
|
||||||
|
listing = 1;
|
||||||
|
} else if (mutated)
|
||||||
|
listing = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(dispstr, sizeof(dispstr), "%s%s%c",
|
||||||
|
promptstr, searchstr, endchar);
|
||||||
|
dx = font_width(font, dispstr, strlen(dispstr));
|
||||||
|
dy = fontheight;
|
||||||
|
|
||||||
|
TAILQ_FOREACH(mi, &resultq, resultentry) {
|
||||||
|
char *text;
|
||||||
|
|
||||||
|
if (print != NULL) {
|
||||||
|
(*print)(mi, listing);
|
||||||
|
text = mi->print;
|
||||||
|
} else {
|
||||||
|
mi->print[0] = '\0';
|
||||||
|
text = mi->text;
|
||||||
|
}
|
||||||
|
|
||||||
|
dx = MAX(dx, font_width(font, text,
|
||||||
|
MIN(strlen(text), MENU_MAXENTRY)));
|
||||||
|
dy += fontheight;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Calculate new geometry.
|
||||||
|
*
|
||||||
|
* XXX - put this into a util function -- it's
|
||||||
|
* used elsewhere, too.
|
||||||
|
*/
|
||||||
|
warp = 0;
|
||||||
|
if (x < 0) {
|
||||||
|
x = 0;
|
||||||
|
warp = 1;
|
||||||
|
}
|
||||||
|
if (x + dx >= xmax) {
|
||||||
|
x = xmax - dx;
|
||||||
|
warp = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y < 0) {
|
||||||
|
y = 0;
|
||||||
|
warp = 1;
|
||||||
|
}
|
||||||
|
if (y + dy >= ymax) {
|
||||||
|
y = ymax - dy;
|
||||||
|
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);
|
||||||
|
|
||||||
|
font_draw(font, dispstr, strlen(dispstr), sc->searchwin,
|
||||||
|
0, font_ascent(font) + 1);
|
||||||
|
|
||||||
|
n = 1;
|
||||||
|
TAILQ_FOREACH(mi, &resultq, resultentry) {
|
||||||
|
char *text = mi->print[0] != '\0' ?
|
||||||
|
mi->print : mi->text;
|
||||||
|
|
||||||
|
font_draw(font, text,
|
||||||
|
MIN(strlen(text), MENU_MAXENTRY),
|
||||||
|
sc->searchwin,
|
||||||
|
0, n*fontheight + font_ascent(font) + 1);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n > 1)
|
||||||
|
XFillRectangle(G_dpy, sc->searchwin, sc->gc,
|
||||||
|
0, fontheight, dx, fontheight);
|
||||||
|
|
||||||
|
if (beobnoxious)
|
||||||
|
XFillRectangle(G_dpy, sc->searchwin, sc->gc,
|
||||||
|
0, 0, dx, fontheight);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
/* (if no match) */
|
||||||
|
xu_ptr_ungrab();
|
||||||
|
XSetInputFocus(G_dpy, focuswin, focusrevert, CurrentTime);
|
||||||
|
found:
|
||||||
|
XUnmapWindow(G_dpy, sc->searchwin);
|
||||||
|
|
||||||
|
return (mi);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Match: label, title, class.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
search_match_client(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||||
|
{
|
||||||
|
struct winname *wn;
|
||||||
|
struct menu *mi, *tierp[4], *before = NULL;
|
||||||
|
int ntiers = sizeof(tierp)/sizeof(tierp[0]);
|
||||||
|
|
||||||
|
TAILQ_INIT(resultq);
|
||||||
|
|
||||||
|
memset(tierp, 0, sizeof(tierp));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In order of rank:
|
||||||
|
*
|
||||||
|
* 1. Look through labels.
|
||||||
|
* 2. Look at title history, from present to past.
|
||||||
|
* 3. Look at window class name.
|
||||||
|
*/
|
||||||
|
|
||||||
|
TAILQ_FOREACH(mi, menuq, entry) {
|
||||||
|
int tier = -1, t;
|
||||||
|
struct client_ctx *cc = mi->ctx;
|
||||||
|
|
||||||
|
/* First, try to match on labels. */
|
||||||
|
if (cc->label != NULL && _strsubmatch(search, cc->label)) {
|
||||||
|
cc->matchname = cc->label;
|
||||||
|
tier = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Then, on window names. */
|
||||||
|
if (tier < 0) {
|
||||||
|
TAILQ_FOREACH_REVERSE(wn, &cc->nameq, winname_q, entry)
|
||||||
|
if (_strsubmatch(search, wn->name)) {
|
||||||
|
cc->matchname = wn->name;
|
||||||
|
tier = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* See if there is a match on the window class
|
||||||
|
* name.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (tier < 0 && _strsubmatch(search, cc->app_class)) {
|
||||||
|
cc->matchname = cc->app_class;
|
||||||
|
tier = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tier < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* De-rank a client one tier if it's the current
|
||||||
|
* window. Furthermore, this is denoted by a "!" when
|
||||||
|
* printing the window name in the search menu.
|
||||||
|
*/
|
||||||
|
if (cc == client_current() && tier < ntiers - 1)
|
||||||
|
tier++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clients that are hidden get ranked one up.
|
||||||
|
*/
|
||||||
|
if (cc->flags & CLIENT_HIDDEN && tier > 0)
|
||||||
|
tier--;
|
||||||
|
|
||||||
|
assert(tier < ntiers);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If you have a tierp, insert after it, and make it
|
||||||
|
* the new tierp. If you don't have a tierp, find the
|
||||||
|
* first nonzero tierp above you, insert after it.
|
||||||
|
* Always make your current tierp the newly inserted
|
||||||
|
* entry.
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (t = tier; t >= 0 && ((before = tierp[t]) == NULL); t--)
|
||||||
|
;
|
||||||
|
|
||||||
|
if (before == NULL)
|
||||||
|
TAILQ_INSERT_HEAD(resultq, mi, resultentry);
|
||||||
|
else
|
||||||
|
TAILQ_INSERT_AFTER(resultq, before, mi, resultentry);
|
||||||
|
|
||||||
|
tierp[tier] = mi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
search_print_client(struct menu *mi, int list)
|
||||||
|
{
|
||||||
|
struct client_ctx *cc = mi->ctx;
|
||||||
|
char flag = ' ';
|
||||||
|
|
||||||
|
if (cc == client_current())
|
||||||
|
flag = '!';
|
||||||
|
else if (cc->flags & CLIENT_HIDDEN)
|
||||||
|
flag = '&';
|
||||||
|
|
||||||
|
if (list)
|
||||||
|
cc->matchname = TAILQ_FIRST(&cc->nameq)->name;
|
||||||
|
|
||||||
|
snprintf(mi->print, sizeof(mi->print), "%c%s", flag, cc->matchname);
|
||||||
|
|
||||||
|
if (!list && cc->matchname != cc->name &&
|
||||||
|
strlen(mi->print) < sizeof(mi->print) - 1) {
|
||||||
|
int diff = sizeof(mi->print) - 1 - strlen(mi->print);
|
||||||
|
const char *marker = "";
|
||||||
|
char buf[MENU_MAXENTRY + 1];
|
||||||
|
|
||||||
|
/* One for the ':' */
|
||||||
|
diff -= 1;
|
||||||
|
|
||||||
|
if (strlen(cc->name) > diff) {
|
||||||
|
marker = "..";
|
||||||
|
diff -= 2;
|
||||||
|
} else {
|
||||||
|
diff = strlen(cc->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
strlcpy(buf, mi->print, sizeof(buf));
|
||||||
|
snprintf(mi->print, sizeof(mi->print),
|
||||||
|
"%s:%.*s%s", buf, diff, cc->name, marker);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
search_match_text(struct menu_q *menuq, struct menu_q *resultq, char *search)
|
||||||
|
{
|
||||||
|
struct menu *mi;
|
||||||
|
|
||||||
|
TAILQ_INIT(resultq);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(mi, menuq, entry)
|
||||||
|
if (_strsubmatch(search, mi->text))
|
||||||
|
TAILQ_INSERT_TAIL(resultq, mi, resultentry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
search_rank_text(struct menu_q *resultq, char *search)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_strsubmatch(char *sub, char *str)
|
||||||
|
{
|
||||||
|
size_t len, sublen;
|
||||||
|
u_int n;
|
||||||
|
|
||||||
|
if (sub == NULL || str == NULL)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
len = strlen(str);
|
||||||
|
sublen = strlen(sub);
|
||||||
|
|
||||||
|
if (sublen > len)
|
||||||
|
return (0);
|
||||||
|
|
||||||
|
for (n = 0; n <= len - sublen; n++)
|
||||||
|
if (strncasecmp(sub, str + n, sublen) == 0)
|
||||||
|
return (1);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
79
strlcat.c
Normal file
79
strlcat.c
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/* $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
Normal file
71
strlcpy.c
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
/* $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
Normal file
95
strsep.c
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/* $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) */
|
72
util.c
Normal file
72
util.c
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "headers.h"
|
||||||
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
#define MAXARGLEN 20
|
||||||
|
|
||||||
|
int
|
||||||
|
u_spawn(char *argstr)
|
||||||
|
{
|
||||||
|
char *args[MAXARGLEN], **ap;
|
||||||
|
char **end = &args[MAXARGLEN - 1];
|
||||||
|
|
||||||
|
switch (fork()) {
|
||||||
|
case 0:
|
||||||
|
ap = args;
|
||||||
|
while (ap < end && (*ap = strsep(&argstr, " \t")) != NULL)
|
||||||
|
ap++;
|
||||||
|
|
||||||
|
*ap = NULL;
|
||||||
|
setsid();
|
||||||
|
execvp(args[0], args);
|
||||||
|
err(1, args[0]);
|
||||||
|
break;
|
||||||
|
case -1:
|
||||||
|
warn("fork");
|
||||||
|
return (-1);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int dirent_exists(char *filename) {
|
||||||
|
struct stat buffer;
|
||||||
|
|
||||||
|
return stat(filename, &buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int dirent_isdir(char *filename) {
|
||||||
|
struct stat buffer;
|
||||||
|
int return_value;
|
||||||
|
|
||||||
|
return_value = stat(filename, &buffer);
|
||||||
|
|
||||||
|
if(return_value == -1)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return S_ISDIR(buffer.st_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
int dirent_islink(char *filename) {
|
||||||
|
struct stat buffer;
|
||||||
|
int return_value;
|
||||||
|
|
||||||
|
return_value = lstat(filename, &buffer);
|
||||||
|
|
||||||
|
if(return_value == -1)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return S_ISLNK(buffer.st_mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
603
xevents.c
Normal file
603
xevents.c
Normal file
@ -0,0 +1,603 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE:
|
||||||
|
* It is the responsibility of the caller to deal with memory
|
||||||
|
* management of the xevent's.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_handle_maprequest(struct xevent *xev, XEvent *ee)
|
||||||
|
{
|
||||||
|
XMapRequestEvent *e = &ee->xmaprequest;
|
||||||
|
struct client_ctx *cc = NULL, *old_cc = client_current();
|
||||||
|
XWindowAttributes xattr;
|
||||||
|
struct screen_ctx *sc;
|
||||||
|
#ifdef notyet
|
||||||
|
int state;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (old_cc != NULL)
|
||||||
|
client_ptrsave(old_cc);
|
||||||
|
|
||||||
|
if ((cc = client_find(e->window)) == NULL) {
|
||||||
|
XGetWindowAttributes(G_dpy, e->window, &xattr);
|
||||||
|
cc = client_new(e->window, screen_fromroot(xattr.root), 1);
|
||||||
|
sc = CCTOSC(cc);
|
||||||
|
} else {
|
||||||
|
cc->beepbeep = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef notyet /* XXX - possibly, we shouldn't map if
|
||||||
|
* the window is withdrawn. */
|
||||||
|
if (xu_getstate(cc, &state) == 0 && state == WithdrawnState)
|
||||||
|
warnx("WITHDRAWNSTATE for %s", cc->name);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
client_ptrwarp(cc);
|
||||||
|
xev_register(xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_handle_unmapnotify(struct xevent *xev, XEvent *ee)
|
||||||
|
{
|
||||||
|
XUnmapEvent *e = &ee->xunmap;
|
||||||
|
struct client_ctx *cc;
|
||||||
|
struct screen_ctx *sc;
|
||||||
|
int wascurrent;
|
||||||
|
|
||||||
|
if ((cc = client_find(e->window)) != NULL) {
|
||||||
|
sc = CCTOSC(cc);
|
||||||
|
wascurrent = cc == client_current();
|
||||||
|
client_delete(cc, e->send_event, 0);
|
||||||
|
|
||||||
|
#ifdef notyet
|
||||||
|
/* XXX disable the ptrwarp until we handle it
|
||||||
|
* better. */
|
||||||
|
if (!client_delete(cc, e->send_event, 0) && wascurrent)
|
||||||
|
;/* client_ptrwarp(new_cc); */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
xev_register(xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_handle_destroynotify(struct xevent *xev, XEvent *ee)
|
||||||
|
{
|
||||||
|
XDestroyWindowEvent *e = &ee->xdestroywindow;
|
||||||
|
struct client_ctx *cc;
|
||||||
|
|
||||||
|
if ((cc = client_find(e->window)) != NULL)
|
||||||
|
client_delete(cc, 1, 1);
|
||||||
|
|
||||||
|
xev_register(xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_handle_configurerequest(struct xevent *xev, XEvent *ee)
|
||||||
|
{
|
||||||
|
XConfigureRequestEvent *e = &ee->xconfigurerequest;
|
||||||
|
struct client_ctx *cc;
|
||||||
|
struct screen_ctx *sc;
|
||||||
|
XWindowChanges wc;
|
||||||
|
|
||||||
|
if ((cc = client_find(e->window)) != NULL) {
|
||||||
|
sc = CCTOSC(cc);
|
||||||
|
|
||||||
|
client_gravitate(cc, 0);
|
||||||
|
if (e->value_mask & CWWidth)
|
||||||
|
cc->geom.width = e->width;
|
||||||
|
if (e->value_mask & CWHeight)
|
||||||
|
cc->geom.height = e->height;
|
||||||
|
if (e->value_mask & CWX)
|
||||||
|
cc->geom.x = e->x;
|
||||||
|
if (e->value_mask & CWY)
|
||||||
|
cc->geom.y = e->y;
|
||||||
|
|
||||||
|
if (cc->geom.x == 0 &&
|
||||||
|
cc->geom.width >= DisplayWidth(G_dpy, sc->which))
|
||||||
|
cc->geom.x -= cc->bwidth;
|
||||||
|
|
||||||
|
if (cc->geom.y == 0 &&
|
||||||
|
cc->geom.height >= DisplayHeight(G_dpy, sc->which))
|
||||||
|
cc->geom.y -= cc->bwidth;
|
||||||
|
|
||||||
|
client_gravitate(cc, 1);
|
||||||
|
|
||||||
|
wc.x = cc->geom.x - cc->bwidth;
|
||||||
|
wc.y = cc->geom.y - cc->bwidth;
|
||||||
|
wc.width = cc->geom.width + cc->bwidth*2;
|
||||||
|
wc.height = cc->geom.height + cc->bwidth*2;
|
||||||
|
wc.border_width = 0;
|
||||||
|
|
||||||
|
/* We need to move the parent window, too. */
|
||||||
|
XConfigureWindow(G_dpy, cc->pwin, e->value_mask, &wc);
|
||||||
|
xev_reconfig(cc);
|
||||||
|
}
|
||||||
|
|
||||||
|
wc.x = cc != NULL ? 0 : e->x;
|
||||||
|
wc.y = cc != NULL ? 0 : e->y;
|
||||||
|
wc.width = e->width;
|
||||||
|
wc.height = e->height;
|
||||||
|
wc.stack_mode = Above;
|
||||||
|
wc.border_width = 0;
|
||||||
|
e->value_mask &= ~CWStackMode;
|
||||||
|
e->value_mask |= CWBorderWidth;
|
||||||
|
|
||||||
|
XConfigureWindow(G_dpy, e->window, e->value_mask, &wc);
|
||||||
|
|
||||||
|
xev_register(xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_handle_propertynotify(struct xevent *xev, XEvent *ee)
|
||||||
|
{
|
||||||
|
XPropertyEvent *e = &ee->xproperty;
|
||||||
|
struct client_ctx *cc;
|
||||||
|
long tmp;
|
||||||
|
|
||||||
|
if ((cc = client_find(e->window)) != NULL) {
|
||||||
|
switch(e->atom) {
|
||||||
|
case XA_WM_NORMAL_HINTS:
|
||||||
|
XGetWMNormalHints(G_dpy, cc->win, cc->size, &tmp);
|
||||||
|
break;
|
||||||
|
case XA_WM_NAME:
|
||||||
|
client_setname(cc);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* do nothing */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xev_register(xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_reconfig(struct client_ctx *cc)
|
||||||
|
{
|
||||||
|
XConfigureEvent ce;
|
||||||
|
|
||||||
|
ce.type = ConfigureNotify;
|
||||||
|
ce.event = cc->win;
|
||||||
|
ce.window = cc->win;
|
||||||
|
ce.x = cc->geom.x;
|
||||||
|
ce.y = cc->geom.y;
|
||||||
|
ce.width = cc->geom.width;
|
||||||
|
ce.height = cc->geom.height;
|
||||||
|
ce.border_width = 0;
|
||||||
|
ce.above = None;
|
||||||
|
ce.override_redirect = 0;
|
||||||
|
|
||||||
|
XSendEvent(G_dpy, cc->win, False, StructureNotifyMask, (XEvent *)&ce);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_handle_enternotify(struct xevent *xev, XEvent *ee)
|
||||||
|
{
|
||||||
|
XCrossingEvent *e = &ee->xcrossing;
|
||||||
|
struct client_ctx *cc;
|
||||||
|
|
||||||
|
if ((cc = client_find(e->window)) == NULL) {
|
||||||
|
/*
|
||||||
|
* XXX - later. messes up unclutter. but may be
|
||||||
|
* needed when we introduce menu windows and such into
|
||||||
|
* the main event loop.
|
||||||
|
*/
|
||||||
|
#ifdef notyet
|
||||||
|
if (e->window != e->root)
|
||||||
|
client_nocurrent();
|
||||||
|
#endif
|
||||||
|
} else
|
||||||
|
client_setactive(cc, 1);
|
||||||
|
|
||||||
|
xev_register(xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_handle_leavenotify(struct xevent *xev, XEvent *ee)
|
||||||
|
{
|
||||||
|
client_leave(NULL);
|
||||||
|
|
||||||
|
xev_register(xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We can split this into two event handlers. */
|
||||||
|
void
|
||||||
|
xev_handle_buttonpress(struct xevent *xev, XEvent *ee)
|
||||||
|
{
|
||||||
|
XButtonEvent *e = &ee->xbutton;
|
||||||
|
struct client_ctx *cc, *old_cc = client_current();
|
||||||
|
struct screen_ctx *sc = screen_fromroot(e->root);
|
||||||
|
char *wname;
|
||||||
|
int altcontrol = e->state == (ControlMask|Mod1Mask);
|
||||||
|
|
||||||
|
cc = client_find(e->window);
|
||||||
|
|
||||||
|
if (sc->rootwin == e->window && !altcontrol) {
|
||||||
|
struct menu_q menuq;
|
||||||
|
struct menu *mi;
|
||||||
|
|
||||||
|
/* XXXSIGH!!!! */
|
||||||
|
if (e->button == Button2) {
|
||||||
|
group_menu(e);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
TAILQ_INIT(&menuq);
|
||||||
|
|
||||||
|
switch (e->button) {
|
||||||
|
case Button1:
|
||||||
|
TAILQ_FOREACH(cc, &G_clientq, entry) {
|
||||||
|
if (cc->flags & CLIENT_HIDDEN) {
|
||||||
|
if (cc->label != NULL)
|
||||||
|
wname = cc->label;
|
||||||
|
else
|
||||||
|
wname = cc->name;
|
||||||
|
|
||||||
|
if (wname == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
XCALLOC(mi, struct menu);
|
||||||
|
strlcpy(mi->text,
|
||||||
|
wname, sizeof(mi->text));
|
||||||
|
mi->ctx = cc;
|
||||||
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
TAILQ_FOREACH(cmd, &G_conf.cmdq, entry) {
|
||||||
|
XCALLOC(mi, struct menu);
|
||||||
|
strlcpy(mi->text, cmd->label, sizeof(mi->text));
|
||||||
|
mi->ctx = cmd;
|
||||||
|
TAILQ_INSERT_TAIL(&menuq, mi, entry);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TAILQ_EMPTY(&menuq))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
mi = (struct menu *)grab_menu(e, &menuq);
|
||||||
|
if (mi == NULL)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
switch (e->button) {
|
||||||
|
case Button1:
|
||||||
|
cc = (struct client_ctx *)mi->ctx;
|
||||||
|
client_unhide(cc);
|
||||||
|
|
||||||
|
if (old_cc != NULL)
|
||||||
|
client_ptrsave(old_cc);
|
||||||
|
client_ptrwarp(cc);
|
||||||
|
break;
|
||||||
|
case Button3:
|
||||||
|
u_spawn(((struct cmd *)mi->ctx)->image);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||||
|
TAILQ_REMOVE(&menuq, mi, entry);
|
||||||
|
xfree(mi);
|
||||||
|
}
|
||||||
|
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cc == NULL || e->state == 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
sc = CCTOSC(cc);
|
||||||
|
|
||||||
|
switch (e->button) {
|
||||||
|
case Button1:
|
||||||
|
if (altcontrol && !G_groupmode)
|
||||||
|
group_sticky_toggle_enter(cc);
|
||||||
|
else {
|
||||||
|
grab_drag(cc);
|
||||||
|
client_move(cc);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Button2:
|
||||||
|
/* XXXSIGH!!! */
|
||||||
|
if (G_groupmode)
|
||||||
|
group_click(cc);
|
||||||
|
else {
|
||||||
|
grab_sweep(cc);
|
||||||
|
client_resize(cc);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Button3:
|
||||||
|
client_ptrsave(cc);
|
||||||
|
client_lower(cc);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
out:
|
||||||
|
xev_register(xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_handle_buttonrelease(struct xevent *xev, XEvent *ee)
|
||||||
|
{
|
||||||
|
struct client_ctx *cc = client_current();
|
||||||
|
|
||||||
|
if (cc != NULL && !G_groupmode)
|
||||||
|
group_sticky_toggle_exit(cc);
|
||||||
|
|
||||||
|
xev_register(xev);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_handle_keypress(struct xevent *xev, XEvent *ee)
|
||||||
|
{
|
||||||
|
XKeyEvent *e = &ee->xkey;
|
||||||
|
struct client_ctx *cc = NULL; /* Make gcc happy. */
|
||||||
|
struct keybinding *kb;
|
||||||
|
KeySym keysym, skeysym;
|
||||||
|
int modshift;
|
||||||
|
|
||||||
|
keysym = XKeycodeToKeysym(G_dpy, e->keycode, 0);
|
||||||
|
skeysym = XKeycodeToKeysym(G_dpy, e->keycode, 1);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(kb, &G_conf.keybindingq, entry) {
|
||||||
|
if (keysym != kb->keysym && skeysym == kb->keysym)
|
||||||
|
modshift = ShiftMask;
|
||||||
|
else
|
||||||
|
modshift = 0;
|
||||||
|
|
||||||
|
if ((kb->modmask | modshift) != e->state)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((kb->keycode != 0 && kb->keysym == NoSymbol &&
|
||||||
|
kb->keycode == e->keycode) || kb->keysym ==
|
||||||
|
(modshift == 0 ? keysym : skeysym))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kb == NULL && e->window == screen_current()->groupwin)
|
||||||
|
group_display_keypress(e->keycode);
|
||||||
|
|
||||||
|
if (kb == NULL)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if ((kb->flags & (KBFLAG_NEEDCLIENT|KBFLAG_FINDCLIENT)) &&
|
||||||
|
(cc = client_find(e->window)) == NULL &&
|
||||||
|
(cc = client_current()) == NULL)
|
||||||
|
if (kb->flags & KBFLAG_NEEDCLIENT)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
(*kb->callback)(cc, kb->argument);
|
||||||
|
|
||||||
|
out:
|
||||||
|
xev_register(xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is only used for the alt supression detection.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xev_handle_keyrelease(struct xevent *xev, XEvent *ee)
|
||||||
|
{
|
||||||
|
XKeyEvent *e = &ee->xkey;
|
||||||
|
struct screen_ctx *sc = screen_fromroot(e->root);
|
||||||
|
int keysym;
|
||||||
|
|
||||||
|
keysym = XKeycodeToKeysym(G_dpy, e->keycode, 0);
|
||||||
|
if (keysym != XK_Alt_L && keysym != XK_Alt_R)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
sc->altpersist = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX - better interface... xevents should not know about
|
||||||
|
* how/when to mtf.
|
||||||
|
*/
|
||||||
|
client_mtf(NULL);
|
||||||
|
client_altrelease();
|
||||||
|
|
||||||
|
out:
|
||||||
|
xev_register(xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (cc == NULL)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (e->message_type == xa_wm_change_state && e->format == 32 &&
|
||||||
|
e->data.l[0] == IconicState)
|
||||||
|
client_hide(cc);
|
||||||
|
out:
|
||||||
|
xev_register(xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* X Event handling
|
||||||
|
*/
|
||||||
|
|
||||||
|
static struct xevent_q _xevq, _xevq_putaway;
|
||||||
|
static short _xev_q_lock = 0;
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_init(void)
|
||||||
|
{
|
||||||
|
TAILQ_INIT(&_xevq);
|
||||||
|
TAILQ_INIT(&_xevq_putaway);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct xevent *
|
||||||
|
xev_new(Window *win, Window *root,
|
||||||
|
int type, void (*cb)(struct xevent *, XEvent *), void *arg)
|
||||||
|
{
|
||||||
|
struct xevent *xev;
|
||||||
|
|
||||||
|
XMALLOC(xev, struct xevent);
|
||||||
|
xev->xev_win = win;
|
||||||
|
xev->xev_root = root;
|
||||||
|
xev->xev_type = type;
|
||||||
|
xev->xev_cb = cb;
|
||||||
|
xev->xev_arg = arg;
|
||||||
|
|
||||||
|
return (xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_register(struct xevent *xev)
|
||||||
|
{
|
||||||
|
struct xevent_q *xq;
|
||||||
|
|
||||||
|
xq = _xev_q_lock ? &_xevq_putaway : &_xevq;
|
||||||
|
TAILQ_INSERT_TAIL(xq, xev, entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_xev_reincorporate(void)
|
||||||
|
{
|
||||||
|
struct xevent *xev;
|
||||||
|
|
||||||
|
while ((xev = TAILQ_FIRST(&_xevq_putaway)) != NULL) {
|
||||||
|
TAILQ_REMOVE(&_xevq_putaway, xev, entry);
|
||||||
|
TAILQ_INSERT_TAIL(&_xevq, xev, entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_handle_expose(struct xevent *xev, XEvent *ee)
|
||||||
|
{
|
||||||
|
XExposeEvent *e = &ee->xexpose;
|
||||||
|
struct screen_ctx *sc = screen_current();
|
||||||
|
struct client_ctx *cc;
|
||||||
|
|
||||||
|
if ((cc = client_find(e->window)) != NULL)
|
||||||
|
client_draw_border(cc);
|
||||||
|
|
||||||
|
if (sc->groupwin == e->window)
|
||||||
|
group_display_draw(sc);
|
||||||
|
|
||||||
|
xev_register(xev);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ASSIGN(xtype) do { \
|
||||||
|
root = e. xtype .root; \
|
||||||
|
win = e. xtype .window; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define ASSIGN1(xtype) do { \
|
||||||
|
win = e. xtype .window; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
void
|
||||||
|
xev_loop(void)
|
||||||
|
{
|
||||||
|
Window win, root;
|
||||||
|
int type;
|
||||||
|
XEvent e;
|
||||||
|
struct xevent *xev, *nextxev;
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
#ifdef DIAGNOSTIC
|
||||||
|
if (TAILQ_EMPTY(&_xevq))
|
||||||
|
errx(1, "X event queue empty");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
XNextEvent(G_dpy, &e);
|
||||||
|
type = e.type;
|
||||||
|
|
||||||
|
win = root = 0;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case MapRequest:
|
||||||
|
ASSIGN1(xmaprequest);
|
||||||
|
break;
|
||||||
|
case UnmapNotify:
|
||||||
|
ASSIGN1(xunmap);
|
||||||
|
break;
|
||||||
|
case ConfigureRequest:
|
||||||
|
ASSIGN1(xconfigurerequest);
|
||||||
|
break;
|
||||||
|
case PropertyNotify:
|
||||||
|
ASSIGN1(xproperty);
|
||||||
|
break;
|
||||||
|
case EnterNotify:
|
||||||
|
case LeaveNotify:
|
||||||
|
ASSIGN(xcrossing);
|
||||||
|
break;
|
||||||
|
case ButtonPress:
|
||||||
|
ASSIGN(xbutton);
|
||||||
|
break;
|
||||||
|
case ButtonRelease:
|
||||||
|
ASSIGN(xbutton);
|
||||||
|
break;
|
||||||
|
case KeyPress:
|
||||||
|
case KeyRelease:
|
||||||
|
ASSIGN(xkey);
|
||||||
|
break;
|
||||||
|
case DestroyNotify:
|
||||||
|
ASSIGN1(xdestroywindow);
|
||||||
|
break;
|
||||||
|
case ClientMessage:
|
||||||
|
ASSIGN1(xclient);
|
||||||
|
break;
|
||||||
|
default: /* XXX - still need shape event support. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now, search for matches, and call each of them.
|
||||||
|
*/
|
||||||
|
_xev_q_lock = 1;
|
||||||
|
for (xev = TAILQ_FIRST(&_xevq); xev != NULL; xev = nextxev) {
|
||||||
|
nextxev = TAILQ_NEXT(xev, entry);
|
||||||
|
|
||||||
|
if ((type != xev->xev_type && xev->xev_type != 0) ||
|
||||||
|
(xev->xev_win != NULL && win != *xev->xev_win) ||
|
||||||
|
(xev->xev_root != NULL && root != *xev->xev_root))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
TAILQ_REMOVE(&_xevq, xev, entry);
|
||||||
|
|
||||||
|
(*xev->xev_cb)(xev, &e);
|
||||||
|
}
|
||||||
|
_xev_q_lock = 0;
|
||||||
|
_xev_reincorporate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef ASSIGN
|
||||||
|
#undef ASSIGN1
|
50
xmalloc.c
Normal file
50
xmalloc.c
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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 *
|
||||||
|
xmalloc(size_t siz)
|
||||||
|
{
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
if ((p = malloc(siz)) == NULL)
|
||||||
|
err(1, "malloc");
|
||||||
|
|
||||||
|
return (p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
xcalloc(size_t siz)
|
||||||
|
{
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
if ((p = calloc(1, siz)) == NULL)
|
||||||
|
err(1, "calloc");
|
||||||
|
|
||||||
|
return (p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xfree(void *p)
|
||||||
|
{
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
xstrdup(const char *str)
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if ((p = strdup(str)) == NULL)
|
||||||
|
err(1, "strdup");
|
||||||
|
|
||||||
|
return (p);
|
||||||
|
}
|
162
xutil.c
Normal file
162
xutil.c
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* calmwm - the calm window manager
|
||||||
|
*
|
||||||
|
* Copyright (c) 2004 Marius Aamodt Eriksen <marius@monkey.org>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "headers.h"
|
||||||
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
xu_ptr_grab(Window win, int mask, Cursor curs)
|
||||||
|
{
|
||||||
|
return (XGrabPointer(G_dpy, win, False, mask,
|
||||||
|
GrabModeAsync, GrabModeAsync,
|
||||||
|
None, curs, CurrentTime) == GrabSuccess ? 0 : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
xu_ptr_regrab(int mask, Cursor curs)
|
||||||
|
{
|
||||||
|
return (XChangeActivePointerGrab(G_dpy, mask,
|
||||||
|
curs, CurrentTime) == GrabSuccess ? 0 : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xu_ptr_ungrab(void)
|
||||||
|
{
|
||||||
|
XUngrabPointer(G_dpy, CurrentTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
xu_btn_grab(Window win, int mask, u_int btn)
|
||||||
|
{
|
||||||
|
return (XGrabButton(G_dpy, btn, mask, win,
|
||||||
|
False, ButtonMask, GrabModeAsync,
|
||||||
|
GrabModeSync, None, None) == GrabSuccess ? 0 : -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xu_btn_ungrab(Window win, int mask, u_int btn)
|
||||||
|
{
|
||||||
|
XUngrabButton(G_dpy, btn, mask, win);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xu_ptr_getpos(Window rootwin, int *x, int *y)
|
||||||
|
{
|
||||||
|
int tmp0, tmp1;
|
||||||
|
u_int tmp2;
|
||||||
|
Window w0, w1;
|
||||||
|
|
||||||
|
XQueryPointer(G_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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
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))
|
||||||
|
mask |= ShiftMask;
|
||||||
|
|
||||||
|
XGrabKey(G_dpy, XKeysymToKeycode(G_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
|
||||||
|
xu_sendmsg(struct client_ctx *cc, Atom atm, long val)
|
||||||
|
{
|
||||||
|
XEvent e;
|
||||||
|
|
||||||
|
memset(&e, 0, sizeof(e));
|
||||||
|
e.xclient.type = ClientMessage;
|
||||||
|
e.xclient.window = cc->win;
|
||||||
|
e.xclient.message_type = atm;
|
||||||
|
e.xclient.format = 32;
|
||||||
|
e.xclient.data.l[0] = val;
|
||||||
|
e.xclient.data.l[1] = CurrentTime;
|
||||||
|
|
||||||
|
XSendEvent(G_dpy, cc->win, False, 0, &e);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
xu_getprop(struct client_ctx *cc, Atom atm, Atom type, long len, u_char **p)
|
||||||
|
{
|
||||||
|
Atom realtype;
|
||||||
|
u_long n, extra;
|
||||||
|
int format;
|
||||||
|
|
||||||
|
if (XGetWindowProperty(G_dpy, cc->win, atm, 0L, len, False, type,
|
||||||
|
&realtype, &format, &n, &extra, p) != Success || *p == NULL)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
if (n == 0)
|
||||||
|
XFree(*p);
|
||||||
|
|
||||||
|
return (n);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
xu_getstate(struct client_ctx *cc, int *state)
|
||||||
|
{
|
||||||
|
Atom wm_state = XInternAtom(G_dpy, "WM_STATE", False);
|
||||||
|
long *p = NULL;
|
||||||
|
|
||||||
|
if (xu_getprop(cc, wm_state, wm_state, 2L, (u_char **)&p) <= 0)
|
||||||
|
return (-1);
|
||||||
|
|
||||||
|
*state = (int)*p;
|
||||||
|
XFree((char *)p);
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
long dat[2];
|
||||||
|
Atom wm_state;
|
||||||
|
|
||||||
|
/* XXX cache */
|
||||||
|
wm_state = XInternAtom(G_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,
|
||||||
|
PropModeReplace, (unsigned char *)dat, 2);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user