diff -urN xdpyinfo-1.0.1/NEWS xdpyinfo-1.0.2/NEWS --- xdpyinfo-1.0.1/NEWS 2005-07-06 20:56:47.000000000 +0100 +++ xdpyinfo-1.0.2/NEWS 2006-08-23 06:38:55.000000000 +0100 @@ -0,0 +1,3 @@ +patch on 21/8/2006 by Eugene St Leger (GrimRC) +- add a version command +- report the virtual root window id, using vroot.h from xscreensaver 5.00 diff -urN xdpyinfo-1.0.1/vroot.h xdpyinfo-1.0.2/vroot.h --- xdpyinfo-1.0.1/vroot.h 1970-01-01 01:00:00.000000000 +0100 +++ xdpyinfo-1.0.2/vroot.h 2006-08-23 06:35:11.000000000 +0100 @@ -0,0 +1,138 @@ +/* -*- Mode: C; tab-width: 2 -*- */ +/*****************************************************************************/ +/** Copyright 1991 by Andreas Stolcke **/ +/** Copyright 1990 by Solbourne Computer Inc. **/ +/** Longmont, Colorado **/ +/** **/ +/** All Rights Reserved **/ +/** **/ +/** Permission to use, copy, modify, and distribute this software and **/ +/** its documentation for any purpose and without fee is hereby **/ +/** granted, provided that the above copyright notice appear in all **/ +/** copies and that both that copyright notice and this permis- **/ +/** sion notice appear in supporting documentation, and that the **/ +/** name of Solbourne not be used in advertising **/ +/** in publicity pertaining to distribution of the software without **/ +/** specific, written prior permission. **/ +/** **/ +/** ANDREAS STOLCKE AND SOLBOURNE COMPUTER INC. DISCLAIMS ALL WARRANTIES **/ +/** WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF **/ +/** MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL ANDREAS STOLCKE **/ +/** OR SOLBOURNE 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. **/ +/*****************************************************************************/ +/* + * vroot.h -- Virtual Root Window handling header file + * + * The function VirtualRootWindowOfScreen returns the virtual root window as + * provided by certain `virtual' window managers like swm and tvtwm. If none + * is found, the ordinary root window is returned, thus retaining backward + * compatibility with standard window managers. + * + * The function implementing the virtual root lookup remembers the result of + * its last invocation to avoid overhead in the case of repeated calls + * on the same display and screen arguments. + * The lookup code itself is taken from Tom LaStrange's ssetroot program. + * + * Andreas Stolcke , 9/7/90 + * - replaced all NULL's with properly cast 0's, 5/6/91 + * - free children list (suggested by Mark Martin ), 5/16/91 + * - include X11/Xlib.h and support RootWindowOfScreen, too 9/17/91 + * + * Jamie Zawinski , 28-Apr-1997 + * - use ANSI C + * + * Jamie Zawinski , 3-Sep-2003 + * - if the environment variable "XSCREENSAVER_WINDOW" is set, use that + * as the root window instead of searching for __SWM_VROOT. + * + * Jamie Zawinski , 14-Aug-2004 + * - changes to get gcc to stop whining about "type punning". + * + * Jamie Zawinski , 16-Dec-2004 + * - fixed that last fix. + * + * Eugene St Leger 23/8/2006 + * - removed the macros and included in xdpyinfo + */ + +#ifndef _VROOT_H_ +#define _VROOT_H_ +#define _XSCREENSAVER_VROOT_H_ + +#if !defined(lint) && !defined(SABER) +static const char vroot_rcsid[] = + "#Id: vroot.h,v 1.8 2004/12/16 05:33:54 jwz Exp #" "\n" + "#Id: vroot.h,v 1.4 1991/09/30 19:23:16 stolcke Exp stolcke #"; +#endif + +#include +#include +#include + +static Window +#ifdef __STDC__ /* ANSIfication added by jwz, to avoid superfluous warnings. */ +VirtualRootWindowOfScreen(Screen *screen) +#else /* !__STDC__ */ +VirtualRootWindowOfScreen(screen) Screen *screen; +#endif /* !__STDC__ */ +{ + static Screen *save_screen = (Screen *)0; + static Window root = (Window)0; + + if (screen != save_screen) { + Display *dpy = DisplayOfScreen(screen); + Atom __SWM_VROOT = None; + int i; + Window rootReturn, parentReturn, *children; + unsigned int numChildren; + + /* first check for a hex or decimal window ID in the environment */ + const char *xss_id = getenv("XSCREENSAVER_WINDOW"); + if (xss_id && *xss_id) { + unsigned long id = 0; + char c; + if (1 == sscanf (xss_id, " 0x%lx %c", &id, &c) || + 1 == sscanf (xss_id, " %lu %c", &id, &c)) { + root = (Window) id; + save_screen = screen; + return root; + } + } + + root = RootWindowOfScreen(screen); + + /* go look for a virtual root */ + __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False); + if (XQueryTree(dpy, root, &rootReturn, &parentReturn, + &children, &numChildren)) { + for (i = 0; i < numChildren; i++) { + Atom actual_type; + int actual_format; + unsigned long nitems, bytesafter; + unsigned char *newRoot = 0; + + if (XGetWindowProperty(dpy, children[i], + __SWM_VROOT, 0, 1, False, XA_WINDOW, + &actual_type, &actual_format, + &nitems, &bytesafter, + &newRoot) == Success + && newRoot) { + root = *((Window *) newRoot); + break; + } + } + if (children) + XFree((char *)children); + } + + save_screen = screen; + } + + return root; +} + +#endif /* _VROOT_H_ */ diff -urN xdpyinfo-1.0.1/xdpyinfo.c xdpyinfo-1.0.2/xdpyinfo.c --- xdpyinfo-1.0.1/xdpyinfo.c 2005-07-08 05:54:09.000000000 +0100 +++ xdpyinfo-1.0.2/xdpyinfo.c 2006-08-23 05:59:57.000000000 +0100 @@ -128,12 +128,15 @@ #include #include #include +#include "vroot.h" /* Turn a NULL pointer string into an empty string */ #define NULLSTR(x) (((x)!=NULL)?(x):("")) char *ProgramName; Bool queryExtensions = False; +Bool version = False; +const char ProgramVersion[] = "1.0.2"; static int print_event_mask(char *buf, int lastcol, int indent, long mask); @@ -497,6 +500,7 @@ putchar ('\n'); if (depths) XFree ((char *) depths); printf (" root window id: 0x%lx\n", RootWindow (dpy, scr)); + printf (" virtual root window id: 0x%lx\n", VirtualRootWindowOfScreen(ScreenOfDisplay(dpy, scr))); printf (" depth of root window: %d plane%s\n", DisplayPlanes (dpy, scr), DisplayPlanes (dpy, scr) == 1 ? "" : "s"); @@ -1477,10 +1481,17 @@ } } +static void +print_version() +{ + printf("xdpyinfo %s\n", &ProgramVersion); +} + static void usage(void) { fprintf (stderr, "usage: %s [options]\n", ProgramName); + fprintf (stderr, "-version\t\tprint version\n"); fprintf (stderr, "-display displayname\tserver to query\n"); fprintf (stderr, "-queryExtensions\tprint info returned by XQueryExtension\n"); fprintf (stderr, "-ext all\t\tprint detailed info for all supported extensions\n"); @@ -1511,24 +1522,31 @@ } else if (!strncmp("-ext", arg, len)) { if (++i >= argc) usage (); mark_extension_for_printing(argv[i]); + } else if (!strncmp("-version", arg, len)) { + version = True; } else usage (); } - dpy = XOpenDisplay (displayname); - if (!dpy) { - fprintf (stderr, "%s: unable to open display \"%s\".\n", - ProgramName, XDisplayName (displayname)); - exit (1); - } + if (version) { + print_version(); + } else { + dpy = XOpenDisplay (displayname); + if (!dpy) { + fprintf (stderr, "%s: unable to open display \"%s\".\n", + ProgramName, XDisplayName (displayname)); + exit (1); + } - print_display_info (dpy); - for (i = 0; i < ScreenCount (dpy); i++) { - print_screen_info (dpy, i); - } + print_display_info (dpy); + for (i = 0; i < ScreenCount (dpy); i++) { + print_screen_info (dpy, i); + } - print_marked_extensions(dpy); + print_marked_extensions(dpy); + + XCloseDisplay (dpy); + } - XCloseDisplay (dpy); exit (0); }