summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2010-06-06 16:06:07 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2010-06-13 13:08:40 -0700
commitc72551c9e8805d44ee76f6723cada6843657031b (patch)
treecfaad795c4d95ef605de41b235cd7eeb45114624
parent6001e8721f232aa1f8b584d903edcea148b0ebc5 (diff)
Make spacing more consistent
Different functions had 2, 4, 6, or 8 spaces per indent level, standardized on 4 spaces. Also more consistenly put spaces before parens. Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--dsimple.c251
-rw-r--r--xwininfo.c1249
2 files changed, 750 insertions, 750 deletions
diff --git a/dsimple.c b/dsimple.c
index 9bc46ea..51df01f 100644
--- a/dsimple.c
+++ b/dsimple.c
@@ -63,7 +63,7 @@ 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(
+char *Get_Display_Name (
int *pargc, /* MODIFIED */
char **argv) /* MODIFIED */
{
@@ -82,10 +82,10 @@ char *Get_Display_Name(
*pargc -= 2;
continue;
}
- if (!strcmp(arg,"-")) {
- while (i<argc)
- *pargv++ = argv[i++];
- break;
+ if (!strcmp (arg,"-")) {
+ while (i<argc)
+ *pargv++ = argv[i++];
+ break;
}
*pargv++ = arg;
}
@@ -100,18 +100,18 @@ 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(char *display_name)
+Display *Open_Display (char *display_name)
{
Display *d;
- d = XOpenDisplay(display_name);
+ d = XOpenDisplay (display_name);
if (d == NULL) {
fprintf (stderr, "%s: unable to open display '%s'\n",
program_name, XDisplayName (display_name));
- exit(1);
+ exit (1);
}
- return(d);
+ return (d);
}
@@ -122,26 +122,26 @@ Display *Open_Display(char *display_name)
* for this display is then stored in screen.
* Does not require dpy or screen defined.
*/
-void Setup_Display_And_Screen(
+void Setup_Display_And_Screen (
int *argc, /* MODIFIED */
char **argv) /* MODIFIED */
{
- char *displayname = NULL;
-
- displayname = Get_Display_Name(argc, argv);
- dpy = Open_Display (displayname);
- screen = XDefaultScreen(dpy);
+ char *displayname = NULL;
+
+ 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;
-
- XCloseDisplay(dpy);
+
+ XCloseDisplay (dpy);
dpy = NULL;
}
@@ -168,56 +168,55 @@ 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(
+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 if (++argv, --argc==0) usage()
#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;
- 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;
- w=0;
- sscanf(OPTION, "0x%lx", &w);
- if (!w)
- sscanf(OPTION, "%lu", &w);
- if (!w)
- Fatal_Error("Invalid window id format: %s.", OPTION);
- continue;
- }
+ while (NXTOPTP) {
+ if (!strcmp (OPTION, "-")) {
+ COPYOPT;
+ while (NXTOPTP)
COPYOPT;
+ break;
+ }
+ if (!strcmp (OPTION, "-root")) {
+ w = RootWindow (dpy, screen);
+ continue;
+ }
+ if (!strcmp (OPTION, "-name")) {
+ NXTOPT;
+ 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;
+ w = 0;
+ sscanf (OPTION, "0x%lx", &w);
+ if (!w)
+ sscanf (OPTION, "%lu", &w);
+ if (!w)
+ Fatal_Error ("Invalid window id format: %s.", OPTION);
+ continue;
}
- ARGC = nargc;
-
- return(w);
+ COPYOPT;
+ }
+ ARGC = nargc;
+
+ return (w);
}
/*
@@ -231,51 +230,51 @@ Window Select_Window_Args(
* Routine to let user select a window using the mouse
*/
-Window Select_Window(Display *dpy, int descend)
+Window Select_Window (Display *dpy, int descend)
{
- int status;
- Cursor cursor;
- XEvent event;
- Window target_win = None, root = RootWindow(dpy,screen);
- int buttons = 0;
-
- /* Make the target cursor */
- cursor = XCreateFontCursor(dpy, XC_crosshair);
-
- /* Grab the pointer using target cursor, letting it room all over */
- status = XGrabPointer(dpy, 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(dpy, SyncPointer, CurrentTime);
- XWindowEvent(dpy, 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 (dpy,screen);
+ int buttons = 0;
+
+ /* Make the target cursor */
+ cursor = XCreateFontCursor (dpy, XC_crosshair);
+
+ /* Grab the pointer using target cursor, letting it room all over */
+ status = XGrabPointer (dpy, 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 (dpy, SyncPointer, CurrentTime);
+ XWindowEvent (dpy, 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(dpy, CurrentTime); /* Done with pointer */
+ XUngrabPointer (dpy, CurrentTime); /* Done with pointer */
- if (!descend || (target_win == root))
- return(target_win);
+ if (!descend || (target_win == root))
+ return (target_win);
- target_win = Find_Client(dpy, root, target_win);
+ target_win = Find_Client (dpy, root, target_win);
- return(target_win);
+ return (target_win);
}
@@ -286,30 +285,30 @@ Window Select_Window(Display *dpy, 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(
+Window Window_With_Name (
Display *dpy,
Window top,
char *name)
{
- Window *children, dummy;
- unsigned int nchildren;
- int i;
- Window w=0;
- char *window_name;
-
- if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name))
- return(top);
-
- if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren))
- return(0);
-
- for (i=0; i<nchildren; i++) {
- w = Window_With_Name(dpy, children[i], name);
- if (w)
- break;
- }
- if (children) XFree ((char *)children);
- return(w);
+ Window *children, dummy;
+ unsigned int nchildren;
+ int i;
+ Window w=0;
+ char *window_name;
+
+ if (XFetchName (dpy, top, &window_name) && !strcmp (window_name, name))
+ return (top);
+
+ if (!XQueryTree (dpy, top, &dummy, &dummy, &children, &nchildren))
+ return (0);
+
+ for (i = 0; i < nchildren; i++) {
+ w = Window_With_Name (dpy, children[i], name);
+ if (w)
+ break;
+ }
+ if (children) XFree ((char *)children);
+ return (w);
}
@@ -317,16 +316,16 @@ Window Window_With_Name(
* Standard fatal error routine - call like printf
* Does not require dpy or screen defined.
*/
-void Fatal_Error(char *msg, ...)
+void Fatal_Error (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/xwininfo.c b/xwininfo.c
index eb4407c..7ca7cd9 100644
--- a/xwininfo.c
+++ b/xwininfo.c
@@ -77,44 +77,44 @@ of the copyright holder.
#include "dsimple.h"
typedef struct {
- long code;
- const char *name;
+ long code;
+ const char *name;
} binding;
-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 **);
-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 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 **);
+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 const char *window_id_format = "0x%lx";
#ifndef HAVE_STRLCAT
-static size_t strlcat(char *dst, const char *src, size_t dstsize)
+static size_t strlcat (char *dst, const char *src, size_t dstsize)
{
- size_t sd = strlen(dst);
- size_t ss = strlen(src);
+ size_t sd = strlen (dst);
+ size_t ss = strlen (src);
size_t s = sd + ss;
-
+
if (s < dstsize) {
- strcpy(dst + sd, src);
+ strcpy (dst + sd, src);
} else {
- strncpy(dst + sd, src, dstsize-sd-1);
+ strncpy (dst + sd, src, dstsize-sd-1);
dst[dstsize] = '\0';
}
return s;
@@ -125,31 +125,31 @@ static size_t strlcat(char *dst, const char *src, size_t dstsize)
* Report the syntax for calling xwininfo:
*/
void
-usage(void)
+usage (void)
{
fprintf (stderr,
- "usage: %s [-options ...]\n\n"
- "where options include:\n"
- " -help print this message\n"
- " -display host:dpy X server to contact\n"
- " -root use the root window\n"
- " -id windowid use the window with the specified id\n"
- " -name windowname use the window with the specified name\n"
- " -int print window id in decimal\n"
- " -children print parent and child identifiers\n"
- " -tree print children identifiers recursively\n"
- " -stats print window geometry [DEFAULT]\n"
- " -bits print window pixel information\n"
- " -events print events selected for on window\n"
- " -size print size hints\n"
- " -wm print window manager hints\n"
- " -shape print shape extents\n"
- " -frame don't ignore window manager frames\n"
- " -english print sizes in english units\n"
- " -metric print sizes in metric units\n"
- " -all -tree, -stats, -bits, -events, -wm, -size, -shape\n"
- "\n",
- program_name);
+ "usage: %s [-options ...]\n\n"
+ "where options include:\n"
+ " -help print this message\n"
+ " -display host:dpy X server to contact\n"
+ " -root use the root window\n"
+ " -id windowid use the window with the specified id\n"
+ " -name windowname use the window with the specified name\n"
+ " -int print window id in decimal\n"
+ " -children print parent and child identifiers\n"
+ " -tree print children identifiers recursively\n"
+ " -stats print window geometry [DEFAULT]\n"
+ " -bits print window pixel information\n"
+ " -events print events selected for on window\n"
+ " -size print size hints\n"
+ " -wm print window manager hints\n"
+ " -shape print shape extents\n"
+ " -frame don't ignore window manager frames\n"
+ " -english print sizes in english units\n"
+ " -metric print sizes in metric units\n"
+ " -all -tree, -stats, -bits, -events, -wm, -size, -shape\n"
+ "\n",
+ program_name);
exit (1);
}
@@ -164,21 +164,21 @@ usage(void)
*
*/
-#define getdsp(var,fn) var = fn(dpy, DefaultScreen(dpy))
-static int xp=0, xmm=0;
-static int yp=0, ymm=0;
-static int bp=0, bmm=0;
+#define getdsp(var,fn) var = fn (dpy, DefaultScreen (dpy))
+static int xp = 0, xmm = 0;
+static int yp = 0, ymm = 0;
+static int bp = 0, bmm = 0;
static int english = 0, metric = 0;
static void
-scale_init(void)
+scale_init (void)
{
- getdsp(yp, DisplayHeight);
- getdsp(ymm, DisplayHeightMM);
- getdsp(xp, DisplayWidth);
- getdsp(xmm, DisplayWidthMM);
- bp = xp + yp;
- bmm = xmm + ymm;
+ getdsp (yp, DisplayHeight);
+ getdsp (ymm, DisplayHeightMM);
+ getdsp (xp, DisplayWidth);
+ getdsp (xmm, DisplayWidthMM);
+ bp = xp + yp;
+ bmm = xmm + ymm;
}
#define MILE (5280*12)
@@ -186,17 +186,17 @@ scale_init(void)
#define FOOT (12)
static char *
-nscale(int n, int np, int nmm, char *nbuf, size_t nbufsize)
+nscale (int n, int np, int nmm, char *nbuf, size_t nbufsize)
{
int s;
- snprintf(nbuf, nbufsize, "%d", n);
-
+ snprintf (nbuf, nbufsize, "%d", n);
+
if (metric||english) {
- s = strlcat(nbuf, " (", nbufsize);
+ s = strlcat (nbuf, " (", nbufsize);
if (metric) {
- snprintf(nbuf+s, nbufsize-s, "%.2f mm%s",
- ((double) n)*nmm/np, english ? "; " : "");
+ snprintf (nbuf+s, nbufsize-s, "%.2f mm%s",
+ ((double) n) * nmm/np , english ? "; " : "");
}
if (english) {
double inch_frac;
@@ -209,71 +209,71 @@ nscale(int n, int np, int nmm, char *nbuf, size_t nbufsize)
if (inr >= MILE) {
mi = inr/MILE;
inr %= MILE;
- s = strlen(nbuf);
- snprintf(nbuf+s, nbufsize-s, "%d %s(?!?)",
- mi, (mi==1) ? "mile" : "miles");
+ 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");
+ 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");
+ 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);
+ s = strlen (nbuf);
+ snprintf (nbuf+s, nbufsize-s, "%.2f inches", inr+inch_frac);
}
}
strlcat (nbuf, ")", nbufsize);
}
- return(nbuf);
-}
-
+ return (nbuf);
+}
+
static char xbuf[BUFSIZ];
static char *
-xscale(int x)
+xscale (int x)
{
- if(!xp) {
- scale_init();
- }
- return(nscale(x, xp, xmm, xbuf, sizeof(xbuf)));
+ if (!xp) {
+ scale_init ();
+ }
+ return (nscale (x, xp, xmm, xbuf, sizeof(xbuf)));
}
static char ybuf[BUFSIZ];
static char *
-yscale(int y)
+yscale (int y)
{
- if(!yp) {
- scale_init();
- }
- return(nscale(y, yp, ymm, ybuf, sizeof(ybuf)));
+ if (!yp) {
+ scale_init ();
+ }
+ return (nscale (y, yp, ymm, ybuf, sizeof(ybuf)));
}
static char bbuf[BUFSIZ];
static char *
-bscale(int b)
+bscale (int b)
{
- if(!bp) {
- scale_init();
- }
- return(nscale(b, bp, bmm, bbuf, sizeof(bbuf)));
+ if (!bp) {
+ scale_init ();
+ }
+ return (nscale (b, bp, bmm, bbuf, sizeof(bbuf)));
}
/* end of pixel to inch, metric converter */
@@ -283,143 +283,143 @@ bscale(int b)
/* ARGSUSED */
static int
-bad_window_handler(Display *disp, XErrorEvent *err)
+bad_window_handler (Display *disp, XErrorEvent *err)
{
char badid[20];
- snprintf(badid, sizeof(badid), window_id_format, err->resourceid);
- Fatal_Error("No such window with id %s.", badid);
+ snprintf (badid, sizeof(badid), window_id_format, err->resourceid);
+ Fatal_Error ("No such window with id %s.", badid);
exit (1);
return 0;
}
int
-main(int argc, char **argv)
+main (int argc, char **argv)
{
- register int i;
- int tree = 0, stats = 0, bits = 0, events = 0, wm = 0, size = 0, shape = 0;
- int frame = 0, children = 0;
- Window window;
+ register int i;
+ int tree = 0, stats = 0, bits = 0, events = 0, wm = 0, size = 0, shape = 0;
+ int frame = 0, children = 0;
+ Window window;
- INIT_NAME;
+ INIT_NAME;
- if (!setlocale(LC_ALL, ""))
- fprintf(stderr, "%s: can not set locale properly\n", program_name);
+ if (!setlocale (LC_ALL, ""))
+ fprintf (stderr, "%s: can not set locale properly\n", program_name);
- /* Open display, handle command line arguments */
- Setup_Display_And_Screen(&argc, argv);
+ /* Open display, handle command line arguments */
+ Setup_Display_And_Screen (&argc, argv);
- /* Get window selected on command line, if any */
- window = Select_Window_Args(&argc, argv);
+ /* Get window selected on command line, if any */
+ window = Select_Window_Args (&argc, argv);
- /* Handle our command line arguments */
- for (i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "-help"))
- usage();
- if (!strcmp(argv[i], "-int")) {
- window_id_format = "%ld";
- continue;
- }
- if (!strcmp(argv[i], "-children")) {
- children = 1;
- continue;
- }
- if (!strcmp(argv[i], "-tree")) {
- tree = 1;
- continue;
- }
- if (!strcmp(argv[i], "-stats")) {
- stats = 1;
- continue;
- }
- if (!strcmp(argv[i], "-bits")) {
- bits = 1;
- continue;
- }
- if (!strcmp(argv[i], "-events")) {
- events = 1;
- continue;
- }
- if (!strcmp(argv[i], "-wm")) {
- wm = 1;
- continue;
- }
- if (!strcmp(argv[i], "-frame")) {
- frame = 1;
- continue;
- }
- if (!strcmp(argv[i], "-size")) {
- size = 1;
- continue;
- }
- if (!strcmp(argv[i], "-shape")) {
- shape = 1;
- continue;
- }
- if (!strcmp(argv[i], "-english")) {
- english = 1;
- continue;
+ /* Handle our command line arguments */
+ for (i = 1; i < argc; i++) {
+ if (!strcmp (argv[i], "-help"))
+ usage ();
+ if (!strcmp (argv[i], "-int")) {
+ window_id_format = "%ld";
+ continue;
+ }
+ if (!strcmp (argv[i], "-children")) {
+ children = 1;
+ continue;
+ }
+ if (!strcmp (argv[i], "-tree")) {
+ tree = 1;
+ continue;
+ }
+ if (!strcmp (argv[i], "-stats")) {
+ stats = 1;
+ continue;
+ }
+ if (!strcmp (argv[i], "-bits")) {
+ bits = 1;
+ continue;
+ }
+ if (!strcmp (argv[i], "-events")) {
+ events = 1;
+ continue;
+ }
+ if (!strcmp (argv[i], "-wm")) {
+ wm = 1;
+ continue;
+ }
+ if (!strcmp (argv[i], "-frame")) {
+ frame = 1;
+ continue;
+ }
+ if (!strcmp (argv[i], "-size")) {
+ size = 1;
+ continue;
+ }
+ if (!strcmp (argv[i], "-shape")) {
+ shape = 1;
+ continue;
+ }
+ if (!strcmp (argv[i], "-english")) {
+ english = 1;
+ continue;
+ }
+ if (!strcmp (argv[i], "-metric")) {
+ metric = 1;
+ continue;
+ }
+ if (!strcmp (argv[i], "-all")) {
+ tree = stats = bits = events = wm = size = shape = 1;
+ continue;
+ }
+ usage ();
}
- if (!strcmp(argv[i], "-metric")) {
- metric = 1;
- continue;
+
+ /* If no window selected on command line, let user pick one the hard way */
+ if (!window) {
+ printf ("\n"
+ "xwininfo: Please select the window about which you\n"
+ " would like information by clicking the\n"
+ " mouse in that window.\n");
+ window = Select_Window (dpy, !frame);
}
- if (!strcmp(argv[i], "-all")) {
- tree = stats = bits = events = wm = size = shape = 1;
- continue;
+
+ /*
+ * Do the actual displaying as per parameters
+ */
+ if (!(children || tree || bits || events || wm || size))
+ stats = 1;
+
+ /*
+ * make sure that the window is valid
+ */
+ {
+ Window root;
+ int x, y;
+ unsigned width, height, bw, depth;
+ XErrorHandler old_handler;
+
+ old_handler = XSetErrorHandler (bad_window_handler);
+ XGetGeometry (dpy, window, &root, &x, &y, &width, &height, &bw, &depth);
+ XSync (dpy, False);
+ (void) XSetErrorHandler (old_handler);
}
- usage();
- }
-
- /* If no window selected on command line, let user pick one the hard way */
- if (!window) {
- printf("\n"
- "xwininfo: Please select the window about which you\n"
- " would like information by clicking the\n"
- " mouse in that window.\n");
- window = Select_Window(dpy, !frame);
- }
-
- /*
- * Do the actual displaying as per parameters
- */
- if (!(children || tree || bits || events || wm || size))
- stats = 1;
-
- /*
- * make sure that the window is valid
- */
- {
- Window root;
- int x, y;
- unsigned width, height, bw, depth;
- XErrorHandler old_handler;
-
- old_handler = XSetErrorHandler(bad_window_handler);
- XGetGeometry (dpy, window, &root, &x, &y, &width, &height, &bw, &depth);
- XSync (dpy, False);
- (void) XSetErrorHandler(old_handler);
- }
-
- printf("\nxwininfo: Window id: ");
- Display_Window_Id(window, True);
- if (children || tree)
- Display_Tree_Info(window, tree);
- if (stats)
- Display_Stats_Info(window);
- if (bits)
- Display_Bits_Info(window);
- if (events)
- Display_Events_Info(window);
- if (wm)
- Display_WM_Info(window);
- if (size)
- Display_Size_Hints(window);
- if (shape)
- Display_Window_Shape(window);
- printf("\n");
- exit(0);
+
+ printf ("\nxwininfo: Window id: ");
+ Display_Window_Id (window, True);
+ if (children || tree)
+ Display_Tree_Info (window, tree);
+ if (stats)
+ Display_Stats_Info (window);
+ if (bits)
+ Display_Bits_Info (window);
+ if (events)
+ Display_Events_Info (window);
+ if (wm)
+ Display_WM_Info (window);
+ if (size)
+ Display_Size_Hints (window);
+ if (shape)
+ Display_Window_Shape (window);
+ printf ("\n");
+ exit (0);
}
@@ -429,29 +429,29 @@ main(int argc, char **argv)
static char _lookup_buffer[100];
static const char *
-LookupL(long code, const binding *table)
+LookupL (long code, const binding *table)
{
- const char *name;
-
- snprintf(_lookup_buffer, sizeof(_lookup_buffer),
- "unknown (code = %ld. = 0x%lx)", code, code);
- name = _lookup_buffer;
-
- while (table->name) {
- if (table->code == code) {
- name = table->name;
- break;
- }
- table++;
+ const char *name;
+
+ snprintf (_lookup_buffer, sizeof(_lookup_buffer),
+ "unknown (code = %ld. = 0x%lx)", code, code);
+ name = _lookup_buffer;
+
+ while (table->name) {
+ if (table->code == code) {
+ name = table->name;
+ break;
}
+ table++;
+ }
- return(name);
+ return (name);
}
static const char *
-Lookup(int code, const binding *table)
+Lookup (int code, const binding *table)
{
- return LookupL((long)code, table);
+ return LookupL ((long)code, table);
}
/*
@@ -459,42 +459,42 @@ Lookup(int code, const binding *table)
*/
static void
-Display_Window_Id(Window window, Bool newline_wanted)
+Display_Window_Id (Window window, Bool newline_wanted)
{
XTextProperty tp;
-
- printf(window_id_format, window); /* print id # in hex/dec */
+
+ printf (window_id_format, window); /* print id # in hex/dec */
if (!window) {
- printf(" (none)");
+ printf (" (none)");
} else {
- if (window == RootWindow(dpy, screen)) {
- printf(" (the root window)");
+ if (window == RootWindow (dpy, screen)) {
+ printf (" (the root window)");
}
- if (!XGetWMName(dpy, window, &tp)) { /* Get window name if any */
- printf(" (has no name)");
+ if (!XGetWMName (dpy, window, &tp)) { /* Get window name if any */
+ printf (" (has no name)");
} else if (tp.nitems > 0) {
- printf(" \"");
+ printf (" \"");
{
int count = 0, i, ret;
char **list = NULL;
- ret = XmbTextPropertyToTextList(dpy, &tp, &list, &count);
- if((ret == Success || ret > 0) && list != NULL){
- for(i=0; i<count; i++)
- printf("%s", list[i]);
- XFreeStringList(list);
+ ret = XmbTextPropertyToTextList (dpy, &tp, &list, &count);
+ if ((ret == Success || ret > 0) && list != NULL){
+ for (i = 0; i < count; i++)
+ printf ("%s", list[i]);
+ XFreeStringList (list);
} else {
- printf("%s", tp.value);
+ printf ("%s", tp.value);
}
}
- printf("\"");
+ printf ("\"");
}
else
- printf(" (has no name)");
+ printf (" (has no name)");
}
if (newline_wanted)
- printf("\n");
+ printf ("\n");
return;
}
@@ -558,167 +558,168 @@ static const binding _visual_classes[] = {
{ 0, NULL }};
static void
-Display_Stats_Info(Window window)
+Display_Stats_Info (Window window)
{
- XWindowAttributes win_attributes;
- XVisualInfo vistemplate, *vinfo;
- XSizeHints hints;
- int dw = DisplayWidth (dpy, screen), dh = DisplayHeight (dpy, screen);
- int rx, ry, xright, ybelow;
- int showright = 0, showbelow = 0;
- Status status;
- Window wmframe;
- int junk;
- long longjunk;
- Window junkwin;
-
- if (!XGetWindowAttributes(dpy, window, &win_attributes))
- Fatal_Error("Can't get window attributes.");
- vistemplate.visualid = XVisualIDFromVisual(win_attributes.visual);
- vinfo = XGetVisualInfo(dpy, VisualIDMask, &vistemplate, &junk);
-
- (void) XTranslateCoordinates (dpy, window, win_attributes.root,
- -win_attributes.border_width,
- -win_attributes.border_width,
- &rx, &ry, &junkwin);
-
- xright = (dw - rx - win_attributes.border_width * 2 -
- win_attributes.width);
- ybelow = (dh - ry - win_attributes.border_width * 2 -
- win_attributes.height);
-
- printf("\n");
- printf(" Absolute upper-left X: %s\n", xscale(rx));
- printf(" Absolute upper-left Y: %s\n", yscale(ry));
- printf(" Relative upper-left X: %s\n", xscale(win_attributes.x));
- printf(" Relative upper-left Y: %s\n", yscale(win_attributes.y));
- printf(" Width: %s\n", xscale(win_attributes.width));
- printf(" Height: %s\n", yscale(win_attributes.height));
- printf(" Depth: %d\n", win_attributes.depth);
- printf(" Visual: 0x%lx\n", vinfo->visualid);
- printf(" Visual Class: %s\n", Lookup(vinfo->class, _visual_classes));
- printf(" Border width: %s\n", bscale(win_attributes.border_width));
- printf(" Class: %s\n",
- Lookup(win_attributes.class, _window_classes));
- printf(" Colormap: 0x%lx (%sinstalled)\n",
- win_attributes.colormap, win_attributes.map_installed ? "" : "not ");
- printf(" Bit Gravity State: %s\n",
- Lookup(win_attributes.bit_gravity, _bit_gravity_states));
- printf(" Window Gravity State: %s\n",
- Lookup(win_attributes.win_gravity, _window_gravity_states));
- printf(" Backing Store State: %s\n",
- Lookup(win_attributes.backing_store, _backing_store_states));
- printf(" Save Under State: %s\n",
- win_attributes.save_under ? "yes" : "no");
- printf(" Map State: %s\n",
- Lookup(win_attributes.map_state, _map_states));
- printf(" Override Redirect State: %s\n",
- win_attributes.override_redirect ? "yes" : "no");
- printf(" Corners: +%d+%d -%d+%d -%d-%d +%d-%d\n",
- rx, ry, xright, ry, xright, ybelow, rx, ybelow);
-
- XFree(vinfo);
-
- /*
- * compute geometry string that would recreate window
- */
- printf(" -geometry ");
-
- /* compute size in appropriate units */
- status = XGetWMNormalHints(dpy, window, &hints, &longjunk);
- if (status && hints.flags & PResizeInc &&
- hints.width_inc != 0 && hints.height_inc != 0) {
- if (hints.flags & (PBaseSize|PMinSize)) {
- if (hints.flags & PBaseSize) {
- win_attributes.width -= hints.base_width;
- win_attributes.height -= hints.base_height;
- } else {
- /* ICCCM says MinSize is default for BaseSize */
- win_attributes.width -= hints.min_width;
- win_attributes.height -= hints.min_height;
- }
- }
- printf("%dx%d", win_attributes.width/hints.width_inc,
- win_attributes.height/hints.height_inc);
- } else
- printf("%dx%d", win_attributes.width, win_attributes.height);
-
- if (!(hints.flags&PWinGravity))
- hints.win_gravity = NorthWestGravity; /* per ICCCM */
- /* find our window manager frame, if any */
- wmframe = window;
- while (True) {
- Window root, parent;
- Window *childlist;
- unsigned int ujunk;
-
- status = XQueryTree(dpy, wmframe, &root, &parent, &childlist, &ujunk);
- if (parent == root || !parent || !status)
- break;
- wmframe = parent;
- if (status && childlist)
- XFree((char *)childlist);
- }
- if (wmframe != window) {
- /* WM reparented, so find edges of the frame */
- /* Only works for ICCCM-compliant WMs, and then only if the
- window has corner gravity. We would need to know the original width
- of the window to correctly handle the other gravities. */
-
- XWindowAttributes frame_attr;
-
- if (!XGetWindowAttributes(dpy, wmframe, &frame_attr))
- Fatal_Error("Can't get frame attributes.");
- switch (hints.win_gravity) {
- case NorthWestGravity: case SouthWestGravity:
- case NorthEastGravity: case SouthEastGravity:
- case WestGravity:
- rx = frame_attr.x;
- }
- switch (hints.win_gravity) {
- case NorthWestGravity: case SouthWestGravity:
- case NorthEastGravity: case SouthEastGravity:
- case EastGravity:
- xright = dw - frame_attr.x - frame_attr.width -
- 2*frame_attr.border_width;
- }
- switch (hints.win_gravity) {
- case NorthWestGravity: case SouthWestGravity:
- case NorthEastGravity: case SouthEastGravity:
- case NorthGravity:
- ry = frame_attr.y;
- }
- switch (hints.win_gravity) {
- case NorthWestGravity: case SouthWestGravity:
- case NorthEastGravity: case SouthEastGravity:
- case SouthGravity:
- ybelow = dh - frame_attr.y - frame_attr.height -
- 2*frame_attr.border_width;
- }
- }
- /* If edge gravity, offer a corner on that edge (because the application
- programmer cares about that edge), otherwise offer upper left unless
- some other corner is close to an edge of the screen.
- (For corner gravity, assume gravity was set by XWMGeometry.
- For CenterGravity, it doesn't matter.) */
- if (hints.win_gravity == EastGravity ||
- (abs(xright) <= 100 && abs(xright) < abs(rx)
- && hints.win_gravity != WestGravity))
- showright = 1;
- if (hints.win_gravity == SouthGravity ||
- (abs(ybelow) <= 100 && abs(ybelow) < abs(ry)
- && hints.win_gravity != NorthGravity))
- showbelow = 1;
-
- if (showright)
- printf("-%d", xright);
- else
- printf("+%d", rx);
- if (showbelow)
- printf("-%d", ybelow);
- else
- printf("+%d", ry);
- printf("\n");
+ XWindowAttributes win_attributes;
+ XVisualInfo vistemplate, *vinfo;
+ XSizeHints hints;
+ int dw = DisplayWidth (dpy, screen), dh = DisplayHeight (dpy, screen);
+ int rx, ry, xright, ybelow;
+ int showright = 0, showbelow = 0;
+ Status status;
+ Window wmframe;
+ int junk;
+ long longjunk;
+ Window junkwin;
+
+ if (!XGetWindowAttributes (dpy, window, &win_attributes))
+ Fatal_Error ("Can't get window attributes.");
+ vistemplate.visualid = XVisualIDFromVisual (win_attributes.visual);
+ vinfo = XGetVisualInfo (dpy, VisualIDMask, &vistemplate, &junk);
+
+ (void) XTranslateCoordinates (dpy, window, win_attributes.root,
+ -win_attributes.border_width,
+ -win_attributes.border_width,
+ &rx, &ry, &junkwin);
+
+ xright = (dw - rx - win_attributes.border_width * 2 -
+ win_attributes.width);
+ ybelow = (dh - ry - win_attributes.border_width * 2 -
+ win_attributes.height);
+
+ printf ("\n");
+ printf (" Absolute upper-left X: %s\n", xscale (rx));
+ printf (" Absolute upper-left Y: %s\n", yscale (ry));
+ printf (" Relative upper-left X: %s\n", xscale (win_attributes.x));
+ printf (" Relative upper-left Y: %s\n", yscale (win_attributes.y));
+ printf (" Width: %s\n", xscale (win_attributes.width));
+ printf (" Height: %s\n", yscale (win_attributes.height));
+ printf (" Depth: %d\n", win_attributes.depth);
+ printf (" Visual: 0x%lx\n", vinfo->visualid);
+ printf (" Visual Class: %s\n", Lookup (vinfo->class, _visual_classes));
+ printf (" Border width: %s\n", bscale (win_attributes.border_width));
+ printf (" Class: %s\n",
+ Lookup (win_attributes.class, _window_classes));
+ printf (" Colormap: 0x%lx (%sinstalled)\n",
+ win_attributes.colormap,
+ win_attributes.map_installed ? "" : "not ");
+ printf (" Bit Gravity State: %s\n",
+ Lookup (win_attributes.bit_gravity, _bit_gravity_states));
+ printf (" Window Gravity State: %s\n",
+ Lookup (win_attributes.win_gravity, _window_gravity_states));
+ printf (" Backing Store State: %s\n",
+ Lookup (win_attributes.backing_store, _backing_store_states));
+ printf (" Save Under State: %s\n",
+ win_attributes.save_under ? "yes" : "no");
+ printf (" Map State: %s\n",
+ Lookup (win_attributes.map_state, _map_states));
+ printf (" Override Redirect State: %s\n",
+ win_attributes.override_redirect ? "yes" : "no");
+ printf (" Corners: +%d+%d -%d+%d -%d-%d +%d-%d\n",
+ rx, ry, xright, ry, xright, ybelow, rx, ybelow);
+
+ XFree (vinfo);
+
+ /*
+ * compute geometry string that would recreate window
+ */
+ printf (" -geometry ");
+
+ /* compute size in appropriate units */
+ status = XGetWMNormalHints (dpy, window, &hints, &longjunk);
+ if (status && hints.flags & PResizeInc &&
+ hints.width_inc != 0 && hints.height_inc != 0) {
+ if (hints.flags & (PBaseSize|PMinSize)) {
+ if (hints.flags & PBaseSize) {
+ win_attributes.width -= hints.base_width;
+ win_attributes.height -= hints.base_height;
+ } else {
+ /* ICCCM says MinSize is default for BaseSize */
+ win_attributes.width -= hints.min_width;
+ win_attributes.height -= hints.min_height;
+ }
+ }
+ printf ("%dx%d", win_attributes.width/hints.width_inc,
+ win_attributes.height/hints.height_inc);
+ } else
+ printf ("%dx%d", win_attributes.width, win_attributes.height);
+
+ if (!(hints.flags&PWinGravity))
+ hints.win_gravity = NorthWestGravity; /* per ICCCM */
+ /* find our window manager frame, if any */
+ wmframe = window;
+ while (True) {
+ Window root, parent;
+ Window *childlist;
+ unsigned int ujunk;
+
+ status = XQueryTree (dpy, wmframe, &root, &parent, &childlist, &ujunk);
+ if (parent == root || !parent || !status)
+ break;
+ wmframe = parent;
+ if (status && childlist)
+ XFree ((char *)childlist);
+ }
+ if (wmframe != window) {
+ /* WM reparented, so find edges of the frame */
+ /* Only works for ICCCM-compliant WMs, and then only if the
+ window has corner gravity. We would need to know the original width
+ of the window to correctly handle the other gravities. */
+
+ XWindowAttributes frame_attr;
+
+ if (!XGetWindowAttributes (dpy, wmframe, &frame_attr))
+ Fatal_Error ("Can't get frame attributes.");
+ switch (hints.win_gravity) {
+ case NorthWestGravity: case SouthWestGravity:
+ case NorthEastGravity: case SouthEastGravity:
+ case WestGravity:
+ rx = frame_attr.x;
+ }
+ switch (hints.win_gravity) {
+ case NorthWestGravity: case SouthWestGravity:
+ case NorthEastGravity: case SouthEastGravity:
+ case EastGravity:
+ xright = dw - frame_attr.x - frame_attr.width -
+ 2*frame_attr.border_width;
+ }
+ switch (hints.win_gravity) {
+ case NorthWestGravity: case SouthWestGravity:
+ case NorthEastGravity: case SouthEastGravity:
+ case NorthGravity:
+ ry = frame_attr.y;
+ }
+ switch (hints.win_gravity) {
+ case NorthWestGravity: case SouthWestGravity:
+ case NorthEastGravity: case SouthEastGravity:
+ case SouthGravity:
+ ybelow = dh - frame_attr.y - frame_attr.height -
+ 2*frame_attr.border_width;
+ }
+ }
+ /* If edge gravity, offer a corner on that edge (because the application
+ programmer cares about that edge), otherwise offer upper left unless
+ some other corner is close to an edge of the screen.
+ (For corner gravity, assume gravity was set by XWMGeometry.
+ For CenterGravity, it doesn't matter.) */
+ if (hints.win_gravity == EastGravity ||
+ (abs (xright) <= 100 && abs (xright) < abs (rx)
+ && hints.win_gravity != WestGravity))
+ showright = 1;
+ if (hints.win_gravity == SouthGravity ||
+ (abs (ybelow) <= 100 && abs (ybelow) < abs (ry)
+ && hints.win_gravity != NorthGravity))
+ showbelow = 1;
+
+ if (showright)
+ printf ("-%d", xright);
+ else
+ printf ("+%d", rx);
+ if (showbelow)
+ printf ("-%d", ybelow);
+ else
+ printf ("+%d", ry);
+ printf ("\n");
}
@@ -752,25 +753,25 @@ static const binding _bool[] = {
{ 0, NULL } };
static void
-Display_Bits_Info(Window window)
+Display_Bits_Info (Window window)
{
- XWindowAttributes win_attributes;
-
- if (!XGetWindowAttributes(dpy, window, &win_attributes))
- Fatal_Error("Can't get window attributes.");
-
- printf("\n");
- printf(" Bit gravity: %s\n",
- Lookup(win_attributes.bit_gravity, _gravities+1));
- printf(" Window gravity: %s\n",
- Lookup(win_attributes.win_gravity, _gravities));
- printf(" Backing-store hint: %s\n",
- Lookup(win_attributes.backing_store, _backing_store_hint));
- printf(" Backing-planes to be preserved: 0x%lx\n",
- win_attributes.backing_planes);
- printf(" Backing pixel: %ld\n", win_attributes.backing_pixel);
- printf(" Save-unders: %s\n",
- Lookup(win_attributes.save_under, _bool));
+ XWindowAttributes win_attributes;
+
+ if (!XGetWindowAttributes (dpy, window, &win_attributes))
+ Fatal_Error ("Can't get window attributes.");
+
+ printf ("\n");
+ printf (" Bit gravity: %s\n",
+ Lookup (win_attributes.bit_gravity, _gravities+1));
+ printf (" Window gravity: %s\n",
+ Lookup (win_attributes.win_gravity, _gravities));
+ printf (" Backing-store hint: %s\n",
+ Lookup (win_attributes.backing_store, _backing_store_hint));
+ printf (" Backing-planes to be preserved: 0x%lx\n",
+ win_attributes.backing_planes);
+ printf (" Backing pixel: %ld\n", win_attributes.backing_pixel);
+ printf (" Save-unders: %s\n",
+ Lookup (win_attributes.save_under, _bool));
}
@@ -806,14 +807,14 @@ static const binding _event_mask_names[] = {
{ 0, NULL } };
static void
-Display_Event_Mask(long mask)
+Display_Event_Mask (long mask)
{
- long bit, bit_mask;
+ long bit, bit_mask;
- for (bit=0, bit_mask=1; bit<sizeof(long)*8; bit++, bit_mask <<= 1)
- if (mask & bit_mask)
- printf(" %s\n",
- LookupL(bit_mask, _event_mask_names));
+ for (bit=0, bit_mask=1; bit < sizeof(long)*8; bit++, bit_mask <<= 1)
+ if (mask & bit_mask)
+ printf (" %s\n",
+ LookupL (bit_mask, _event_mask_names));
}
@@ -821,22 +822,22 @@ Display_Event_Mask(long mask)
* Display info on events
*/
static void
-Display_Events_Info(Window window)
+Display_Events_Info (Window window)
{
- XWindowAttributes win_attributes;
+ XWindowAttributes win_attributes;
- if (!XGetWindowAttributes(dpy, window, &win_attributes))
- Fatal_Error("Can't get window attributes.");
+ if (!XGetWindowAttributes (dpy, window, &win_attributes))
+ Fatal_Error ("Can't get window attributes.");
- printf("\n");
- printf(" Someone wants these events:\n");
- Display_Event_Mask(win_attributes.all_event_masks);
+ printf ("\n");
+ printf (" Someone wants these events:\n");
+ Display_Event_Mask (win_attributes.all_event_masks);
- printf(" Do not propagate these events:\n");
- Display_Event_Mask(win_attributes.do_not_propagate_mask);
+ printf (" Do not propagate these events:\n");
+ Display_Event_Mask (win_attributes.do_not_propagate_mask);
- printf(" Override redirection?: %s\n",
- Lookup(win_attributes.override_redirect, _bool));
+ printf (" Override redirection?: %s\n",
+ Lookup (win_attributes.override_redirect, _bool));
}
@@ -850,80 +851,80 @@ Display_Events_Info(Window window)
* recurse - true to show children information
*/
static void
-Display_Tree_Info(Window window, int recurse)
+Display_Tree_Info (Window window, int recurse)
{
- display_tree_info_1(window, recurse, 0);
+ display_tree_info_1 (window, recurse, 0);
}
/*
* level - recursion level
*/
static void
-display_tree_info_1(Window window, int recurse, int level)
+display_tree_info_1 (Window window, int recurse, int level)
{
- int i, j;
- int rel_x, rel_y, abs_x, abs_y;
- unsigned int width, height, border, depth;
- Window root_win, parent_win;
- unsigned int num_children;
- Window *child_list;
- XClassHint classhint;
-
- if (!XQueryTree(dpy, window, &root_win, &parent_win, &child_list,
- &num_children))
- Fatal_Error("Can't query window tree.");
-
- if (level == 0) {
- printf("\n");
- printf(" Root window id: ");
- Display_Window_Id(root_win, True);
- printf(" Parent window id: ");
- Display_Window_Id(parent_win, True);
- }
-
- if (level == 0 || num_children > 0) {
- printf(" ");
- for (j=0; j<level; j++) printf(" ");
- printf("%d child%s%s\n", num_children, num_children == 1 ? "" : "ren",
- num_children ? ":" : ".");
- }
-
- for (i = (int)num_children - 1; i >= 0; i--) {
- printf(" ");
- for (j=0; j<level; j++) printf(" ");
- Display_Window_Id(child_list[i], False);
- printf(": (");
- if(XGetClassHint(dpy, child_list[i], &classhint)) {
- if(classhint.res_name) {
- printf("\"%s\" ", classhint.res_name);
- XFree(classhint.res_name);
- } else
- printf("(none) ");
- if(classhint.res_class) {
- printf("\"%s\") ", classhint.res_class);
- XFree(classhint.res_class);
+ int i, j;
+ int rel_x, rel_y, abs_x, abs_y;
+ unsigned int width, height, border, depth;
+ Window root_win, parent_win;
+ unsigned int num_children;
+ Window *child_list;
+ XClassHint classhint;
+
+ if (!XQueryTree (dpy, window, &root_win, &parent_win, &child_list,
+ &num_children))
+ Fatal_Error ("Can't query window tree.");
+
+ if (level == 0) {
+ printf ("\n");
+ printf (" Root window id: ");
+ Display_Window_Id (root_win, True);
+ printf (" Parent window id: ");
+ Display_Window_Id (parent_win, True);
+ }
+
+ if (level == 0 || num_children > 0) {
+ printf (" ");
+ for (j = 0; j < level; j++) printf (" ");
+ printf ("%d child%s%s\n", num_children, num_children == 1 ? "" : "ren",
+ num_children ? ":" : ".");
+ }
+
+ for (i = (int)num_children - 1; i >= 0; i--) {
+ printf (" ");
+ for (j = 0; j < level; j++) printf (" ");
+ Display_Window_Id (child_list[i], False);
+ printf (": (");
+ if (XGetClassHint (dpy, child_list[i], &classhint)) {
+ if (classhint.res_name) {
+ printf ("\"%s\" ", classhint.res_name);
+ XFree (classhint.res_name);
+ } else
+ printf ("(none) ");
+ if (classhint.res_class) {
+ printf ("\"%s\") ", classhint.res_class);
+ XFree (classhint.res_class);
+ } else
+ printf ("(none)) ");
} else
- printf("(none)) ");
- } else
- printf(") ");
+ printf (") ");
- if (XGetGeometry(dpy, child_list[i], &root_win,
- &rel_x, &rel_y, &width, &height, &border, &depth)) {
- Window child;
+ if (XGetGeometry (dpy, child_list[i], &root_win,
+ &rel_x, &rel_y, &width, &height, &border, &depth)) {
+ Window child;
- printf (" %ux%u+%d+%d", width, height, rel_x, rel_y);
- if (XTranslateCoordinates (dpy, child_list[i], root_win,
- 0 ,0, &abs_x, &abs_y, &child)) {
- printf (" +%d+%d", abs_x - border, abs_y - border);
+ printf (" %ux%u+%d+%d", width, height, rel_x, rel_y);
+ if (XTranslateCoordinates (dpy, child_list[i], root_win,
+ 0 ,0, &abs_x, &abs_y, &child)) {
+ printf (" +%d+%d", abs_x - border, abs_y - border);
+ }
}
+ printf ("\n");
+
+ if (recurse)
+ display_tree_info_1 (child_list[i], 1, level+1);
}
- printf("\n");
-
- if (recurse)
- display_tree_info_1(child_list[i], 1, level+1);
- }
- if (child_list) XFree((char *)child_list);
+ if (child_list) XFree ((char *)child_list);
}
@@ -931,77 +932,77 @@ display_tree_info_1(Window window, int recurse, int level)
* Display a set of size hints
*/
static void
-Display_Hints(XSizeHints *hints)
+Display_Hints (XSizeHints *hints)
{
- long flags;
+ long flags;
- flags = hints->flags;
-
- if (flags & USPosition)
- printf(" User supplied location: %s, %s\n",
- xscale(hints->x), yscale(hints->y));
+ flags = hints->flags;
- if (flags & PPosition)
- printf(" Program supplied location: %s, %s\n",
- xscale(hints->x), yscale(hints->y));
+ if (flags & USPosition)
+ printf (" User supplied location: %s, %s\n",
+ xscale (hints->x), yscale (hints->y));
- if (flags & USSize) {
- printf(" User supplied size: %s by %s\n",
- xscale(hints->width), yscale(hints->height));
- }
+ if (flags & PPosition)
+ printf (" Program supplied location: %s, %s\n",
+ xscale (hints->x), yscale (hints->y));
- if (flags & PSize)
- printf(" Program supplied size: %s by %s\n",
- xscale(hints->width), yscale(hints->height));
+ if (flags & USSize) {
+ printf (" User supplied size: %s by %s\n",
+ xscale (hints->width), yscale (hints->height));
+ }
- if (flags & PMinSize)
- printf(" Program supplied minimum size: %s by %s\n",
- xscale(hints->min_width), yscale(hints->min_height));
+ if (flags & PSize)
+ printf (" Program supplied size: %s by %s\n",
+ xscale (hints->width), yscale (hints->height));
- if (flags & PMaxSize)
- printf(" Program supplied maximum size: %s by %s\n",
- xscale(hints->max_width), yscale(hints->max_height));
+ if (flags & PMinSize)
+ printf (" Program supplied minimum size: %s by %s\n",
+ xscale (hints->min_width), yscale (hints->min_height));
- if (flags & PBaseSize) {
- printf(" Program supplied base size: %s by %s\n",
- xscale(hints->base_width), yscale(hints->base_height));
- }
+ if (flags & PMaxSize)
+ printf (" Program supplied maximum size: %s by %s\n",
+ xscale (hints->max_width), yscale (hints->max_height));
- if (flags & PResizeInc) {
- printf(" Program supplied x resize increment: %s\n",
- xscale(hints->width_inc));
- printf(" Program supplied y resize increment: %s\n",
- yscale(hints->height_inc));
- if (hints->width_inc != 0 && hints->height_inc != 0) {
- if (flags & USSize)
- printf(" User supplied size in resize increments: %s by %s\n",
- (xscale(hints->width / hints->width_inc)),
- (yscale(hints->height / hints->height_inc)));
- if (flags & PSize)
- printf(" Program supplied size in resize increments: %s by %s\n",
- (xscale(hints->width / hints->width_inc)),
- (yscale(hints->height / hints->height_inc)));
- if (flags & PMinSize)
- printf(" Program supplied minimum size in resize increments: %s by %s\n",
- xscale(hints->min_width / hints->width_inc), yscale(hints->min_height / hints->height_inc));
- if (flags & PBaseSize)
- printf(" Program supplied base size in resize increments: %s by %s\n",
- (xscale(hints->base_width / hints->width_inc)),
- (yscale(hints->base_height / hints->height_inc)));
- }
- }
-
- if (flags & PAspect) {
- printf(" Program supplied min aspect ratio: %s/%s\n",
- xscale(hints->min_aspect.x), yscale(hints->min_aspect.y));
- printf(" Program supplied max aspect ratio: %s/%s\n",
- xscale(hints->max_aspect.x), yscale(hints->max_aspect.y));
- }
-
- if (flags & PWinGravity) {
- printf(" Program supplied window gravity: %s\n",
- Lookup(hints->win_gravity, _gravities));
+ if (flags & PBaseSize) {
+ printf (" Program supplied base size: %s by %s\n",
+ xscale (hints->base_width), yscale (hints->base_height));
+ }
+
+ if (flags & PResizeInc) {
+ printf (" Program supplied x resize increment: %s\n",
+ xscale (hints->width_inc));
+ printf (" Program supplied y resize increment: %s\n",
+ yscale (hints->height_inc));
+ if (hints->width_inc != 0 && hints->height_inc != 0) {
+ if (flags & USSize)
+ printf (" User supplied size in resize increments: %s by %s\n",
+ (xscale (hints->width / hints->width_inc)),
+ (yscale (hints->height / hints->height_inc)));
+ if (flags & PSize)
+ printf (" Program supplied size in resize increments: %s by %s\n",
+ (xscale (hints->width / hints->width_inc)),
+ (yscale (hints->height / hints->height_inc)));
+ if (flags & PMinSize)
+ printf (" Program supplied minimum size in resize increments: %s by %s\n",
+ xscale (hints->min_width / hints->width_inc), yscale (hints->min_height / hints->height_inc));
+ if (flags & PBaseSize)
+ printf (" Program supplied base size in resize increments: %s by %s\n",
+ (xscale (hints->base_width / hints->width_inc)),
+ (yscale (hints->base_height / hints->height_inc)));
}
+ }
+
+ if (flags & PAspect) {
+ printf (" Program supplied min aspect ratio: %s/%s\n",
+ xscale (hints->min_aspect.x), yscale (hints->min_aspect.y));
+ printf (" Program supplied max aspect ratio: %s/%s\n",
+ xscale (hints->max_aspect.x), yscale (hints->max_aspect.y));
+ }
+
+ if (flags & PWinGravity) {
+ printf (" Program supplied window gravity: %s\n",
+ Lookup (hints->win_gravity, _gravities));
+ }
}
@@ -1009,28 +1010,28 @@ Display_Hints(XSizeHints *hints)
* Display Size Hints info
*/
static void
-Display_Size_Hints(Window window)
+Display_Size_Hints (Window window)
{
- XSizeHints *hints = XAllocSizeHints();
- long supplied;
-
- printf("\n");
- if (!XGetWMNormalHints(dpy, window, hints, &supplied))
- printf(" No normal window size hints defined\n");
- else {
- printf(" Normal window size hints:\n");
- hints->flags &= supplied;
- Display_Hints(hints);
- }
+ XSizeHints *hints = XAllocSizeHints ();
+ long supplied;
- if (!XGetWMSizeHints(dpy, window, hints, &supplied, XA_WM_ZOOM_HINTS))
- printf(" No zoom window size hints defined\n");
- else {
- printf(" Zoom window size hints:\n");
- hints->flags &= supplied;
- Display_Hints(hints);
- }
- XFree((char *)hints);
+ printf ("\n");
+ if (!XGetWMNormalHints (dpy, window, hints, &supplied))
+ printf (" No normal window size hints defined\n");
+ else {
+ printf (" Normal window size hints:\n");
+ hints->flags &= supplied;
+ Display_Hints (hints);
+ }
+
+ if (!XGetWMSizeHints (dpy, window, hints, &supplied, XA_WM_ZOOM_HINTS))
+ printf (" No zoom window size hints defined\n");
+ else {
+ printf (" Zoom window size hints:\n");
+ hints->flags &= supplied;
+ Display_Hints (hints);
+ }
+ XFree ((char *)hints);
}
@@ -1044,22 +1045,22 @@ Display_Window_Shape (Window window)
if (!XShapeQueryExtension (dpy, &bs, &ws))
return;
- printf("\n");
+ printf ("\n");
XShapeQueryExtents (dpy, window, &ws, &xws, &yws, &wws, &hws,
&bs, &xbs, &ybs, &wbs, &hbs);
if (!ws)
- printf(" No window shape defined\n");
+ printf (" No window shape defined\n");
else {
- printf(" Window shape extents: %sx%s",
- xscale(wws), yscale(hws));
- printf("+%s+%s\n", xscale(xws), yscale(yws));
+ printf (" Window shape extents: %sx%s",
+ xscale (wws), yscale (hws));
+ printf ("+%s+%s\n", xscale (xws), yscale (yws));
}
if (!bs)
- printf(" No border shape defined\n");
+ printf (" No border shape defined\n");
else {
- printf(" Border shape extents: %sx%s",
- xscale(wbs), yscale(hbs));
- printf("+%s+%s\n", xscale(xbs), yscale(ybs));
+ printf (" Border shape extents: %sx%s",
+ xscale (wbs), yscale (hbs));
+ printf ("+%s+%s\n", xscale (xbs), yscale (ybs));
}
}
@@ -1075,37 +1076,37 @@ static const binding _state_hints[] = {
{ 0, NULL } };
static void
-Display_WM_Info(Window window)
+Display_WM_Info (Window window)
{
- XWMHints *wmhints;
- long flags;
-
- wmhints = XGetWMHints(dpy, window);
- printf("\n");
- if (!wmhints) {
- printf(" No window manager hints defined\n");
- return;
- }
- flags = wmhints->flags;
+ XWMHints *wmhints;
+ long flags;
- printf(" Window manager hints:\n");
+ wmhints = XGetWMHints (dpy, window);
+ printf ("\n");
+ if (!wmhints) {
+ printf (" No window manager hints defined\n");
+ return;
+ }
+ flags = wmhints->flags;
- if (flags & InputHint)
- printf(" Client accepts input or input focus: %s\n",
- Lookup(wmhints->input, _bool));
+ printf (" Window manager hints:\n");
- if (flags & IconWindowHint) {
- printf(" Icon window id: ");
- Display_Window_Id(wmhints->icon_window, True);
- }
+ if (flags & InputHint)
+ printf (" Client accepts input or input focus: %s\n",
+ Lookup (wmhints->input, _bool));
+
+ if (flags & IconWindowHint) {
+ printf (" Icon window id: ");
+ Display_Window_Id (wmhints->icon_window, True);
+ }
- if (flags & IconPositionHint)
- printf(" Initial icon position: %s, %s\n",
- xscale(wmhints->icon_x), yscale(wmhints->icon_y));
+ if (flags & IconPositionHint)
+ printf (" Initial icon position: %s, %s\n",
+ xscale (wmhints->icon_x), yscale (wmhints->icon_y));
- if (flags & StateHint)
- printf(" Initial state is %s\n",
- Lookup(wmhints->initial_state, _state_hints));
+ if (flags & StateHint)
+ printf (" Initial state is %s\n",
+ Lookup (wmhints->initial_state, _state_hints));
- XFree(wmhints);
+ XFree (wmhints);
}