xserver: Branch 'master' - 3 commits

Keith Packard keithp at kemper.freedesktop.org
Thu Nov 11 12:59:10 PST 2010


 dix/globals.c        |    4 
 dix/window.c         |  230 ++++++---------------------------------------------
 doc/Xserver.man.pre  |    8 -
 include/opaque.h     |    4 
 include/scrnintstr.h |    6 +
 include/site.h       |    3 
 os/utils.c           |   23 +----
 7 files changed, 44 insertions(+), 234 deletions(-)

New commits:
commit da66119593b63ef82ae6fa2e034ccd0856b03a80
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Wed Nov 10 21:48:04 2010 +0200

    dix: fix root window background behaviour for protocol calls
    
    Instead always paint root tiled (-retro like), protocol calls
    (XSetWindowBackgroundPixmap and related) should behave accordingly when None
    and ParentRelative is set as background pixmap.
    
    It follow what the protocol states: "changing the background of a root window
    to None or ParentRelative restores the default background pixmap".
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Rami Ylimäki <rami.ylimaki at vincit.fi>

diff --git a/dix/window.c b/dix/window.c
index e1bdd8b..d140dda 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -956,6 +956,26 @@ DestroySubwindows(WindowPtr pWin, ClientPtr client)
     return Success;
 }
 
+static void
+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) {
+	pWin->backgroundState = XaceBackgroundNoneState(pWin);
+	pWin->background.pixel = pScreen->whitePixel;
+    }
+    else if (party_like_its_1989)
+	MakeRootTile(pWin);
+    else {
+	if (whiteRoot)
+	    pWin->background.pixel = pScreen->whitePixel;
+	else
+	    pWin->background.pixel = pScreen->blackPixel;
+	*index2 = CWBackPixel;
+    }
+}
+
 /*****
  *  ChangeWindowAttributes
  *   
@@ -1005,7 +1025,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
 		if (pWin->backgroundState == BackgroundPixmap)
 		    (*pScreen->DestroyPixmap)(pWin->background.pixmap);
 		if (!pWin->parent)
-		    MakeRootTile(pWin);
+		    SetRootWindowBackground(pWin, pScreen, &index2);
 		else {
 		    pWin->backgroundState = XaceBackgroundNoneState(pWin);
 		    pWin->background.pixel = pScreen->whitePixel;
@@ -1022,7 +1042,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
 		if (pWin->backgroundState == BackgroundPixmap)
 		    (*pScreen->DestroyPixmap)(pWin->background.pixmap);
 		if (!pWin->parent)
-		    MakeRootTile(pWin);
+		    SetRootWindowBackground(pWin, pScreen, &index2);
 		else
 		    pWin->backgroundState = ParentRelative;
 		borderRelative = TRUE;
commit 8976e9766edfb33f5cf3f6d54f09e46d29bc4ec5
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Wed Nov 10 21:48:03 2010 +0200

    dix: adds support for none root window background
    
    It lets the driver notify the server whether it can draw a background when
    '-background none' option is used by the system platform. Use cases for that
    could be video drivers performing mode-setting in kernel time, before X is up,
    so a seamless transition would happen until X clients start to show up.
    
    If the driver can copy the framebuffer cleanly then it can set the flag
    (canDoBGNoneRoot), otherwise the server will fallback to the normal behaviour.
    The system must explicit indicates willingness of doing so through
    '-background none'. We could do this option as default; in such case,
    malicious users would be able to steal the framebuffer with a bit of tricks.
    
    For instance, I can see the content of my nVidia Quadro FX 580 framebuffer
    old X session modifying a bit nv driver:
    
         xf86DPMSInit(pScreen, xf86DPMSSet, 0);
    
    -    /* Clear the screen */
    -    if(pNv->xaa) {
    -        /* Use the acceleration engine */
    -        pNv->xaa->SetupForSolidFill(pScrn, 0, GXcopy, ~0);
    -        pNv->xaa->SubsequentSolidFillRect(pScrn,
    -            0, 0, pScrn->displayWidth, pNv->offscreenHeight);
    -        G80DmaKickoff(pNv);
    -    } else {
    -        /* Use a slow software clear path */
    -        memset(pNv->mem, 0, pitch * pNv->offscreenHeight);
    -    }
    +    pScreen->canDoBGNoneRoot = TRUE;
    
    The commit is originally based on discussions happened on xorg-devel:
    http://lists.freedesktop.org/archives/xorg-devel/2010-June/009755.html
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
    Acked-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/window.c b/dix/window.c
index a2b1507..e1bdd8b 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -137,6 +137,8 @@ Equipment Corporation.
  *    ChangeWindowDeviceCursor
  ******/
 
+Bool bgNoneRoot = FALSE;
+
 static unsigned char _back_lsb[4] = {0x88, 0x22, 0x44, 0x11};
 static unsigned char _back_msb[4] = {0x11, 0x44, 0x22, 0x88};
 
@@ -463,6 +465,10 @@ InitRootWindow(WindowPtr pWin)
     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 {
 	if (whiteRoot)
             pWin->background.pixel = pScreen->whitePixel;
diff --git a/include/opaque.h b/include/opaque.h
index abaee45..5c70717 100644
--- a/include/opaque.h
+++ b/include/opaque.h
@@ -69,6 +69,7 @@ extern _X_EXPORT Bool defeatAccessControl;
 extern _X_EXPORT long maxBigRequestSize;
 extern _X_EXPORT Bool party_like_its_1989;
 extern _X_EXPORT Bool whiteRoot;
+extern _X_EXPORT Bool bgNoneRoot;
 
 extern _X_EXPORT Bool CoreDump;
 
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index e36b15f..cd4fb70 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -601,6 +601,12 @@ typedef struct _Screen {
     /* Device cursor procedures */
     DeviceCursorInitializeProcPtr DeviceCursorInitialize;
     DeviceCursorCleanupProcPtr    DeviceCursorCleanup;
+
+    /* set it in driver side if X server can copy the framebuffer content.
+     * Meant to be used together with '-background none' option, avoiding
+     * malicious users to steal framebuffer's content if that would be the
+     * default */
+    Bool		canDoBGNoneRoot;
 } ScreenRec;
 
 static inline RegionPtr BitmapToRegion(ScreenPtr _pScreen, PixmapPtr pPix) {
diff --git a/os/utils.c b/os/utils.c
index c2158dc..afdff0c 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -498,6 +498,7 @@ void UseMsg(void)
     ErrorF("-nolock                disable the locking mechanism\n");
     ErrorF("-nolisten string       don't listen on protocol\n");
     ErrorF("-noreset               don't reset after last client exists\n");
+    ErrorF("-background [none]     create root window with no background\n");
     ErrorF("-reset                 reset after last client exists\n");
     ErrorF("-p #                   screen-saver pattern duration (minutes)\n");
     ErrorF("-pn                    accept failure to listen on all ports\n");
@@ -828,6 +829,14 @@ ProcessCommandLine(int argc, char *argv[])
 	    defaultBackingStore = WhenMapped;
         else if ( strcmp( argv[i], "-wr") == 0)
             whiteRoot = TRUE;
+        else if ( strcmp( argv[i], "-background") == 0) {
+            if(++i < argc) {
+                if (!strcmp ( argv[i], "none"))
+                    bgNoneRoot = TRUE;
+                else
+                    UseMsg();
+            }
+        }
         else if ( strcmp( argv[i], "-maxbigreqsize") == 0) {
              if(++i < argc) {
                  long reqSizeArg = atol(argv[i]);
commit bfe9cdd11bcb60cf33dc48136ebee028001a737e
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Wed Oct 20 17:54:58 2010 -0200

    dix: delete logo hack screen saver
    
    Protocol doesn't mention about screen saver with logo being required and
    people are already using more intelligent ways to draw screen saver themes. So
    consider -logo as deprecated option, deleting its code.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/globals.c b/dix/globals.c
index b128569..0a6b170 100644
--- a/dix/globals.c
+++ b/dix/globals.c
@@ -106,10 +106,6 @@ CARD32 defaultScreenSaverTime = DEFAULT_SCREEN_SAVER_TIME;
 CARD32 defaultScreenSaverInterval = DEFAULT_SCREEN_SAVER_INTERVAL;
 int  defaultScreenSaverBlanking = DEFAULT_SCREEN_SAVER_BLANKING;
 int  defaultScreenSaverAllowExposures = DEFAULT_SCREEN_SAVER_EXPOSURES;
-#ifndef NOLOGOHACK
-int  logoScreenSaver = DEFAULT_LOGO_SCREEN_SAVER;
-#endif
-
 #ifdef SCREENSAVER
 Bool screenSaverSuspended = FALSE;
 #endif
diff --git a/dix/window.c b/dix/window.c
index edb146e..a2b1507 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -3087,13 +3087,6 @@ SendVisibilityNotify(WindowPtr pWin)
 }
 
 #define RANDOM_WIDTH 32
-
-#ifndef NOLOGOHACK
-static void DrawLogo(
-    WindowPtr pWin
-);
-#endif
-
 int
 dixSaveScreens(ClientPtr client, int on, int mode)
 {
@@ -3155,18 +3148,10 @@ dixSaveScreens(ClientPtr client, int on, int mode)
 		 * for the root window, so miPaintWindow works
 		 */
 		screenIsSaved = SCREEN_SAVER_OFF;
-#ifndef NOLOGOHACK
-		if (logoScreenSaver)
-		    (*pWin->drawable.pScreen->ClearToBackground)(pWin, 0, 0, 0, 0, FALSE);
-#endif
 		(*pWin->drawable.pScreen->MoveWindow)(pWin,
 			   (short)(-(rand() % RANDOM_WIDTH)),
 			   (short)(-(rand() % RANDOM_WIDTH)),
 			   pWin->nextSib, VTMove);
-#ifndef NOLOGOHACK
-		if (logoScreenSaver)
-		    DrawLogo(pWin);
-#endif
 		screenIsSaved = SCREEN_SAVER_ON;
 	    }
 	    /*
@@ -3324,10 +3309,6 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
 	(*pWin->drawable.pScreen->ChangeWindowAttributes)(pWin, CWBackPixmap);
     }
     MapWindow(pWin, serverClient);
-#ifndef NOLOGOHACK
-    if (kind == SCREEN_IS_TILED && logoScreenSaver)
-	DrawLogo(pWin);
-#endif
     return TRUE;
 }
 
@@ -3673,184 +3654,3 @@ WindowParentHasDeviceCursor(WindowPtr pWin,
     }
     return FALSE;
 }
-
-#ifndef NOLOGOHACK
-static void
-DrawLogo(WindowPtr pWin)
-{
-    DrawablePtr pDraw;
-    ScreenPtr pScreen;
-    int x, y;
-    unsigned int width, height, size;
-    GC *pGC;
-    int rc, thin, gap, d31;
-    DDXPointRec poly[4];
-    ChangeGCVal fore[2], back[2];
-    xrgb rgb[2];
-    BITS32 fmask, bmask;
-    ColormapPtr cmap;
-
-    pDraw = (DrawablePtr)pWin;
-    pScreen = pDraw->pScreen;
-    x = -pWin->origin.x;
-    y = -pWin->origin.y;
-    width = pScreen->width;
-    height = pScreen->height;
-    pGC = GetScratchGC(pScreen->rootDepth, pScreen);
-    if (!pGC)
-	return;
-
-    if ((rand() % 100) <= 17) /* make the probability for white fairly low */
-	fore[0].val = pScreen->whitePixel;
-    else
-	fore[0].val = pScreen->blackPixel;
-    if (pWin->backgroundState == BackgroundPixel) {
-	rc = dixLookupResourceByType((pointer *)&cmap, wColormap(pWin),
-				     RT_COLORMAP, serverClient, DixReadAccess);
-	if (rc == Success) {
-	    Pixel querypixels[2];
-
-	    querypixels[0] = fore[0].val;
-	    querypixels[1] = pWin->background.pixel;
-	    QueryColors(cmap, 2, querypixels, rgb, serverClient);
-	    if ((rgb[0].red == rgb[1].red) &&
-		(rgb[0].green == rgb[1].green) &&
-		(rgb[0].blue == rgb[1].blue)) {
-		if (fore[0].val == pScreen->blackPixel)
-		    fore[0].val = pScreen->whitePixel;
-		else
-		    fore[0].val = pScreen->blackPixel;
-	    }
-	}
-    }
-    fore[1].val = FillSolid;
-    fmask = GCForeground|GCFillStyle;
-    if (pWin->backgroundState == BackgroundPixel) {
-	back[0].val = pWin->background.pixel;
-	back[1].val = FillSolid;
-	bmask = GCForeground|GCFillStyle;
-    } else {
-	back[0].val = 0;
-	back[1].val = 0;
-	ChangeGC(NullClient, pGC, GCTileStipXOrigin|GCTileStipYOrigin, back);
-	back[0].val = FillTiled;
-	back[1].ptr = pWin->background.pixmap;
-	bmask = GCFillStyle|GCTile;
-    }
-
-    /* should be the same as the reference function XmuDrawLogo() */
-
-    size = width;
-    if (height < width)
-	 size = height;
-    size = RANDOM_WIDTH + rand() % (size - RANDOM_WIDTH);
-    size &= ~1;
-    x += rand() % (width - size);
-    y += rand() % (height - size);
-
-/*
- * Draw what will be the thin strokes.
- *
- *           -----
- *          /    /
- *         /    /
- *        /    /
- *       /    /
- *      /____/
- *           d
- *
- * Point d is 9/44 (~1/5) of the way across.
- */
-
-    thin = (size / 11);
-    if (thin < 1) thin = 1;
-    gap = (thin+3) / 4;
-    d31 = thin + thin + gap;
-    poly[0].x = x + size;	       poly[0].y = y;
-    poly[1].x = x + size-d31;	       poly[1].y = y;
-    poly[2].x = x + 0;		       poly[2].y = y + size;
-    poly[3].x = x + d31;	       poly[3].y = y + size;
-    ChangeGC(NullClient, pGC, fmask, fore);
-    ValidateGC(pDraw, pGC);
-    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-/*
- * Erase area not needed for lower thin stroke.
- *
- *           ------
- *          /	  /
- *         /  __ /
- *        /  /	/
- *       /  /  /
- *      /__/__/
- */
-
-    poly[0].x = x + d31/2;			 poly[0].y = y + size;
-    poly[1].x = x + size / 2;			 poly[1].y = y + size/2;
-    poly[2].x = x + (size/2)+(d31-(d31/2));	 poly[2].y = y + size/2;
-    poly[3].x = x + d31;			 poly[3].y = y + size;
-    ChangeGC(NullClient, pGC, bmask, back);
-    ValidateGC(pDraw, pGC);
-    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-/*
- * Erase area not needed for upper thin stroke.
- *
- *	     ------
- *	    /  /  /
- *	   /--/	 /
- *	  /	/
- *	 /     /
- *	/_____/
- */
-
-    poly[0].x = x + size - d31/2;		 poly[0].y = y;
-    poly[1].x = x + size / 2;			 poly[1].y = y + size/2;
-    poly[2].x = x + (size/2)-(d31-(d31/2));	 poly[2].y = y + size/2;
-    poly[3].x = x + size - d31;			 poly[3].y = y;
-    ValidateGC(pDraw, pGC);
-    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-/*
- * Draw thick stroke.
- * Point b is 1/4 of the way across.
- *
- *      b
- * -----
- * \	\
- *  \	 \
- *   \	  \
- *    \	   \
- *     \____\
- */
-
-    poly[0].x = x;		       poly[0].y = y;
-    poly[1].x = x + size/4;	       poly[1].y = y;
-    poly[2].x = x + size;	       poly[2].y = y + size;
-    poly[3].x = x + size - size/4;     poly[3].y = y + size;
-    ChangeGC(NullClient, pGC, fmask, fore);
-    ValidateGC(pDraw, pGC);
-    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-/*
- * Erase to create gap.
- *
- *	    /
- *	   /
- *	  /
- *	 /
- *	/
- */
-
-    poly[0].x = x + size- thin;	      poly[0].y = y;
-    poly[1].x = x + size-( thin+gap);  poly[1].y = y;
-    poly[2].x = x + thin;	      poly[2].y = y + size;
-    poly[3].x = x + thin + gap;	      poly[3].y = y + size;
-    ChangeGC(NullClient, pGC, bmask, back);
-    ValidateGC(pDraw, pGC);
-    (*pGC->ops->FillPolygon)(pDraw, pGC, Convex, CoordModeOrigin, 4, poly);
-
-    FreeScratchGC(pGC);
-}
-
-#endif
diff --git a/doc/Xserver.man.pre b/doc/Xserver.man.pre
index ce3b3a1..240f05c 100644
--- a/doc/Xserver.man.pre
+++ b/doc/Xserver.man.pre
@@ -285,14 +285,6 @@ sets the stack space limit of the server to the specified number of kilobytes.
 A value of zero makes the stack size as large as possible.  The default value
 of \-1 leaves the stack space limit unchanged.
 .TP 8
-.B \-logo
-turns on the X Window System logo display in the screen-saver.
-There is currently no way to change this from a client.
-.TP 8
-.B nologo
-turns off the X Window System logo display in the screen-saver.
-There is currently no way to change this from a client.
-.TP 8
 .B \-render 
 .BR default | mono | gray | color
 sets the color allocation policy that will be used by the render extension.
diff --git a/include/opaque.h b/include/opaque.h
index dfe440c..abaee45 100644
--- a/include/opaque.h
+++ b/include/opaque.h
@@ -56,9 +56,6 @@ extern _X_EXPORT Bool disableBackingStore;
 extern _X_EXPORT Bool enableBackingStore;
 extern _X_EXPORT Bool PartialNetwork;
 extern _X_EXPORT Bool RunFromSigStopParent;
-#ifndef NOLOGOHACK
-extern _X_EXPORT int logoScreenSaver;
-#endif
 #ifdef RLIMIT_DATA
 extern _X_EXPORT int limitDataSpace;
 #endif
diff --git a/include/site.h b/include/site.h
index b134212..9c2836f 100644
--- a/include/site.h
+++ b/include/site.h
@@ -112,9 +112,6 @@ SOFTWARE.
 #define DEFAULT_SCREEN_SAVER_INTERVAL (10 * (60 * 1000))
 #define DEFAULT_SCREEN_SAVER_BLANKING PreferBlanking
 #define DEFAULT_SCREEN_SAVER_EXPOSURES AllowExposures
-#ifndef NOLOGOHACK
-#define DEFAULT_LOGO_SCREEN_SAVER 1
-#endif
 #ifndef DEFAULT_ACCESS_CONTROL
 #define DEFAULT_ACCESS_CONTROL TRUE
 #endif
diff --git a/os/utils.c b/os/utils.c
index 8921d7c..c2158dc 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -496,10 +496,6 @@ void UseMsg(void)
     ErrorF("-ls int                limit stack space to N Kb\n");
 #endif
     ErrorF("-nolock                disable the locking mechanism\n");
-#ifndef NOLOGOHACK
-    ErrorF("-logo                  enable logo in screen saver\n");
-    ErrorF("nologo                 disable logo in screen saver\n");
-#endif
     ErrorF("-nolisten string       don't listen on protocol\n");
     ErrorF("-noreset               don't reset after last client exists\n");
     ErrorF("-reset                 reset after last client exists\n");
@@ -755,16 +751,6 @@ ProcessCommandLine(int argc, char *argv[])
 #endif
 	    nolock = TRUE;
 	}
-#ifndef NOLOGOHACK
-	else if ( strcmp( argv[i], "-logo") == 0)
-	{
-	    logoScreenSaver = 1;
-	}
-	else if ( strcmp( argv[i], "nologo") == 0)
-	{
-	    logoScreenSaver = 0;
-	}
-#endif
 	else if ( strcmp( argv[i], "-nolisten") == 0)
 	{
             if(++i < argc) {


More information about the xorg-commit mailing list