summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2021-08-29 18:23:59 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2021-08-29 18:23:59 +0000
commitdd8941239e7e7f6312d2804a556ae31a5d0a5695 (patch)
tree4b4dc42f57a3a700d772cf473ad13e3022e443f9
parentb72eaa12e584775cc214ee6630f9dc2cf73fdef1 (diff)
Update to xwd 1.0.8
-rw-r--r--app/xwd/ChangeLog81
-rw-r--r--app/xwd/Makefile.am2
-rw-r--r--app/xwd/Makefile.in4
-rw-r--r--app/xwd/README25
-rw-r--r--app/xwd/README.md18
-rw-r--r--app/xwd/aclocal.m4224
-rw-r--r--app/xwd/clientwin.c2
-rw-r--r--app/xwd/compile17
-rw-r--r--app/xwd/configure52
-rw-r--r--app/xwd/configure.ac4
-rw-r--r--app/xwd/dsimple.c330
-rw-r--r--app/xwd/dsimple.h13
-rw-r--r--app/xwd/list.c110
-rw-r--r--app/xwd/list.h52
-rw-r--r--app/xwd/man/Makefile.in1
-rw-r--r--app/xwd/man/xwd.man14
-rw-r--r--app/xwd/multiVis.c1423
-rw-r--r--app/xwd/multiVis.h29
-rw-r--r--app/xwd/xwd.c516
19 files changed, 1547 insertions, 1370 deletions
diff --git a/app/xwd/ChangeLog b/app/xwd/ChangeLog
index c25c47aaf..06a70b119 100644
--- a/app/xwd/ChangeLog
+++ b/app/xwd/ChangeLog
@@ -1,3 +1,80 @@
+commit 57586247e0c6bce744c04f072185762e76879baf
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sun Aug 1 17:14:35 2021 -0700
+
+ xwd 1.0.8
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit ae07bdd696b8e6ba8af4dbeb96c96e378166eede
+Author: Jim Rees <rees@umich.edu>
+Date: Mon Jun 22 19:19:30 2020 -0500
+
+ Zero out uninitialized memory so as not to write stack garbage to dump file
+
+ Also check return from XFetchName()
+
+ Signed-off-by: Jim Rees <rees@umich.edu>
+
+commit aeabe09fdf0750933fdbd970780bd50c8dfda5fd
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Mon Sep 23 10:35:10 2019 -0700
+
+ Elide empty else
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 68dc9400f0047b10eebd77d60353fb96ccf4914d
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Mon Sep 23 10:28:07 2019 -0700
+
+ Adopt standard X.Org coding style
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 8026ace54250eba699ad9979586e78d27a7745dc
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Mon Sep 23 08:25:19 2019 -0700
+
+ QueryColorMap() function in multiVis.c may retrieve incorrect colours (#3)
+
+ Fixes: https://gitlab.freedesktop.org/xorg/app/xwd/issues/3
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 9fe45abd6589dcc501e415926d8aaa3568fb1933
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Sat Mar 9 21:46:46 2019 -0800
+
+ Combine options info into a single string in usage()
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit bab5bb9bbcb7e7424ec3276f6d74ca1a7dfa863f
+Author: Stéphane Aulery <lkppo@free.fr>
+Date: Sun Jul 7 03:03:59 2013 +0200
+
+ Ensure consistency between the manpage and the output of the -help option
+
+ Signed-off-by: Stéphane Aulery <lkppo@free.fr>
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit fff6825528bc85d20337e4abe284c84d814c5bcd
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Wed Nov 21 17:21:32 2018 -0800
+
+ Update configure.ac bug URL for gitlab migration
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 5879dad42baf52ddb55dd0405cdb115e41cde0a2
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date: Fri Nov 16 23:31:44 2018 -0800
+
+ Update README for gitlab migration
+
+ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
commit e325d626acca54aa2b845aa0c0fb328659bd1b80
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Fri Mar 9 20:37:36 2018 -0800
@@ -216,7 +293,7 @@ Date: Tue Dec 13 15:53:02 2011 -0800
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
commit 7d88d8ab44b17247753f7225a1d8133d55d8423e
-Author: Pär Lidberg <par.lidberg@elekta.com>
+Author: Pär Lidberg <par.lidberg@elekta.com>
Date: Mon Oct 3 00:24:06 2011 -0700
Fix LP64 bug
@@ -624,7 +701,7 @@ Date: Wed Jul 20 19:32:05 2005 +0000
configure cache, you cache it, and the cached value is probably wrong.
commit 504daf4567c93ac5ec425ab122cd88f29089ea7d
-Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
+Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
Date: Fri Jul 8 20:59:16 2005 +0000
Add build system for xwd
diff --git a/app/xwd/Makefile.am b/app/xwd/Makefile.am
index 03bead7bd..8364ee791 100644
--- a/app/xwd/Makefile.am
+++ b/app/xwd/Makefile.am
@@ -48,3 +48,5 @@ ChangeLog:
$(CHANGELOG_CMD)
dist-hook: ChangeLog INSTALL
+
+EXTRA_DIST = README.md
diff --git a/app/xwd/Makefile.in b/app/xwd/Makefile.in
index cf04e56ca..79d5654cf 100644
--- a/app/xwd/Makefile.in
+++ b/app/xwd/Makefile.in
@@ -73,7 +73,7 @@ build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = xwd$(EXEEXT)
subdir = .
-DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
+DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/configure COPYING ChangeLog INSTALL compile \
config.guess config.sub depcomp install-sh missing \
@@ -301,6 +301,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -325,6 +326,7 @@ xwd_SOURCES = \
xwd.c
MAINTAINERCLEANFILES = ChangeLog INSTALL
+EXTRA_DIST = README.md
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
diff --git a/app/xwd/README b/app/xwd/README
deleted file mode 100644
index fd85d649f..000000000
--- a/app/xwd/README
+++ /dev/null
@@ -1,25 +0,0 @@
-xwd - dump an image of an X window
-
-All questions regarding this software should be directed at the
-Xorg mailing list:
-
- http://lists.freedesktop.org/mailman/listinfo/xorg
-
-Please submit bug reports to the Xorg bugzilla:
-
- https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
-
-The master development code repository can be found at:
-
- git://anongit.freedesktop.org/git/xorg/app/xwd
-
- http://cgit.freedesktop.org/xorg/app/xwd
-
-For patch submission instructions, see:
-
- http://www.x.org/wiki/Development/Documentation/SubmittingPatches
-
-For more information on the git code manager, see:
-
- http://wiki.x.org/wiki/GitPage
-
diff --git a/app/xwd/README.md b/app/xwd/README.md
new file mode 100644
index 000000000..1996b2e16
--- /dev/null
+++ b/app/xwd/README.md
@@ -0,0 +1,18 @@
+xwd - dump an image of an X window
+----------------------------------
+
+All questions regarding this software should be directed at the
+Xorg mailing list:
+
+ https://lists.x.org/mailman/listinfo/xorg
+
+The master development code repository can be found at:
+
+ https://gitlab.freedesktop.org/xorg/app/xwd
+
+Please submit bug reports and requests to merge patches there.
+
+For patch submission instructions, see:
+
+ https://www.x.org/wiki/Development/Documentation/SubmittingPatches
+
diff --git a/app/xwd/aclocal.m4 b/app/xwd/aclocal.m4
index 8bef9a948..d0a818e1e 100644
--- a/app/xwd/aclocal.m4
+++ b/app/xwd/aclocal.m4
@@ -19,32 +19,63 @@ You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
-# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
-# serial 1 (pkg-config-0.24)
-#
-# Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
-#
-# 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 of the License, 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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.
-
-# PKG_PROG_PKG_CONFIG([MIN-VERSION])
-# ----------------------------------
+# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
+# serial 12 (pkg-config-0.29.2)
+
+dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
+dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 2 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful, but
+dnl WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+dnl 02111-1307, USA.
+dnl
+dnl As a special exception to the GNU General Public License, if you
+dnl distribute this file as part of a program that contains a
+dnl configuration script generated by Autoconf, you may include it under
+dnl the same distribution terms that you use for the rest of that
+dnl program.
+
+dnl PKG_PREREQ(MIN-VERSION)
+dnl -----------------------
+dnl Since: 0.29
+dnl
+dnl Verify that the version of the pkg-config macros are at least
+dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's
+dnl installed version of pkg-config, this checks the developer's version
+dnl of pkg.m4 when generating configure.
+dnl
+dnl To ensure that this macro is defined, also add:
+dnl m4_ifndef([PKG_PREREQ],
+dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])])
+dnl
+dnl See the "Since" comment for each macro you use to see what version
+dnl of the macros you require.
+m4_defun([PKG_PREREQ],
+[m4_define([PKG_MACROS_VERSION], [0.29.2])
+m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
+ [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
+])dnl PKG_PREREQ
+
+dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
+dnl ----------------------------------
+dnl Since: 0.16
+dnl
+dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
+dnl first found in the path. Checks that the version of pkg-config found
+dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
+dnl used since that's the first version where most current features of
+dnl pkg-config existed.
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
@@ -66,18 +97,19 @@ if test -n "$PKG_CONFIG"; then
PKG_CONFIG=""
fi
fi[]dnl
-])# PKG_PROG_PKG_CONFIG
+])dnl PKG_PROG_PKG_CONFIG
-# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
-#
-# Check to see whether a particular set of modules exists. Similar
-# to PKG_CHECK_MODULES(), but does not set variables or print errors.
-#
-# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
-# only at the first occurence in configure.ac, so if the first place
-# it's called might be skipped (such as if it is within an "if", you
-# have to call PKG_CHECK_EXISTS manually
-# --------------------------------------------------------------
+dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------------------------------
+dnl Since: 0.18
+dnl
+dnl Check to see whether a particular set of modules exists. Similar to
+dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
+dnl
+dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+dnl only at the first occurence in configure.ac, so if the first place
+dnl it's called might be skipped (such as if it is within an "if", you
+dnl have to call PKG_CHECK_EXISTS manually
AC_DEFUN([PKG_CHECK_EXISTS],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
if test -n "$PKG_CONFIG" && \
@@ -87,8 +119,10 @@ m4_ifvaln([$3], [else
$3])dnl
fi])
-# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
-# ---------------------------------------------
+dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+dnl ---------------------------------------------
+dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting
+dnl pkg_failed based on the result.
m4_define([_PKG_CONFIG],
[if test -n "$$1"; then
pkg_cv_[]$1="$$1"
@@ -100,10 +134,11 @@ m4_define([_PKG_CONFIG],
else
pkg_failed=untried
fi[]dnl
-])# _PKG_CONFIG
+])dnl _PKG_CONFIG
-# _PKG_SHORT_ERRORS_SUPPORTED
-# -----------------------------
+dnl _PKG_SHORT_ERRORS_SUPPORTED
+dnl ---------------------------
+dnl Internal check to see if pkg-config supports short errors.
AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -111,26 +146,24 @@ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
else
_pkg_short_errors_supported=no
fi[]dnl
-])# _PKG_SHORT_ERRORS_SUPPORTED
+])dnl _PKG_SHORT_ERRORS_SUPPORTED
-# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
-# [ACTION-IF-NOT-FOUND])
-#
-#
-# Note that if there is a possibility the first call to
-# PKG_CHECK_MODULES might not happen, you should be sure to include an
-# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
-#
-#
-# --------------------------------------------------------------
+dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl [ACTION-IF-NOT-FOUND])
+dnl --------------------------------------------------------------
+dnl Since: 0.4.0
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES might not happen, you should be sure to include an
+dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
AC_DEFUN([PKG_CHECK_MODULES],
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
-AC_MSG_CHECKING([for $1])
+AC_MSG_CHECKING([for $2])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
@@ -140,11 +173,11 @@ and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
- AC_MSG_RESULT([no])
+ AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
- else
+ else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
@@ -161,7 +194,7 @@ installed software in a non-standard prefix.
_PKG_TEXT])[]dnl
])
elif test $pkg_failed = untried; then
- AC_MSG_RESULT([no])
+ AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
@@ -177,16 +210,40 @@ else
AC_MSG_RESULT([yes])
$3
fi[]dnl
-])# PKG_CHECK_MODULES
+])dnl PKG_CHECK_MODULES
+
+
+dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+dnl [ACTION-IF-NOT-FOUND])
+dnl ---------------------------------------------------------------------
+dnl Since: 0.29
+dnl
+dnl Checks for existence of MODULES and gathers its build flags with
+dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags
+dnl and VARIABLE-PREFIX_LIBS from --libs.
+dnl
+dnl Note that if there is a possibility the first call to
+dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to
+dnl include an explicit call to PKG_PROG_PKG_CONFIG in your
+dnl configure.ac.
+AC_DEFUN([PKG_CHECK_MODULES_STATIC],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+_save_PKG_CONFIG=$PKG_CONFIG
+PKG_CONFIG="$PKG_CONFIG --static"
+PKG_CHECK_MODULES($@)
+PKG_CONFIG=$_save_PKG_CONFIG[]dnl
+])dnl PKG_CHECK_MODULES_STATIC
-# PKG_INSTALLDIR(DIRECTORY)
-# -------------------------
-# Substitutes the variable pkgconfigdir as the location where a module
-# should install pkg-config .pc files. By default the directory is
-# $libdir/pkgconfig, but the default can be changed by passing
-# DIRECTORY. The user can override through the --with-pkgconfigdir
-# parameter.
+dnl PKG_INSTALLDIR([DIRECTORY])
+dnl -------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable pkgconfigdir as the location where a module
+dnl should install pkg-config .pc files. By default the directory is
+dnl $libdir/pkgconfig, but the default can be changed by passing
+dnl DIRECTORY. The user can override through the --with-pkgconfigdir
+dnl parameter.
AC_DEFUN([PKG_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
m4_pushdef([pkg_description],
@@ -197,16 +254,18 @@ AC_ARG_WITH([pkgconfigdir],
AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
-]) dnl PKG_INSTALLDIR
+])dnl PKG_INSTALLDIR
-# PKG_NOARCH_INSTALLDIR(DIRECTORY)
-# -------------------------
-# Substitutes the variable noarch_pkgconfigdir as the location where a
-# module should install arch-independent pkg-config .pc files. By
-# default the directory is $datadir/pkgconfig, but the default can be
-# changed by passing DIRECTORY. The user can override through the
-# --with-noarch-pkgconfigdir parameter.
+dnl PKG_NOARCH_INSTALLDIR([DIRECTORY])
+dnl --------------------------------
+dnl Since: 0.27
+dnl
+dnl Substitutes the variable noarch_pkgconfigdir as the location where a
+dnl module should install arch-independent pkg-config .pc files. By
+dnl default the directory is $datadir/pkgconfig, but the default can be
+dnl changed by passing DIRECTORY. The user can override through the
+dnl --with-noarch-pkgconfigdir parameter.
AC_DEFUN([PKG_NOARCH_INSTALLDIR],
[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
m4_pushdef([pkg_description],
@@ -217,7 +276,24 @@ AC_ARG_WITH([noarch-pkgconfigdir],
AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
m4_popdef([pkg_default])
m4_popdef([pkg_description])
-]) dnl PKG_NOARCH_INSTALLDIR
+])dnl PKG_NOARCH_INSTALLDIR
+
+
+dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+dnl -------------------------------------------
+dnl Since: 0.28
+dnl
+dnl Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])dnl PKG_CHECK_VAR
# Copyright (C) 2002-2012 Free Software Foundation, Inc.
#
diff --git a/app/xwd/clientwin.c b/app/xwd/clientwin.c
index afb06f8b5..14050d00d 100644
--- a/app/xwd/clientwin.c
+++ b/app/xwd/clientwin.c
@@ -107,7 +107,7 @@ Find_Client_In_Children(Display * dpy, Window win)
break;
}
- done:
+ done:
XFree(children);
return win;
diff --git a/app/xwd/compile b/app/xwd/compile
index a85b723c7..df363c8fb 100644
--- a/app/xwd/compile
+++ b/app/xwd/compile
@@ -1,9 +1,9 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
-scriptversion=2012-10-14.11; # UTC
+scriptversion=2018-03-07.03; # UTC
-# Copyright (C) 1999-2014 Free Software Foundation, Inc.
+# Copyright (C) 1999-2021 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC
# 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, see <http://www.gnu.org/licenses/>.
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -53,7 +53,7 @@ func_file_conv ()
MINGW*)
file_conv=mingw
;;
- CYGWIN*)
+ CYGWIN* | MSYS*)
file_conv=cygwin
;;
*)
@@ -67,7 +67,7 @@ func_file_conv ()
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
- cygwin/*)
+ cygwin/* | msys/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
@@ -255,7 +255,8 @@ EOF
echo "compile $scriptversion"
exit $?
;;
- cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
+ cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
+ icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
@@ -339,9 +340,9 @@ exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
+# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:
diff --git a/app/xwd/configure b/app/xwd/configure
index 5a3174e81..70ee31695 100644
--- a/app/xwd/configure
+++ b/app/xwd/configure
@@ -1,8 +1,8 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for xwd 1.0.7.
+# Generated by GNU Autoconf 2.69 for xwd 1.0.8.
#
-# Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>.
+# Report bugs to <https://gitlab.freedesktop.org/xorg/app/xwd/issues>.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -267,7 +267,7 @@ fi
$as_echo "$0: be upgraded to zsh 4.3.4 or later."
else
$as_echo "$0: Please tell bug-autoconf@gnu.org and
-$0: https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
+$0: https://gitlab.freedesktop.org/xorg/app/xwd/issues
$0: about your system, including any error possibly output
$0: before this message. Then install a modern shell, or
$0: manually run the script under such a shell if you do
@@ -581,9 +581,9 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='xwd'
PACKAGE_TARNAME='xwd'
-PACKAGE_VERSION='1.0.7'
-PACKAGE_STRING='xwd 1.0.7'
-PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=xorg'
+PACKAGE_VERSION='1.0.8'
+PACKAGE_STRING='xwd 1.0.8'
+PACKAGE_BUGREPORT='https://gitlab.freedesktop.org/xorg/app/xwd/issues'
PACKAGE_URL=''
ac_unique_file="Makefile.am"
@@ -729,6 +729,7 @@ infodir
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -810,6 +811,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1062,6 +1064,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1199,7 +1210,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1312,7 +1323,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures xwd 1.0.7 to adapt to many kinds of systems.
+\`configure' configures xwd 1.0.8 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1352,6 +1363,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -1382,7 +1394,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of xwd 1.0.7:";;
+ short | recursive ) echo "Configuration of xwd 1.0.8:";;
esac
cat <<\_ACEOF
@@ -1432,7 +1444,7 @@ Some influential environment variables:
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
-Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>.
+Report bugs to <https://gitlab.freedesktop.org/xorg/app/xwd/issues>.
_ACEOF
ac_status=$?
fi
@@ -1495,7 +1507,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-xwd configure 1.0.7
+xwd configure 1.0.8
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1752,7 +1764,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by xwd $as_me 1.0.7, which was
+It was created by xwd $as_me 1.0.8, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2581,7 +2593,7 @@ fi
# Define the identity of the package.
PACKAGE='xwd'
- VERSION='1.0.7'
+ VERSION='1.0.8'
cat >>confdefs.h <<_ACEOF
@@ -10445,8 +10457,8 @@ fi
# Checks for pkg-config packages
pkg_failed=no
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XWD" >&5
-$as_echo_n "checking for XWD... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for x11 xproto >= 7.0.25 ${XKBMODULE}" >&5
+$as_echo_n "checking for x11 xproto >= 7.0.25 ${XKBMODULE}... " >&6; }
if test -n "$XWD_CFLAGS"; then
pkg_cv_XWD_CFLAGS="$XWD_CFLAGS"
@@ -10486,7 +10498,7 @@ fi
if test $pkg_failed = yes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -10513,7 +10525,7 @@ Alternatively, you may set the environment variables XWD_CFLAGS
and XWD_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details." "$LINENO" 5
elif test $pkg_failed = untried; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -11075,7 +11087,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by xwd $as_me 1.0.7, which was
+This file was extended by xwd $as_me 1.0.8, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -11135,13 +11147,13 @@ $config_headers
Configuration commands:
$config_commands
-Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>."
+Report bugs to <https://gitlab.freedesktop.org/xorg/app/xwd/issues>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-xwd config.status 1.0.7
+xwd config.status 1.0.8
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/app/xwd/configure.ac b/app/xwd/configure.ac
index 99a678da7..f0f79cfd5 100644
--- a/app/xwd/configure.ac
+++ b/app/xwd/configure.ac
@@ -23,8 +23,8 @@ dnl Process this file with autoconf to create configure.
# Initialize Autoconf
AC_PREREQ([2.60])
-AC_INIT([xwd], [1.0.7],
- [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xwd])
+AC_INIT([xwd], [1.0.8],
+ [https://gitlab.freedesktop.org/xorg/app/xwd/issues], [xwd])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
diff --git a/app/xwd/dsimple.c b/app/xwd/dsimple.c
index 4fb1a8130..972a72ef5 100644
--- a/app/xwd/dsimple.c
+++ b/app/xwd/dsimple.c
@@ -33,6 +33,7 @@ from The Open Group.
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+
/*
* Other_stuff.h: Definitions of routines in other_stuff.
*
@@ -63,31 +64,32 @@ int screen = 0;
* Get_Display_Name (argc, argv) Look for -display, -d, or host:dpy (obselete)
* If found, remove it from command line. Don't go past a lone -.
*/
-char *Get_Display_Name(
- int *pargc, /* MODIFIED */
- char **argv) /* MODIFIED */
+char *
+Get_Display_Name(int *pargc, /* MODIFIED */
+ char **argv) /* MODIFIED */
{
int argc = *pargc;
- char **pargv = argv+1;
+ char **pargv = argv + 1;
char *displayname = NULL;
int i;
for (i = 1; i < argc; i++) {
- char *arg = argv[i];
-
- if (!strcmp (arg, "-display") || !strcmp (arg, "-d")) {
- if (++i >= argc) usage ("-display requires an argument");
-
- displayname = argv[i];
- *pargc -= 2;
- continue;
- }
- if (!strcmp(arg,"-")) {
- while (i<argc)
- *pargv++ = argv[i++];
- break;
- }
- *pargv++ = arg;
+ char *arg = argv[i];
+
+ if (!strcmp(arg, "-display") || !strcmp(arg, "-d")) {
+ if (++i >= argc)
+ usage("-display requires an argument");
+
+ displayname = argv[i];
+ *pargc -= 2;
+ continue;
+ }
+ if (!strcmp(arg, "-")) {
+ while (i < argc)
+ *pargv++ = argv[i++];
+ break;
+ }
+ *pargv++ = arg;
}
*pargv = NULL;
@@ -99,18 +101,19 @@ char *Get_Display_Name(
* Open_Display: Routine to open a display with correct error handling.
* Does not require dpy or screen defined on entry.
*/
-Display *Open_Display(const char *display_name)
+Display *
+Open_Display(const char *display_name)
{
- Display *d;
+ Display *d;
- d = XOpenDisplay(display_name);
- if (d == NULL) {
- fprintf (stderr, "%s: unable to open display '%s'\n",
- program_name, XDisplayName (display_name));
- exit(1);
- }
+ d = XOpenDisplay(display_name);
+ if (d == NULL) {
+ fprintf(stderr, "%s: unable to open display '%s'\n",
+ program_name, XDisplayName(display_name));
+ exit(1);
+ }
- return(d);
+ return (d);
}
@@ -121,24 +124,25 @@ Display *Open_Display(const char *display_name)
* for this display is then stored in screen.
* Does not require dpy or screen defined.
*/
-void Setup_Display_And_Screen(
- int *argc, /* MODIFIED */
- char **argv) /* MODIFIED */
+void
+Setup_Display_And_Screen(int *argc, /* MODIFIED */
+ char **argv) /* MODIFIED */
{
- char *displayname = NULL;
+ char *displayname = NULL;
- displayname = Get_Display_Name(argc, argv);
- dpy = Open_Display (displayname);
- screen = XDefaultScreen(dpy);
+ displayname = Get_Display_Name(argc, argv);
+ dpy = Open_Display(displayname);
+ screen = XDefaultScreen(dpy);
}
/*
* Close_Display: Close display
*/
-void Close_Display(void)
+void
+Close_Display(void)
{
if (dpy == NULL)
- return;
+ return;
XCloseDisplay(dpy);
dpy = NULL;
@@ -167,56 +171,56 @@ void Close_Display(void)
* all command line arguments, and other setup is done.
* For examples of usage, see xwininfo, xwd, or xprop.
*/
-Window Select_Window_Args(
- int *rargc,
- char **argv)
+Window
+Select_Window_Args(int *rargc, char **argv)
#define ARGC (*rargc)
{
- int nargc=1;
- int argc;
- char **nargv;
- Window w=0;
+ int nargc = 1;
+ int argc;
+ char **nargv;
+ Window w = 0;
+
+ nargv = argv + 1;
+ argc = ARGC;
- nargv = argv+1; argc = ARGC;
#define OPTION argv[0]
#define NXTOPTP ++argv, --argc>0
#define NXTOPT(arg) if (++argv, --argc==0) usage(arg " requires an argument")
#define COPYOPT nargv++[0]=OPTION, nargc++
- while (NXTOPTP) {
- if (!strcmp(OPTION, "-")) {
- COPYOPT;
- while (NXTOPTP)
- COPYOPT;
- break;
- }
- if (!strcmp(OPTION, "-root")) {
- w=RootWindow(dpy, screen);
- continue;
- }
- if (!strcmp(OPTION, "-name")) {
- NXTOPT("-name");
- w = Window_With_Name(dpy, RootWindow(dpy, screen),
- OPTION);
- if (!w)
- Fatal_Error("No window with name %s exists!",OPTION);
- continue;
- }
- if (!strcmp(OPTION, "-id")) {
- NXTOPT("-id");
- w=0;
- sscanf(OPTION, "0x%lx", &w);
- if (!w)
- sscanf(OPTION, "%lu", &w);
- if (!w)
- Fatal_Error("Invalid window id format: %s.", OPTION);
- continue;
- }
- COPYOPT;
- }
- ARGC = nargc;
-
- return(w);
+ while (NXTOPTP) {
+ if (!strcmp(OPTION, "-")) {
+ COPYOPT;
+ while (NXTOPTP)
+ COPYOPT;
+ break;
+ }
+ if (!strcmp(OPTION, "-root")) {
+ w = RootWindow(dpy, screen);
+ continue;
+ }
+ if (!strcmp(OPTION, "-name")) {
+ NXTOPT("-name");
+ w = Window_With_Name(dpy, RootWindow(dpy, screen), OPTION);
+ if (!w)
+ Fatal_Error("No window with name %s exists!", OPTION);
+ continue;
+ }
+ if (!strcmp(OPTION, "-id")) {
+ NXTOPT("-id");
+ w = 0;
+ sscanf(OPTION, "0x%lx", &w);
+ if (!w)
+ sscanf(OPTION, "%lu", &w);
+ if (!w)
+ Fatal_Error("Invalid window id format: %s.", OPTION);
+ continue;
+ }
+ COPYOPT;
+ }
+ ARGC = nargc;
+
+ return (w);
}
/*
@@ -230,51 +234,54 @@ Window Select_Window_Args(
* Routine to let user select a window using the mouse
*/
-Window Select_Window(Display *disp, int descend)
+Window
+Select_Window(Display *disp, int descend)
{
- int status;
- Cursor cursor;
- XEvent event;
- Window target_win = None, root = RootWindow(disp,screen);
- int buttons = 0;
-
- /* Make the target cursor */
- cursor = XCreateFontCursor(disp, XC_crosshair);
-
- /* Grab the pointer using target cursor, letting it room all over */
- status = XGrabPointer(disp, root, False,
- ButtonPressMask|ButtonReleaseMask, GrabModeSync,
- GrabModeAsync, root, cursor, CurrentTime);
- if (status != GrabSuccess) Fatal_Error("Can't grab the mouse.");
-
- /* Let the user select a window... */
- while ((target_win == None) || (buttons != 0)) {
- /* allow one more event */
- XAllowEvents(disp, SyncPointer, CurrentTime);
- XWindowEvent(disp, root, ButtonPressMask|ButtonReleaseMask, &event);
- switch (event.type) {
- case ButtonPress:
- if (target_win == None) {
- target_win = event.xbutton.subwindow; /* window selected */
- if (target_win == None) target_win = root;
- }
- buttons++;
- break;
- case ButtonRelease:
- if (buttons > 0) /* there may have been some down before we started */
- buttons--;
- break;
+ int status;
+ Cursor cursor;
+ XEvent event;
+ Window target_win = None, root = RootWindow(disp, screen);
+ int buttons = 0;
+
+ /* Make the target cursor */
+ cursor = XCreateFontCursor(disp, XC_crosshair);
+
+ /* Grab the pointer using target cursor, letting it room all over */
+ status = XGrabPointer(disp, root, False,
+ ButtonPressMask | ButtonReleaseMask, GrabModeSync,
+ GrabModeAsync, root, cursor, CurrentTime);
+ if (status != GrabSuccess)
+ Fatal_Error("Can't grab the mouse.");
+
+ /* Let the user select a window... */
+ while ((target_win == None) || (buttons != 0)) {
+ /* allow one more event */
+ XAllowEvents(disp, SyncPointer, CurrentTime);
+ XWindowEvent(disp, root, ButtonPressMask | ButtonReleaseMask, &event);
+ switch (event.type) {
+ case ButtonPress:
+ if (target_win == None) {
+ target_win = event.xbutton.subwindow; /* window selected */
+ if (target_win == None)
+ target_win = root;
+ }
+ buttons++;
+ break;
+ case ButtonRelease:
+ if (buttons > 0) /* there may have been some down before we started */
+ buttons--;
+ break;
+ }
}
- }
- XUngrabPointer(disp, CurrentTime); /* Done with pointer */
+ XUngrabPointer(disp, CurrentTime); /* Done with pointer */
- if (!descend || (target_win == root))
- return(target_win);
+ if (!descend || (target_win == root))
+ return (target_win);
- target_win = Find_Client(disp, root, target_win);
+ target_win = Find_Client(disp, root, target_win);
- return(target_win);
+ return (target_win);
}
@@ -285,30 +292,31 @@ Window Select_Window(Display *disp, int descend)
* one found will be returned. Only top and its subwindows
* are looked at. Normally, top should be the RootWindow.
*/
-Window Window_With_Name(
- Display *disp,
- Window top,
- const char *name)
+Window
+Window_With_Name(Display *disp, Window top, const char *name)
{
- Window *children, dummy;
- unsigned int nchildren;
- unsigned int i;
- Window w=0;
- char *window_name;
-
- if (XFetchName(disp, top, &window_name) && !strcmp(window_name, name))
- return(top);
-
- if (!XQueryTree(disp, top, &dummy, &dummy, &children, &nchildren))
- return(0);
-
- for (i=0; i<nchildren; i++) {
- w = Window_With_Name(disp, children[i], name);
- if (w)
- break;
- }
- if (children) XFree ((char *)children);
- return(w);
+ Window *children, dummy;
+ unsigned int nchildren;
+ unsigned int i;
+ Window w = 0;
+ char *window_name;
+
+ if (XFetchName(disp, top, &window_name) && !strcmp(window_name, name))
+ return (top);
+
+ if (!XQueryTree(disp, top, &dummy, &dummy, &children, &nchildren))
+ return (0);
+
+ for (i = 0; i < nchildren; i++) {
+ w = Window_With_Name(disp, children[i], name);
+ if (w)
+ break;
+ }
+
+ if (children)
+ XFree((char *) children);
+
+ return (w);
}
/*
@@ -319,30 +327,32 @@ Window Window_With_Name(
void
outl(const char *msg, ...)
{
- va_list args;
- fflush(stdout);
- va_start(args, msg);
- vfprintf(stderr, msg, args);
- va_end(args);
- fprintf(stderr, "\n");
- fflush(stderr);
+ va_list args;
+
+ fflush(stdout);
+ va_start(args, msg);
+ vfprintf(stderr, msg, args);
+ va_end(args);
+ fprintf(stderr, "\n");
+ fflush(stderr);
}
-
/*
* Standard fatal error routine - call like printf.
* Does not require dpy or screen defined.
*/
-void Fatal_Error(const char *msg, ...)
+void
+Fatal_Error(const char *msg, ...)
{
- va_list args;
- fflush(stdout);
- fflush(stderr);
- fprintf(stderr, "%s: error: ", program_name);
- va_start(args, msg);
- vfprintf(stderr, msg, args);
- va_end(args);
- fprintf(stderr, "\n");
- Close_Display();
- exit(EXIT_FAILURE);
+ va_list args;
+
+ fflush(stdout);
+ fflush(stderr);
+ fprintf(stderr, "%s: error: ", program_name);
+ va_start(args, msg);
+ vfprintf(stderr, msg, args);
+ va_end(args);
+ fprintf(stderr, "\n");
+ Close_Display();
+ exit(EXIT_FAILURE);
}
diff --git a/app/xwd/dsimple.h b/app/xwd/dsimple.h
index 18679b87c..416e96ab3 100644
--- a/app/xwd/dsimple.h
+++ b/app/xwd/dsimple.h
@@ -51,10 +51,10 @@ extern const char *program_name; /* Name of this program */
extern Display *dpy; /* The current display */
extern int screen; /* The current screen */
-#define INIT_NAME program_name=argv[0] /* use this in main to setup
- program_name */
+#define INIT_NAME program_name=argv[0] /* use this in main to setup
+ program_name */
- /* Declaritions for functions in just_display.c */
+ /* Declarations for functions in just_display.c */
char *Get_Display_Name(int *, char **);
Display *Open_Display(const char *);
@@ -63,8 +63,8 @@ void Close_Display(void);
Window Select_Window_Args(int *, char **);
void usage(const char *errmsg) _X_NORETURN _X_COLD;
-#define X_USAGE "[host:display]" /* X arguments handled by
- Get_Display_Name */
+#define X_USAGE "[host:display]" /* X arguments handled by
+ Get_Display_Name */
/*
* Other_stuff.h: Definitions of routines in other_stuff.
@@ -76,5 +76,6 @@ void usage(const char *errmsg) _X_NORETURN _X_COLD;
Window Select_Window(Display *, int);
Window Window_With_Name(Display *, Window, const char *);
-void Fatal_Error(const char *, ...) _X_NORETURN _X_ATTRIBUTE_PRINTF(1, 2) _X_COLD;
+void Fatal_Error(const char *, ...) _X_NORETURN _X_ATTRIBUTE_PRINTF(1, 2)
+ _X_COLD;
void outl(const char *, ...) _X_ATTRIBUTE_PRINTF(1, 2);
diff --git a/app/xwd/list.c b/app/xwd/list.c
index 6e9a7a488..4a50fc026 100644
--- a/app/xwd/list.c
+++ b/app/xwd/list.c
@@ -43,13 +43,13 @@ from The Open Group.
/** ------------------------------------------------------------------------
Sets the pointers of the specified list to NULL.
--------------------------------------------------------------------- **/
-void zero_list(list_ptr lp)
+void
+zero_list(list_ptr lp)
{
lp->next = NULL;
lp->ptr.item = NULL;
}
-
/** ------------------------------------------------------------------------
Adds item to the list pointed to by lp. Finds the end of the
list, then mallocs a new list node onto the end of the list.
@@ -57,14 +57,15 @@ void zero_list(list_ptr lp)
and the next pointer in the new node is set to NULL.
Returns 1 if successful, 0 if the malloc failed.
-------------------------------------------------------------------- **/
-int add_to_list(list_ptr lp, void *item)
+int
+add_to_list(list_ptr lp, void *item)
{
while (lp->next) {
- lp = lp->next;
+ lp = lp->next;
}
- if ((lp->next = (list_ptr) malloc( sizeof( list_item))) == NULL) {
+ if ((lp->next = (list_ptr) malloc(sizeof(list_item))) == NULL) {
- return 0;
+ return 0;
}
lp->next->ptr.item = item;
lp->next->next = NULL;
@@ -77,13 +78,14 @@ int add_to_list(list_ptr lp, void *item)
Creates a new list and sets its pointers to NULL.
Returns a pointer to the new list.
-------------------------------------------------------------------- **/
-list_ptr new_list (void)
+list_ptr
+new_list(void)
{
list_ptr lp;
- if ((lp = (list_ptr) malloc( sizeof( list_item)))) {
- lp->next = NULL;
- lp->ptr.item = NULL;
+ if ((lp = (list_ptr) malloc(sizeof(list_item)))) {
+ lp->next = NULL;
+ lp->ptr.item = NULL;
}
return lp;
@@ -99,13 +101,14 @@ list_ptr new_list (void)
curr pointer in the new list is the same as in the old list.
Returns a pointer to the new list head.
-------------------------------------------------------------------- **/
-list_ptr dup_list_head(list_ptr lp, int start_at_curr)
+list_ptr
+dup_list_head(list_ptr lp, int start_at_curr)
{
list_ptr new_listp;
- if ((new_listp = (list_ptr) malloc( sizeof( list_item))) == NULL) {
+ if ((new_listp = (list_ptr) malloc(sizeof(list_item))) == NULL) {
- return (list_ptr)NULL;
+ return (list_ptr) NULL;
}
new_listp->next = start_at_curr ? lp->ptr.curr : lp->next;
new_listp->ptr.curr = lp->ptr.curr;
@@ -117,13 +120,14 @@ list_ptr dup_list_head(list_ptr lp, int start_at_curr)
/** ------------------------------------------------------------------------
Returns the number of items in the list.
-------------------------------------------------------------------- **/
-unsigned int list_length(list_ptr lp)
+unsigned int
+list_length(list_ptr lp)
{
unsigned int count = 0;
while (lp->next) {
- count++;
- lp = lp->next;
+ count++;
+ lp = lp->next;
}
return count;
@@ -139,19 +143,20 @@ unsigned int list_length(list_ptr lp)
Returns a pointer to the item, so the caller can free it if it
so desires. If a match is not found, returns NULL.
-------------------------------------------------------------------- **/
-void *delete_from_list(list_ptr lp, void *item)
+void *
+delete_from_list(list_ptr lp, void *item)
{
list_ptr new_next;
while (lp->next) {
- if (lp->next->ptr.item == item) {
- new_next = lp->next->next;
- free (lp->next);
- lp->next = new_next;
-
- return item;
- }
- lp = lp->next;
+ if (lp->next->ptr.item == item) {
+ new_next = lp->next->next;
+ free(lp->next);
+ lp->next = new_next;
+
+ return item;
+ }
+ lp = lp->next;
}
return NULL;
@@ -164,35 +169,38 @@ void *delete_from_list(list_ptr lp, void *item)
with new_list(). If free_items is true, each item pointed to
from the node is freed, in addition to the node itself.
-------------------------------------------------------------------- **/
-void delete_list(list_ptr lp, int free_items)
+void
+delete_list(list_ptr lp, int free_items)
{
list_ptr del_node;
void *item;
while (lp->next) {
- del_node = lp->next;
- item = del_node->ptr.item;
- lp->next = del_node->next;
- free (del_node);
- if (free_items) {
- free( item);
- }
+ del_node = lp->next;
+ item = del_node->ptr.item;
+ lp->next = del_node->next;
+ free(del_node);
+ if (free_items) {
+ free(item);
+ }
}
}
-void delete_list_destroying(list_ptr lp, void destructor(void *item))
+void
+delete_list_destroying(list_ptr lp, void destructor(void *item))
{
list_ptr del_node;
+
void *item;
while (lp->next) {
- del_node = lp->next;
- item = del_node->ptr.item;
- lp->next = del_node->next;
- free( del_node);
- if (destructor) {
- destructor( item);
- }
+ del_node = lp->next;
+ item = del_node->ptr.item;
+ lp->next = del_node->next;
+ free(del_node);
+ if (destructor) {
+ destructor(item);
+ }
}
}
@@ -202,11 +210,12 @@ void delete_list_destroying(list_ptr lp, void destructor(void *item))
Sets the list head node's curr ptr to the first node in the list.
Returns NULL if the list is empty.
-------------------------------------------------------------------- **/
-void * first_in_list(list_ptr lp)
+void *
+first_in_list(list_ptr lp)
{
- if (! lp) {
+ if (!lp) {
- return NULL;
+ return NULL;
}
lp->ptr.curr = lp->next;
@@ -219,21 +228,22 @@ void * first_in_list(list_ptr lp)
first_in_list must have been called prior.
Returns NULL if no next item.
-------------------------------------------------------------------- **/
-void * next_in_list(list_ptr lp)
+void *
+next_in_list(list_ptr lp)
{
- if (! lp) {
+ if (!lp) {
- return NULL;
+ return NULL;
}
if (lp->ptr.curr) {
- lp->ptr.curr = lp->ptr.curr->next;
+ lp->ptr.curr = lp->ptr.curr->next;
}
return lp->ptr.curr ? lp->ptr.curr->ptr.item : NULL;
}
-int list_is_empty(list_ptr lp)
+int
+list_is_empty(list_ptr lp)
{
return (lp == NULL || lp->next == NULL);
}
-
diff --git a/app/xwd/list.h b/app/xwd/list.h
index 664075d91..23f36f2b8 100644
--- a/app/xwd/list.h
+++ b/app/xwd/list.h
@@ -47,47 +47,23 @@ from The Open Group.
typedef struct _list_item {
struct _list_item *next;
union {
- void *item; /* in normal list node, pts to data */
- struct _list_item *curr; /* in list head, pts to curr for 1st, next */
+ void *item; /* in normal list node, pts to data */
+ struct _list_item *curr; /* in list head, pts to curr for 1st, next */
} ptr;
} list, list_item, *list_ptr;
-typedef void (*DESTRUCT_FUNC_PTR)(
-void *
-);
+typedef void (*DESTRUCT_FUNC_PTR) (void *);
-void zero_list(
- list_ptr
- );
-int add_to_list (
- list_ptr , void *
- );
-list_ptr new_list (
- void
- );
-list_ptr dup_list_head (
- list_ptr , int
- );
-unsigned int list_length(
- list_ptr
- );
-void *delete_from_list (
- list_ptr , void *
- );
-void delete_list(
- list_ptr , int
- );
-void delete_list_destroying (
- list_ptr , DESTRUCT_FUNC_PTR
- );
-void *first_in_list (
- list_ptr
- );
-void *next_in_list (
- list_ptr
- );
-int list_is_empty (
- list_ptr
- );
+void zero_list(list_ptr);
+int add_to_list(list_ptr, void *);
+list_ptr new_list(void);
+list_ptr dup_list_head(list_ptr, int);
+unsigned int list_length(list_ptr);
+void *delete_from_list(list_ptr, void *);
+void delete_list(list_ptr, int);
+void delete_list_destroying(list_ptr, DESTRUCT_FUNC_PTR);
+void *first_in_list(list_ptr);
+void *next_in_list(list_ptr);
+int list_is_empty(list_ptr);
#endif
diff --git a/app/xwd/man/Makefile.in b/app/xwd/man/Makefile.in
index d42ed1c79..6a8247c8e 100644
--- a/app/xwd/man/Makefile.in
+++ b/app/xwd/man/Makefile.in
@@ -223,6 +223,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
diff --git a/app/xwd/man/xwd.man b/app/xwd/man/xwd.man
index da06d7474..be4cc5817 100644
--- a/app/xwd/man/xwd.man
+++ b/app/xwd/man/xwd.man
@@ -28,8 +28,8 @@ xwd - dump an image of an X window
.SH SYNOPSIS
.B "xwd"
[-debug] [-help] [-nobdrs] [-out \fIfile\fP] [-xy] [-frame] [-add \fIvalue\fP]
-[-root | -id \fIid\fP | -name \fIname\fP ] [-icmap] [-screen] [-silent]
-[-display \fIdisplay\fP] [-version]
+[-root | -id \fIwdid\fP | -name \fIwdname\fP ] [-icmap] [-screen] [-silent]
+[-display \fIhost:dpy\fP] [-version]
.SH DESCRIPTION
.PP
.I Xwd
@@ -44,7 +44,11 @@ the dump is completed.
.SH OPTIONS
.PP
.TP 8
-.B "-display \fIdisplay\fP"
+.B "-debug"
+Enable debug mode.
+.PP
+.TP 8
+.B "-d, -display \fIhost:dpy\fP"
This argument allows you to specify the server to connect to; see \fIX(__miscmansuffix__)\fP.
.PP
.TP 8
@@ -83,13 +87,13 @@ This option indicates that the root window should be selected for the
window dump, without requiring the user to select a window with the pointer.
.PP
.TP 8
-.B "-id \fIid\fP"
+.B "-id \fIwdid\fP"
This option indicates that the window with the specified resource id
should be selected for the window dump, without requiring the user to
select a window with the pointer.
.PP
.TP 8
-.B "-name \fIname\fP"
+.B "-name \fIwdname\fP"
This option indicates that the window with the specified WM_NAME property
should be selected for the window dump, without requiring the user to
select a window with the pointer.
diff --git a/app/xwd/multiVis.c b/app/xwd/multiVis.c
index 86e963465..97f740ed9 100644
--- a/app/xwd/multiVis.c
+++ b/app/xwd/multiVis.c
@@ -34,11 +34,12 @@ from The Open Group.
------------------------------------------------------------------------ **/
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/X.h>
-#include <stdio.h>
#include "list.h"
#include "wsutils.h"
#include "multiVis.h"
@@ -61,24 +62,24 @@ typedef struct {
Window win;
Visual *vis;
Colormap cmap;
- int x_rootrel, y_rootrel; /* root relative location of window */
- int x_vis, y_vis; /* rt rel x,y of vis part, not parent clipped */
- int width, height; /* width and height of visible part */
- int border_width; /* border width of the window */
- Window parent; /* id of parent (for debugging) */
+ int x_rootrel, y_rootrel; /* root relative location of window */
+ int x_vis, y_vis; /* rt rel x,y of vis part, not parent clipped */
+ int width, height; /* width and height of visible part */
+ int border_width; /* border width of the window */
+ Window parent; /* id of parent (for debugging) */
} image_win_type;
/* Items in short list of regions that tile the grabbed area. May have
multiple windows in the region.
*/
typedef struct {
- Window win; /* lowest window of this visual */
+ Window win; /* lowest window of this visual */
Visual *vis;
Colormap cmap;
- int x_rootrel, y_rootrel; /* root relative location of bottom window */
- int x_vis, y_vis; /* rt rel x,y of vis part, not parent clipped */
- int width, height; /* w & h of visible rect of bottom window */
- int border; /* border width of the window */
+ int x_rootrel, y_rootrel; /* root relative location of bottom window */
+ int x_vis, y_vis; /* rt rel x,y of vis part, not parent clipped */
+ int width, height; /* w & h of visible rect of bottom window */
+ int border; /* border width of the window */
Region visible_region;
} image_region_type;
@@ -116,499 +117,490 @@ extern unsigned int list_length();
*/
/* Prototype Declarations for Static Functions */
-static void QueryColorMap(
- Display *, Colormap , Visual *,
- XColor **, int *, int *, int *
- );
-static void TransferImage(
- Display *, XImage *,int, int , image_region_type*,
- XImage *,int ,int
- );
-static XImage * ReadRegionsInList(
- Display *, Visual *, int, int, unsigned int,
- unsigned int, XRectangle, list_ptr
- );
-
-static list_ptr make_region_list(
- Display*, Window, XRectangle*,
- int*, int, XVisualInfo**, int *
- );
-
-static void destroy_region_list(
- list_ptr
- ) ;
-static void subtr_rect_from_image_region(
- image_region_type *, int , int , int , int
- );
-static void add_rect_to_image_region(
- image_region_type *,
- int , int , int , int
- );
-static int src_in_region_list(
- image_win_type *, list_ptr
- );
-static void add_window_to_list(
- list_ptr, Window, int, int ,
- int , int , int , int, int,
- Visual*, Colormap, Window
- );
-static int src_in_image(
- image_win_type *, int , XVisualInfo**
- );
-static int src_in_overlay(
- image_region_type *, int, OverlayInfo *, int*, int*
- );
-static void make_src_list(
- Display *, list_ptr, XRectangle *, Window,
- int, int, XWindowAttributes *, XRectangle *
-);
-static void destroy_image_region(
- image_region_type *
-);
+static void QueryColorMap(Display *, Colormap, Visual *,
+ XColor **, int *, int *, int *);
+static void TransferImage(Display *, XImage *, int, int, image_region_type *,
+ XImage *, int, int);
+static XImage *ReadRegionsInList(Display *, Visual *, int, int, unsigned int,
+ unsigned int, XRectangle, list_ptr);
+
+static list_ptr make_region_list(Display *, Window, XRectangle *,
+ int *, int, XVisualInfo **, int *);
+static void destroy_region_list(list_ptr);
+static void subtr_rect_from_image_region(image_region_type *,
+ int, int, int, int);
+static void add_rect_to_image_region(image_region_type *,
+ int, int, int, int);
+static int src_in_region_list(image_win_type *, list_ptr);
+static void add_window_to_list(list_ptr, Window, int, int,
+ int, int, int, int, int,
+ Visual *, Colormap, Window);
+static int src_in_image(image_win_type *, int, XVisualInfo **);
+static int src_in_overlay(image_region_type *, int, OverlayInfo *, int *,
+ int *);
+static void make_src_list(Display *, list_ptr, XRectangle *, Window, int, int,
+ XWindowAttributes *, XRectangle *);
+static void destroy_image_region(image_region_type *);
/* End of Prototype Declarations */
-void initFakeVisual(Visual *Vis)
+void
+initFakeVisual(Visual *Vis)
{
- Vis->ext_data=NULL;
- Vis->class = DirectColor ;
- Vis->red_mask = 0x00FF0000;
- Vis->green_mask = 0x0000FF00 ;
- Vis->blue_mask = 0x000000FF ;
- Vis->map_entries = 256 ;
- Vis->bits_per_rgb = 8 ;
+ Vis->ext_data = NULL;
+ Vis->class = DirectColor;
+ Vis->red_mask = 0x00FF0000;
+ Vis->green_mask = 0x0000FF00;
+ Vis->blue_mask = 0x000000FF;
+ Vis->map_entries = 256;
+ Vis->bits_per_rgb = 8;
}
static void
QueryColorMap(Display *disp, Colormap src_cmap, Visual *src_vis,
- XColor **src_colors, int *rShift, int *gShift, int *bShift)
+ XColor **src_colors, int *rShift, int *gShift, int *bShift)
{
- unsigned int ncolors,i ;
- unsigned long redMask, greenMask, blueMask;
- int redShift, greenShift, blueShift;
- XColor *colors ;
-
- ncolors = (unsigned) src_vis->map_entries ;
- *src_colors = colors = (XColor *)malloc(ncolors * sizeof(XColor) ) ;
-
- if(src_vis->class != TrueColor && src_vis->class != DirectColor)
- {
- for(i=0 ; i < ncolors ; i++)
- {
- colors[i].pixel = i ;
- colors[i].pad = 0;
- colors[i].flags = DoRed|DoGreen|DoBlue;
- }
- }
- else /** src is decomposed rgb ***/
- {
+ unsigned int ncolors, i;
+ unsigned long redMask, greenMask, blueMask;
+ int redShift, greenShift, blueShift;
+ XColor *colors;
+
+ ncolors = (unsigned) src_vis->map_entries;
+ *src_colors = colors = calloc(ncolors, sizeof(XColor));
+
+ if (src_vis->class != TrueColor && src_vis->class != DirectColor) {
+ for (i = 0; i < ncolors; i++) {
+ colors[i].pixel = i;
+ colors[i].pad = 0;
+ colors[i].flags = DoRed | DoGreen | DoBlue;
+ }
+ }
+ else { /** src is decomposed rgb ***/
+
/* Get the X colormap */
redMask = src_vis->red_mask;
greenMask = src_vis->green_mask;
blueMask = src_vis->blue_mask;
- redShift = 0; while (!(redMask&0x1)) {
- redShift++;
- redMask = redMask>>1;
+ redShift = 0;
+ while (!(redMask & 0x1)) {
+ redShift++;
+ redMask = redMask >> 1;
}
- greenShift = 0; while (!(greenMask&0x1)) {
- greenShift++;
- greenMask = greenMask>>1;
+ greenShift = 0;
+ while (!(greenMask & 0x1)) {
+ greenShift++;
+ greenMask = greenMask >> 1;
}
- blueShift = 0; while (!(blueMask&0x1)) {
- blueShift++;
- blueMask = blueMask>>1;
+ blueShift = 0;
+ while (!(blueMask & 0x1)) {
+ blueShift++;
+ blueMask = blueMask >> 1;
}
- *rShift = redShift ;
- *gShift = greenShift ;
- *bShift = blueShift ;
- for (i=0; i<ncolors; i++) {
- if( i <= redMask)colors[i].pixel = (i<<redShift) ;
- if( i <= greenMask)colors[i].pixel |= (i<<greenShift) ;
- if( i <= blueMask)colors[i].pixel |= (i<<blueShift) ;
- /***** example :for gecko's 3-3-2 map, blue index should be <= 3.
+ *rShift = redShift;
+ *gShift = greenShift;
+ *bShift = blueShift;
+ for (i = 0; i < ncolors; i++) {
+ if (i <= redMask)
+ colors[i].pixel = (i << redShift);
+ if (i <= greenMask)
+ colors[i].pixel |= (i << greenShift);
+ if (i <= blueMask)
+ colors[i].pixel |= (i << blueShift);
+ /***** example: for gecko's 3-3-2 map, blue index should be <= 3.
colors[i].pixel = (i<<redShift)|(i<<greenShift)|(i<<blueShift);
- *****/
- colors[i].pad = 0;
- colors[i].flags = DoRed|DoGreen|DoBlue;
+ *****/
+ colors[i].pad = 0;
+ colors[i].flags = DoRed | DoGreen | DoBlue;
}
- }
+ }
- XQueryColors(disp, src_cmap, colors, (int) ncolors);
+ XQueryColors(disp, src_cmap, colors, (int) ncolors);
}
int
GetMultiVisualRegions(Display *disp,
- /* root win on which grab was done */
- Window srcRootWinid,
- /* root rel UL corner of bounding box of grab */
- int x, int y,
- /* size of bounding box of grab */
- unsigned int width, unsigned int height,
- int *transparentOverlays, int *numVisuals,
- XVisualInfo **pVisuals, int *numOverlayVisuals,
- OverlayInfo **pOverlayVisuals,
- int *numImageVisuals, XVisualInfo ***pImageVisuals,
- /* list of regions to read from */
- list_ptr *vis_regions,
- list_ptr *vis_image_regions, int *allImage)
+ /* root win on which grab was done */
+ Window srcRootWinid,
+ /* root rel UL corner of bounding box of grab */
+ int x, int y,
+ /* size of bounding box of grab */
+ unsigned int width, unsigned int height,
+ int *transparentOverlays, int *numVisuals,
+ XVisualInfo **pVisuals, int *numOverlayVisuals,
+ OverlayInfo **pOverlayVisuals,
+ int *numImageVisuals, XVisualInfo ***pImageVisuals,
+ /* list of regions to read from */
+ list_ptr *vis_regions,
+ list_ptr *vis_image_regions, int *allImage)
{
- int hasNonDefault;
- XRectangle bbox; /* bounding box of grabbed area */
-
+ int hasNonDefault;
+ XRectangle bbox; /* bounding box of grabbed area */
bbox.x = x; /* init X rect for bounding box */
bbox.y = y;
bbox.width = width;
bbox.height = height;
- GetXVisualInfo(disp,DefaultScreen(disp),
- transparentOverlays,
- numVisuals, pVisuals,
- numOverlayVisuals, pOverlayVisuals,
- numImageVisuals, pImageVisuals);
+ GetXVisualInfo(disp, DefaultScreen(disp),
+ transparentOverlays,
+ numVisuals, pVisuals,
+ numOverlayVisuals, pOverlayVisuals,
+ numImageVisuals, pImageVisuals);
- *vis_regions = *vis_image_regions = NULL ;
- if ((*vis_regions = make_region_list( disp, srcRootWinid, &bbox,
+ *vis_regions = *vis_image_regions = NULL;
+ if ((*vis_regions = make_region_list(disp, srcRootWinid, &bbox,
&hasNonDefault, *numImageVisuals,
*pImageVisuals, allImage)) == NULL)
- return 0 ;
+ return 0;
- if (*transparentOverlays)
- {
- *allImage = 1; /* until proven otherwise,
- this flags that it to be an image only list */
+ if (*transparentOverlays) {
+ *allImage = 1; /* until proven otherwise,
+ this flags that it to be an image only list */
*vis_image_regions =
- make_region_list( disp, srcRootWinid, &bbox, &hasNonDefault,
- *numImageVisuals, *pImageVisuals, allImage);
+ make_region_list(disp, srcRootWinid, &bbox, &hasNonDefault,
+ *numImageVisuals, *pImageVisuals, allImage);
}
- /* if there is a second region in any of the two lists return 1 **/
- if ( ( *vis_regions && (*vis_regions)->next && (*vis_regions)->next->next ) ||
- ( *vis_image_regions && (*vis_image_regions)->next &&
- (*vis_image_regions)->next->next ) ) return 1 ;
- else return 0 ;
+ /* if there is a second region in any of the two lists return 1 */
+ if ((*vis_regions && (*vis_regions)->next && (*vis_regions)->next->next) ||
+ (*vis_image_regions && (*vis_image_regions)->next &&
+ (*vis_image_regions)->next->next))
+ return 1;
+ else
+ return 0;
}
-static void TransferImage(Display *disp, XImage *reg_image,
- int srcw, int srch,
- image_region_type *reg, XImage *target_image,
- int dst_x, int dst_y)
+static void
+TransferImage(Display *disp, XImage *reg_image,
+ int srcw, int srch,
+ image_region_type *reg, XImage *target_image,
+ int dst_x, int dst_y)
{
- int i,j,old_pixel,new_pixel,red_ind,green_ind,blue_ind ;
+ int i, j, old_pixel, new_pixel, red_ind, green_ind, blue_ind;
XColor *colors;
int rShift = 0, gShift = 0, bShift = 0;
- QueryColorMap(disp,reg->cmap,reg->vis,&colors,
- &rShift,&gShift,&bShift) ;
+ QueryColorMap(disp, reg->cmap, reg->vis, &colors,
+ &rShift, &gShift, &bShift);
switch (reg->vis->class) {
- case TrueColor :
- for(i=0 ; i < srch ; i++)
- {
- for(j=0 ; j < srcw ; j++)
- {
- old_pixel = XGetPixel(reg_image,j,i) ;
-
- if( reg->vis->map_entries == 16) {
-
- red_ind = (old_pixel & reg->vis->red_mask) >> rShift ;
- green_ind = (old_pixel & reg->vis->green_mask) >> gShift ;
- blue_ind = (old_pixel & reg->vis->blue_mask) >> bShift ;
-
- new_pixel = (
- ((colors[red_ind].red >> 8) << RED_SHIFT)
- |((colors[green_ind].green >> 8) << GREEN_SHIFT)
- |((colors[blue_ind].blue >> 8) << BLUE_SHIFT)
- );
- }
- else
- new_pixel = old_pixel;
-
- XPutPixel(target_image,dst_x+j, dst_y+i,new_pixel);
-
- }
- }
- break;
- case DirectColor :
- for(i=0 ; i < srch ; i++)
- {
-
- for(j=0 ; j < srcw ; j++)
- {
- old_pixel = XGetPixel(reg_image,j,i) ;
- red_ind = (old_pixel & reg->vis->red_mask) >> rShift ;
- green_ind = (old_pixel & reg->vis->green_mask) >> gShift ;
- blue_ind = (old_pixel & reg->vis->blue_mask) >> bShift ;
-
- new_pixel = (
- ((colors[red_ind].red >> 8) << RED_SHIFT)
- |((colors[green_ind].green >> 8) << GREEN_SHIFT)
- |((colors[blue_ind].blue >> 8) << BLUE_SHIFT)
- );
- XPutPixel(target_image,dst_x+j, dst_y+i,new_pixel);
-
- }
- }
- break;
- default :
- for(i=0 ; i < srch ; i++)
- {
- for(j=0 ; j < srcw ; j++)
- {
- old_pixel = XGetPixel(reg_image,j,i) ;
-
- new_pixel = (
- ((colors[old_pixel].red >> 8) << RED_SHIFT)
- |((colors[old_pixel].green >> 8) << GREEN_SHIFT)
- |((colors[old_pixel].blue >> 8) << BLUE_SHIFT)
- );
- XPutPixel(target_image,dst_x+j, dst_y+i,new_pixel);
-
- }
- }
- break;
+ case TrueColor:
+ for (i = 0; i < srch; i++) {
+ for (j = 0; j < srcw; j++) {
+ old_pixel = XGetPixel(reg_image, j, i);
+
+ if (reg->vis->map_entries == 16) {
+
+ red_ind = (old_pixel & reg->vis->red_mask) >> rShift;
+ green_ind = (old_pixel & reg->vis->green_mask) >> gShift;
+ blue_ind = (old_pixel & reg->vis->blue_mask) >> bShift;
+
+ new_pixel = (
+ ((colors[red_ind].red >> 8) << RED_SHIFT) |
+ ((colors[green_ind].green >> 8) << GREEN_SHIFT) |
+ ((colors[blue_ind].blue >> 8) << BLUE_SHIFT)
+ );
+ }
+ else
+ new_pixel = old_pixel;
+
+ XPutPixel(target_image, dst_x + j, dst_y + i, new_pixel);
+
+ }
+ }
+ break;
+ case DirectColor:
+ for (i = 0; i < srch; i++) {
+
+ for (j = 0; j < srcw; j++) {
+ old_pixel = XGetPixel(reg_image, j, i);
+ red_ind = (old_pixel & reg->vis->red_mask) >> rShift;
+ green_ind = (old_pixel & reg->vis->green_mask) >> gShift;
+ blue_ind = (old_pixel & reg->vis->blue_mask) >> bShift;
+
+ new_pixel = (
+ ((colors[red_ind].red >> 8) << RED_SHIFT) |
+ ((colors[green_ind].green >> 8) << GREEN_SHIFT) |
+ ((colors[blue_ind].blue >> 8) << BLUE_SHIFT)
+ );
+ XPutPixel(target_image, dst_x + j, dst_y + i, new_pixel);
+
+ }
+ }
+ break;
+ default:
+ for (i = 0; i < srch; i++) {
+ for (j = 0; j < srcw; j++) {
+ old_pixel = XGetPixel(reg_image, j, i);
+
+ new_pixel = (
+ ((colors[old_pixel].red >> 8) << RED_SHIFT) |
+ ((colors[old_pixel].green >> 8) << GREEN_SHIFT) |
+ ((colors[old_pixel].blue >> 8) << BLUE_SHIFT)
+ );
+ XPutPixel(target_image, dst_x + j, dst_y + i, new_pixel);
+
+ }
+ }
+ break;
}
}
static XImage *
ReadRegionsInList(Display *disp, Visual *fakeVis, int depth, int format,
- unsigned int width, unsigned int height,
- XRectangle bbox, /* bounding box of grabbed area */
- list_ptr regions) /* list of regions to read from */
+ unsigned int width, unsigned int height,
+ XRectangle bbox, /* bounding box of grabbed area */
+ list_ptr regions) /* list of regions to read from */
{
- image_region_type *reg;
- int dst_x, dst_y; /* where in pixmap to write (UL) */
- int diff;
+ image_region_type *reg;
+ int dst_x, dst_y; /* where in pixmap to write (UL) */
+ int datalen, diff;
- XImage *reg_image,*ximage ;
- int srcRect_x,srcRect_y,srcRect_width,srcRect_height ;
- int bytes_per_line;
+ XImage *reg_image, *ximage;
+ int srcRect_x, srcRect_y, srcRect_width, srcRect_height;
+ int bytes_per_line;
- ximage = XCreateImage(disp,fakeVis,depth,format,0,NULL,width,height,
- 8,0) ;
+ ximage = XCreateImage(disp, fakeVis, depth, format, 0, NULL, width, height,
+ 8, 0);
bytes_per_line = ximage->bytes_per_line;
- if (format == ZPixmap)
- ximage->data = malloc(height*bytes_per_line);
- else
- ximage->data = malloc(height*bytes_per_line*depth);
+ datalen = height * bytes_per_line;
+ if (format != ZPixmap)
+ datalen *= depth;
+ ximage->data = malloc(datalen);
+ memset(ximage->data, 0, datalen);
ximage->bits_per_pixel = depth; /** Valid only if format is ZPixmap ***/
- for (reg = (image_region_type *) first_in_list( regions); reg;
- reg = (image_region_type *) next_in_list( regions))
- {
- int rect;
- struct my_XRegion *vis_reg;
- vis_reg = (struct my_XRegion *)(reg->visible_region);
- for (rect = 0;
- rect < vis_reg->numRects;
- rect++)
- {
- /** ------------------------------------------------------------------------
- Intersect bbox with visible part of region giving src rect & output
- location. Width is the min right side minus the max left side.
- Similar for height. Offset src rect so x,y are relative to
- origin of win, not the root-relative visible rect of win.
- ------------------------------------------------------------------------ **/
- srcRect_width = MIN( vis_reg->rects[rect].x2, bbox.width + bbox.x) -
- MAX( vis_reg->rects[rect].x1, bbox.x);
- srcRect_height = MIN( vis_reg->rects[rect].y2, bbox.height + bbox.y) -
- MAX( vis_reg->rects[rect].y1, bbox.y);
- diff = bbox.x - vis_reg->rects[rect].x1;
- srcRect_x = MAX( 0, diff) + (vis_reg->rects[rect].x1 - reg->x_rootrel - reg->border);
- dst_x = MAX( 0, -diff) ;
- diff = bbox.y - vis_reg->rects[rect].y1;
- srcRect_y = MAX( 0, diff) + (vis_reg->rects[rect].y1 - reg->y_rootrel - reg->border);
- dst_y = MAX( 0, -diff) ;
- reg_image = XGetImage(disp,reg->win,srcRect_x,srcRect_y,
- srcRect_width,srcRect_height,AllPlanes,format) ;
- TransferImage(disp,reg_image,srcRect_width,
- srcRect_height,reg,ximage,dst_x,dst_y) ;
- }
+ for (reg = (image_region_type *) first_in_list(regions); reg;
+ reg = (image_region_type *) next_in_list(regions)) {
+ int rect;
+ struct my_XRegion *vis_reg;
+
+ vis_reg = (struct my_XRegion *) (reg->visible_region);
+ for (rect = 0; rect < vis_reg->numRects; rect++) {
+/** ------------------------------------------------------------------------
+ Intersect bbox with visible part of region giving src rect & output
+ location. Width is the min right side minus the max left side.
+ Similar for height. Offset src rect so x,y are relative to
+ origin of win, not the root-relative visible rect of win.
+ ------------------------------------------------------------------------ **/
+ srcRect_width =
+ MIN(vis_reg->rects[rect].x2, bbox.width + bbox.x) -
+ MAX(vis_reg->rects[rect].x1, bbox.x);
+ srcRect_height =
+ MIN(vis_reg->rects[rect].y2, bbox.height + bbox.y) -
+ MAX(vis_reg->rects[rect].y1, bbox.y);
+
+ diff = bbox.x - vis_reg->rects[rect].x1;
+ srcRect_x = MAX(0,diff) +
+ (vis_reg->rects[rect].x1 - reg->x_rootrel - reg->border);
+ dst_x = MAX(0, -diff);
+
+ diff = bbox.y - vis_reg->rects[rect].y1;
+ srcRect_y = MAX(0, diff) +
+ (vis_reg->rects[rect].y1 - reg->y_rootrel - reg->border);
+ dst_y = MAX(0, -diff);
+
+ reg_image = XGetImage(disp, reg->win, srcRect_x, srcRect_y,
+ srcRect_width, srcRect_height, AllPlanes,
+ format);
+ TransferImage(disp, reg_image, srcRect_width, srcRect_height, reg,
+ ximage, dst_x, dst_y);
+ }
}
- return ximage ;
+ return ximage;
}
/** ------------------------------------------------------------------------
------------------------------------------------------------------------ **/
-XImage *ReadAreaToImage(Display *disp,
- /* root win on which grab was done */
- Window srcRootWinid,
- /* root rel UL corner of bounding box of grab */
- int x, int y,
- /* size of bounding box of grab */
- unsigned int width, unsigned int height,
- int numVisuals, XVisualInfo *pVisuals,
- int numOverlayVisuals, OverlayInfo *pOverlayVisuals,
- int numImageVisuals, XVisualInfo **pImageVisuals,
- /* list of regions to read from */
- list_ptr vis_regions,
- /* list of regions to read from */
- list_ptr vis_image_regions,
- int format, int allImage)
+XImage *
+ReadAreaToImage(Display *disp,
+ /* root win on which grab was done */
+ Window srcRootWinid,
+ /* root rel UL corner of bounding box of grab */
+ int x, int y,
+ /* size of bounding box of grab */
+ unsigned int width, unsigned int height,
+ int numVisuals, XVisualInfo *pVisuals,
+ int numOverlayVisuals, OverlayInfo *pOverlayVisuals,
+ int numImageVisuals, XVisualInfo **pImageVisuals,
+ /* list of regions to read from */
+ list_ptr vis_regions,
+ /* list of regions to read from */
+ list_ptr vis_image_regions,
+ int format, int allImage)
{
- image_region_type *reg;
- XRectangle bbox; /* bounding box of grabbed area */
- int depth ;
- XImage *ximage, *ximage_ipm = NULL;
- Visual fakeVis ;
- int x1, y1;
- XImage *image;
+ image_region_type *reg;
+ XRectangle bbox; /* bounding box of grabbed area */
+ int depth;
+ XImage *ximage, *ximage_ipm = NULL;
+ Visual fakeVis;
+ int x1, y1;
+ XImage *image;
+
#if 0
- unsigned char *pmData , *ipmData ;
+ unsigned char *pmData, *ipmData;
#endif
- int transparentColor, transparentType;
- int srcRect_x,srcRect_y,srcRect_width,srcRect_height ;
- int diff ;
- int dst_x, dst_y; /* where in pixmap to write (UL) */
- int pixel;
+ int transparentColor, transparentType;
+ int srcRect_x, srcRect_y, srcRect_width, srcRect_height;
+ int diff;
+ int dst_x, dst_y; /* where in pixmap to write (UL) */
+ int pixel;
- bbox.x = x; /* init X rect for bounding box */
+ bbox.x = x; /* init X rect for bounding box */
bbox.y = y;
bbox.width = width;
bbox.height = height;
+ initFakeVisual(&fakeVis);
- initFakeVisual(&fakeVis) ;
-
- depth = 24 ;
- ximage = ReadRegionsInList(disp,&fakeVis,depth,format,width,height,
- bbox,vis_regions) ;
+ depth = 24;
+ ximage = ReadRegionsInList(disp, &fakeVis, depth, format, width, height,
+ bbox, vis_regions);
#if 0
- pmData = (unsigned char *)ximage -> data ;
+ pmData = (unsigned char *) ximage->data;
#endif
/* if transparency possible do it again, but this time for image planes only */
- if (vis_image_regions && (vis_image_regions->next) && !allImage)
- {
- ximage_ipm = ReadRegionsInList(disp,&fakeVis,depth,format,width,height,
- bbox,vis_image_regions) ;
+ if (vis_image_regions && (vis_image_regions->next) && !allImage) {
+ ximage_ipm =
+ ReadRegionsInList(disp, &fakeVis, depth, format, width, height,
+ bbox, vis_image_regions);
#if 0
- ipmData = (unsigned char *)ximage_ipm -> data ;
+ ipmData = (unsigned char *) ximage_ipm->data;
#endif
}
/* Now tranverse the overlay visual windows and test for transparency index. */
/* If you find one, subsitute the value from the matching image plane pixmap. */
- for (reg = (image_region_type *) first_in_list( vis_regions); reg;
- reg = (image_region_type *) next_in_list( vis_regions))
- {
-
- if (src_in_overlay( reg, numOverlayVisuals, pOverlayVisuals,
- &transparentColor, &transparentType))
- {
- int test = 0 ;
- srcRect_width = MIN( reg->width + reg->x_vis, bbox.width + bbox.x)
- - MAX( reg->x_vis, bbox.x);
- srcRect_height = MIN( reg->height + reg->y_vis, bbox.height
- + bbox.y) - MAX( reg->y_vis, bbox.y);
- diff = bbox.x - reg->x_vis;
- srcRect_x = MAX( 0, diff) + (reg->x_vis - reg->x_rootrel - reg->border);
- dst_x = MAX( 0, -diff) ;
- diff = bbox.y - reg->y_vis;
- srcRect_y = MAX( 0, diff) + (reg->y_vis - reg->y_rootrel - reg->border);
- dst_y = MAX( 0, -diff) ;
- /* let's test some pixels for transparency */
- image = XGetImage(disp, reg->win, srcRect_x, srcRect_y,
- srcRect_width, srcRect_height, 0xffffffff, ZPixmap);
-
- /* let's assume byte per pixel for overlay image for now */
- if ((image->depth == 8) && (transparentType == TransparentPixel))
- {
- unsigned char *pixel_ptr;
- unsigned char *start_of_line = (unsigned char *) image->data;
-
- for (y1 = 0; y1 < srcRect_height; y1++) {
- pixel_ptr = start_of_line;
- for (x1 = 0; x1 < srcRect_width; x1++)
- {
- if (*pixel_ptr++ == transparentColor)
- {
+ for (reg = (image_region_type *) first_in_list(vis_regions); reg;
+ reg = (image_region_type *) next_in_list(vis_regions)) {
+
+ if (src_in_overlay(reg, numOverlayVisuals, pOverlayVisuals,
+ &transparentColor, &transparentType)) {
+ int test = 0;
+
+ srcRect_width =
+ MIN(reg->width + reg->x_vis, bbox.width + bbox.x)
+ - MAX(reg->x_vis, bbox.x);
+ srcRect_height =
+ MIN(reg->height + reg->y_vis, bbox.height + bbox.y)
+ - MAX(reg->y_vis, bbox.y);
+ diff = bbox.x - reg->x_vis;
+ srcRect_x =
+ MAX(0, diff) + (reg->x_vis - reg->x_rootrel - reg->border);
+ dst_x = MAX(0, -diff);
+ diff = bbox.y - reg->y_vis;
+ srcRect_y =
+ MAX(0, diff) + (reg->y_vis - reg->y_rootrel - reg->border);
+ dst_y = MAX(0, -diff);
+ /* let's test some pixels for transparency */
+ image = XGetImage(disp, reg->win, srcRect_x, srcRect_y,
+ srcRect_width, srcRect_height, 0xffffffff,
+ ZPixmap);
+
+ /* let's assume byte per pixel for overlay image for now */
+ if ((image->depth == 8) && (transparentType == TransparentPixel)) {
+ unsigned char *pixel_ptr;
+ unsigned char *start_of_line = (unsigned char *) image->data;
+
+ for (y1 = 0; y1 < srcRect_height; y1++) {
+ pixel_ptr = start_of_line;
+ for (x1 = 0; x1 < srcRect_width; x1++) {
+ if (*pixel_ptr++ == transparentColor) {
#if 0
- *pmData++ = *ipmData++;
- *pmData++ = *ipmData++;
- *pmData++ = *ipmData++;
+ *pmData++ = *ipmData++;
+ *pmData++ = *ipmData++;
+ *pmData++ = *ipmData++;
#endif
- pixel = XGetPixel(ximage_ipm,dst_x+x1,dst_y+y1) ;
- XPutPixel(ximage,dst_x+x1, dst_y+y1,pixel);
-
- if(!test){
- test = 1 ;
- }
- }
+ pixel =
+ XGetPixel(ximage_ipm, dst_x + x1, dst_y + y1);
+ XPutPixel(ximage, dst_x + x1, dst_y + y1, pixel);
+
+ if (!test) {
+ test = 1;
+ }
+ }
#if 0
- else {
- pmData +=3;
- ipmData +=3;
- }
+ else {
+ pmData += 3;
+ ipmData += 3;
+ }
#endif
- }
- start_of_line += image->bytes_per_line;
- }
- } else {
- if (transparentType == TransparentPixel) {
- for (y1 = 0; y1 < srcRect_height; y1++) {
- for (x1 = 0; x1 < srcRect_width; x1++)
- {
- int pixel_value = XGetPixel(image, x1, y1);
- if (pixel_value == transparentColor)
- {
+ }
+ start_of_line += image->bytes_per_line;
+ }
+ }
+ else {
+ if (transparentType == TransparentPixel) {
+ for (y1 = 0; y1 < srcRect_height; y1++) {
+ for (x1 = 0; x1 < srcRect_width; x1++) {
+ int pixel_value = XGetPixel(image, x1, y1);
+
+ if (pixel_value == transparentColor) {
#if 0
- *pmData++ = *ipmData++;
- *pmData++ = *ipmData++;
- *pmData++ = *ipmData++;
+ *pmData++ = *ipmData++;
+ *pmData++ = *ipmData++;
+ *pmData++ = *ipmData++;
#endif
- pixel = XGetPixel(ximage_ipm,dst_x+x1,dst_y+y1) ;
- XPutPixel(ximage,dst_x+x1, dst_y+y1,pixel);
- if(!test){
- test = 1 ;
- }
- }
+ pixel =
+ XGetPixel(ximage_ipm, dst_x + x1,
+ dst_y + y1);
+ XPutPixel(ximage, dst_x + x1, dst_y + y1,
+ pixel);
+ if (!test) {
+ test = 1;
+ }
+ }
#if 0
- else {
- pmData +=3;
- ipmData +=3;
- }
+ else {
+ pmData += 3;
+ ipmData += 3;
+ }
#endif
- }
- }
- } else {
- for (y1 = 0; y1 < srcRect_height; y1++) {
- for (x1 = 0; x1 < srcRect_width; x1++)
- {
- int pixel_value = XGetPixel(image, x1, y1);
- if (pixel_value & transparentColor)
- {
+ }
+ }
+ }
+ else {
+ for (y1 = 0; y1 < srcRect_height; y1++) {
+ for (x1 = 0; x1 < srcRect_width; x1++) {
+ int pixel_value = XGetPixel(image, x1, y1);
+
+ if (pixel_value & transparentColor) {
#if 0
- *pmData++ = *ipmData++;
- *pmData++ = *ipmData++;
- *pmData++ = *ipmData++;
+ *pmData++ = *ipmData++;
+ *pmData++ = *ipmData++;
+ *pmData++ = *ipmData++;
#endif
- pixel = XGetPixel(ximage_ipm,dst_x+x1,dst_y+y1) ;
- XPutPixel(ximage,dst_x+x1, dst_y+y1,pixel);
- if(!test){
- test = 1 ;
- }
- }
+ pixel =
+ XGetPixel(ximage_ipm, dst_x + x1,
+ dst_y + y1);
+ XPutPixel(ximage, dst_x + x1, dst_y + y1,
+ pixel);
+ if (!test) {
+ test = 1;
+ }
+ }
#if 0
- else {
- pmData +=3;
- ipmData +=3;
- }
+ else {
+ pmData += 3;
+ ipmData += 3;
+ }
#endif
- }
- }
- }
- }
- XDestroyImage (image);
- } /* end of src_in_overlay */
+ }
+ }
+ }
+ }
+ XDestroyImage(image);
+ } /* end of src_in_overlay */
} /** end transparency **/
- destroy_region_list( vis_regions);
- if (vis_image_regions) destroy_region_list( vis_image_regions );
+ destroy_region_list(vis_regions);
+ if (vis_image_regions)
+ destroy_region_list(vis_image_regions);
FreeXVisualInfo(pVisuals, pOverlayVisuals, pImageVisuals);
XSync(disp, 0);
@@ -623,39 +615,39 @@ XImage *ReadAreaToImage(Display *disp,
image_wins must point to an existing list struct that's already
been zeroed (zero_list()).
------------------------------------------------------------------------ **/
-static void make_src_list(Display *disp, list_ptr image_wins,
- /* bnding box of area we want */
- XRectangle *bbox,
- Window curr,
- /* pos of curr WRT root */
- int x_rootrel, int y_rootrel,
- XWindowAttributes *curr_attrs,
- /* visible part of curr, not obscurred by ancestors */
- XRectangle *pclip)
+static void
+make_src_list(Display *disp, list_ptr image_wins,
+ /* bnding box of area we want */
+ XRectangle *bbox,
+ Window curr,
+ /* pos of curr WRT root */
+ int x_rootrel, int y_rootrel,
+ XWindowAttributes *curr_attrs,
+ /* visible part of curr, not obscurred by ancestors */
+ XRectangle *pclip)
{
XWindowAttributes child_attrs;
- Window root, parent, *child; /* variables for XQueryTree() */
- Window *save_child_list; /* variables for XQueryTree() */
- unsigned int nchild; /* variables for XQueryTree() */
- XRectangle child_clip; /* vis part of child */
+ Window root, parent, *child; /* variables for XQueryTree() */
+ Window *save_child_list; /* variables for XQueryTree() */
+ unsigned int nchild; /* variables for XQueryTree() */
+ XRectangle child_clip; /* vis part of child */
int curr_clipX, curr_clipY, curr_clipRt, curr_clipBt;
/* check that win is mapped & not outside bounding box */
if (curr_attrs->map_state == IsViewable &&
- curr_attrs->class == InputOutput &&
- !( pclip->x >= (int) (bbox->x + bbox->width) ||
- pclip->y >= (int) (bbox->y + bbox->height) ||
- (int) (pclip->x + pclip->width) <= bbox->x ||
- (int) (pclip->y + pclip->height) <= bbox->y)) {
-
- XQueryTree( disp, curr, &root, &parent, &child, &nchild );
- save_child_list = child; /* so we can free list when we're done */
- add_window_to_list( image_wins, curr, x_rootrel, y_rootrel,
- pclip->x, pclip->y,
- pclip->width, pclip->height,
- curr_attrs->border_width,curr_attrs->visual,
- curr_attrs->colormap, parent);
-
+ curr_attrs->class == InputOutput &&
+ !(pclip->x >= (int) (bbox->x + bbox->width) ||
+ pclip->y >= (int) (bbox->y + bbox->height) ||
+ (int) (pclip->x + pclip->width) <= bbox->x ||
+ (int) (pclip->y + pclip->height) <= bbox->y)) {
+
+ XQueryTree(disp, curr, &root, &parent, &child, &nchild);
+ save_child_list = child; /* so we can free list when we're done */
+ add_window_to_list(image_wins, curr, x_rootrel, y_rootrel,
+ pclip->x, pclip->y,
+ pclip->width, pclip->height,
+ curr_attrs->border_width, curr_attrs->visual,
+ curr_attrs->colormap, parent);
/** ------------------------------------------------------------------------
set RR coords of right (Rt), left (X), bottom (Bt) and top (Y)
@@ -664,47 +656,47 @@ static void make_src_list(Display *disp, list_ptr image_wins,
child loop, we figure the clip rect for each child by adding in
it's rectangle (not taking into account the child's borders).
------------------------------------------------------------------------ **/
- curr_clipX = MAX( pclip->x, x_rootrel + (int) curr_attrs->border_width);
- curr_clipY = MAX( pclip->y, y_rootrel + (int) curr_attrs->border_width);
- curr_clipRt = MIN( pclip->x + (int) pclip->width,
- x_rootrel + (int) curr_attrs->width +
- 2 * (int) curr_attrs->border_width);
- curr_clipBt = MIN( pclip->y + (int) pclip->height,
- y_rootrel + (int) curr_attrs->height +
- 2 * (int) curr_attrs->border_width);
-
- while (nchild--) {
- int new_width, new_height;
- int child_xrr, child_yrr; /* root relative x & y of child */
-
- XGetWindowAttributes( disp, *child, &child_attrs);
-
- /* intersect parent & child clip rects */
- child_xrr = x_rootrel + child_attrs.x + curr_attrs->border_width;
- child_clip.x = MAX( curr_clipX, child_xrr);
- new_width = MIN( curr_clipRt, child_xrr + (int) child_attrs.width
- + 2 * child_attrs.border_width)
- - child_clip.x;
- if (new_width >= 0) {
- child_clip.width = new_width;
-
- child_yrr = y_rootrel + child_attrs.y +
- curr_attrs->border_width;
- child_clip.y = MAX( curr_clipY, child_yrr);
- new_height = MIN( curr_clipBt,
- child_yrr + (int) child_attrs.height +
- 2 * child_attrs.border_width)
- - child_clip.y;
- if (new_height >= 0) {
- child_clip.height = new_height;
- make_src_list( disp, image_wins, bbox, *child,
- child_xrr, child_yrr,
- &child_attrs, &child_clip);
- }
- }
- child++;
- }
- XFree( save_child_list);
+ curr_clipX = MAX(pclip->x, x_rootrel + (int) curr_attrs->border_width);
+ curr_clipY = MAX(pclip->y, y_rootrel + (int) curr_attrs->border_width);
+ curr_clipRt = MIN(pclip->x + (int) pclip->width,
+ x_rootrel + (int) curr_attrs->width +
+ 2 * (int) curr_attrs->border_width);
+ curr_clipBt = MIN(pclip->y + (int) pclip->height,
+ y_rootrel + (int) curr_attrs->height +
+ 2 * (int) curr_attrs->border_width);
+
+ while (nchild--) {
+ int new_width, new_height;
+ int child_xrr, child_yrr; /* root relative x & y of child */
+
+ XGetWindowAttributes(disp, *child, &child_attrs);
+
+ /* intersect parent & child clip rects */
+ child_xrr = x_rootrel + child_attrs.x + curr_attrs->border_width;
+ child_clip.x = MAX(curr_clipX, child_xrr);
+ new_width = MIN(curr_clipRt, child_xrr + (int) child_attrs.width
+ + 2 * child_attrs.border_width)
+ - child_clip.x;
+ if (new_width >= 0) {
+ child_clip.width = new_width;
+
+ child_yrr = y_rootrel + child_attrs.y +
+ curr_attrs->border_width;
+ child_clip.y = MAX(curr_clipY, child_yrr);
+ new_height = MIN(curr_clipBt,
+ child_yrr + (int) child_attrs.height +
+ 2 * child_attrs.border_width)
+ - child_clip.y;
+ if (new_height >= 0) {
+ child_clip.height = new_height;
+ make_src_list(disp, image_wins, bbox, *child,
+ child_xrr, child_yrr,
+ &child_attrs, &child_clip);
+ }
+ }
+ child++;
+ }
+ XFree(save_child_list);
}
}
@@ -717,126 +709,133 @@ static void make_src_list(Display *disp, list_ptr image_wins,
there will be two regions in the list.
Returns a pointer to the list.
------------------------------------------------------------------------ **/
-static list_ptr make_region_list(Display *disp, Window win, XRectangle *bbox,
- int *hasNonDefault, int numImageVisuals,
- XVisualInfo **pImageVisuals, int *allImage)
+static list_ptr
+make_region_list(Display *disp, Window win, XRectangle *bbox,
+ int *hasNonDefault, int numImageVisuals,
+ XVisualInfo **pImageVisuals, int *allImage)
{
- XWindowAttributes win_attrs;
- list image_wins;
- list_ptr image_regions;
- list_ptr srcs_left;
- image_region_type *new_reg;
- image_win_type *base_src, *src;
- Region bbox_region = XCreateRegion();
- XRectangle clip;
- int image_only;
-
- int count=0 ;
+ XWindowAttributes win_attrs;
+ list image_wins;
+ list_ptr image_regions;
+ list_ptr srcs_left;
+ image_region_type *new_reg;
+ image_win_type *base_src, *src;
+ Region bbox_region = XCreateRegion();
+ XRectangle clip;
+ int image_only;
+ int count = 0;
*hasNonDefault = False;
- XUnionRectWithRegion( bbox, bbox_region, bbox_region);
- XGetWindowAttributes( disp, win, &win_attrs);
+ XUnionRectWithRegion(bbox, bbox_region, bbox_region);
+ XGetWindowAttributes(disp, win, &win_attrs);
- zero_list( &image_wins);
+ zero_list(&image_wins);
clip.x = 0;
clip.y = 0;
- clip.width = win_attrs.width;
+ clip.width = win_attrs.width;
clip.height = win_attrs.height;
- make_src_list( disp, &image_wins, bbox, win,
- 0 /* x_rootrel */, 0 /* y_rootrel */, &win_attrs, &clip);
+ make_src_list(disp, &image_wins, bbox, win,
+ 0 /* x_rootrel */, 0 /* y_rootrel */, &win_attrs, &clip);
image_regions = new_list();
- image_only = (*allImage) ? True:False;
-
- for (base_src = (image_win_type *) first_in_list( &image_wins); base_src;
- base_src = (image_win_type *) next_in_list( &image_wins))
- {
- /* test for image visual */
- if (!image_only || src_in_image(base_src, numImageVisuals, pImageVisuals))
- {
- /* find a window whose visual hasn't been put in list yet */
- if (!src_in_region_list( base_src, image_regions))
- {
- if (! (new_reg = (image_region_type *)
- malloc( sizeof( image_region_type)))) {
- return (list_ptr) NULL;
- }
- count++;
-
- new_reg->visible_region = XCreateRegion();
- new_reg->win = base_src->win;
- new_reg->vis = base_src->vis;
- new_reg->cmap = base_src->cmap;
- new_reg->x_rootrel = base_src->x_rootrel;
- new_reg->y_rootrel = base_src->y_rootrel;
- new_reg->x_vis = base_src->x_vis;
- new_reg->y_vis = base_src->y_vis;
- new_reg->width = base_src->width;
- new_reg->height = base_src->height;
- new_reg->border = base_src->border_width;
-
- srcs_left = (list_ptr) dup_list_head( &image_wins, START_AT_CURR);
- for (src = (image_win_type *) first_in_list( srcs_left); src;
- src = (image_win_type *) next_in_list( srcs_left)) {
- if (SAME_REGIONS( base_src, src)) {
- add_rect_to_image_region( new_reg, src->x_vis, src->y_vis,
- src->width, src->height);
- }
- else {
- if (!image_only || src_in_image(src, numImageVisuals, pImageVisuals))
- {
- subtr_rect_from_image_region( new_reg, src->x_vis,
- src->y_vis, src->width, src->height);
- }
- }
- }
- XIntersectRegion( bbox_region, new_reg->visible_region,
- new_reg->visible_region);
- if (! XEmptyRegion( new_reg->visible_region)) {
- add_to_list( image_regions, new_reg);
- if (new_reg->vis != DefaultVisualOfScreen( win_attrs.screen) ||
- new_reg->cmap != DefaultColormapOfScreen(
- win_attrs.screen)) {
- *hasNonDefault = True;
- }
- }
- else {
- XDestroyRegion( new_reg->visible_region);
- free( (void *) new_reg);
- }
- }
- } else *allImage = 0;
+ image_only = (*allImage) ? True : False;
+
+ for (base_src = (image_win_type *) first_in_list(&image_wins); base_src;
+ base_src = (image_win_type *) next_in_list(&image_wins)) {
+ /* test for image visual */
+ if (!image_only ||
+ src_in_image(base_src, numImageVisuals, pImageVisuals)) {
+ /* find a window whose visual hasn't been put in list yet */
+ if (!src_in_region_list(base_src, image_regions)) {
+ if (!(new_reg = (image_region_type *)
+ malloc(sizeof(image_region_type)))) {
+ return (list_ptr) NULL;
+ }
+ count++;
+
+ new_reg->visible_region = XCreateRegion();
+ new_reg->win = base_src->win;
+ new_reg->vis = base_src->vis;
+ new_reg->cmap = base_src->cmap;
+ new_reg->x_rootrel = base_src->x_rootrel;
+ new_reg->y_rootrel = base_src->y_rootrel;
+ new_reg->x_vis = base_src->x_vis;
+ new_reg->y_vis = base_src->y_vis;
+ new_reg->width = base_src->width;
+ new_reg->height = base_src->height;
+ new_reg->border = base_src->border_width;
+
+ srcs_left =
+ (list_ptr) dup_list_head(&image_wins, START_AT_CURR);
+ for (src = (image_win_type *) first_in_list(srcs_left); src;
+ src = (image_win_type *) next_in_list(srcs_left)) {
+ if (SAME_REGIONS(base_src, src)) {
+ add_rect_to_image_region(new_reg,
+ src->x_vis, src->y_vis,
+ src->width, src->height);
+ }
+ else {
+ if (!image_only ||
+ src_in_image(src, numImageVisuals, pImageVisuals))
+ {
+ subtr_rect_from_image_region(new_reg, src->x_vis,
+ src->y_vis, src->width,
+ src->height);
+ }
+ }
+ }
+ XIntersectRegion(bbox_region, new_reg->visible_region,
+ new_reg->visible_region);
+ if (!XEmptyRegion(new_reg->visible_region)) {
+ add_to_list(image_regions, new_reg);
+ if (new_reg->vis != DefaultVisualOfScreen(win_attrs.screen)
+ || new_reg->cmap !=
+ DefaultColormapOfScreen(win_attrs.screen)) {
+ *hasNonDefault = True;
+ }
+ }
+ else {
+ XDestroyRegion(new_reg->visible_region);
+ free((void *) new_reg);
+ }
+ }
+ }
+ else
+ *allImage = 0;
}
- delete_list( &image_wins, True);
- XDestroyRegion( bbox_region);
+ delete_list(&image_wins, True);
+ XDestroyRegion(bbox_region);
return image_regions;
}
+
/** ------------------------------------------------------------------------
Destructor called from destroy_region_list().
------------------------------------------------------------------------ **/
-static void destroy_image_region(image_region_type *image_region)
+static void
+destroy_image_region(image_region_type *image_region)
{
- XDestroyRegion( image_region->visible_region);
- free( (void *) image_region);
+ XDestroyRegion(image_region->visible_region);
+ free((void *) image_region);
}
/** ------------------------------------------------------------------------
Destroys the region list, destroying all the regions contained in it.
------------------------------------------------------------------------ **/
-static void destroy_region_list(list_ptr rlist)
+static void
+destroy_region_list(list_ptr rlist)
{
- delete_list_destroying( rlist, (DESTRUCT_FUNC_PTR)destroy_image_region);
+ delete_list_destroying(rlist, (DESTRUCT_FUNC_PTR) destroy_image_region);
}
-
/** ------------------------------------------------------------------------
Subtracts the specified rectangle from the region in image_region.
First converts the rectangle to a region of its own, since X
only provides a way to subtract one region from another, not a
rectangle from a region.
------------------------------------------------------------------------ **/
-static void subtr_rect_from_image_region(image_region_type *image_region,
- int x, int y, int width, int height)
+static void
+subtr_rect_from_image_region(image_region_type *image_region,
+ int x, int y, int width, int height)
{
XRectangle rect;
Region rect_region;
@@ -846,18 +845,18 @@ static void subtr_rect_from_image_region(image_region_type *image_region,
rect.y = y;
rect.width = width;
rect.height = height;
- XUnionRectWithRegion( &rect, rect_region, rect_region);
- XSubtractRegion( image_region->visible_region, rect_region,
- image_region->visible_region);
- XDestroyRegion( rect_region);
+ XUnionRectWithRegion(&rect, rect_region, rect_region);
+ XSubtractRegion(image_region->visible_region, rect_region,
+ image_region->visible_region);
+ XDestroyRegion(rect_region);
}
-
/** ------------------------------------------------------------------------
Adds the specified rectangle to the region in image_region.
------------------------------------------------------------------------ **/
-static void add_rect_to_image_region(image_region_type *image_region,
- int x, int y, int width, int height)
+static void
+add_rect_to_image_region(image_region_type *image_region,
+ int x, int y, int width, int height)
{
XRectangle rect;
@@ -865,44 +864,43 @@ static void add_rect_to_image_region(image_region_type *image_region,
rect.y = y;
rect.width = width;
rect.height = height;
- XUnionRectWithRegion( &rect, image_region->visible_region,
- image_region->visible_region);
+ XUnionRectWithRegion(&rect, image_region->visible_region,
+ image_region->visible_region);
}
-
/** ------------------------------------------------------------------------
Returns TRUE if the given src's visual is already represented in
the image_regions list, FALSE otherwise.
------------------------------------------------------------------------ **/
-static int src_in_region_list(image_win_type *src, list_ptr image_regions)
+static int
+src_in_region_list(image_win_type *src, list_ptr image_regions)
{
- image_region_type *ir;
+ image_region_type *ir;
- for (ir = (image_region_type *) first_in_list( image_regions); ir;
- ir = (image_region_type *) next_in_list( image_regions)) {
- if (SAME_REGIONS( ir, src)) {
+ for (ir = (image_region_type *) first_in_list(image_regions); ir;
+ ir = (image_region_type *) next_in_list(image_regions)) {
+ if (SAME_REGIONS(ir, src)) {
- return 1;
- }
+ return 1;
+ }
}
return 0;
}
-
/** ------------------------------------------------------------------------
Makes a new entry in image_wins with the given fields filled in.
------------------------------------------------------------------------ **/
-static void add_window_to_list(list_ptr image_wins, Window w,
- int xrr, int yrr, int x_vis, int y_vis,
- int width, int height, int border_width,
- Visual *vis, Colormap cmap, Window parent)
+static void
+add_window_to_list(list_ptr image_wins, Window w,
+ int xrr, int yrr, int x_vis, int y_vis,
+ int width, int height, int border_width,
+ Visual *vis, Colormap cmap, Window parent)
{
- image_win_type *new_src;
-
- if ((new_src = (image_win_type *) malloc( sizeof( image_win_type))) == NULL)
+ image_win_type *new_src;
- return;
+ if ((new_src = (image_win_type *) malloc(sizeof(image_win_type))) == NULL)
+ return;
new_src->win = w;
new_src->x_rootrel = xrr;
@@ -915,22 +913,22 @@ static void add_window_to_list(list_ptr image_wins, Window w,
new_src->vis = vis;
new_src->cmap = cmap;
new_src->parent = parent;
- add_to_list( image_wins, new_src);
+ add_to_list(image_wins, new_src);
}
/** ------------------------------------------------------------------------
Returns TRUE if the given src's visual is in the image planes,
FALSE otherwise.
------------------------------------------------------------------------ **/
-static int src_in_image(image_win_type *src, int numImageVisuals,
- XVisualInfo **pImageVisuals)
+static int
+src_in_image(image_win_type *src, int numImageVisuals,
+ XVisualInfo **pImageVisuals)
{
- int i;
+ int i;
- for (i = 0 ; i < numImageVisuals ; i++)
- {
- if (pImageVisuals[i]->visual == src->vis)
- return 1;
+ for (i = 0; i < numImageVisuals; i++) {
+ if (pImageVisuals[i]->visual == src->vis)
+ return 1;
}
return 0;
}
@@ -940,25 +938,20 @@ static int src_in_image(image_win_type *src, int numImageVisuals,
Returns TRUE if the given src's visual is in the overlay planes
and transparency is possible, FALSE otherwise.
------------------------------------------------------------------------ **/
-static int src_in_overlay(image_region_type *src, int numOverlayVisuals,
- OverlayInfo *pOverlayVisuals,
- int *transparentColor, int *transparentType)
+static int
+src_in_overlay(image_region_type *src, int numOverlayVisuals,
+ OverlayInfo *pOverlayVisuals,
+ int *transparentColor, int *transparentType)
{
- int i;
-
- for (i = 0 ; i < numOverlayVisuals ; i++)
- {
- if (((pOverlayVisuals[i].pOverlayVisualInfo)->visual == src->vis)
- && (pOverlayVisuals[i].transparentType != None))
- {
- *transparentColor = pOverlayVisuals[i].value;
- *transparentType = pOverlayVisuals[i].transparentType;
- return 1;
- }
-
- else {
- }
-
+ int i;
+
+ for (i = 0; i < numOverlayVisuals; i++) {
+ if (((pOverlayVisuals[i].pOverlayVisualInfo)->visual == src->vis)
+ && (pOverlayVisuals[i].transparentType != None)) {
+ *transparentColor = pOverlayVisuals[i].value;
+ *transparentType = pOverlayVisuals[i].transparentType;
+ return 1;
+ }
}
return 0;
}
@@ -977,15 +970,13 @@ static int src_in_overlay(image_region_type *src, int numOverlayVisuals,
******************************************************************************/
-
#define STATIC_GRAY 0x01
#define GRAY_SCALE 0x02
#define PSEUDO_COLOR 0x04
#define TRUE_COLOR 0x10
#define DIRECT_COLOR 0x11
-
-static int weCreateServerOverlayVisualsProperty = False;
+static int weCreateServerOverlayVisualsProperty = False;
/******************************************************************************
@@ -1010,129 +1001,118 @@ static int weCreateServerOverlayVisualsProperty = False;
*
******************************************************************************/
-int GetXVisualInfo(/* Which X server (aka "display"). */
- Display *display,
- /* Which screen of the "display". */
- int screen,
- /* Non-zero if there's at least one overlay visual and
- * if at least one of those supports a transparent pixel. */
- int *transparentOverlays,
- /* Number of XVisualInfo struct's pointed to by pVisuals. */
- int *numVisuals,
- /* All of the device's visuals. */
- XVisualInfo **pVisuals,
- /* Number of OverlayInfo's pointed to by pOverlayVisuals.
- * If this number is zero, the device does not have
- * overlay planes. */
- int *numOverlayVisuals,
- /* The device's overlay plane visual information. */
- OverlayInfo **pOverlayVisuals,
- /* Number of XVisualInfo's pointed to by pImageVisuals. */
- int *numImageVisuals,
- /* The device's image visuals. */
- XVisualInfo ***pImageVisuals)
+int
+GetXVisualInfo( /* Which X server (aka "display"). */
+ Display *display,
+ /* Which screen of the "display". */
+ int screen,
+ /* Non-zero if there's at least one overlay visual and
+ * if at least one of those supports a transparent pixel. */
+ int *transparentOverlays,
+ /* Number of XVisualInfo struct's pointed to by pVisuals. */
+ int *numVisuals,
+ /* All of the device's visuals. */
+ XVisualInfo **pVisuals,
+ /* Number of OverlayInfo's pointed to by pOverlayVisuals.
+ * If this number is zero, the device does not have
+ * overlay planes. */
+ int *numOverlayVisuals,
+ /* The device's overlay plane visual information. */
+ OverlayInfo **pOverlayVisuals,
+ /* Number of XVisualInfo's pointed to by pImageVisuals. */
+ int *numImageVisuals,
+ /* The device's image visuals. */
+ XVisualInfo ***pImageVisuals)
{
- XVisualInfo getVisInfo; /* Paramters of XGetVisualInfo */
- int mask;
- XVisualInfo *pVis, **pIVis; /* Faster, local copies */
- OverlayInfo *pOVis;
- OverlayVisualPropertyRec *pOOldVis;
- int nVisuals, nOVisuals;
- Atom overlayVisualsAtom; /* Parameters for XGetWindowProperty */
- Atom actualType;
+ XVisualInfo getVisInfo; /* Parameters of XGetVisualInfo */
+ int mask;
+ XVisualInfo *pVis, **pIVis; /* Faster, local copies */
+ OverlayInfo *pOVis;
+ OverlayVisualPropertyRec *pOOldVis;
+ int nVisuals, nOVisuals;
+ Atom overlayVisualsAtom; /* Parameters for XGetWindowProperty */
+ Atom actualType;
unsigned long numLongs, bytesAfter;
- int actualFormat;
- int nImageVisualsAlloced; /* Values to process the XVisualInfo */
- int imageVisual; /* array */
-
+ int actualFormat;
+ int nImageVisualsAlloced; /* Values to process the XVisualInfo */
+ int imageVisual; /* array */
/* First, get the list of visuals for this screen. */
getVisInfo.screen = screen;
mask = VisualScreenMask;
*pVisuals = XGetVisualInfo(display, mask, &getVisInfo, numVisuals);
- if ((nVisuals = *numVisuals) <= 0)
- {
- /* Return that the information wasn't sucessfully obtained: */
- return(1);
+ if ((nVisuals = *numVisuals) <= 0) {
+ /* Return that the information wasn't sucessfully obtained: */
+ return (1);
}
pVis = *pVisuals;
-
/* Now, get the overlay visual information for this screen. To obtain
* this information, get the SERVER_OVERLAY_VISUALS property.
*/
overlayVisualsAtom = XInternAtom(display, "SERVER_OVERLAY_VISUALS", True);
- if (overlayVisualsAtom != None)
- {
- /* Since the Atom exists, we can request the property's contents. The
- * do-while loop makes sure we get the entire list from the X server.
- */
- bytesAfter = 0;
- numLongs = sizeof(OverlayVisualPropertyRec) / sizeof(long);
- do
- {
- numLongs += bytesAfter * sizeof(long);
- XGetWindowProperty(display, RootWindow(display, screen),
- overlayVisualsAtom, 0, numLongs, False,
- overlayVisualsAtom, &actualType, &actualFormat,
- &numLongs, &bytesAfter, (unsigned char**) pOverlayVisuals);
- } while (bytesAfter > 0);
-
-
- /* Calculate the number of overlay visuals in the list. */
- *numOverlayVisuals = numLongs / (sizeof(OverlayVisualPropertyRec) / sizeof(long));
+ if (overlayVisualsAtom != None) {
+ /* Since the Atom exists, we can request the property's contents. The
+ * do-while loop makes sure we get the entire list from the X server.
+ */
+ bytesAfter = 0;
+ numLongs = sizeof(OverlayVisualPropertyRec) / sizeof(long);
+ do {
+ numLongs += bytesAfter * sizeof(long);
+ XGetWindowProperty(display, RootWindow(display, screen),
+ overlayVisualsAtom, 0, numLongs, False,
+ overlayVisualsAtom, &actualType, &actualFormat,
+ &numLongs, &bytesAfter,
+ (unsigned char **) pOverlayVisuals);
+ } while (bytesAfter > 0);
+
+ /* Calculate the number of overlay visuals in the list. */
+ *numOverlayVisuals =
+ numLongs / (sizeof(OverlayVisualPropertyRec) / sizeof(long));
}
- else
- {
- /* This screen doesn't have overlay planes. */
- *numOverlayVisuals = 0;
- *pOverlayVisuals = NULL;
- *transparentOverlays = 0;
+ else {
+ /* This screen doesn't have overlay planes. */
+ *numOverlayVisuals = 0;
+ *pOverlayVisuals = NULL;
+ *transparentOverlays = 0;
}
-
/* Process the pVisuals array. */
*numImageVisuals = 0;
nImageVisualsAlloced = 1;
pIVis = *pImageVisuals = (XVisualInfo **) malloc(sizeof(XVisualInfo *));
- while (--nVisuals >= 0)
- {
- nOVisuals = *numOverlayVisuals;
- pOVis = *pOverlayVisuals;
- imageVisual = True;
- while (--nOVisuals >= 0)
- {
- pOOldVis = (OverlayVisualPropertyRec *) pOVis;
- if (pVis->visualid == pOOldVis->visualID)
- {
- imageVisual = False;
- pOVis->pOverlayVisualInfo = pVis;
- if (pOVis->transparentType == TransparentPixel)
- *transparentOverlays = 1;
- }
- pOVis++;
- }
- if (imageVisual)
- {
- if ((*numImageVisuals += 1) > nImageVisualsAlloced)
- {
- nImageVisualsAlloced++;
- *pImageVisuals = (XVisualInfo **)
- realloc(*pImageVisuals, (nImageVisualsAlloced * sizeof(XVisualInfo *)));
- pIVis = *pImageVisuals + (*numImageVisuals - 1);
- }
- *pIVis++ = pVis;
- }
- pVis++;
+ while (--nVisuals >= 0) {
+ nOVisuals = *numOverlayVisuals;
+ pOVis = *pOverlayVisuals;
+ imageVisual = True;
+ while (--nOVisuals >= 0) {
+ pOOldVis = (OverlayVisualPropertyRec *) pOVis;
+ if (pVis->visualid == pOOldVis->visualID) {
+ imageVisual = False;
+ pOVis->pOverlayVisualInfo = pVis;
+ if (pOVis->transparentType == TransparentPixel)
+ *transparentOverlays = 1;
+ }
+ pOVis++;
+ }
+ if (imageVisual) {
+ if ((*numImageVisuals += 1) > nImageVisualsAlloced) {
+ nImageVisualsAlloced++;
+ *pImageVisuals = (XVisualInfo **)
+ realloc(*pImageVisuals,
+ (nImageVisualsAlloced * sizeof(XVisualInfo *)));
+ pIVis = *pImageVisuals + (*numImageVisuals - 1);
+ }
+ *pIVis++ = pVis;
+ }
+ pVis++;
}
-
/* Return that the information was sucessfully obtained: */
- return(0);
-
-} /* GetXVisualInfo() */
+ return (0);
+} /* GetXVisualInfo() */
/******************************************************************************
*
@@ -1142,14 +1122,15 @@ int GetXVisualInfo(/* Which X server (aka "display"). */
*
******************************************************************************/
-void FreeXVisualInfo(XVisualInfo *pVisuals, OverlayInfo *pOverlayVisuals,
- XVisualInfo **pImageVisuals)
+void
+FreeXVisualInfo(XVisualInfo *pVisuals, OverlayInfo *pOverlayVisuals,
+ XVisualInfo **pImageVisuals)
{
XFree(pVisuals);
if (weCreateServerOverlayVisualsProperty)
- free(pOverlayVisuals);
+ free(pOverlayVisuals);
else
- XFree(pOverlayVisuals);
+ XFree(pOverlayVisuals);
free(pImageVisuals);
-} /* FreeXVisualInfo() */
+} /* FreeXVisualInfo() */
diff --git a/app/xwd/multiVis.h b/app/xwd/multiVis.h
index 28b940b1c..28488b1c9 100644
--- a/app/xwd/multiVis.h
+++ b/app/xwd/multiVis.h
@@ -34,20 +34,15 @@ from The Open Group.
------------------------------------------------------------------------ **/
-extern int GetMultiVisualRegions(
- Display *, Window, int, int, unsigned int,
- unsigned int, int *, int *, XVisualInfo **, int *,
- OverlayInfo **, int *, XVisualInfo ***, list_ptr *,
- list_ptr *, int *
-);
-
-extern XImage *ReadAreaToImage(
- Display *, Window, int, int, unsigned int,
- unsigned int, int, XVisualInfo *, int,
- OverlayInfo *, int, XVisualInfo **, list_ptr,
- list_ptr, int, int
-);
-
-extern void initFakeVisual(
- Visual *
-);
+extern int GetMultiVisualRegions(Display *, Window, int, int, unsigned int,
+ unsigned int, int *, int *, XVisualInfo **,
+ int *, OverlayInfo **, int *, XVisualInfo ***,
+ list_ptr *, list_ptr *, int *);
+
+extern XImage *ReadAreaToImage(Display *, Window, int, int, unsigned int,
+ unsigned int, int, XVisualInfo *, int,
+ OverlayInfo *, int, XVisualInfo **, list_ptr,
+ list_ptr, int, int
+ );
+
+extern void initFakeVisual(Visual *);
diff --git a/app/xwd/xwd.c b/app/xwd/xwd.c
index c3a053b79..708a06e1a 100644
--- a/app/xwd/xwd.c
+++ b/app/xwd/xwd.c
@@ -111,29 +111,29 @@ static long parse_long(char *);
static int Get24bitDirectColors(XColor **);
static int ReadColors(Visual *, Colormap, XColor **);
-
-static long parse_long (char *s)
+static long
+parse_long(char *s)
{
long retval = 0L;
int thesign = 1;
if (s && s[0]) {
- switch(s[0]) {
- case '-':
- (void) sscanf (s + 1, "%lu", &retval);
- thesign = -1;
- break;
- case '0':
- (void) sscanf (s + 1, "%lo", &retval);
- break;
- case 'x':
- case 'X':
- (void) sscanf (s + 1, "%lx", &retval);
- break;
- default:
- (void) sscanf (s, "%lu", &retval);
- break;
- }
+ switch (s[0]) {
+ case '-':
+ (void) sscanf(s + 1, "%lu", &retval);
+ thesign = -1;
+ break;
+ case '0':
+ (void) sscanf(s + 1, "%lo", &retval);
+ break;
+ case 'x':
+ case 'X':
+ (void) sscanf(s + 1, "%lx", &retval);
+ break;
+ default:
+ (void) sscanf(s, "%lu", &retval);
+ break;
+ }
}
return (thesign * retval);
}
@@ -154,66 +154,68 @@ main(int argc, char **argv)
target_win = Select_Window_Args(&argc, argv);
for (i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "-nobdrs")) {
- nobdrs = True;
- continue;
- }
- if (!strcmp(argv[i], "-debug")) {
- debug = True;
- continue;
- }
- if (!strcmp(argv[i], "-help"))
- usage(NULL);
- if (!strcmp(argv[i], "-out")) {
- if (++i >= argc) usage("-out requires an argument");
- if (!(out_file = fopen(argv[i], "wb")))
- Fatal_Error("Can't open output file as specified.");
- standard_out = False;
- continue;
- }
- if (!strcmp(argv[i], "-xy")) {
- format = XYPixmap;
- continue;
- }
- if (!strcmp(argv[i], "-screen")) {
- on_root = True;
- continue;
- }
- if (!strcmp(argv[i], "-icmap")) {
- use_installed = True;
- continue;
- }
- if (!strcmp(argv[i], "-add")) {
- if (++i >= argc) usage("-add requires an argument");
- add_pixel_value = parse_long (argv[i]);
- continue;
- }
- if (!strcmp(argv[i], "-frame")) {
- frame_only = True;
- continue;
- }
- if (!strcmp(argv[i], "-silent")) {
- silent = True;
- continue;
- }
- if (!strcmp(argv[i], "-version")) {
- puts(PACKAGE_STRING);
- exit(0);
- }
- fprintf (stderr, "%s: unrecognized argument '%s'\n",
- program_name, argv[i]);
- usage(NULL);
+ if (!strcmp(argv[i], "-nobdrs")) {
+ nobdrs = True;
+ continue;
+ }
+ if (!strcmp(argv[i], "-debug")) {
+ debug = True;
+ continue;
+ }
+ if (!strcmp(argv[i], "-help"))
+ usage(NULL);
+ if (!strcmp(argv[i], "-out")) {
+ if (++i >= argc)
+ usage("-out requires an argument");
+ if (!(out_file = fopen(argv[i], "wb")))
+ Fatal_Error("Can't open output file as specified.");
+ standard_out = False;
+ continue;
+ }
+ if (!strcmp(argv[i], "-xy")) {
+ format = XYPixmap;
+ continue;
+ }
+ if (!strcmp(argv[i], "-screen")) {
+ on_root = True;
+ continue;
+ }
+ if (!strcmp(argv[i], "-icmap")) {
+ use_installed = True;
+ continue;
+ }
+ if (!strcmp(argv[i], "-add")) {
+ if (++i >= argc)
+ usage("-add requires an argument");
+ add_pixel_value = parse_long(argv[i]);
+ continue;
+ }
+ if (!strcmp(argv[i], "-frame")) {
+ frame_only = True;
+ continue;
+ }
+ if (!strcmp(argv[i], "-silent")) {
+ silent = True;
+ continue;
+ }
+ if (!strcmp(argv[i], "-version")) {
+ puts(PACKAGE_STRING);
+ exit(0);
+ }
+ fprintf(stderr, "%s: unrecognized argument '%s'\n",
+ program_name, argv[i]);
+ usage(NULL);
}
#ifdef WIN32
if (standard_out)
- _setmode(fileno(out_file), _O_BINARY);
+ _setmode(fileno(out_file), _O_BINARY);
#endif
/*
* Let the user select the target window.
*/
if (target_win == None)
- target_win = Select_Window(dpy, !frame_only);
+ target_win = Select_Window(dpy, !frame_only);
/*
* Dump it!
@@ -222,8 +224,8 @@ main(int argc, char **argv)
XCloseDisplay(dpy);
if (fclose(out_file)) {
- perror("xwd");
- exit(1);
+ perror("xwd");
+ exit(1);
}
exit(0);
}
@@ -231,24 +233,23 @@ main(int argc, char **argv)
static int
Get24bitDirectColors(XColor **colors)
{
- int i , ncolors = 256 ;
- XColor *tcol ;
+ int i, ncolors = 256;
+ XColor *tcol;
- *colors = tcol = (XColor *)malloc(sizeof(XColor) * ncolors) ;
+ *colors = tcol = (XColor *) malloc(sizeof(XColor) * ncolors);
- for(i=0 ; i < ncolors ; i++)
- {
- tcol[i].pixel = i << 16 | i << 8 | i ;
- tcol[i].red = tcol[i].green = tcol[i].blue = i << 8 | i ;
+ for (i = 0; i < ncolors; i++) {
+ tcol[i].pixel = i << 16 | i << 8 | i;
+ tcol[i].red = tcol[i].green = tcol[i].blue = i << 8 | i;
+ tcol[i].flags = 0;
}
- return ncolors ;
+ return ncolors;
}
-
/*
* Window_Dump: dump a window to a file which must already be open for
- * writting.
+ * writing.
*/
void
@@ -272,44 +273,45 @@ Window_Dump(Window window, FILE *out)
XWDFileHeader header;
XWDColor xwdcolor;
- int transparentOverlays , multiVis;
- int numVisuals;
- XVisualInfo *pVisuals;
- int numOverlayVisuals;
- OverlayInfo *pOverlayVisuals;
- int numImageVisuals;
- XVisualInfo **pImageVisuals;
- list_ptr vis_regions; /* list of regions to read from */
- list_ptr vis_image_regions ;
- Visual vis_h,*vis ;
- int allImage = 0 ;
+ int transparentOverlays, multiVis;
+ int numVisuals;
+ XVisualInfo *pVisuals;
+ int numOverlayVisuals;
+ OverlayInfo *pOverlayVisuals;
+ int numImageVisuals;
+ XVisualInfo **pImageVisuals;
+ list_ptr vis_regions; /* list of regions to read from */
+ list_ptr vis_image_regions;
+ Visual vis_h, *vis;
+ int allImage = 0;
/*
* Inform the user not to alter the screen.
*/
if (!silent) {
#ifdef XKB
- XkbStdBell(dpy,None,50,XkbBI_Wait);
+ XkbStdBell(dpy, None, 50, XkbBI_Wait);
#else
- XBell(dpy,FEEP_VOLUME);
+ XBell(dpy, FEEP_VOLUME);
#endif
- XFlush(dpy);
+ XFlush(dpy);
}
/*
* Get the parameters of the window being dumped.
*/
- if (debug) outl("xwd: Getting target window information.\n");
- if(!XGetWindowAttributes(dpy, window, &win_info))
- Fatal_Error("Can't get target window attributes.");
+ if (debug)
+ outl("xwd: Getting target window information.\n");
+ if (!XGetWindowAttributes(dpy, window, &win_info))
+ Fatal_Error("Can't get target window attributes.");
/* handle any frame window */
- if (!XTranslateCoordinates (dpy, window, RootWindow (dpy, screen), 0, 0,
- &absx, &absy, &dummywin)) {
- fprintf (stderr,
- "%s: unable to translate window coordinates (%d,%d)\n",
- program_name, absx, absy);
- exit (1);
+ if (!XTranslateCoordinates(dpy, window, RootWindow(dpy, screen), 0, 0,
+ &absx, &absy, &dummywin)) {
+ fprintf(stderr,
+ "%s: unable to translate window coordinates (%d,%d)\n",
+ program_name, absx, absy);
+ exit(1);
}
win_info.x = absx;
win_info.y = absy;
@@ -317,27 +319,30 @@ Window_Dump(Window window, FILE *out)
height = win_info.height;
if (!nobdrs) {
- absx -= win_info.border_width;
- absy -= win_info.border_width;
- width += (2 * win_info.border_width);
- height += (2 * win_info.border_width);
+ absx -= win_info.border_width;
+ absy -= win_info.border_width;
+ width += (2 * win_info.border_width);
+ height += (2 * win_info.border_width);
}
- dwidth = DisplayWidth (dpy, screen);
- dheight = DisplayHeight (dpy, screen);
-
+ dwidth = DisplayWidth(dpy, screen);
+ dheight = DisplayHeight(dpy, screen);
/* clip to window */
- if (absx < 0) width += absx, absx = 0;
- if (absy < 0) height += absy, absy = 0;
- if (absx + width > dwidth) width = dwidth - absx;
- if (absy + height > dheight) height = dheight - absy;
-
- XFetchName(dpy, window, &win_name);
- if (!win_name || !win_name[0]) {
- win_name = default_win_name;
- got_win_name = False;
- } else {
- got_win_name = True;
+ if (absx < 0)
+ width += absx, absx = 0;
+ if (absy < 0)
+ height += absy, absy = 0;
+ if (absx + width > dwidth)
+ width = dwidth - absx;
+ if (absy + height > dheight)
+ height = dheight - absy;
+
+ if (!XFetchName(dpy, window, &win_name) || !win_name || !win_name[0]) {
+ win_name = default_win_name;
+ got_win_name = False;
+ }
+ else {
+ got_win_name = True;
}
/* sizeof(char) is included for the null string terminator. */
@@ -350,75 +355,82 @@ Window_Dump(Window window, FILE *out)
x = absx - win_info.x;
y = absy - win_info.y;
- multiVis = GetMultiVisualRegions(dpy,RootWindow(dpy, screen),
- absx, absy,
- width, height,&transparentOverlays,&numVisuals, &pVisuals,
- &numOverlayVisuals,&pOverlayVisuals,&numImageVisuals,
- &pImageVisuals,&vis_regions,&vis_image_regions,&allImage) ;
- if (on_root || multiVis)
- {
- if(!multiVis)
- image = XGetImage (dpy, RootWindow(dpy, screen), absx, absy,
- width, height, AllPlanes, format);
- else
- image = ReadAreaToImage(dpy, RootWindow(dpy, screen), absx, absy,
- width, height,
- numVisuals,pVisuals,numOverlayVisuals,pOverlayVisuals,
- numImageVisuals, pImageVisuals,vis_regions,
- vis_image_regions,format,allImage);
+ multiVis = GetMultiVisualRegions(dpy, RootWindow(dpy, screen),
+ absx, absy,
+ width, height, &transparentOverlays,
+ &numVisuals, &pVisuals,
+ &numOverlayVisuals, &pOverlayVisuals,
+ &numImageVisuals, &pImageVisuals,
+ &vis_regions, &vis_image_regions,
+ &allImage);
+ if (on_root || multiVis) {
+ if (!multiVis)
+ image = XGetImage(dpy, RootWindow(dpy, screen), absx, absy,
+ width, height, AllPlanes, format);
+ else
+ image = ReadAreaToImage(dpy, RootWindow(dpy, screen), absx, absy,
+ width, height,
+ numVisuals, pVisuals,
+ numOverlayVisuals, pOverlayVisuals,
+ numImageVisuals, pImageVisuals,
+ vis_regions, vis_image_regions,
+ format, allImage);
}
else
- image = XGetImage (dpy, window, x, y, width, height, AllPlanes, format);
+ image = XGetImage(dpy, window, x, y, width, height, AllPlanes, format);
if (!image) {
- fprintf (stderr, "%s: unable to get image at %dx%d+%d+%d\n",
- program_name, width, height, x, y);
- exit (1);
+ fprintf(stderr, "%s: unable to get image at %dx%d+%d+%d\n",
+ program_name, width, height, x, y);
+ exit(1);
}
- if (add_pixel_value != 0) XAddPixel (image, add_pixel_value);
+ if (add_pixel_value != 0)
+ XAddPixel(image, add_pixel_value);
/*
* Determine the pixmap size.
*/
buffer_size = Image_Size(image);
- if (debug) outl("xwd: Getting Colors.\n");
+ if (debug)
+ outl("xwd: Getting Colors.\n");
- if( !multiVis)
- {
- ncolors = Get_XColors(&win_info, &colors);
- vis = win_info.visual ;
+ if (!multiVis) {
+ ncolors = Get_XColors(&win_info, &colors);
+ vis = win_info.visual;
}
- else
- {
- ncolors = Get24bitDirectColors(&colors) ;
- initFakeVisual(&vis_h) ;
- vis = &vis_h ;
+ else {
+ ncolors = Get24bitDirectColors(&colors);
+ initFakeVisual(&vis_h);
+ vis = &vis_h;
}
/*
* Inform the user that the image has been retrieved.
*/
if (!silent) {
#ifdef XKB
- XkbStdBell(dpy,window,FEEP_VOLUME,XkbBI_Proceed);
- XkbStdBell(dpy,window,FEEP_VOLUME,XkbBI_RepeatingLastBell);
+ XkbStdBell(dpy, window, FEEP_VOLUME, XkbBI_Proceed);
+ XkbStdBell(dpy, window, FEEP_VOLUME, XkbBI_RepeatingLastBell);
#else
- XBell(dpy, FEEP_VOLUME);
- XBell(dpy, FEEP_VOLUME);
+ XBell(dpy, FEEP_VOLUME);
+ XBell(dpy, FEEP_VOLUME);
#endif
- XFlush(dpy);
+ XFlush(dpy);
}
/*
* Calculate header size.
*/
- if (debug) outl("xwd: Calculating header size.\n");
+ if (debug)
+ outl("xwd: Calculating header size.\n");
header_size = SIZEOF(XWDheader) + (CARD32) win_name_size;
/*
* Write out header information.
*/
- if (debug) outl("xwd: Constructing and dumping file header.\n");
+ if (debug)
+ outl("xwd: Constructing and dumping file header.\n");
+ memset(&header, 0, SIZEOF(XWDheader));
header.header_size = (CARD32) header_size;
header.file_version = (CARD32) XWD_FILE_VERSION;
header.pixmap_format = (CARD32) format;
@@ -455,64 +467,70 @@ Window_Dump(Window window, FILE *out)
header.window_bdrwidth = (CARD32) win_info.border_width;
if (*(char *) &swaptest) {
- _swaplong((char *) &header, sizeof(header));
- for (i = 0; i < ncolors; i++) {
- _swaplong((char *) &colors[i].pixel, sizeof(CARD32));
- _swapshort((char *) &colors[i].red, 3 * sizeof(short));
- }
+ _swaplong((char *) &header, sizeof(header));
+ for (i = 0; i < ncolors; i++) {
+ _swaplong((char *) &colors[i].pixel, sizeof(CARD32));
+ _swapshort((char *) &colors[i].red, 3 * sizeof(short));
+ }
}
- if (fwrite((char *)&header, SIZEOF(XWDheader), 1, out) != 1 ||
- fwrite(win_name, win_name_size, 1, out) != 1) {
- perror("xwd");
- exit(1);
+ if (fwrite((char *) &header, SIZEOF(XWDheader), 1, out) != 1 ||
+ fwrite(win_name, win_name_size, 1, out) != 1) {
+ perror("xwd");
+ exit(1);
}
/*
* Write out the color maps, if any
*/
- if (debug) outl("xwd: Dumping %d colors.\n", ncolors);
+ if (debug)
+ outl("xwd: Dumping %d colors.\n", ncolors);
for (i = 0; i < ncolors; i++) {
- xwdcolor.pixel = colors[i].pixel;
- xwdcolor.red = colors[i].red;
- xwdcolor.green = colors[i].green;
- xwdcolor.blue = colors[i].blue;
- xwdcolor.flags = colors[i].flags;
- if (fwrite((char *) &xwdcolor, SIZEOF(XWDColor), 1, out) != 1) {
- perror("xwd");
- exit(1);
- }
+ xwdcolor.pixel = colors[i].pixel;
+ xwdcolor.red = colors[i].red;
+ xwdcolor.green = colors[i].green;
+ xwdcolor.blue = colors[i].blue;
+ xwdcolor.flags = colors[i].flags;
+ if (fwrite((char *) &xwdcolor, SIZEOF(XWDColor), 1, out) != 1) {
+ perror("xwd");
+ exit(1);
+ }
}
/*
* Write out the buffer.
*/
- if (debug) outl("xwd: Dumping pixmap. bufsize=%d\n",buffer_size);
+ if (debug)
+ outl("xwd: Dumping pixmap. bufsize=%d\n", buffer_size);
/*
- * This copying of the bit stream (data) to a file is to be replaced
+ * This copying of the bit stream (data) to a file is to be replaced
* by an Xlib call which hasn't been written yet. It is not clear
* what other functions of xwd will be taken over by this (as yet)
* non-existant X function.
*/
if (fwrite(image->data, (int) buffer_size, 1, out) != 1) {
- perror("xwd");
- exit(1);
+ perror("xwd");
+ exit(1);
}
/*
* free the color buffer.
*/
- if(debug && ncolors > 0) outl("xwd: Freeing colors.\n");
- if(ncolors > 0) free(colors);
+ if (debug && ncolors > 0)
+ outl("xwd: Freeing colors.\n");
+ if (ncolors > 0)
+ free(colors);
/*
* Free window name string.
*/
- if (debug) outl("xwd: Freeing window name string.\n");
- if (got_win_name) XFree(win_name);
+ if (debug)
+ outl("xwd: Freeing window name string.\n");
+ if (got_win_name)
+ XFree(win_name);
/*
* Free image
@@ -527,26 +545,43 @@ void
usage(const char *errmsg)
{
if (errmsg != NULL)
- fprintf (stderr, "%s: %s\n", program_name, errmsg);
-
- fprintf (stderr,
-"usage: %s [-display host:dpy] [-debug] [-help] %s [-nobdrs] [-out <file>]",
- program_name, "[{-root|-id <id>|-name <name>}]");
- fprintf (stderr, " [-xy] [-add value] [-frame] [-version]\n");
+ fprintf(stderr, "%s: %s\n", program_name, errmsg);
+
+ fprintf(stderr,
+ "Usage: %s [options] [-root| -id <wdid>| -name <wdname>] > mywddump\n",
+ program_name);
+ fprintf(stderr,
+ " %s [options] [-root| -id <wdid>| -name <wdname>] -out mywddump\n",
+ program_name);
+ fputs("Options:\n" " -help Print this message\n"
+ " -version Print the program version and exit\n"
+ " -debug Enable debug mode\n"
+ " -d, -display <host:dpy> Specify server to connect\n"
+ " -nobdrs Exclude window borders\n"
+ " -out <file> Specify an output file\n"
+ " -xy Select XY dumping format for color displays\n"
+ " -add <value> Add a signed value to every pixel\n"
+ " -frame Include window manager frame\n"
+ " -root Select the root window\n"
+ " -id <wdid> Select a window by its resource id\n"
+ " -name <wdname> Select a window by its WM_NAME property\n"
+ " -icmap Use the first colormap of the screen\n"
+ " -screen Send the request against the root window\n"
+ " -silent Don't ring any bells\n", stderr);
exit(1);
}
-
/*
* Determine the pixmap size.
*/
-int Image_Size(XImage *image)
+int
+Image_Size(XImage *image)
{
if (image->format != ZPixmap)
- return(image->bytes_per_line * image->height * image->depth);
+ return (image->bytes_per_line * image->height * image->depth);
- return(image->bytes_per_line * image->height);
+ return (image->bytes_per_line * image->height);
}
#define lowbit(x) ((x) & (~(x) + 1))
@@ -554,79 +589,80 @@ int Image_Size(XImage *image)
static int
ReadColors(Visual *vis, Colormap cmap, XColor **colors)
{
- int i,ncolors ;
+ int i, ncolors;
ncolors = vis->map_entries;
- if (!(*colors = (XColor *) malloc (sizeof(XColor) * ncolors)))
- Fatal_Error("Out of memory!");
-
- if (vis->class == DirectColor ||
- vis->class == TrueColor) {
- Pixel red, green, blue, red1, green1, blue1;
-
- red = green = blue = 0;
- red1 = lowbit(vis->red_mask);
- green1 = lowbit(vis->green_mask);
- blue1 = lowbit(vis->blue_mask);
- for (i=0; i<ncolors; i++) {
- (*colors)[i].pixel = red|green|blue;
- (*colors)[i].pad = 0;
- red += red1;
- if (red > vis->red_mask)
- red = 0;
- green += green1;
- if (green > vis->green_mask)
- green = 0;
- blue += blue1;
- if (blue > vis->blue_mask)
- blue = 0;
- }
- } else {
- for (i=0; i<ncolors; i++) {
- (*colors)[i].pixel = i;
- (*colors)[i].pad = 0;
- }
+ if (!(*colors = (XColor *) malloc(sizeof(XColor) * ncolors)))
+ Fatal_Error("Out of memory!");
+
+ if (vis->class == DirectColor || vis->class == TrueColor) {
+ Pixel red, green, blue, red1, green1, blue1;
+
+ red = green = blue = 0;
+ red1 = lowbit(vis->red_mask);
+ green1 = lowbit(vis->green_mask);
+ blue1 = lowbit(vis->blue_mask);
+ for (i = 0; i < ncolors; i++) {
+ (*colors)[i].pixel = red | green | blue;
+ (*colors)[i].pad = 0;
+ red += red1;
+ if (red > vis->red_mask)
+ red = 0;
+ green += green1;
+ if (green > vis->green_mask)
+ green = 0;
+ blue += blue1;
+ if (blue > vis->blue_mask)
+ blue = 0;
+ }
+ }
+ else {
+ for (i = 0; i < ncolors; i++) {
+ (*colors)[i].pixel = i;
+ (*colors)[i].pad = 0;
+ }
}
XQueryColors(dpy, cmap, *colors, ncolors);
- return(ncolors);
+ return (ncolors);
}
/*
* Get the XColors of all pixels in image - returns # of colors
*/
-int Get_XColors(XWindowAttributes *win_info, XColor **colors)
+int
+Get_XColors(XWindowAttributes *win_info, XColor **colors)
{
int i, ncolors;
Colormap cmap = win_info->colormap;
if (use_installed)
- /* assume the visual will be OK ... */
- cmap = XListInstalledColormaps(dpy, win_info->root, &i)[0];
+ /* assume the visual will be OK ... */
+ cmap = XListInstalledColormaps(dpy, win_info->root, &i)[0];
if (!cmap)
- return(0);
- ncolors = ReadColors(win_info->visual,cmap,colors) ;
- return ncolors ;
+ return (0);
+ ncolors = ReadColors(win_info->visual, cmap, colors);
+ return ncolors;
}
void
-_swapshort (register char *bp, register unsigned n)
+_swapshort(register char *bp, register unsigned n)
{
register char c;
register char *ep = bp + n;
while (bp < ep) {
- c = *bp;
- *bp = *(bp + 1);
- bp++;
- *bp++ = c;
+ c = *bp;
+ *bp = *(bp + 1);
+ bp++;
+ *bp++ = c;
}
}
void
-_swaplong (register char *bp, register unsigned n)
+_swaplong(register char *bp, register unsigned n)
{
register char c;
register char *ep = bp + n;