diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/xwininfo/ChangeLog | 287 | ||||
-rw-r--r-- | app/xwininfo/Makefile.am | 14 | ||||
-rw-r--r-- | app/xwininfo/Makefile.in | 6 | ||||
-rw-r--r-- | app/xwininfo/aclocal.m4 | 12 | ||||
-rw-r--r-- | app/xwininfo/clientwin.c | 214 | ||||
-rw-r--r-- | app/xwininfo/clientwin.h | 29 | ||||
-rw-r--r-- | app/xwininfo/configure | 44 | ||||
-rw-r--r-- | app/xwininfo/configure.ac | 6 | ||||
-rw-r--r-- | app/xwininfo/dsimple.c | 339 | ||||
-rw-r--r-- | app/xwininfo/dsimple.h | 23 | ||||
-rw-r--r-- | app/xwininfo/xwininfo.c | 268 |
11 files changed, 726 insertions, 516 deletions
diff --git a/app/xwininfo/ChangeLog b/app/xwininfo/ChangeLog index 5294bfdb8..13e7a3c85 100644 --- a/app/xwininfo/ChangeLog +++ b/app/xwininfo/ChangeLog @@ -1,46 +1,277 @@ -2006-04-01 Adam Jackson <ajax@freedesktop.org> +commit b8115ee0e43c6c03025cad72219481e3fdb119d4 +Author: James Cloos <cloos@jhcloos.com> +Date: Sun Jun 29 10:49:10 2008 -0400 - * configure.ac: - Bump to 1.0.2. + xwininfo 1.0.4 -2006-03-09 Alan Coopersmith <alan.coopersmith@sun.com> +commit c229611bcb7ee94bea5c075f5e15447e14c0f6ce +Author: Kim Woelders <kim@woelders.dk> +Date: Sun Jun 22 01:11:50 2008 -0400 - * xwininfo.c: - Clear two tiny memory leaks. (Coverity ids #900 & 901) + Fix window selection by pointer. + + This should fix things in WM’s using virtual roots as well as in tabbing WM’s. + + Signed-off-by: James Cloos <cloos@jhcloos.com> -2005-12-20 Kevin E. Martin <kem-at-freedesktop-dot-org> +commit b7e88cd9d28a3d3e467b769f3efe87f7c2f4c0a5 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Mon Aug 27 14:20:12 2007 -0700 - * configure.ac: - Update package version for X11R7 release. + Version bump: 1.0.3 -2005-12-14 Kevin E. Martin <kem-at-freedesktop-dot-org> +commit 56f0b5dfb1486e262eb514fac44c73cea4bb4471 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Mon Aug 27 14:19:39 2007 -0700 - * configure.ac: - Update package version number for final X11R7 release candidate. + Replace static ChangeLog with dist-hook to generate from git log -2005-12-06 Kevin E. Martin <kem-at-freedesktop-dot-org> +commit c8d205c30547ca526404a0b257c3cc5d40970be6 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Tue Aug 7 15:49:50 2007 -0700 - * Makefile.am: - Change *man_SOURCES ==> *man_PRE to fix autotools warnings. + Add static & const qualifiers to xwininfo.c -2005-12-03 Kevin E. Martin <kem-at-freedesktop-dot-org> +commit 77d50c0bf824f847bd9ede30c21618845258de76 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Tue Aug 7 15:38:00 2007 -0700 - * configure.ac: - Update package version number for X11R7 RC3 release. + Replace sprintf's with snprintf & strlcat -2005-11-20 Alan Coopersmith <alan.coopersmith@sun.com> +commit 118bd50a9bbc10cab7846fb6ac1a0d25ba4c3422 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Mon Aug 6 19:51:50 2007 -0700 - * configure.ac: - Change dependency from xmu to xmuu since the full xmu - (with all its baggage like Xt) is not needed here. + dsimple.c: ANSIfy function declarations -2005-11-19 Kevin E. Martin <kem-at-freedesktop-dot-org> +commit e093e4be56bb2be385a972962cf89f234e987ab4 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Mon Aug 6 19:44:01 2007 -0700 - * configure.ac: - Update dependencies to work with separate build roots. + Purge unused code from dsimple.c + + dsimple.c was originally shared source among several X apps. + Since modularization gave each app it's own copy, much of the code is + no longer needed in each app. -2005-10-18 Kevin E. Martin <kem-at-freedesktop-dot-org> +commit 59bbe12a40fdb3d39429d0d0ce809ad28116e7ed +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Mon Aug 6 19:18:34 2007 -0700 - * configure.ac: - Update package version number for RC1 release. + Rename xwininfo_CFLAGS to AM_CFLAGS to make automake-1.10 happier + + Makefile.am:27: compiling `dsimple.c' with per-target flags requires `AM_PROG_CC_C_O' in `configure.ac' +commit 5a251886c0f158f4c8a342b6fbdeebf3dbd1c0fd +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Thu May 24 18:19:48 2007 -0700 + + Man page formatting: make -geometry bold like other options + +commit 07459b14b36f15cfdfc6384019aaf020c7920cd4 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Thu May 24 18:17:05 2007 -0700 + + renamed: .cvsignore -> .gitignore + +commit 24fc2a569df9eaa776bcdddbb26bf4ea97b69d13 +Author: Alan Coopersmith <alan.coopersmith@sun.com> +Date: Thu May 24 18:16:30 2007 -0700 + + X.Org bug #10616: Add all the X info commands to See Also in man page + + X.Org Bugzilla #10616: <https://bugs.freedesktop.org/show_bug.cgi?id=10616> + Reported upstream from + Debian bug #350313 <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=350313> + +commit 412a3232373131634072df0d0b4843abf360def4 +Author: Adam Jackson <ajax@nwnk.net> +Date: Sun Apr 2 01:19:30 2006 +0000 + + Bump to 1.0.2. + +commit 8d62050702532be39688d468663466199492510b +Author: Alan Coopersmith <Alan.Coopersmith@sun.com> +Date: Fri Mar 10 02:36:55 2006 +0000 + + Clear two tiny memory leaks. (Coverity ids #900 & 901) + +commit 609828be5a05bc71fffaf8fc129a0cae8082fd57 +Author: Kevin E Martin <kem@kem.org> +Date: Wed Dec 21 02:29:33 2005 +0000 + + Update package version for X11R7 release. + +commit a4169ffa7eb6eb9a28fd64a0686a813da975736c +Author: Adam Jackson <ajax@nwnk.net> +Date: Mon Dec 19 16:22:26 2005 +0000 + + Stub COPYING files + +commit b9403df95678e568a326fe3f37bf29285a6a211e +Author: Kevin E Martin <kem@kem.org> +Date: Thu Dec 15 00:23:50 2005 +0000 + + Update package version number for final X11R7 release candidate. + +commit 6f9523999cc4eb34accfe0bcc2c7a74bae9259ef +Author: Kevin E Martin <kem@kem.org> +Date: Tue Dec 6 22:48:05 2005 +0000 + + Change *man_SOURCES ==> *man_PRE to fix autotools warnings. + +commit 28c0455ea50bdf37f1d9d53c6756beebed429f0e +Author: Kevin E Martin <kem@kem.org> +Date: Sat Dec 3 05:49:07 2005 +0000 + + Update package version number for X11R7 RC3 release. + +commit 988471c67e10a5ca309b90146b37a6037f5b2efc +Author: Alan Coopersmith <Alan.Coopersmith@sun.com> +Date: Mon Nov 28 22:01:26 2005 +0000 + + Change *mandir targets to use new *_MAN_DIR variables set by xorg-macros.m4 + update to fix bug #5167 (Linux prefers *.1x man pages in man1 subdir) + +commit 4496e95380b2f0ad7e9bdca02ec192dbb6d5e2e5 +Author: Eric Anholt <anholt@freebsd.org> +Date: Mon Nov 21 10:34:47 2005 +0000 + + Another pass at .cvsignores for apps. + +commit 296d8e6ab8a86e5653529d0497ca5751d89f23b5 +Author: Alan Coopersmith <Alan.Coopersmith@sun.com> +Date: Mon Nov 21 03:13:55 2005 +0000 + + Change dependency from xmu to xmuu since the full xmu (with all its baggage + like Xt) is not needed here. + +commit 27898506332f1a4e698cbd65aecc47fdbc6d0a7b +Author: Eric Anholt <anholt@freebsd.org> +Date: Sun Nov 20 22:08:34 2005 +0000 + + Add/improve .cvsignore files for apps. + +commit ee7bf4989434ba5f30451c3f07e4a6e01e6532d4 +Author: Kevin E Martin <kem@kem.org> +Date: Sat Nov 19 07:15:16 2005 +0000 + + Update pkgconfig files to separate library build-time dependencies from + application build-time dependencies, and update package deps to work + with separate build roots. + +commit 4e58b0e12d46503c5f75ead9a859694aafd5b9b7 +Author: Kevin E Martin <kem@kem.org> +Date: Wed Oct 19 02:47:36 2005 +0000 + + Update package version number for RC1 release. + +commit fc097904a8d7ded9a60df35fd58b9f5b5e226e17 +Author: Alan Coopersmith <Alan.Coopersmith@sun.com> +Date: Mon Oct 17 23:56:03 2005 +0000 + + Use @APP_MAN_SUFFIX@ instead of $(APP_MAN_SUFFIX) in macro substitutions to + work better with BSD make + +commit 22feb546d5bf499ec0bc726c60a6c46f2e2cbd1c +Author: Alan Coopersmith <Alan.Coopersmith@sun.com> +Date: Fri Oct 14 00:25:26 2005 +0000 + + Use sed to fill in variables in man page + +commit 9b1a4cbaf609bb102adec047934ad4c1b05f01ab +Author: Alan Coopersmith <Alan.Coopersmith@sun.com> +Date: Mon Aug 1 20:25:11 2005 +0000 + + Install man pages to section 1 instead of section m (Patch from Donnie + Berkholz) + +commit 70ed22f5e63d5759a0b7c6574a92d124c0777562 +Author: Kevin E Martin <kem@kem.org> +Date: Fri Jul 29 21:22:17 2005 +0000 + + Various changes preparing packages for RC0: + - Verify and update package version numbers as needed + - Implement versioning scheme + - Change bug address to point to bugzilla bug entry form + - Disable loadable i18n in libX11 by default (use --enable-loadable-i18n to + reenable it) + - Fix makedepend to use pkgconfig and pass distcheck + - Update build script to build macros first + - Update modular Xorg version + +commit 270145dc0f3ad5c7ad7d6086da19c0a25ea853a9 +Author: Adam Jackson <ajax@nwnk.net> +Date: Wed Jul 20 19:31:43 2005 +0000 + + Use a unique token for PKG_CHECK_MODULES. Otherwise, if you use a global + configure cache, you cache it, and the cached value is probably wrong. + +commit 97aa768841e147fde3cf16ba9a4c852358085d27 +Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk> +Date: Fri Jul 8 21:00:24 2005 +0000 + + Build system for xwininfo + +commit 5cd08344c43c739c9a6837f1a60ae7c42e5afabe +Author: Roland Mainz <roland.mainz@nrubsig.org> +Date: Wed Oct 6 19:29:37 2004 +0000 + + Fix for https://freedesktop.org/bugzilla/show_bug.cgi?id=1518 - Add filter + support to "xlsfonts" that it can filter builtin-, glyph- and/or other + kinds of printer fonts (controlled by the xp-listfonts-modes attribute + as described in the CDE DtPrint and Xprint specifications). + +commit ac7cc196b722ee4653326aee459f40ad16a260c1 +Author: Egbert Eich <eich@suse.de> +Date: Fri Apr 23 19:54:47 2004 +0000 + + Merging XORG-CURRENT into trunk + +commit 43e099d499d4dbabb32ca0410175e0e1b814cd94 +Author: Egbert Eich <eich@suse.de> +Date: Sun Mar 14 08:35:32 2004 +0000 + + Importing vendor version xf86-4_4_99_1 on Sun Mar 14 00:26:39 PST 2004 + +commit cd710399eb415673c180f65080d685ee8d149361 +Author: Egbert Eich <eich@suse.de> +Date: Wed Mar 3 12:12:58 2004 +0000 + + Importing vendor version xf86-4_4_0 on Wed Mar 3 04:09:24 PST 2004 + +commit 436a7ecb4b764394abcdd06fd99d6232c633cad1 +Author: Egbert Eich <eich@suse.de> +Date: Thu Feb 26 13:36:10 2004 +0000 + + readding XFree86's cvs IDs + +commit 6dfbd3f819f10e4d04653df2074526860007968e +Author: Egbert Eich <eich@suse.de> +Date: Thu Feb 26 09:23:56 2004 +0000 + + Importing vendor version xf86-4_3_99_903 on Wed Feb 26 01:21:00 PST 2004 + +commit a2fa980ce0e98c2bbc503d1d9fe51ab539b7ea46 +Author: Egbert Eich <eich@suse.de> +Date: Thu Jan 29 08:08:59 2004 +0000 + + Importing vendor version xf86-012804-2330 on Thu Jan 29 00:06:33 PST 2004 + +commit 429530ba6f7699436d6f789a17550ec1a691c675 +Author: Kaleb Keithley <kaleb@freedesktop.org> +Date: Tue Nov 25 19:29:01 2003 +0000 + + XFree86 4.3.99.16 Bring the tree up to date for the Cygwin folks + +commit be0f398fee08e03ab73ec0d580df688cc989fbaa +Author: Kaleb Keithley <kaleb@freedesktop.org> +Date: Fri Nov 14 16:49:02 2003 +0000 + + XFree86 4.3.0.1 + +commit 5e5a590668dc3ebe7e2cb568aad4c9c14021f2a2 +Author: Kaleb Keithley <kaleb@freedesktop.org> +Date: Fri Nov 14 15:54:33 2003 +0000 + + R6.6 is the Xorg base-line diff --git a/app/xwininfo/Makefile.am b/app/xwininfo/Makefile.am index d5bb27c1a..854f4892c 100644 --- a/app/xwininfo/Makefile.am +++ b/app/xwininfo/Makefile.am @@ -21,10 +21,12 @@ bin_PROGRAMS = xwininfo -xwininfo_CFLAGS = $(XWININFO_CFLAGS) +AM_CFLAGS = $(XWININFO_CFLAGS) xwininfo_LDADD = $(XWININFO_LIBS) xwininfo_SOURCES = \ + clientwin.c \ + clientwin.h \ dsimple.c \ dsimple.h \ xwininfo.c @@ -37,8 +39,16 @@ appmandir = $(APP_MAN_DIR) appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) -EXTRA_DIST = $(appman_PRE) +EXTRA_DIST = $(appman_PRE) ChangeLog autogen.sh 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) + +dist-hook: ChangeLog SED = sed diff --git a/app/xwininfo/Makefile.in b/app/xwininfo/Makefile.in index b77426927..f6cc8bde7 100644 --- a/app/xwininfo/Makefile.in +++ b/app/xwininfo/Makefile.in @@ -76,7 +76,8 @@ CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(appmandir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) -am_xwininfo_OBJECTS = dsimple.$(OBJEXT) xwininfo.$(OBJEXT) +am_xwininfo_OBJECTS = clientwin.$(OBJEXT) dsimple.$(OBJEXT) \ + xwininfo.$(OBJEXT) xwininfo_OBJECTS = $(am_xwininfo_OBJECTS) am__DEPENDENCIES_1 = xwininfo_DEPENDENCIES = $(am__DEPENDENCIES_1) @@ -209,6 +210,8 @@ target_alias = @target_alias@ AM_CFLAGS = $(XWININFO_CFLAGS) xwininfo_LDADD = $(XWININFO_LIBS) xwininfo_SOURCES = \ + clientwin.c \ + clientwin.h \ dsimple.c \ dsimple.h \ xwininfo.c @@ -328,6 +331,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clientwin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dsimple.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xwininfo.Po@am__quote@ diff --git a/app/xwininfo/aclocal.m4 b/app/xwininfo/aclocal.m4 index 5419cfb3c..48f9f8de2 100644 --- a/app/xwininfo/aclocal.m4 +++ b/app/xwininfo/aclocal.m4 @@ -1042,7 +1042,7 @@ AC_DEFUN([XORG_MACROS_VERSION],[ 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.5 + [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 @@ -1191,7 +1191,11 @@ AC_DEFUN([XORG_CHECK_LINUXDOC],[ XORG_SGML_PATH=$prefix/share/sgml HAVE_DEFS_ENT= -AC_CHECK_FILE([$XORG_SGML_PATH/X11/defs.ent], [HAVE_DEFS_ENT=yes]) +if test x"$cross_compiling" = x"yes" ; then + HAVE_DEFS_ENT=no +else + AC_CHECK_FILE([$XORG_SGML_PATH/X11/defs.ent], [HAVE_DEFS_ENT=yes]) +fi AC_PATH_PROG(LINUXDOC, linuxdoc) AC_PATH_PROG(PS2PDF, ps2pdf) @@ -1463,14 +1467,14 @@ AC_DEFUN([XORG_RELEASE_VERSION],[ AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR], [`echo $PACKAGE_VERSION | cut -d . -f 1`], [Major version of this package]) - PVM=`echo $PACKAGE_VERSION | cut -d . -f 2` + PVM=`echo $PACKAGE_VERSION | cut -d . -f 2 | cut -d - -f 1` if test "x$PVM" = "x"; then PVM="0" fi AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR], [$PVM], [Minor version of this package]) - PVP=`echo $PACKAGE_VERSION | cut -d . -f 3` + PVP=`echo $PACKAGE_VERSION | cut -d . -f 3 | cut -d - -f 1` if test "x$PVP" = "x"; then PVP="0" fi diff --git a/app/xwininfo/clientwin.c b/app/xwininfo/clientwin.c new file mode 100644 index 000000000..808adec24 --- /dev/null +++ b/app/xwininfo/clientwin.c @@ -0,0 +1,214 @@ +/* + * Copyright 2007 Kim woelders + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ +#include <X11/Xatom.h> +#include <X11/Xlib.h> + +static Atom atom_wm_state = None; + +/* + * Check if window has given property + */ +static Bool +Window_Has_Property(Display * dpy, Window win, Atom atom) +{ + Atom type_ret; + int format_ret; + unsigned char *prop_ret; + unsigned long bytes_after, num_ret; + + type_ret = None; + prop_ret = NULL; + XGetWindowProperty(dpy, win, atom, 0, 0, False, AnyPropertyType, + &type_ret, &format_ret, &num_ret, + &bytes_after, &prop_ret); + if (prop_ret) + XFree(prop_ret); + + return (type_ret != None) ? True : False; +} + +/* + * Check if window is viewable + */ +static Bool +Window_Is_Viewable(Display * dpy, Window win) +{ + Bool ok; + XWindowAttributes xwa; + + XGetWindowAttributes(dpy, win, &xwa); + + ok = (xwa.class == InputOutput) && (xwa.map_state == IsViewable); + + return ok; +} + +/* + * Find a window that has WM_STATE set in the window tree below win. + * Unmapped/unviewable windows are not considered valid matches. + * Children are searched in top-down stacking order. + * The first matching window is returned, None if no match is found. + */ +Window +Find_Client_In_Children(Display * dpy, Window win) +{ + Window root, parent; + Window *children; + unsigned int n_children; + int i; + + if (!XQueryTree(dpy, win, &root, &parent, &children, &n_children)) + return None; + if (!children) + return None; + + /* Check each child for WM_STATE and other validity */ + win = None; + for (i = (int) n_children - 1; i >= 0; i--) { + if (!Window_Is_Viewable(dpy, children[i])) { + children[i] = None; /* Don't bother descending into this one */ + continue; + } + if (!Window_Has_Property(dpy, children[i], atom_wm_state)) + continue; + + /* Got one */ + win = children[i]; + goto done; + } + + /* No children matched, now descend into each child */ + for (i = (int) n_children - 1; i >= 0; i--) { + if (children[i] == None) + continue; + win = Find_Client_In_Children(dpy, children[i]); + if (win != None) + break; + } + + done: + XFree(children); + + return win; +} + +/* + * Find virtual roots (_NET_VIRTUAL_ROOTS) + */ +unsigned long * +Find_Roots(Display * dpy, Window root, unsigned int *num) +{ + Atom type_ret; + int format_ret; + unsigned char *prop_ret; + unsigned long bytes_after, num_ret; + Atom atom; + + *num = 0; + atom = XInternAtom(dpy, "_NET_VIRTUAL_ROOTS", False); + if (!atom) + return NULL; + + type_ret = None; + prop_ret = NULL; + if (XGetWindowProperty(dpy, root, atom, 0, 0x7fffffff, False, + XA_WINDOW, &type_ret, &format_ret, &num_ret, + &bytes_after, &prop_ret) != Success) + return NULL; + + if (prop_ret && type_ret == XA_WINDOW && format_ret == 32) { + *num = num_ret; + return ((unsigned long *) prop_ret); + } + if (prop_ret) + XFree(prop_ret); + + return NULL; +} + +/* + * Find child window at pointer location + */ +static Window +Find_Child_At_Pointer(Display * dpy, Window win) +{ + Window root_return, child_return; + int dummyi; + unsigned int dummyu; + + XQueryPointer(dpy, win, &root_return, &child_return, + &dummyi, &dummyi, &dummyi, &dummyi, &dummyu); + + return child_return; +} + +/* + * Find client window at pointer location + * + * root is the root window. + * subwin is the subwindow reported by a ButtonPress event on root. + * + * If the WM uses virtual roots subwin may be a virtual root. + * If so, we descend the window stack at the pointer location and assume the + * child is the client or one of its WM frame windows. + * This will of course work only if the virtual roots are children of the real + * root. + */ +Window +Find_Client(Display * dpy, Window root, Window subwin) +{ + unsigned long *roots; + unsigned int i, n_roots; + Window win; + + /* Check if subwin is a virtual root */ + roots = Find_Roots(dpy, root, &n_roots); + for (i = 0; i < n_roots; i++) { + if (subwin != roots[i]) + continue; + win = Find_Child_At_Pointer(dpy, subwin); + if (win == None) + return subwin; /* No child - Return virtual root. */ + subwin = win; + break; + } + if (roots) + XFree(roots); + + if (atom_wm_state == None) { + atom_wm_state = XInternAtom(dpy, "WM_STATE", False); + if (!atom_wm_state) + return subwin; + } + + /* Check if subwin has WM_STATE */ + if (Window_Has_Property(dpy, subwin, atom_wm_state)) + return subwin; + + /* Attempt to find a client window in subwin's children */ + win = Find_Client_In_Children(dpy, subwin); + if (win != None) + return win; /* Found a client */ + + /* Did not find a client */ + return subwin; +} diff --git a/app/xwininfo/clientwin.h b/app/xwininfo/clientwin.h new file mode 100644 index 000000000..9fc59b5eb --- /dev/null +++ b/app/xwininfo/clientwin.h @@ -0,0 +1,29 @@ +/* + * Copyright 2007 Kim woelders + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ +#ifndef _CLIENTWIN_H_ +#define _CLIENTWIN_H_ + +#include <X11/Xlib.h> + +extern Window Find_Client(Display * dpy, Window root, Window target_win); + +#endif diff --git a/app/xwininfo/configure b/app/xwininfo/configure index 506d16118..2d4f99842 100644 --- a/app/xwininfo/configure +++ b/app/xwininfo/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for xwininfo 1.0.3. +# Generated by GNU Autoconf 2.59 for xwininfo 1.0.4. # # Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=xorg>. # @@ -269,8 +269,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='xwininfo' PACKAGE_TARNAME='xwininfo' -PACKAGE_VERSION='1.0.3' -PACKAGE_STRING='xwininfo 1.0.3' +PACKAGE_VERSION='1.0.4' +PACKAGE_STRING='xwininfo 1.0.4' PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=xorg' ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE PKG_CONFIG ac_pt_PKG_CONFIG XWININFO_CFLAGS XWININFO_LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os APP_MAN_SUFFIX LIB_MAN_SUFFIX FILE_MAN_SUFFIX MISC_MAN_SUFFIX DRIVER_MAN_SUFFIX ADMIN_MAN_SUFFIX APP_MAN_DIR LIB_MAN_DIR FILE_MAN_DIR MISC_MAN_DIR DRIVER_MAN_DIR ADMIN_MAN_DIR LIBOBJS LTLIBOBJS' @@ -750,7 +750,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 xwininfo 1.0.3 to adapt to many kinds of systems. +\`configure' configures xwininfo 1.0.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -816,7 +816,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of xwininfo 1.0.3:";; + short | recursive ) echo "Configuration of xwininfo 1.0.4:";; esac cat <<\_ACEOF @@ -946,7 +946,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -xwininfo configure 1.0.3 +xwininfo configure 1.0.4 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -960,7 +960,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by xwininfo $as_me 1.0.3, which was +It was created by xwininfo $as_me 1.0.4, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1558,7 +1558,7 @@ fi # Define the identity of the package. PACKAGE='xwininfo' - VERSION='1.0.3' + VERSION='1.0.4' cat >>confdefs.h <<_ACEOF @@ -3120,12 +3120,12 @@ if test -n "$PKG_CONFIG"; then pkg_cv_XWININFO_CFLAGS="$XWININFO_CFLAGS" else if test -n "$PKG_CONFIG" && \ - { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"xmuu xext x11\"") >&5 - ($PKG_CONFIG --exists --print-errors "xmuu xext x11") 2>&5 + { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"xext x11\"") >&5 + ($PKG_CONFIG --exists --print-errors "xext x11") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - pkg_cv_XWININFO_CFLAGS=`$PKG_CONFIG --cflags "xmuu xext x11" 2>/dev/null` + pkg_cv_XWININFO_CFLAGS=`$PKG_CONFIG --cflags "xext x11" 2>/dev/null` else pkg_failed=yes fi @@ -3138,12 +3138,12 @@ if test -n "$PKG_CONFIG"; then pkg_cv_XWININFO_LIBS="$XWININFO_LIBS" else if test -n "$PKG_CONFIG" && \ - { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"xmuu xext x11\"") >&5 - ($PKG_CONFIG --exists --print-errors "xmuu xext x11") 2>&5 + { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"xext x11\"") >&5 + ($PKG_CONFIG --exists --print-errors "xext x11") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then - pkg_cv_XWININFO_LIBS=`$PKG_CONFIG --libs "xmuu xext x11" 2>/dev/null` + pkg_cv_XWININFO_LIBS=`$PKG_CONFIG --libs "xext x11" 2>/dev/null` else pkg_failed=yes fi @@ -3162,14 +3162,14 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - XWININFO_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "xmuu xext x11"` + XWININFO_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "xext x11"` else - XWININFO_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "xmuu xext x11"` + XWININFO_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "xext x11"` fi # Put the nasty error message in config.log where it belongs echo "$XWININFO_PKG_ERRORS" >&5 - { { echo "$as_me:$LINENO: error: Package requirements (xmuu xext x11) were not met: + { { echo "$as_me:$LINENO: error: Package requirements (xext x11) were not met: $XWININFO_PKG_ERRORS @@ -3180,7 +3180,7 @@ Alternatively, you may set the environment variables XWININFO_CFLAGS and XWININFO_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. " >&5 -echo "$as_me: error: Package requirements (xmuu xext x11) were not met: +echo "$as_me: error: Package requirements (xext x11) were not met: $XWININFO_PKG_ERRORS @@ -3369,7 +3369,7 @@ cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION_MAJOR `echo $PACKAGE_VERSION | cut -d . -f 1` _ACEOF - PVM=`echo $PACKAGE_VERSION | cut -d . -f 2` + PVM=`echo $PACKAGE_VERSION | cut -d . -f 2 | cut -d - -f 1` if test "x$PVM" = "x"; then PVM="0" fi @@ -3378,7 +3378,7 @@ cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION_MINOR $PVM _ACEOF - PVP=`echo $PACKAGE_VERSION | cut -d . -f 3` + PVP=`echo $PACKAGE_VERSION | cut -d . -f 3 | cut -d - -f 1` if test "x$PVP" = "x"; then PVP="0" fi @@ -3773,7 +3773,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by xwininfo $as_me 1.0.3, which was +This file was extended by xwininfo $as_me 1.0.4, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -3836,7 +3836,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -xwininfo config.status 1.0.3 +xwininfo config.status 1.0.4 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff --git a/app/xwininfo/configure.ac b/app/xwininfo/configure.ac index 9a8cdfe8e..5cef3bc7b 100644 --- a/app/xwininfo/configure.ac +++ b/app/xwininfo/configure.ac @@ -22,7 +22,7 @@ dnl dnl Process this file with autoconf to create configure. AC_PREREQ([2.57]) -AC_INIT(xwininfo,[1.0.2], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],xwininfo) +AC_INIT(xwininfo,[1.0.4], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],xwininfo) AM_INIT_AUTOMAKE([dist-bzip2]) AM_MAINTAINER_MODE @@ -31,8 +31,10 @@ AM_CONFIG_HEADER(config.h) AC_PROG_CC AC_PROG_INSTALL +AC_CHECK_FUNCS([strlcat]) + # Checks for pkg-config packages -PKG_CHECK_MODULES(XWININFO, xmuu xext x11) +PKG_CHECK_MODULES(XWININFO, xext x11) AC_SUBST(XWININFO_CFLAGS) AC_SUBST(XWININFO_LIBS) diff --git a/app/xwininfo/dsimple.c b/app/xwininfo/dsimple.c index c84ac3b51..171795b79 100644 --- a/app/xwininfo/dsimple.c +++ b/app/xwininfo/dsimple.c @@ -41,13 +41,11 @@ from The Open Group. * Written by Mark Lillibridge. Last updated 7/1/87 */ -#ifdef BUILD_PRINTSUPPORT -#include <X11/XprintUtil/xprintutil.h> -#endif /* BUILD_PRINTSUPPORT */ +#include "clientwin.h" #include "dsimple.h" /* - * Just_display: A group of routines designed to make the writting of simple + * Just_display: A group of routines designed to make the writing of simple * X11 applications which open a display but do not open * any windows much faster and easier. Unless a routine says * otherwise, it may be assumed to require program_name, dpy, @@ -61,54 +59,15 @@ from The Open Group. char *program_name = "unknown_program"; Display *dpy = NULL; int screen = 0; -Bool printer_output = False; /* Video or printer output ? */ -#ifdef BUILD_PRINTSUPPORT -XPContext pcontext = None; -#endif /* BUILD_PRINTSUPPORT */ - -static void _bitmap_error(int, char *); - -/* - * Malloc: like malloc but handles out of memory using Fatal_Error. - */ -char *Malloc(size) - unsigned size; -{ - char *data; - - if (!(data = malloc(size))) - Fatal_Error("Out of memory!"); - - return(data); -} - - -/* - * Realloc: like Malloc except for realloc, handles NULL using Malloc. - */ -char *Realloc(ptr, size) - char *ptr; - int size; -{ - char *new_ptr; - - if (!ptr) - return(Malloc(size)); - - if (!(new_ptr = realloc(ptr, size))) - Fatal_Error("Out of memory!"); - - return(new_ptr); -} /* * 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(pargc, argv) - int *pargc; /* MODIFIED */ - char **argv; /* MODIFIED */ +char *Get_Display_Name( + int *pargc, /* MODIFIED */ + char **argv) /* MODIFIED */ { int argc = *pargc; char **pargv = argv+1; @@ -138,49 +97,12 @@ char *Get_Display_Name(pargc, argv) } -#ifdef BUILD_PRINTSUPPORT -/* - * Get_Printer_Name (argc, argv) Look for -printer, -p, - * If found, remove it from command line. Don't go past a lone -. - */ -char *Get_Printer_Name(pargc, argv) - int *pargc; /* MODIFIED */ - char **argv; /* MODIFIED */ -{ - int argc = *pargc; - char **pargv = argv+1; - char *printername = NULL; - int i; - - for (i = 1; i < argc; i++) { - char *arg = argv[i]; - - if (!strcmp (arg, "-printer") || !strcmp (arg, "-p")) { - if (++i >= argc) usage (); - - printername = argv[i]; - *pargc -= 2; - continue; - } - if (!strcmp(arg,"-")) { - while (i<argc) - *pargv++ = argv[i++]; - break; - } - *pargv++ = arg; - } - - *pargv = NULL; - return (printername); -} -#endif /* BUILD_PRINTSUPPORT */ /* * Open_Display: Routine to open a display with correct error handling. * Does not require dpy or screen defined on entry. */ -Display *Open_Display(display_name) -char *display_name; +Display *Open_Display(char *display_name) { Display *d; @@ -203,41 +125,15 @@ char *display_name; * for this display is then stored in screen. * Does not require dpy or screen defined. */ -void Setup_Display_And_Screen(argc, argv) -int *argc; /* MODIFIED */ -char **argv; /* MODIFIED */ +void Setup_Display_And_Screen( + int *argc, /* MODIFIED */ + char **argv) /* MODIFIED */ { - char *displayname = NULL, - *printername = NULL; + char *displayname = NULL; displayname = Get_Display_Name(argc, argv); -#ifdef BUILD_PRINTSUPPORT - printername = Get_Printer_Name(argc, argv); - - if (displayname && printername) { - fprintf (stderr, "%s: you cannot specify -printer (-p) and -display (-d) at the same time.\n", - program_name); - usage (); - } - - if (printername) { - printer_output = True; - - if (XpuGetPrinter(printername, &dpy, &pcontext) != 1) { - fprintf(stderr, "%s: Cannot open printer '%s'.\n", program_name, printername); - exit(EXIT_FAILURE); - } - - screen = XScreenNumberOfScreen(XpGetScreenOfContext(dpy, pcontext)); - } - else -#endif /* BUILD_PRINTSUPPORT */ - { - printer_output = False; - - dpy = Open_Display (displayname); - screen = XDefaultScreen(dpy); - } + dpy = Open_Display (displayname); + screen = XDefaultScreen(dpy); } /* @@ -248,95 +144,8 @@ void Close_Display(void) if (dpy == NULL) return; -#ifdef BUILD_PRINTSUPPORT - if (printer_output) { - XpuClosePrinterDisplay(dpy, pcontext); - dpy = NULL; - pcontext = None; - printer_output = False; - } - else -#endif /* BUILD_PRINTSUPPORT */ - { - XCloseDisplay(dpy); - dpy = NULL; - } -} - - -/* - * Open_Font: This routine opens a font with error handling. - */ -XFontStruct *Open_Font(name) -char *name; -{ - XFontStruct *font; - - if (!(font=XLoadQueryFont(dpy, name))) - Fatal_Error("Unable to open font %s!", name); - - return(font); -} - - -/* - * Beep: Routine to beep the display. - */ -void Beep() -{ - XBell(dpy, 50); -} - - -/* - * ReadBitmapFile: same as XReadBitmapFile except it returns the bitmap - * directly and handles errors using Fatal_Error. - */ -static void _bitmap_error(status, filename) - int status; - char *filename; -{ - if (status == BitmapOpenFailed) - Fatal_Error("Can't open file %s!", filename); - else if (status == BitmapFileInvalid) - Fatal_Error("file %s: Bad bitmap format.", filename); - else - Fatal_Error("Out of memory!"); -} - -Pixmap ReadBitmapFile(d, filename, width, height, x_hot, y_hot) - Drawable d; - char *filename; - int *width, *height, *x_hot, *y_hot; -{ - Pixmap bitmap; - int status; - - status = XReadBitmapFile(dpy, RootWindow(dpy, screen), filename, - (unsigned int *)width, (unsigned int *)height, - &bitmap, x_hot, y_hot); - if (status != BitmapSuccess) - _bitmap_error(status, filename); - - return(bitmap); -} - - -/* - * WriteBitmapFile: same as XWriteBitmapFile except it handles errors - * using Fatal_Error. - */ -void WriteBitmapFile(filename, bitmap, width, height, x_hot, y_hot) - char *filename; - Pixmap bitmap; - int width, height, x_hot, y_hot; -{ - int status; - - status= XWriteBitmapFile(dpy, filename, bitmap, width, height, x_hot, - y_hot); - if (status != BitmapSuccess) - _bitmap_error(status, filename); + XCloseDisplay(dpy); + dpy = NULL; } @@ -362,9 +171,9 @@ void WriteBitmapFile(filename, bitmap, width, height, x_hot, y_hot) * all command line arguments, and other setup is done. * For examples of usage, see xwininfo, xwd, or xprop. */ -Window Select_Window_Args(rargc, argv) - int *rargc; - char **argv; +Window Select_Window_Args( + int *rargc, + char **argv) #define ARGC (*rargc) { int nargc=1; @@ -420,91 +229,12 @@ Window Select_Window_Args(rargc, argv) * Written by Mark Lillibridge. Last updated 7/1/87 */ -/* - * Resolve_Color: This routine takes a color name and returns the pixel # - * that when used in the window w will be of color name. - * (WARNING: The colormap of w MAY be modified! ) - * If colors are run out of, only the first n colors will be - * as correct as the hardware can make them where n depends - * on the display. This routine does not require wind to - * be defined. - */ -unsigned long Resolve_Color(w, name) - Window w; - char *name; -{ - XColor c; - Colormap colormap; - XWindowAttributes wind_info; - - /* - * The following is a hack to insure machines without a rgb table - * handle at least white & black right. - */ - if (!strcmp(name, "white")) - name="#ffffffffffff"; - if (!strcmp(name, "black")) - name="#000000000000"; - - XGetWindowAttributes(dpy, w, &wind_info); - colormap = wind_info.colormap; - - if (!XParseColor(dpy, colormap, name, &c)) - Fatal_Error("Bad color format '%s'.", name); - - if (!XAllocColor(dpy, colormap, &c)) - Fatal_Error("XAllocColor failed!"); - - return(c.pixel); -} - - -/* - * Bitmap_To_Pixmap: Convert a bitmap to a 2 colored pixmap. The colors come - * from the foreground and background colors of the gc. - * Width and height are required solely for efficiency. - * If needed, they can be obtained via. XGetGeometry. - */ -Pixmap Bitmap_To_Pixmap(dpy, d, gc, bitmap, width, height) - Display *dpy; - Drawable d; - GC gc; - Pixmap bitmap; - int width, height; -{ - Pixmap pix; - int x; - unsigned int i, depth; - Drawable root; - - if (!XGetGeometry(dpy, d, &root, &x, &x, &i, &i, &i, &depth)) - return(0); - - pix = XCreatePixmap(dpy, d, width, height, (int)depth); - - XCopyPlane(dpy, bitmap, pix, gc, 0, 0, width, height, 0, 0, 1); - - return(pix); -} - - -/* - * blip: a debugging routine. Prints Blip! on stderr with flushing. - */ -void blip() -{ - fflush(stdout); - fprintf(stderr, "blip!\n"); - fflush(stderr); -} - /* * Routine to let user select a window using the mouse */ -Window Select_Window(dpy) - Display *dpy; +Window Select_Window(Display *dpy, int descend) { int status; Cursor cursor; @@ -543,6 +273,11 @@ Window Select_Window(dpy) XUngrabPointer(dpy, CurrentTime); /* Done with pointer */ + if (!descend || (target_win == root)) + return(target_win); + + target_win = Find_Client(dpy, root, target_win); + return(target_win); } @@ -554,10 +289,10 @@ Window Select_Window(dpy) * one found will be returned. Only top and its subwindows * are looked at. Normally, top should be the RootWindow. */ -Window Window_With_Name(dpy, top, name) - Display *dpy; - Window top; - char *name; +Window Window_With_Name( + Display *dpy, + Window top, + char *name) { Window *children, dummy; unsigned int nchildren; @@ -580,27 +315,9 @@ Window Window_With_Name(dpy, top, name) return(w); } -/* - * outl: a debugging routine. Flushes stdout then prints a message on stderr - * and flushes stderr. Used to print messages when past certain points - * in code so we can tell where we are. Outl may be invoked like - * printf with up to 7 arguments. - */ -void -outl(char *msg, ...) -{ - 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 but maximum of 7 arguments. + * Standard fatal error routine - call like printf * Does not require dpy or screen defined. */ void Fatal_Error(char *msg, ...) diff --git a/app/xwininfo/dsimple.h b/app/xwininfo/dsimple.h index d4dbd0190..90a6c66a2 100644 --- a/app/xwininfo/dsimple.h +++ b/app/xwininfo/dsimple.h @@ -47,34 +47,21 @@ from The Open Group. #define MIN(a,b) (((a)<(b))?(a):(b)) #endif /* MIN */ - /* Global variables used by routines in just_display.c */ + /* Global variables used by routines in dsimple.c */ extern char *program_name; /* Name of this program */ extern Display *dpy; /* The current display */ extern int screen; /* The current screen */ -extern Bool printer_output; /* Video or printer output ? */ -#ifdef BUILD_PRINTSUPPORT -extern XPContext pcontext; /* The current print context */ -#endif /* BUILD_PRINTSUPPORT */ #define INIT_NAME program_name=argv[0] /* use this in main to setup program_name */ - /* Declaritions for functions in just_display.c */ + /* Declaritions for functions in dsimple.c */ -char *Malloc(unsigned); -char *Realloc(char *, int); char *Get_Display_Name(int *, char **); -#ifdef BUILD_PRINTSUPPORT -char *Get_Printer_Name(int *, char **); -#endif /* BUILD_PRINTSUPPORT */ Display *Open_Display(char *); void Setup_Display_And_Screen(int *, char **); void Close_Display(void); -XFontStruct *Open_Font(char *); -void Beep(void); -Pixmap ReadBitmapFile(Drawable, char *, int *, int *, int *, int *); -void WriteBitmapFile(char *, Pixmap, int, int, int, int); Window Select_Window_Args(int *, char **); void usage(void); @@ -89,14 +76,10 @@ void usage(void); * Send bugs, etc. to chariot@athena.mit.edu. */ -unsigned long Resolve_Color(Window, char *); -Pixmap Bitmap_To_Pixmap(Display *, Drawable, GC, Pixmap, int, int); -Window Select_Window(Display *); -void blip(void); +Window Select_Window(Display *, int); Window Window_With_Name(Display *, Window, char *); #ifdef __GNUC__ void Fatal_Error(char *, ...) __attribute__((__noreturn__)); #else void Fatal_Error(char *, ...); #endif -void outl(char *, ...); diff --git a/app/xwininfo/xwininfo.c b/app/xwininfo/xwininfo.c index 1491c03ba..3f94b4276 100644 --- a/app/xwininfo/xwininfo.c +++ b/app/xwininfo/xwininfo.c @@ -1,4 +1,4 @@ -/* $XdotOrg: app/xwininfo/xwininfo.c,v 1.3 2006/03/10 02:37:18 alanc Exp $ */ +/* $XdotOrg: $ */ /* $Xorg: xwininfo.c,v 1.4 2001/02/09 02:06:04 xorgcvs Exp $ */ /* @@ -45,12 +45,12 @@ of the copyright holder. * 16-Jun-87 */ +#include "config.h" #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xatom.h> #include <X11/Xos.h> #include <X11/extensions/shape.h> -#include <X11/Xmu/WinUtil.h> #ifndef NO_I18N #include <X11/Xlocale.h> #endif @@ -62,32 +62,49 @@ of the copyright holder. typedef struct { long code; - char *name; + const char *name; } binding; -void scale_init(void); -char *nscale(int, int, int, char *); -char *xscale(int); -char *yscale(int); -char *bscale(int); -int bad_window_handler(Display *, XErrorEvent *); +static void scale_init(void); +static char *nscale(int, int, int, char *, size_t); +static char *xscale(int); +static char *yscale(int); +static char *bscale(int); +static int bad_window_handler(Display *, XErrorEvent *); int main(int, char **); -char *LookupL(long, binding *); -char *Lookup(int, binding *); -void Display_Window_Id(Window, int); -void Display_Stats_Info(Window); -void Display_Bits_Info(Window); -void Display_Event_Mask(long); -void Display_Events_Info(Window); -void Display_Tree_Info(Window, int); -void display_tree_info_1(Window, int, int); -void Display_Hints(XSizeHints *); -void Display_Size_Hints(Window); -void Display_Window_Shape(Window); -void Display_WM_Info(Window); +static const char *LookupL(long, const binding *); +static const char *Lookup(int, const binding *); +static void Display_Window_Id(Window, int); +static void Display_Stats_Info(Window); +static void Display_Bits_Info(Window); +static void Display_Event_Mask(long); +static void Display_Events_Info(Window); +static void Display_Tree_Info(Window, int); +static void display_tree_info_1(Window, int, int); +static void Display_Hints(XSizeHints *); +static void Display_Size_Hints(Window); +static void Display_Window_Shape(Window); +static void Display_WM_Info(Window); static char *window_id_format = "0x%lx"; +#ifndef HAVE_STRLCAT +static size_t strlcat(char *dst, const char *src, size_t dstsize) +{ + size_t sd = strlen(dst); + size_t ss = strlen(src); + size_t s = sd + ss; + + if (s < dstsize) { + strcpy(dst + sd, src); + } else { + strncpy(dst + sd, src, dstsize-sd-1); + dst[dstsize] = '\0'; + } + return s; +} +#endif + /* * Report the syntax for calling xwininfo: */ @@ -151,12 +168,12 @@ usage(void) */ #define getdsp(var,fn) var = fn(dpy, DefaultScreen(dpy)) -int xp=0, xmm=0; -int yp=0, ymm=0; -int bp=0, bmm=0; -int english = 0, metric = 0; +static int xp=0, xmm=0; +static int yp=0, ymm=0; +static int bp=0, bmm=0; +static int english = 0, metric = 0; -void +static void scale_init(void) { getdsp(yp, DisplayHeight); @@ -171,87 +188,95 @@ scale_init(void) #define YARD (3*12) #define FOOT (12) -char * -nscale(int n, int np, int nmm, char *nbuf) +static char * +nscale(int n, int np, int nmm, char *nbuf, size_t nbufsize) { - sprintf(nbuf, "%d", n); - if(metric||english) { - sprintf(nbuf+strlen(nbuf), " ("); - } - if(metric) { - sprintf(nbuf+strlen(nbuf),"%.2f mm%s", ((double) n)*nmm/np, english?"; ":""); - } - if(english) { - double inch_frac; - Bool printed_anything = False; - int mi, yar, ft, inr; - - inch_frac = ((double) n)*(nmm/25.4)/np; - inr = (int)inch_frac; - inch_frac -= (double)inr; - if(inr>=MILE) { - mi = inr/MILE; - inr %= MILE; - sprintf(nbuf+strlen(nbuf), "%d %s(?!?)", - mi, (mi==1)?"mile":"miles"); - printed_anything = True; - } - if(inr>=YARD) { - yar = inr/YARD; - inr %= YARD; - if (printed_anything) - sprintf(nbuf+strlen(nbuf), ", "); - sprintf(nbuf+strlen(nbuf), "%d %s", - yar, (yar==1)?"yard":"yards"); - printed_anything = True; - } - if(inr>=FOOT) { - ft = inr/FOOT; - inr %= FOOT; - if (printed_anything) - sprintf(nbuf+strlen(nbuf), ", "); - sprintf(nbuf+strlen(nbuf), "%d %s", - ft, (ft==1)?"foot":"feet"); - printed_anything = True; - } - if (!printed_anything || inch_frac != 0.0 || inr != 0) { - if (printed_anything) - sprintf(nbuf+strlen(nbuf), ", "); - sprintf(nbuf+strlen(nbuf), "%.2f inches", inr+inch_frac); + int s; + snprintf(nbuf, nbufsize, "%d", n); + + if (metric||english) { + s = strlcat(nbuf, " (", nbufsize); + + if (metric) { + snprintf(nbuf+s, nbufsize-s, "%.2f mm%s", + ((double) n)*nmm/np, english ? "; " : ""); + } + if (english) { + double inch_frac; + Bool printed_anything = False; + int mi, yar, ft, inr; + + inch_frac = ((double) n)*(nmm/25.4)/np; + inr = (int)inch_frac; + inch_frac -= (double)inr; + if (inr >= MILE) { + mi = inr/MILE; + inr %= MILE; + s = strlen(nbuf); + snprintf(nbuf+s, nbufsize-s, "%d %s(?!?)", + mi, (mi==1) ? "mile" : "miles"); + printed_anything = True; + } + if (inr >= YARD) { + yar = inr/YARD; + inr %= YARD; + if (printed_anything) + strlcat(nbuf, ", ", nbufsize); + s = strlen(nbuf); + snprintf(nbuf+s, nbufsize-s, "%d %s", + yar, (yar==1) ? "yard" : "yards"); + printed_anything = True; + } + if (inr >= FOOT) { + ft = inr/FOOT; + inr %= FOOT; + if (printed_anything) + strlcat(nbuf, ", ", nbufsize); + s = strlen(nbuf); + snprintf(nbuf+s, nbufsize-s, "%d %s", + ft, (ft==1) ? "foot" : "feet"); + printed_anything = True; + } + if (!printed_anything || inch_frac != 0.0 || inr != 0) { + if (printed_anything) + strlcat(nbuf, ", ", nbufsize); + s = strlen(nbuf); + snprintf(nbuf+s, nbufsize-s, "%.2f inches", inr+inch_frac); + } + } + strlcat (nbuf, ")", nbufsize); } - } - if (english || metric) strcat (nbuf, ")"); - return(nbuf); + return(nbuf); } -char xbuf[BUFSIZ]; -char * +static char xbuf[BUFSIZ]; +static char * xscale(int x) { if(!xp) { scale_init(); } - return(nscale(x, xp, xmm, xbuf)); + return(nscale(x, xp, xmm, xbuf, sizeof(xbuf))); } -char ybuf[BUFSIZ]; -char * +static char ybuf[BUFSIZ]; +static char * yscale(int y) { if(!yp) { scale_init(); } - return(nscale(y, yp, ymm, ybuf)); + return(nscale(y, yp, ymm, ybuf, sizeof(ybuf))); } -char bbuf[BUFSIZ]; -char * +static char bbuf[BUFSIZ]; +static char * bscale(int b) { if(!bp) { scale_init(); } - return(nscale(b, bp, bmm, bbuf)); + return(nscale(b, bp, bmm, bbuf, sizeof(bbuf))); } /* end of pixel to inch, metric converter */ @@ -260,12 +285,12 @@ bscale(int b) to see if the -id the user specified is valid. */ /* ARGSUSED */ -int +static int bad_window_handler(Display *disp, XErrorEvent *err) { char badid[20]; - sprintf(badid, window_id_format, err->resourceid); + snprintf(badid, sizeof(badid), window_id_format, err->resourceid); Fatal_Error("No such window with id %s.", badid); exit (1); return 0; @@ -362,17 +387,7 @@ main(int argc, char **argv) printf("xwininfo: Please select the window about which you\n"); printf(" would like information by clicking the\n"); printf(" mouse in that window.\n"); - window = Select_Window(dpy); - if (window && !frame) { - Window root; - int dummyi; - unsigned int dummy; - - if (XGetGeometry (dpy, window, &root, &dummyi, &dummyi, - &dummy, &dummy, &dummy, &dummy) && - window != root) - window = XmuClientWindow (dpy, window); - } + window = Select_Window(dpy, !frame); } /* @@ -422,12 +437,13 @@ main(int argc, char **argv) */ static char _lookup_buffer[100]; -char * -LookupL(long code, binding *table) +static const char * +LookupL(long code, const binding *table) { - char *name; + const char *name; - sprintf(_lookup_buffer, "unknown (code = %ld. = 0x%lx)", code, code); + snprintf(_lookup_buffer, sizeof(_lookup_buffer), + "unknown (code = %ld. = 0x%lx)", code, code); name = _lookup_buffer; while (table->name) { @@ -441,8 +457,8 @@ LookupL(long code, binding *table) return(name); } -char * -Lookup(int code, binding *table) +static const char * +Lookup(int code, const binding *table) { return LookupL((long)code, table); } @@ -451,7 +467,7 @@ Lookup(int code, binding *table) * Routine to display a window id in dec/hex with name if window has one */ -void +static void Display_Window_Id(Window window, Bool newline_wanted) { #ifdef NO_I18N @@ -509,24 +525,24 @@ Display_Window_Id(Window window, Bool newline_wanted) /* * Display Stats on window */ -static binding _window_classes[] = { +static const binding _window_classes[] = { { InputOutput, "InputOutput" }, { InputOnly, "InputOnly" }, { 0, 0 } }; -static binding _map_states[] = { +static const binding _map_states[] = { { IsUnmapped, "IsUnMapped" }, { IsUnviewable, "IsUnviewable" }, { IsViewable, "IsViewable" }, { 0, 0 } }; -static binding _backing_store_states[] = { +static const binding _backing_store_states[] = { { NotUseful, "NotUseful" }, { WhenMapped, "WhenMapped" }, { Always, "Always" }, { 0, 0 } }; -static binding _bit_gravity_states[] = { +static const binding _bit_gravity_states[] = { { ForgetGravity, "ForgetGravity" }, { NorthWestGravity, "NorthWestGravity" }, { NorthGravity, "NorthGravity" }, @@ -540,7 +556,7 @@ static binding _bit_gravity_states[] = { { StaticGravity, "StaticGravity" }, { 0, 0 }}; -static binding _window_gravity_states[] = { +static const binding _window_gravity_states[] = { { UnmapGravity, "UnmapGravity" }, { NorthWestGravity, "NorthWestGravity" }, { NorthGravity, "NorthGravity" }, @@ -554,7 +570,7 @@ static binding _window_gravity_states[] = { { StaticGravity, "StaticGravity" }, { 0, 0 }}; -static binding _visual_classes[] = { +static const binding _visual_classes[] = { { StaticGray, "StaticGray" }, { GrayScale, "GrayScale" }, { StaticColor, "StaticColor" }, @@ -563,7 +579,7 @@ static binding _visual_classes[] = { { DirectColor, "DirectColor" }, { 0, 0 }}; -void +static void Display_Stats_Info(Window window) { XWindowAttributes win_attributes; @@ -730,7 +746,7 @@ Display_Stats_Info(Window window) /* * Display bits info: */ -static binding _gravities[] = { +static const binding _gravities[] = { { UnmapGravity, "UnMapGravity" }, /* WARNING: both of these have*/ { ForgetGravity, "ForgetGravity" }, /* the same value - see code */ { NorthWestGravity, "NorthWestGravity" }, @@ -745,18 +761,18 @@ static binding _gravities[] = { { StaticGravity, "StaticGravity" }, { 0, 0 } }; -static binding _backing_store_hint[] = { +static const binding _backing_store_hint[] = { { NotUseful, "NotUseful" }, { WhenMapped, "WhenMapped" }, { Always, "Always" }, { 0, 0 } }; -static binding _bool[] = { +static const binding _bool[] = { { 0, "No" }, { 1, "Yes" }, { 0, 0 } }; -void +static void Display_Bits_Info(Window window) { XWindowAttributes win_attributes; @@ -782,7 +798,7 @@ Display_Bits_Info(Window window) /* * Routine to display all events in an event mask */ -static binding _event_mask_names[] = { +static const binding _event_mask_names[] = { { KeyPressMask, "KeyPress" }, { KeyReleaseMask, "KeyRelease" }, { ButtonPressMask, "ButtonPress" }, @@ -810,7 +826,7 @@ static binding _event_mask_names[] = { { OwnerGrabButtonMask, "OwnerGrabButton" }, { 0, 0 } }; -void +static void Display_Event_Mask(long mask) { long bit, bit_mask; @@ -825,7 +841,7 @@ Display_Event_Mask(long mask) /* * Display info on events */ -void +static void Display_Events_Info(Window window) { XWindowAttributes win_attributes; @@ -854,7 +870,7 @@ Display_Events_Info(Window window) * Display root, parent, and (recursively) children information * recurse - true to show children information */ -void +static void Display_Tree_Info(Window window, int recurse) { display_tree_info_1(window, recurse, 0); @@ -863,7 +879,7 @@ Display_Tree_Info(Window window, int recurse) /* * level - recursion level */ -void +static void display_tree_info_1(Window window, int recurse, int level) { int i, j; @@ -935,7 +951,7 @@ display_tree_info_1(Window window, int recurse, int level) /* * Display a set of size hints */ -void +static void Display_Hints(XSizeHints *hints) { long flags; @@ -1013,7 +1029,7 @@ Display_Hints(XSizeHints *hints) /* * Display Size Hints info */ -void +static void Display_Size_Hints(Window window) { XSizeHints *hints = XAllocSizeHints(); @@ -1039,7 +1055,7 @@ Display_Size_Hints(Window window) } -void +static void Display_Window_Shape (Window window) { Bool ws, bs; @@ -1071,7 +1087,7 @@ Display_Window_Shape (Window window) /* * Display Window Manager Info */ -static binding _state_hints[] = { +static const binding _state_hints[] = { { DontCareState, "Don't Care State" }, { NormalState, "Normal State" }, { ZoomState, "Zoomed State" }, @@ -1079,7 +1095,7 @@ static binding _state_hints[] = { { InactiveState, "Inactive State" }, { 0, 0 } }; -void +static void Display_WM_Info(Window window) { XWMHints *wmhints; |