Commit 3d37db07 authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

Events.c: shorten window tree debugging code

scope improvements, use fprintf for indentation instead of loops.
parent 022d64d2
...@@ -426,20 +426,14 @@ void nxagentRemoteWindowID(Window window, Bool newline) ...@@ -426,20 +426,14 @@ void nxagentRemoteWindowID(Window window, Bool newline)
void nxagentRemoteWindowInfo(Window win, int indent, Bool newLine) void nxagentRemoteWindowInfo(Window win, int indent, Bool newLine)
{ {
XWindowAttributes attributes; XWindowAttributes attributes;
int i;
if (XGetWindowAttributes(nxagentDisplay, win, &attributes) == 0) if (XGetWindowAttributes(nxagentDisplay, win, &attributes) == 0)
{ {
return; return;
} }
for (i = 0; i < indent; i++) fprintf(stderr, "%*sx=%d y=%d width=%d height=%d class=%s map_state=%s "
{ "override_redirect=%s\n", indent, "", attributes.x, attributes.y,
fprintf(stderr, " ");
}
fprintf(stderr, "x=%d y=%d width=%d height=%d class=%s map_state=%s "
"override_redirect=%s\n", attributes.x, attributes.y,
attributes.width, attributes.height, attributes.width, attributes.height,
(attributes.class == 0) ? "CopyFromParent" : (attributes.class == 0) ? "CopyFromParent" :
((attributes.class == 1) ? "InputOutput" : "InputOnly"), ((attributes.class == 1) ? "InputOutput" : "InputOnly"),
...@@ -462,7 +456,6 @@ void nxagentRemoteWindowInfo(Window win, int indent, Bool newLine) ...@@ -462,7 +456,6 @@ void nxagentRemoteWindowInfo(Window win, int indent, Bool newLine)
void nxagentRemoteWindowsTree(Window window, int level) void nxagentRemoteWindowsTree(Window window, int level)
{ {
int i, j;
unsigned long rootWin, parentWin; unsigned long rootWin, parentWin;
unsigned int numChildren; unsigned int numChildren;
unsigned long *childList = NULL; unsigned long *childList = NULL;
...@@ -487,25 +480,15 @@ void nxagentRemoteWindowsTree(Window window, int level) ...@@ -487,25 +480,15 @@ void nxagentRemoteWindowsTree(Window window, int level)
if (level == 0 || numChildren > 0) if (level == 0 || numChildren > 0)
{ {
fprintf(stderr, " "); fprintf(stderr, "%*s", (level * 4) + 5, ""); /* 4 spaces per level */
for (j = 0; j < level; j++)
{
fprintf(stderr, " ");
}
fprintf(stderr, "%d child%s%s\n", numChildren, (numChildren == 1) ? "" : fprintf(stderr, "%d child%s%s\n", numChildren, (numChildren == 1) ? "" :
"ren", (numChildren == 1) ? ":" : "."); "ren", (numChildren == 1) ? ":" : ".");
} }
for (i = (int) numChildren - 1; i >= 0; i--) for (int i = (int) numChildren - 1; i >= 0; i--)
{ {
fprintf(stderr, " "); fprintf(stderr, "%*s", (level * 5) + 6, ""); /* 5 spaces per level */
for (j = 0; j < level; j++)
{
fprintf(stderr, " ");
}
nxagentRemoteWindowID(childList[i], TRUE); nxagentRemoteWindowID(childList[i], TRUE);
...@@ -523,7 +506,6 @@ void nxagentRemoteWindowsTree(Window window, int level) ...@@ -523,7 +506,6 @@ void nxagentRemoteWindowsTree(Window window, int level)
void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine) void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine)
{ {
int i;
int result; int result;
unsigned long ulReturnItems; unsigned long ulReturnItems;
unsigned long ulReturnBytesLeft; unsigned long ulReturnBytesLeft;
...@@ -551,13 +533,8 @@ void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine) ...@@ -551,13 +533,8 @@ void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine)
fprintf(stderr, "%s\n", "( has no name )"); fprintf(stderr, "%s\n", "( has no name )");
} }
for (i = 0; i < indent; i++) fprintf(stderr, "%*sx=%d y=%d width=%d height=%d class=%s map_state=%s "
{ "override_redirect=%s", indent, "", pWin -> drawable.x, pWin -> drawable.y,
fprintf(stderr, " ");
}
fprintf(stderr, "x=%d y=%d width=%d height=%d class=%s map_state=%s "
"override_redirect=%s", pWin -> drawable.x, pWin -> drawable.y,
pWin -> drawable.width, pWin -> drawable.height, pWin -> drawable.width, pWin -> drawable.height,
(pWin -> drawable.class == 0) ? "CopyFromParent" : (pWin -> drawable.class == 0) ? "CopyFromParent" :
((pWin -> drawable.class == 1) ? "InputOutput" : ((pWin -> drawable.class == 1) ? "InputOutput" :
...@@ -580,17 +557,11 @@ void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine) ...@@ -580,17 +557,11 @@ void nxagentInternalWindowInfo(WindowPtr pWin, int indent, Bool newLine)
void nxagentInternalWindowsTree(WindowPtr pWin, int indent) void nxagentInternalWindowsTree(WindowPtr pWin, int indent)
{ {
WindowPtr pChild;
int i;
while (pWin) while (pWin)
{ {
pChild = pWin -> firstChild; WindowPtr pChild = pWin -> firstChild;
for (i = 0; i < indent; i++) fprintf(stderr, "%*s", indent, "");
{
fprintf(stderr, " ");
}
nxagentInternalWindowInfo(pWin, indent, TRUE); nxagentInternalWindowInfo(pWin, indent, TRUE);
...@@ -1021,7 +992,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate) ...@@ -1021,7 +992,7 @@ void nxagentDispatchEvents(PredicateFuncPtr predicate)
case doDebugTree: case doDebugTree:
{ {
fprintf(stderr, "\n ========== nxagentRemoteWindowsTree ==========\n"); fprintf(stderr, "\n========== nxagentRemoteWindowsTree ============\n");
nxagentRemoteWindowsTree(nxagentWindow(screenInfo.screens[0]->root), 0); nxagentRemoteWindowsTree(nxagentWindow(screenInfo.screens[0]->root), 0);
fprintf(stderr, "\n========== nxagentInternalWindowsTree ==========\n"); fprintf(stderr, "\n========== nxagentInternalWindowsTree ==========\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment