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

Jamey Sharp jamey at minilop.net
Sun Nov 20 03:48:52 PST 2011


The protocol requires ChangeWindowAttributes to be able to set the root
window's background and cursor to their defaults. So let's just use that
when InitRootWindow needs to set up the defaults in the first place.

This guarantees that using ChangeWindowAttributes to reset the root
window really does restore the startup state, which wasn't quite true
before:

- If both party_like_its_1989 and bgNoneRoot were set, then the root
  background was initially the root weave, but ChangeWindowAttributes
  would reset it to background None.

- InitRootWindow checked whether the screen supported background None,
  while ChangeWindowAttributes unconditionally trusted bgNoneRoot.

Signed-off-by: Jamey Sharp <jamey at minilop.net>
---
 dix/window.c |   44 +++++++++-----------------------------------
 1 files changed, 9 insertions(+), 35 deletions(-)

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);
 }
 
@@ -1062,14 +1037,13 @@ SetRootWindowBackground(WindowPtr pWin, ScreenPtr pScreen, Mask *index2)
 {
     /* following the protocol: "Changing the background of a root window to
      * None or ParentRelative restores the default background pixmap" */
-    if (bgNoneRoot) {
+    if (party_like_its_1989)
+	MakeRootTile(pWin);
+    else if (pScreen->canDoBGNoneRoot && bgNoneRoot) {
 	pWin->backgroundState = XaceBackgroundNoneState(pWin);
 	pWin->background.pixel = pScreen->whitePixel;
-    }
-    else if (party_like_its_1989)
-	MakeRootTile(pWin);
-    else {
-        pWin->backgroundState = BackgroundPixel;
+    } else {
+	pWin->backgroundState = BackgroundPixel;
 	if (whiteRoot)
 	    pWin->background.pixel = pScreen->whitePixel;
 	else
@@ -1278,7 +1252,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
 		goto PatchUp;
 	    }
 	    pWin->backingStore = val;
-	    pWin->forcedBS = FALSE;
+	    pWin->forcedBS = (client == serverClient && pWin->backingStore != NotUseful);
 	    break;
 	  case CWBackingPlanes:
 	    if (pWin->optional || ((CARD32)*pVlist != (CARD32)~0L)) {
-- 
1.7.5.4



More information about the xorg-devel mailing list