[PATCH 1/2] DIX: Make PrintWindowTree actually useful

Alan Coopersmith alan.coopersmith at oracle.com
Wed Jun 15 22:31:05 PDT 2011


On 06/15/11 05:35 PM, Peter Hutterer wrote:
>> -static void
>> -PrintChildren(WindowPtr p1, int indent)
>> +static const char *
>> +get_window_name(WindowPtr pWin)
>>  {
>> -    WindowPtr p2;
>> -    int i;
>> +    PropertyPtr prop;
>> +    CompScreenPtr comp_screen = GetCompScreen(pWin->drawable.pScreen);
>> +
>> +    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->type != XA_STRING || !prop->data ||
>> +            prop->propertyName != XA_WM_NAME)
>> +            continue;
>>      }
>> +    if (!prop)
>> +        return NULL;
>> +
>> +    return prop->data;
>>  }
> 
> I don't seem to have a single window with a name. Can't spot the bug at a
> glance though 
> 
> fwiw, xprop lists WM_NAME(STRING) = "xeyes" with WM_NAME being XA_WM_NAME

Shouldn't there be something after the continue statement in the block?
Otherwise the if is pointless - if the if statement is true, go to the
next iteration, else fall through to the next iteration.

Should it be reversed to:
	   if (prop->type == XA_STRING && prop->data &&
               prop->propertyName == XA_WM_NAME)
		   return prop->data;
	}
	return NULL;
}

or even just break instead of continue?

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list