[PATCH v2 1/6] DIX: Make PrintWindowTree actually useful
Jeremy Huddleston
jeremyhu at apple.com
Sun Jul 3 01:36:24 PDT 2011
This breaks !composite
If you want to fix XQuartz so that it doesn't crash under composite, you're more than welcome to, but short of that, would you mind fixing builds for the !composite case:
http://tinderbox.x.org/builds/2011-07-03-0000/logs/xserver/#build
--Jeremy
On Jun 22, 2011, at 2:17 AM, Daniel Stone wrote:
> Rewrite PrintWindowTree to make it actually tell you what you want to
> know.
>
> Signed-off-by: Daniel Stone <daniel at fooishbar.org>
> ---
> dix/window.c | 139 ++++++++++++++++++++++++++++++++++++++++++++----------
> include/window.h | 2 +
> 2 files changed, 115 insertions(+), 26 deletions(-)
>
> v2: Fixed formatting of <composite overlay> text.
> Fixed window name detection to actually work.
> Broke window information print out into a separate function.
>
> diff --git a/dix/window.c b/dix/window.c
> index 5defe58..556509a 100644
> --- a/dix/window.c
> +++ b/dix/window.c
> @@ -108,6 +108,7 @@ Equipment Corporation.
> #include "regionstr.h"
> #include "validate.h"
> #include "windowstr.h"
> +#include "propertyst.h"
> #include "input.h"
> #include "inputstr.h"
> #include "resource.h"
> @@ -124,10 +125,13 @@ Equipment Corporation.
> #include "dixevents.h"
> #include "globals.h"
> #include "mi.h" /* miPaintWindow */
> +#include "compint.h"
>
> #include "privates.h"
> #include "xace.h"
>
> +#include <X11/Xatom.h> /* must come after server includes */
> +
> /******
> * Window stuff for server
> *
> @@ -176,46 +180,129 @@ static Bool TileScreenSaver(ScreenPtr pScreen, int kind);
>
> #define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent))
>
> -#ifdef DEBUG
> -/******
> - * PrintWindowTree
> - * For debugging only
> - ******/
> +static const char *overlay_win_name = "<composite overlay>";
>
> -static void
> -PrintChildren(WindowPtr p1, int indent)
> +static const char *
> +get_window_name(WindowPtr pWin)
> {
> - WindowPtr p2;
> - int i;
> +#define WINDOW_NAME_BUF_LEN 512
> + PropertyPtr prop;
> + CompScreenPtr comp_screen = GetCompScreen(pWin->drawable.pScreen);
> + static char buf[WINDOW_NAME_BUF_LEN];
> + int len;
> +
> + if (comp_screen && pWin == comp_screen->pOverlayWin)
> + return overlay_win_name;
>
> - while (p1)
> + for (prop = wUserProps(pWin); prop; prop = prop->next)
> {
> - p2 = p1->firstChild;
> - ErrorF("[dix] ");
> - for (i=0; i<indent; i++) ErrorF(" ");
> - ErrorF("%lx\n", p1->drawable.id);
> - RegionPrint(&p1->clipList);
> - PrintChildren(p2, indent+4);
> - p1 = p1->nextSib;
> + if (prop->propertyName == XA_WM_NAME && prop->type == XA_STRING &&
> + prop->data)
> + {
> + len = min(prop->size, WINDOW_NAME_BUF_LEN - 1);
> + memcpy(buf, prop->data, len);
> + buf[len] = '\0';
> + return buf;
> + }
> }
> +
> + return NULL;
> +#undef WINDOW_NAME_BUF_LEN
> }
>
> -static void
> -PrintWindowTree(void)
> +static void log_window_info(WindowPtr pWin, int depth)
> {
> int i;
> - WindowPtr pWin, p1;
> + const char *win_name, *visibility;
> + BoxPtr rects;
> + ScreenPtr pScreen = pWin->drawable.pScreen;
> +
> + for (i = 0; i < (depth << 2); i++)
> + ErrorF(" ");
> +
> + win_name = get_window_name(pWin);
> + ErrorF("win 0x%.8x (%s), [%d, %d] to [%d, %d]",
> + pWin->drawable.id,
> + win_name ? win_name : "no name",
> + pWin->drawable.x, pWin->drawable.y,
> + pWin->drawable.x + pWin->drawable.width,
> + pWin->drawable.y + pWin->drawable.height);
> +
> + if (pWin->overrideRedirect)
> + ErrorF(" (override redirect)");
> + if (pWin->redirectDraw)
> + ErrorF(" (%s compositing: pixmap %x)",
> + (pWin->redirectDraw == RedirectDrawAutomatic) ?
> + "automatic" : "manual",
> + pScreen->GetWindowPixmap(pWin)->drawable.id);
> +
> + switch (pWin->visibility)
> + {
> + case VisibilityUnobscured:
> + visibility = "unobscured";
> + break;
> + case VisibilityPartiallyObscured:
> + visibility = "partially obscured";
> + break;
> + case VisibilityFullyObscured:
> + visibility = "fully obscured";
> + break;
> + case VisibilityNotViewable:
> + visibility = "unviewable";
> + break;
> + }
> + ErrorF(", %s", visibility);
> +
> + if (REGION_NOTEMPTY(pScreen, &pWin->clipList))
> + {
> + ErrorF(", clip list:");
> + rects = REGION_RECTS(&pWin->clipList);
> + for (i = 0; i < REGION_NUM_RECTS(&pWin->clipList); i++)
> + ErrorF(" [(%d, %d) to (%d, %d)]",
> + rects[i].x1, rects[i].y1,
> + rects[i].x2, rects[i].y2);
> + ErrorF("; extents [(%d, %d) to (%d, %d)]",
> + pWin->clipList.extents.x1, pWin->clipList.extents.y1,
> + pWin->clipList.extents.x2, pWin->clipList.extents.y2);
> + }
> +
> + ErrorF("\n");
> +}
> +
> +void
> +PrintWindowTree(void)
> +{
> + int scrnum, depth;
> + ScreenPtr pScreen;
> + WindowPtr pWin;
>
> - for (i=0; i<screenInfo.numScreens; i++)
> + for (scrnum = 0; scrnum < screenInfo.numScreens; scrnum++)
> {
> - ErrorF("[dix] WINDOW %d\n", i);
> - pWin = screenInfo.screens[i]->root;
> - RegionPrint(&pWin->clipList);
> - p1 = pWin->firstChild;
> - PrintChildren(p1, 4);
> + pScreen = screenInfo.screens[scrnum];
> + ErrorF("[dix] Dumping windows for screen %d (pixmap %x):\n", scrnum,
> + pScreen->GetScreenPixmap(pScreen)->drawable.id);
> + pWin = pScreen->root;
> + depth = 1;
> + while (pWin)
> + {
> + log_window_info(pWin, depth);
> + if (pWin->firstChild)
> + {
> + pWin = pWin->firstChild;
> + depth++;
> + continue;
> + }
> + while (pWin && !pWin->nextSib)
> + {
> + pWin = pWin->parent;
> + depth--;
> + }
> + if (!pWin)
> + break;
> + pWin = pWin->nextSib;
> + }
> }
> }
> -#endif
>
> int
> TraverseTree(WindowPtr pWin, VisitWindowProcPtr func, pointer data)
> diff --git a/include/window.h b/include/window.h
> index 1e4e9bf..e13598b 100644
> --- a/include/window.h
> +++ b/include/window.h
> @@ -267,4 +267,6 @@ extern _X_EXPORT void EnableMapUnmapEvents(
> WindowPtr /* pWin */ );
>
> extern _X_EXPORT void SetRootClip(ScreenPtr pScreen, Bool enable);
> +extern _X_EXPORT void PrintWindowTree(void);
> +
> #endif /* WINDOW_H */
> --
> 1.7.5.4
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
More information about the xorg-devel
mailing list