Update to xprop 1.1.0

This commit is contained in:
matthieu 2009-10-24 15:10:42 +00:00
parent a97776ca7f
commit fe899414b6
13 changed files with 4156 additions and 2688 deletions

View File

@ -21,7 +21,7 @@
bin_PROGRAMS = xprop
AM_CFLAGS = $(XPROP_CFLAGS)
AM_CFLAGS = $(CWARNFLAGS) $(XPROP_CFLAGS)
xprop_LDADD = $(XPROP_LIBS)
xprop_SOURCES = \
@ -39,14 +39,14 @@ appmandir = $(APP_MAN_DIR)
appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@)
EXTRA_DIST = $(appman_PRE) ChangeLog autogen.sh
EXTRA_DIST = $(appman_PRE) ChangeLog
CLEANFILES = $(appman_DATA)
MAINTAINERCLEANFILES = ChangeLog
.PHONY: ChangeLog
ChangeLog:
(GIT_DIR=$(top_srcdir)/.git git-log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2)
$(CHANGELOG_CMD)
dist-hook: ChangeLog
@ -72,7 +72,7 @@ MAN_SUBSTS = \
SUFFIXES = .$(APP_MAN_SUFFIX) .man
.man.$(APP_MAN_SUFFIX):
sed $(MAN_SUBSTS) < $< > $@
$(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
if LINT
ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \

View File

@ -110,7 +110,6 @@ am__remove_distdir = \
DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.bz2
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
@ -126,8 +125,10 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CHANGELOG_CMD = @CHANGELOG_CMD@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CWARNFLAGS = @CWARNFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
@ -140,6 +141,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FILE_MAN_DIR = @FILE_MAN_DIR@
FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
@ -176,8 +178,6 @@ VERSION = @VERSION@
XPROP_CFLAGS = @XPROP_CFLAGS@
XPROP_LIBS = @XPROP_LIBS@
ac_ct_CC = @ac_ct_CC@
ac_ct_STRIP = @ac_ct_STRIP@
ac_pt_PKG_CONFIG = @ac_pt_PKG_CONFIG@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
@ -192,28 +192,36 @@ build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
distcleancheck_listfiles = @distcleancheck_listfiles@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
AM_CFLAGS = $(XPROP_CFLAGS)
AM_CFLAGS = $(CWARNFLAGS) $(XPROP_CFLAGS)
xprop_LDADD = $(XPROP_LIBS)
xprop_SOURCES = \
dsimple.c \
@ -227,7 +235,7 @@ appman_PRE = \
appmandir = $(APP_MAN_DIR)
appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@)
EXTRA_DIST = $(appman_PRE) ChangeLog autogen.sh
EXTRA_DIST = $(appman_PRE) ChangeLog
CLEANFILES = $(appman_DATA)
MAINTAINERCLEANFILES = ChangeLog
SED = sed
@ -658,12 +666,12 @@ uninstall-am: uninstall-appmanDATA uninstall-binPROGRAMS \
.PHONY: ChangeLog
ChangeLog:
(GIT_DIR=$(top_srcdir)/.git git-log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2)
$(CHANGELOG_CMD)
dist-hook: ChangeLog
.man.$(APP_MAN_SUFFIX):
sed $(MAN_SUBSTS) < $< > $@
$(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
@LINT_TRUE@lint:
@LINT_TRUE@ $(LINT) $(ALL_LINT_FLAGS) $(xprop_SOURCES)

View File

@ -0,0 +1,25 @@
xprop displays window and font properties of an X server.
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/xprop
http://cgit.freedesktop.org/xorg/app/xprop
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

138
app/xprop/aclocal.m4 vendored
View File

@ -995,6 +995,7 @@ AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
dnl xorg-macros.m4. Generated from xorg-macros.m4.in xorgversion.m4 by configure.
dnl
dnl Copyright 2005-2006 Sun Microsystems, Inc. All rights reserved.
dnl
@ -1031,27 +1032,24 @@ dnl of the copyright holder.
# your configure.ac with the minimum required version, such as:
# XORG_MACROS_VERSION(1.1)
#
# To force at least a version with this macro defined, also add:
# m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.1 or later before running autoconf/autogen])])
# To ensure that this macro is defined, also add:
# m4_ifndef([XORG_MACROS_VERSION],
# [m4_fatal([must install xorg-macros 1.1 or later before running autoconf/autogen])])
#
#
# See the "minimum version" comment for each macro you use to see what
# version you require.
AC_DEFUN([XORG_MACROS_VERSION],[
[XORG_MACROS_needed_version=$1
XORG_MACROS_needed_major=`echo $XORG_MACROS_needed_version | sed 's/\..*$//'`
XORG_MACROS_needed_minor=`echo $XORG_MACROS_needed_version | sed -e 's/^[0-9]*\.//' -e 's/\..*$//'`]
AC_MSG_CHECKING([if xorg-macros used to generate configure is at least ${XORG_MACROS_needed_major}.${XORG_MACROS_needed_minor}])
[XORG_MACROS_version=1.1.6
XORG_MACROS_major=`echo $XORG_MACROS_version | sed 's/\..*$//'`
XORG_MACROS_minor=`echo $XORG_MACROS_version | sed -e 's/^[0-9]*\.//' -e 's/\..*$//'`]
if test $XORG_MACROS_major -ne $XORG_MACROS_needed_major ; then
AC_MSG_ERROR([configure built with incompatible version of xorg-macros.m4 - requires version ${XORG_MACROS_major}.x])
fi
if test $XORG_MACROS_minor -lt $XORG_MACROS_needed_minor ; then
AC_MSG_ERROR([configure built with too old of a version of xorg-macros.m4 - requires version ${XORG_MACROS_major}.${XORG_MACROS_minor}.0 or newer])
fi
AC_MSG_RESULT([yes, $XORG_MACROS_version])
m4_defun([XORG_MACROS_VERSION],[
m4_define([vers_have], [1.3.0])
m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.])))
m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.])))
m4_if(m4_cmp(maj_have, maj_needed), 0,,
[m4_fatal([xorg-macros major version ]maj_needed[ is required but ]vers_have[ found])])
m4_if(m4_version_compare(vers_have, [$1]), -1,
[m4_fatal([xorg-macros version $1 or higher is required but ]vers_have[ found])])
m4_undefine([vers_have])
m4_undefine([maj_have])
m4_undefine([maj_needed])
]) # XORG_MACROS_VERSION
# XORG_PROG_RAWCPP()
@ -1076,6 +1074,10 @@ else
if test `${RAWCPP} -undef < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
RAWCPPFLAGS=-undef
AC_MSG_RESULT([yes])
# under Cygwin unix is still defined even with -undef
elif test `${RAWCPP} -undef -ansi < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then
RAWCPPFLAGS="-undef -ansi"
AC_MSG_RESULT([yes, with -ansi])
else
AC_MSG_ERROR([${RAWCPP} defines unix with or without -undef. I don't know what to do.])
fi
@ -1188,7 +1190,9 @@ AC_SUBST([ADMIN_MAN_DIR])
# Whether or not the necessary tools and files are found can be checked
# with the AM_CONDITIONAL "BUILD_LINUXDOC"
AC_DEFUN([XORG_CHECK_LINUXDOC],[
XORG_SGML_PATH=$prefix/share/sgml
if test x$XORG_SGML_PATH = x ; then
XORG_SGML_PATH=$prefix/share/sgml
fi
HAVE_DEFS_ENT=
if test x"$cross_compiling" = x"yes" ; then
@ -1244,7 +1248,9 @@ AC_SUBST(MAKE_HTML)
# indicates whether the necessary tools and files are found and, if set,
# $(MAKE_XXX) blah.sgml will produce blah.xxx.
AC_DEFUN([XORG_CHECK_DOCBOOK],[
XORG_SGML_PATH=$prefix/share/sgml
if test x$XORG_SGML_PATH = x ; then
XORG_SGML_PATH=$prefix/share/sgml
fi
HAVE_DEFS_ENT=
BUILDTXTDOC=no
BUILDPDFDOC=no
@ -1310,7 +1316,7 @@ AC_SUBST(MAKE_HTML)
# their AM_CFLAGS (or other appropriate *_CFLAGS) to use them.
AC_DEFUN([XORG_CHECK_MALLOC_ZERO],[
AC_ARG_ENABLE(malloc0returnsnull,
AC_HELP_STRING([--enable-malloc0returnsnull],
AS_HELP_STRING([--enable-malloc0returnsnull],
[malloc(0) returns NULL (default: auto)]),
[MALLOC_ZERO_RETURNS_NULL=$enableval],
[MALLOC_ZERO_RETURNS_NULL=auto])
@ -1362,7 +1368,7 @@ AC_SUBST([XTMALLOC_ZERO_CFLAGS])
AC_DEFUN([XORG_WITH_LINT],[
# Allow checking code with lint, sparse, etc.
AC_ARG_WITH(lint, [AC_HELP_STRING([--with-lint],
AC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint],
[Use a lint-style source code checker (default: disabled)])],
[use_lint=$withval], [use_lint=no])
if test "x$use_lint" = "xyes" ; then
@ -1403,7 +1409,7 @@ AM_CONDITIONAL(LINT, [test x$LINT != xno])
AC_DEFUN([XORG_LINT_LIBRARY],[
AC_REQUIRE([XORG_WITH_LINT])
# Build lint "library" for more indepth checks of programs calling this library
AC_ARG_ENABLE(lint-library, [AC_HELP_STRING([--enable-lint-library],
AC_ARG_ENABLE(lint-library, [AS_HELP_STRING([--enable-lint-library],
[Create lint library (default: disabled)])],
[make_lint_lib=$enableval], [make_lint_lib=no])
if test "x$make_lint_lib" != "xno" ; then
@ -1421,6 +1427,75 @@ AM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno])
]) # XORG_LINT_LIBRARY
# XORG_CWARNFLAGS
# ---------------
# Minimum version: 1.2.0
#
# Defines CWARNFLAGS to enable C compiler warnings.
#
AC_DEFUN([XORG_CWARNFLAGS], [
AC_REQUIRE([AC_PROG_CC])
if test "x$GCC" = xyes ; then
CWARNFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes \
-Wmissing-declarations -Wnested-externs -fno-strict-aliasing \
-Wbad-function-cast"
case `$CC -dumpversion` in
3.4.* | 4.*)
CWARNFLAGS="$CWARNFLAGS -Wold-style-definition -Wdeclaration-after-statement"
;;
esac
else
AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
if test "x$SUNCC" = "xyes"; then
CWARNFLAGS="-v"
fi
fi
AC_SUBST(CWARNFLAGS)
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
]) # XORG_CWARNFLAGS
# XORG_STRICT_OPTION
# -----------------------
# Minimum version: 1.3.0
#
# Add configure option to enable strict compilation
AC_DEFUN([XORG_STRICT_OPTION], [
AC_REQUIRE([AC_PROG_CC])
AC_REQUIRE([AC_PROG_CC_C99])
AC_REQUIRE([XORG_CWARNFLAGS])
AC_ARG_ENABLE(strict-compilation,
AS_HELP_STRING([--enable-strict-compilation],
[Enable all warnings from compiler and make them errors (default: disabled)]),
[STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
if test "x$STRICT_COMPILE" = "xyes"; then
AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
if test "x$GCC" = xyes ; then
STRICT_CFLAGS="-pedantic -Werror"
elif test "x$SUNCC" = "xyes"; then
STRICT_CFLAGS="-errwarn"
elif test "x$INTELCC" = "xyes"; then
STRICT_CFLAGS="-Werror"
fi
fi
CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"
AC_SUBST([CWARNFLAGS])
]) # XORG_STRICT_OPTION
# XORG_DEFAULT_OPTIONS
# --------------------
# Minimum version: 1.3.0
#
# Defines default options for X.Org modules.
#
AC_DEFUN([XORG_DEFAULT_OPTIONS], [
XORG_CWARNFLAGS
XORG_STRICT_OPTION
XORG_RELEASE_VERSION
XORG_CHANGELOG
XORG_MANPAGE_SECTIONS
]) # XORG_DEFAULT_OPTIONS
dnl Copyright 2005 Red Hat, Inc
dnl
dnl Permission to use, copy, modify, distribute, and sell this software and its
@ -1455,7 +1530,7 @@ dnl
AC_DEFUN([XORG_RELEASE_VERSION],[
AC_ARG_WITH(release-version,
AC_HELP_STRING([--with-release-version=STRING],
AS_HELP_STRING([--with-release-version=STRING],
[Use release version string in package name]),
[RELEASE_VERSION="$withval"],
[RELEASE_VERSION=""])
@ -1483,3 +1558,20 @@ AC_DEFUN([XORG_RELEASE_VERSION],[
[Patch version of this package])
])
# XORG_CHANGELOG()
# ----------------
# Minimum version: 1.2.0
#
# Defines the variable CHANGELOG_CMD as the command to generate
# ChangeLog from git.
#
# Arrange that distcleancheck ignores ChangeLog left over by distclean.
#
AC_DEFUN([XORG_CHANGELOG], [
CHANGELOG_CMD="(GIT_DIR=\$(top_srcdir)/.git git log > .changelog.tmp && \
mv .changelog.tmp ChangeLog) || (rm -f .changelog.tmp; touch ChangeLog; \
echo 'git directory not found: installing possibly empty changelog.' >&2)"
AC_SUBST([CHANGELOG_CMD])
AC_SUBST([distcleancheck_listfiles], ['find . -type f ! -name ChangeLog -print'])
]) # XORG_CHANGELOG

View File

@ -1,13 +0,0 @@
#! /bin/sh
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
ORIGDIR=`pwd`
cd $srcdir
autoreconf -v --install || exit 1
cd $ORIGDIR || exit $?
$srcdir/configure --enable-maintainer-mode "$@"

View File

@ -22,6 +22,8 @@
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include "clientwin.h"
static Atom atom_wm_state = None;
/*
@ -68,7 +70,7 @@ Window_Is_Viewable(Display * dpy, Window win)
* Children are searched in top-down stacking order.
* The first matching window is returned, None if no match is found.
*/
Window
static Window
Find_Client_In_Children(Display * dpy, Window win)
{
Window root, parent;
@ -114,7 +116,7 @@ Find_Client_In_Children(Display * dpy, Window win)
/*
* Find virtual roots (_NET_VIRTUAL_ROOTS)
*/
unsigned long *
static unsigned long *
Find_Roots(Display * dpy, Window root, unsigned int *num)
{
Atom type_ret;

View File

@ -3,6 +3,9 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

6440
app/xprop/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -21,28 +21,29 @@ dnl
dnl Process this file with autoconf to create configure.
AC_PREREQ([2.57])
AC_INIT(xprop,[1.0.4], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],xprop)
AC_INIT(xprop,[1.1.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],xprop)
AM_INIT_AUTOMAKE([dist-bzip2])
AM_MAINTAINER_MODE
AM_CONFIG_HEADER(config.h)
# Require xorg-macros version 1.1.0 or newer for XORG_WITH_LINT macro
m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.1 or later before running autoconf/autogen])])
XORG_MACROS_VERSION(1.1)
# Require xorg-macros 1.3 or later: XORG_DEFAULT_OPTIONS
m4_ifndef([XORG_MACROS_VERSION],
[m4_fatal([must install xorg-macros 1.3 or later before running autoconf/autogen])])
XORG_MACROS_VERSION(1.3)
AC_PROG_CC
AC_PROG_INSTALL
AC_CHECK_HEADERS([wchar.h wctype.h])
XORG_DEFAULT_OPTIONS
AC_CHECK_HEADERS([wchar.h wctype.h langinfo.h])
# Checks for pkg-config packages
PKG_CHECK_MODULES(XPROP, xmuu x11)
PKG_CHECK_MODULES(XPROP, x11)
AC_SUBST(XPROP_CFLAGS)
AC_SUBST(XPROP_LIBS)
XORG_WITH_LINT
XORG_MANPAGE_SECTIONS
XORG_RELEASE_VERSION
AC_OUTPUT([Makefile])

View File

@ -73,6 +73,16 @@ char *Malloc(unsigned size)
return(data);
}
/*
* Realloc: like realloc but handles out of memory using Fatal_Error:
*/
char *Realloc(char *mem, unsigned size)
{
if (!(mem = realloc (mem, size)))
Fatal_Error("Out of memory!");
return mem;
}
/*
* Get_Display_Name (argc, argv) Look for -display, -d, or host:dpy (obselete)
@ -123,8 +133,7 @@ Display *Open_Display(const char *display_name)
if (d == NULL) {
fprintf (stderr, "%s: unable to open display '%s'\n",
program_name, XDisplayName (display_name));
usage ();
/* doesn't return */
exit(1);
}
return(d);

View File

@ -59,6 +59,7 @@ extern int screen; /* The current screen */
/* Declarations for functions in just_display.c */
char *Malloc(unsigned);
char *Realloc(char *,unsigned);
char *Get_Display_Name(int *, char **);
Display *Open_Display(const char *);
void Setup_Display_And_Screen(int *, char **);

View File

@ -45,6 +45,9 @@ from The Open Group.
#include <wctype.h>
#endif
#include <locale.h>
#ifdef HAVE_LANGINFO_H
#include <langinfo.h>
#endif
#ifndef HAVE_WCTYPE_H
#define iswprint(x) isprint(x)
@ -355,7 +358,7 @@ typedef struct _propertyRec {
"?m3(\t\twindow id # to use for icon: $4\n)"\
"?m4(\t\tstarting position for icon: $5, $6\n)"\
"?m6(\t\twindow id # of group leader: $8\n)"\
"?m8(\t\tThe visible hint bit is set\n)"
"?m8(\t\tThe urgency hint bit is set\n)"
#define WM_ICON_SIZE_DFORMAT ":\n"\
"\t\tminimum icon size: $0 by $1\n"\
@ -416,6 +419,7 @@ static propertyRec windowPropTable[] = {
{"WM_NAME", XA_WM_NAME, "8t", 0 },
{"WM_PROTOCOLS", 0, "32a", ": protocols $0+\n"},
{"WM_SIZE_HINTS", XA_WM_SIZE_HINTS,"32mii", WM_SIZE_HINTS_DFORMAT },
{"_NET_WM_ICON", 0, "32o", 0 },
{"WM_STATE", 0, "32cx", WM_STATE_DFORMAT}
};
#undef ARC_DFORMAT
@ -740,6 +744,113 @@ Format_Len_String (const char *string, int len)
return result;
}
static int
is_utf8_locale (void)
{
#ifdef HAVE_LANGINFO_H
char *charmap = nl_langinfo (CODESET);
return charmap && strcmp (charmap, "UTF-8") == 0;
#else
return 0;
#endif
}
static const char *
Format_Icons (const unsigned long *icon, int len)
{
char *result = NULL, *tail = NULL;
int alloced;
const unsigned long *end = icon + len / sizeof (unsigned long);
alloced = 0;
while (icon < end)
{
unsigned long width, height;
int w, h;
int offset;
width = *icon++;
height = *icon++;
offset = (tail - result);
alloced += 80; /* For the header */
alloced += (width*4 + 8) * height; /* For the rows (plus padding) */
result = Realloc (result, alloced);
tail = &result[offset];
if (end - icon < width * height)
break;
tail += sprintf (tail, "\tIcon (%lu x %lu):\n", width, height);
if (width > 144 || height > 144)
{
tail += sprintf (tail, "\t(not shown)");
icon += width * height;
continue;
}
for (h = 0; h < height; ++h)
{
tail += sprintf (tail, "\t");
for (w = 0; w < width; ++w)
{
unsigned char a, r, g, b;
unsigned long pixel = *icon++;
unsigned long brightness;
a = (pixel & 0xff000000) >> 24;
r = (pixel & 0x00ff0000) >> 16;
g = (pixel & 0x0000ff00) >> 8;
b = (pixel & 0x000000ff);
brightness =
(a / 255.0) * (1000 - ((299 * (r / 255.0)) +
(587 * (g / 255.0)) +
(114 * (b / 255.0))));
if (is_utf8_locale())
{
static const char palette[][4] =
{
" ",
"\342\226\221", /* 25% */
"\342\226\222", /* 50% */
"\342\226\223", /* 75% */
"\342\226\210", /* 100% */
};
int idx;
idx = (brightness * ((sizeof (palette)/sizeof(palette[0])) - 1)) / 1000;
tail += sprintf (tail, "%s", palette[idx]);
}
else
{
static const char palette[] =
" .'`,^:\";~-_+<>i!lI?/\\|()1{}[]rcvunxzjftLCJUYXZO0Qoahkbdpqwm*WMB8&%$#@";
int idx;
idx = (brightness * (sizeof(palette) - 2)) / 1000;
*tail++ = palette[idx];
}
}
tail += sprintf (tail, "\n");
}
tail += sprintf (tail, "\n");
}
return result;
}
static const char *
Format_Len_Text (const char *string, int len, Atom encoding)
{
@ -859,6 +970,8 @@ Format_Thunk (thunk t, char format_char)
return Format_Mask_Word(value);
case 'a':
return Format_Atom(value);
case 'o':
return Format_Icons((const unsigned long *)t.extra_value, (int)t.value);
default:
Fatal_Error("bad format character: %c", format_char);
}
@ -1112,6 +1225,20 @@ Extract_Len_String (const char **pointer, int *length, int size, const char **st
return len;
}
static long
Extract_Icon (const char **pointer, int *length, int size, const char **icon)
{
int len = 0;
if (size != 32)
Fatal_Error("can't use format character 'o' with any size except 32.");
len = *length;
*icon = *pointer;
*length = 0;
return len;
}
static thunk *
Break_Down_Property (const char *pointer, int length, Atom type, const char *format, int size)
{
@ -1130,7 +1257,10 @@ Break_Down_Property (const char *pointer, int length, Atom type, const char *for
else if (format_char == 't') {
t.extra_encoding = type;
t.value = Extract_Len_String(&pointer,&length,size,&t.extra_value);
} else
}
else if (format_char == 'o')
t.value = Extract_Icon (&pointer,&length,size,&t.extra_value);
else
t.value = Extract_Value(&pointer,&length,size,format_char=='i');
thunks = Add_Thunk(thunks, t);
i++;
@ -1596,6 +1726,22 @@ Parse_Format_Mapping (int *argc, char ***argv)
static int spy = 0;
static int (*old_error_handler)(Display *dpy, XErrorEvent *ev);
static int spy_error_handler(Display *dpy, XErrorEvent *ev)
{
if (ev->error_code == BadWindow || ev->error_code == BadMatch) {
/* Window was destroyed */
puts("");
exit(0);
}
if (old_error_handler)
return old_error_handler(dpy, ev);
return 0;
}
int
main (int argc, char **argv)
{
@ -1738,9 +1884,15 @@ main (int argc, char **argv)
XEvent event;
const char *format, *dformat;
XSelectInput(dpy, target_win, PropertyChangeMask);
XSelectInput(dpy, target_win, PropertyChangeMask | StructureNotifyMask);
old_error_handler = XSetErrorHandler(spy_error_handler);
for (;;) {
fflush(stdout);
XNextEvent(dpy, &event);
if (event.type == DestroyNotify)
break;
if (event.type != PropertyNotify)
continue;
format = dformat = NULL;
if (props) {
int i;

View File

@ -216,6 +216,12 @@ The field is a signed integer.
m
The field is a set of bit flags, 1 meaning on.
.TP
o
The field is an array of icons, packed as a sequence of 32 bit numbers
consisting of the width, height and ARGB pixel values, as defined for
the _NET_WM_ICON property in the \fIExtended Window Manager Hints\fP
specification. A field of this type must be of size 32.
.TP
s
This field and the next ones until either a 0 or the end of the property
represent a sequence of bytes. This format character is only usable with