4f6f879
From a3e15680da24cb8259f6a83dee0c930dab024290 Mon Sep 17 00:00:00 2001
d86f66b
From: Kristian <krh@redhat.com>
d86f66b
Date: Fri, 15 Aug 2008 15:15:14 +1000
d86f66b
Subject: [PATCH] Add nr for background=none root
d86f66b
d86f66b
---
4f6f879
 dix/globals.c                |    1 +
4f6f879
 dix/window.c                 |   22 ++++++++++++----------
4f6f879
 hw/xfree86/common/xf86Init.c |   11 +++++++++++
4f6f879
 hw/xfree86/common/xf86str.h  |    5 ++++-
4f6f879
 include/opaque.h             |    1 +
4f6f879
 os/utils.c                   |    3 +++
4f6f879
 6 files changed, 32 insertions(+), 11 deletions(-)
d86f66b
Kristian Høgsberg 7be4d82
diff --git a/dix/globals.c b/dix/globals.c
e32b32d
index 973dc43..dbd76bb 100644
Kristian Høgsberg 7be4d82
--- a/dix/globals.c
Kristian Høgsberg 7be4d82
+++ b/dix/globals.c
e32b32d
@@ -141,6 +141,7 @@ FontPtr defaultFont;   /* not declared in dix.h to avoid including font.h in
Kristian Høgsberg 7be4d82
 CursorPtr rootCursor;
e32b32d
 Bool party_like_its_1989 = FALSE;
e32b32d
 Bool whiteRoot = FALSE;
e32b32d
+Bool bgNoneRoot = FALSE;
e32b32d
 
e32b32d
 int cursorScreenDevPriv[MAXSCREENS];
e32b32d
 
Kristian Høgsberg 7be4d82
diff --git a/dix/window.c b/dix/window.c
e32b32d
index c31fa87..8bb178d 100644
Kristian Høgsberg 7be4d82
--- a/dix/window.c
Kristian Høgsberg 7be4d82
+++ b/dix/window.c
e32b32d
@@ -482,23 +482,24 @@ InitRootWindow(WindowPtr pWin)
4f6f879
     pWin->cursorIsNone = FALSE;
Kristian Høgsberg 7be4d82
     pWin->optional->cursor = rootCursor;
Kristian Høgsberg 7be4d82
     rootCursor->refcnt++;
e32b32d
-
4f6f879
+    pWin->backingStore = defaultBackingStore;
4f6f879
+    pWin->forcedBS = (defaultBackingStore != NotUseful);
Kristian Høgsberg 7be4d82
 
e32b32d
     if (party_like_its_1989) {
e32b32d
         MakeRootTile(pWin);
e32b32d
         backFlag |= CWBackPixmap;
e32b32d
+        pScreen->ChangeWindowAttributes(pWin, backFlag);
e32b32d
+    } else if (bgNoneRoot) {
4f6f879
+	/* nothing, handled in xf86CreateRootWindow */
e32b32d
     } else {
e32b32d
 	if (whiteRoot)
Kristian Høgsberg 7be4d82
             pWin->background.pixel = pScreen->whitePixel;
e32b32d
         else
e32b32d
             pWin->background.pixel = pScreen->blackPixel;
Kristian Høgsberg 7be4d82
         backFlag |= CWBackPixel;
e40bc9d
-    } 
e32b32d
 
4f6f879
-    pWin->backingStore = defaultBackingStore;
4f6f879
-    pWin->forcedBS = (defaultBackingStore != NotUseful);
4f6f879
-    /* We SHOULD check for an error value here XXX */
4f6f879
-    (*pScreen->ChangeWindowAttributes)(pWin, backFlag);
e32b32d
+        pScreen->ChangeWindowAttributes(pWin, backFlag);
e40bc9d
+    }
Kristian Høgsberg 7be4d82
 
4f6f879
     MapWindow(pWin, serverClient);
4f6f879
 }
4f6f879
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
e32b32d
index 236c00b..083a6ac 100644
4f6f879
--- a/hw/xfree86/common/xf86Init.c
4f6f879
+++ b/hw/xfree86/common/xf86Init.c
e32b32d
@@ -79,6 +79,7 @@
4f6f879
 #ifdef RENDER
4f6f879
 #include "picturestr.h"
4f6f879
 #endif
4f6f879
+#include "xace.h"
4f6f879
 
4f6f879
 #include "globals.h"
4f6f879
 
e32b32d
@@ -328,6 +329,7 @@ xf86CreateRootWindow(WindowPtr pWin)
4f6f879
   int ret = TRUE;
4f6f879
   int err = Success;
4f6f879
   ScreenPtr pScreen = pWin->drawable.pScreen;
4f6f879
+  ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
4f6f879
   RootWinPropPtr pProp;
4f6f879
   CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
4f6f879
       dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
e32b32d
@@ -381,6 +383,15 @@ xf86CreateRootWindow(WindowPtr pWin)
4f6f879
     }
4f6f879
   }
4f6f879
 
4f6f879
+  if (bgNoneRoot && pScrn->canDoBGNoneRoot) {
4f6f879
+      pWin->backgroundState = XaceBackgroundNoneState(pWin);
4f6f879
+      pWin->background.pixel = pScreen->whitePixel;
4f6f879
+      pScreen->ChangeWindowAttributes(pWin, CWBackPixmap | CWBorderPixel | CWCursor | CWBackingStore);
4f6f879
+  } else {
4f6f879
+      pWin->background.pixel = pScreen->blackPixel;
4f6f879
+      pScreen->ChangeWindowAttributes(pWin, CWBackPixel | CWBorderPixel | CWCursor | CWBackingStore);
4f6f879
+  }
4f6f879
+
4f6f879
 #ifdef DEBUG
4f6f879
   ErrorF("xf86CreateRootWindow() returns %d\n", ret);
4f6f879
 #endif
4f6f879
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
e32b32d
index 904c369..8c38f69 100644
4f6f879
--- a/hw/xfree86/common/xf86str.h
4f6f879
+++ b/hw/xfree86/common/xf86str.h
e32b32d
@@ -531,7 +531,7 @@ typedef struct _confdrirec {
4f6f879
 } confDRIRec, *confDRIPtr;
4f6f879
 
4f6f879
 /* These values should be adjusted when new fields are added to ScrnInfoRec */
4f6f879
-#define NUM_RESERVED_INTS		16
4f6f879
+#define NUM_RESERVED_INTS		15
4f6f879
 #define NUM_RESERVED_POINTERS		15
4f6f879
 #define NUM_RESERVED_FUNCS		11
4f6f879
 
e32b32d
@@ -959,6 +959,9 @@ typedef struct _ScrnInfoRec {
4f6f879
     ClockRangesPtr	clockRanges;
4f6f879
     int			adjustFlags;
4f6f879
 
4f6f879
+    /* -nr support */
4f6f879
+    int			canDoBGNoneRoot;
4f6f879
+
4f6f879
     /*
4f6f879
      * These can be used when the minor ABI version is incremented.
4f6f879
      * The NUM_* parameters must be reduced appropriately to keep the
Kristian Høgsberg 7be4d82
diff --git a/include/opaque.h b/include/opaque.h
e32b32d
index 07a0715..be1577b 100644
Kristian Høgsberg 7be4d82
--- a/include/opaque.h
Kristian Høgsberg 7be4d82
+++ b/include/opaque.h
e32b32d
@@ -71,6 +71,7 @@ extern Bool defeatAccessControl;
Kristian Høgsberg 7be4d82
 extern long maxBigRequestSize;
e32b32d
 extern Bool party_like_its_1989;
Kristian Høgsberg 7be4d82
 extern Bool whiteRoot;
Kristian Høgsberg 7be4d82
+extern Bool bgNoneRoot;
Kristian Høgsberg 7be4d82
 
Kristian Høgsberg 7be4d82
 extern Bool CoreDump;
Kristian Høgsberg 7be4d82
 
Kristian Høgsberg 7be4d82
diff --git a/os/utils.c b/os/utils.c
e32b32d
index b100949..c41b45b 100644
Kristian Høgsberg 7be4d82
--- a/os/utils.c
Kristian Høgsberg 7be4d82
+++ b/os/utils.c
e32b32d
@@ -515,6 +515,7 @@ void UseMsg(void)
Kristian Høgsberg 7be4d82
 #endif
Kristian Høgsberg 7be4d82
     ErrorF("-nolisten string       don't listen on protocol\n");
Kristian Høgsberg 7be4d82
     ErrorF("-noreset               don't reset after last client exists\n");
Kristian Høgsberg 7be4d82
+    ErrorF("-nr                    create root window with no background\n");
Kristian Høgsberg 7be4d82
     ErrorF("-reset                 reset after last client exists\n");
Kristian Høgsberg 7be4d82
     ErrorF("-p #                   screen-saver pattern duration (minutes)\n");
Kristian Høgsberg 7be4d82
     ErrorF("-pn                    accept failure to listen on all ports\n");
e32b32d
@@ -859,6 +860,8 @@ ProcessCommandLine(int argc, char *argv[])
Kristian Høgsberg 7be4d82
 	    defaultBackingStore = WhenMapped;
Kristian Høgsberg 7be4d82
         else if ( strcmp( argv[i], "-wr") == 0)
Kristian Høgsberg 7be4d82
             whiteRoot = TRUE;
Kristian Høgsberg 7be4d82
+        else if ( strcmp( argv[i], "-nr") == 0)
Kristian Høgsberg 7be4d82
+            bgNoneRoot = TRUE;
Kristian Høgsberg 7be4d82
         else if ( strcmp( argv[i], "-maxbigreqsize") == 0) {
Kristian Høgsberg 7be4d82
              if(++i < argc) {
Kristian Høgsberg 7be4d82
                  long reqSizeArg = atol(argv[i]);