Why X protocol/server forbid zero width/height?

Russell Shaw rjshaw at netspace.net.au
Wed Nov 23 05:12:16 PST 2005


Dmitry Yu. Bolkhovityanov wrote:
> On Wed, 23 Nov 2005, Russell Shaw wrote:
> 
>> Jim Gettys wrote:
>>
>>> I have no clue; I certainly don't remember any reason for this in the
>>> dusty attic of my brain.                 - Jim
>>> b
>>>
>>> On Wed, 2005-11-23 at 11:35 +0600, Dmitry Yu. Bolkhovityanov wrote:
>>>
>>>>      Hi!
>>>>
>>>>      As specs say, and as practice confirms, attempt to set 
>>>> XWindow's width and/or height to 0 results in BadValue error.
>>>>
>>>>      BUT: why such a design decision was made (19 years ago?)?
>>>>
>>>>      Zero width and/or height seem to be a natural concept (so that
>>>> windows can exist and be "invisible" when they have no content -- 
>>>> this is particularly useful for container windows).  And forbidding 
>>>> zero size creates a "hole" in "size space", so that all widgets have 
>>>> to avoid zero size, including unnatural code like "if (width==0) 
>>>> width=1".
>>>>
>>>>      Googling through Usenet gave no answer to this question.
>>>>
>>>> P.S. Of course, now this can't be changed -- but the reasons of that
>>>>       decision are of interest for better understanding of X ideology.
>>
>> It should be able to be changed if you do your own extension. I'm going
>> to fix lots of things for my own uses.
> 
>     Well, in this case -- no.  The check is hardcoded in 
> xc/programs/Xserver/dix/window.c::ConfigureWindow(), lines 2236-2240:
> 
>     if (!w || !h)
>     {
>         client->errorValue = 0;
>         return BadValue;
>     }

X could be modded to eliminate any hard-coded problems, but still be made to
exhibit the same old behaviour to legacy apps.

>     What I'm curious about is -- why?  Why is that check at all there?

Don't know. Perhaps the original designers weren't thinking the api could
be under algorithmic control, and so decided that a zero size from a programmer
would be a mistake.



More information about the xorg mailing list