[PATCH 1/3] InitRootWindow: Use ChangeWindowAttributes instead of duplicating it.

Jamey Sharp jamey at minilop.net
Sun Nov 20 11:20:51 PST 2011


On 11/20/11, walter harms <wharms at bfs.de> wrote:
> Am 20.11.2011 12:48, schrieb Jamey Sharp:
>> diff --git a/dix/window.c b/dix/window.c
>> index 1953f02..44bfa18 100644
>> --- a/dix/window.c
>> +++ b/dix/window.c
>> @@ -551,38 +551,13 @@ void
>>  InitRootWindow(WindowPtr pWin)
>>  {
>>      ScreenPtr pScreen = pWin->drawable.pScreen;
>> -    int backFlag = CWBorderPixel | CWCursor | CWBackingStore;
>> +    int mask = CWBackPixmap | CWBackingStore | CWCursor;
>> +    XID attrs[] = { None, defaultBackingStore, None };
>>
>>      if (!(*pScreen->CreateWindow)(pWin))
>>  	return; /* XXX */
>>      (*pScreen->PositionWindow)(pWin, 0, 0);
>> -
>> -    pWin->cursorIsNone = FALSE;
>> -    pWin->optional->cursor = rootCursor;
>> -    rootCursor->refcnt++;
>> -
>> -
>> -    if (party_like_its_1989) {
>> -        MakeRootTile(pWin);
>> -        backFlag |= CWBackPixmap;
>> -    } else if (pScreen->canDoBGNoneRoot && bgNoneRoot) {
>> -        pWin->backgroundState = XaceBackgroundNoneState(pWin);
>> -        pWin->background.pixel = pScreen->whitePixel;
>> -        backFlag |= CWBackPixmap;
>> -    } else {
>> -        pWin->backgroundState = BackgroundPixel;
>> -	if (whiteRoot)
>> -            pWin->background.pixel = pScreen->whitePixel;
>> -        else
>> -            pWin->background.pixel = pScreen->blackPixel;
>> -        backFlag |= CWBackPixel;
>> -    }
>> -
>> -    pWin->backingStore = defaultBackingStore;
>> -    pWin->forcedBS = (defaultBackingStore != NotUseful);
>> -    /* We SHOULD check for an error value here XXX */
>> -    (*pScreen->ChangeWindowAttributes)(pWin, backFlag);
>> -
>> +    ChangeWindowAttributes(pWin, mask, attrs, serverClient);
>>      MapWindow(pWin, serverClient);
>>  }
>
> maybe you can use ResetRootWindow() from patch 3 here ?

I don't think there's any reason to extract those three lines as a
function unless we're going to call it from somewhere else, as patch 3
does. But yes, this re-write was motivated by patch 3's need to
extract that code, and especially because in patch 3, ResetRootWindow
needs to free any resources that the root window was pointing to,
which InitRootWindow didn't do.

Oh, but I got the first two patches in the wrong order; WindowOptPtrs
need to be fully initialized before this patch is correct. Oops.

Jamey


More information about the xorg-devel mailing list