Bug 3456

Summary: MakeRootTile() and blackRoot need rethinking
Product: xorg Reporter: Daniel Stone <daniel>
Component: Server/GeneralAssignee: Xorg Project Team <xorg-team>
Status: RESOLVED WONTFIX QA Contact: Xorg Project Team <xorg-team>
Severity: enhancement    
Priority: high CC: ajax
Version: unspecified   
Hardware: All   
OS: All   
URL: http://cvs.freedesktop.org/xorg/xc/programs/Xserver/dix/window.c
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
less-bogus-root-tiling-1.patch none

Description FreeDesktop Bugzilla Database Corruption Fix User 2005-06-02 10:52:30 UTC
In xc/programs/Xserver/dix/window.c, this code exists in MakeRootTile():

    unsigned char back[128];
    ...
    register unsigned char *from, *to;
   ...
   from = (screenInfo.bitmapBitOrder == LSBFirst) ? _back_lsb : _back_msb;
   to = back;

   for (i = 4; i > 0; i--, from++)
	for (j = len; j > 0; j--)
	    *to++ = *from;

   if (blackRoot)
       bzero(back, sizeof(back));

I'm no X developer, but this looks screwy to me.  The if (blackRoot) statement
is something I do understand--for the benefit of distro makers who want their X
to start up nicely, it does away with the head-splitting hatch pattern tile. 
But it's obviously a nasty hack; it reeks of ad-hockery.  The for loop shouldn't
even be necessary with blackRoot on, so that would show up in an else (or an
#else, given a couple of changes--blackRoot originates in globals.c as a const
set to FALSE) of if (blackRoot).

But this sort of change shouldn't even require a recompile; it should be a
matter of individual taste, even if the individual doesn't feel like recompiling
X.  This is more of an environment variable sort of thing, I think, and it
should do more than just the hatch or the black.  Again, I've never developed
for X, but I offer this code for somebody who does to translate into X's
internal parlance (or at least to a more compatible C idiom) and hopefully
commit to the public codebase.


    ...
    ValidateGC((DrawablePtr)pWin->background.pixmap, pGC);
    {
        /* Process XROOTTILE env variable
            No variable:  Use default (hatch).
            Empty string: Use black.
            String:       Path to data. Hatch on failure.
        */
    
        /* see where we need to find a tile */
        char* tileloc;
        FILE* file;
    
        tileloc = getenv("XROOTTILE");

        if( tileloc != NULL ) {
            if( strcmp(tileloc,"") == 0 ) {
                /* on empty string use black root */
                memset(back, 0, sizeof(back));
            }
            else {
                /* try to load from the file */
                file = fopen(tileloc,"rb");
                if(file) {
                    /* this might fail; maybe add error checks. */
                    fread(back, sizeof(back[0]), sizeof(back), file);
                    fclose(file);
                }
                else {
                    /* default to hatch */
                    tileloc = NULL;
                }
            }
        }
    
        /* if env wasn't set or turned out to be bogus */
        if( tileloc == NULL ) {
            /* use normal hatch pattern */
            from = (screenInfo.bitmapBitOrder == LSBFirst) ? _back_lsb : _back_msb;
            to = back;
    
            for (i = 4; i > 0; i--, from++)
                for (j = len; j > 0; j--)
                    *to++ = *from;
        }
    }
    (*pGC->ops->PutImage)((DrawablePtr)pWin->background.pixmap, pGC, 1,
                0, 0, len, 4, 0, XYBitmap, (char *)back);
    ...

-- PSM
Comment 1 Adam Jackson 2005-06-02 14:12:30 UTC
X has far too many ways to set the background as it is, we really don't need to
be adding another.  but switching the if (blackRoot) around to not fill in the
stipple first seems sane enough.
Comment 2 FreeDesktop Bugzilla Database Corruption Fix User 2005-06-03 10:37:08 UTC
(In reply to comment #1)
> X has far too many ways to set the background as it is, we really don't need to
> be adding another.  but switching the if (blackRoot) around to not fill in the
> stipple first seems sane enough.

Actually, the file stuff is something I just made up because it can be done.  I
myself would be fine with simply not having to recompile the whole server so set
blackRoot high.  In globals.c, blackRoot ought not be declared constant, and
then somewhere in the code blackRoot could be set by an environment variable.  I
would venture to say that a black startup tile is good enough.  It's unoffensive
and subtle.  The hatch pattern isn't.
Comment 3 Adam Jackson 2005-06-08 18:51:39 UTC
Created attachment 2854 [details] [review]
less-bogus-root-tiling-1.patch

um, blackRoot isn't const.  that's what the -br flag to the server is for.

changing the default root has been discussed for ages and there are actually
compelling reasons for keeping it (mostly to do with getting cheapo monitors to
sync properly).

this patch moves the tile fill into the other branch of the blackRoot
conditional, and fixes some whitespace too.
Comment 4 Daniel Stone 2007-02-27 01:26:55 UTC
Sorry about the phenomenal bug spam, guys.  Adding xorg-team@ to the QA contact so bugs don't get lost in future.
Comment 5 chemtech 2013-03-15 14:33:30 UTC
FreeDesktop Bugzilla Database Corruption Fix User 
Do you still experience this issue with newer soft ?
Please check the status of your issue.
Comment 6 Adam Jackson 2018-06-12 16:43:24 UTC
I don't really care that much about following up on thirteen year old patches.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.