From 7c9733d063acee04735a0e75d62e508fe4ea1163 Mon Sep 17 00:00:00 2001 From: Jamey Sharp Date: Fri, 23 Apr 2010 06:41:00 +0200 Subject: [PATCH 01/10] xfree86: use screen privates for Xv offscreen images. This replaces a globally-allocated array that depended on MAXSCREENS. Signed-off-by: Jamey Sharp Acked-by: Tiago Vignatti --- hw/xfree86/common/xf86xv.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c index bdcc4fc2b..1503502b5 100644 --- a/hw/xfree86/common/xf86xv.c +++ b/hw/xfree86/common/xf86xv.c @@ -186,7 +186,9 @@ typedef struct { int num; } OffscreenImageRec; -static OffscreenImageRec OffscreenImages[MAXSCREENS]; +static int OffscreenPrivateKeyIndex; +static DevPrivateKey OffscreenPrivateKey = &OffscreenPrivateKeyIndex; +#define GetOffscreenImage(pScreen) ((OffscreenImageRec *) dixLookupPrivate(&(pScreen)->devPrivates, OffscreenPrivateKey)) Bool xf86XVRegisterOffscreenImages( @@ -194,9 +196,15 @@ xf86XVRegisterOffscreenImages( XF86OffscreenImagePtr images, int num ){ - OffscreenImages[pScreen->myNum].num = num; - OffscreenImages[pScreen->myNum].images = images; + OffscreenImageRec *OffscreenImage; + if(!dixRequestPrivate(OffscreenPrivateKey, sizeof(OffscreenImageRec)) || + !(OffscreenImage = GetOffscreenImage(pScreen))) + /* Every X.org driver assumes this function always succeeds, so + * just die on allocation failure. */ + FatalError("Could not allocate private storage for XV offscreen images.\n"); + OffscreenImage->num = num; + OffscreenImage->images = images; return TRUE; } @@ -205,8 +213,9 @@ xf86XVQueryOffscreenImages( ScreenPtr pScreen, int *num ){ - *num = OffscreenImages[pScreen->myNum].num; - return OffscreenImages[pScreen->myNum].images; + OffscreenImageRec *OffscreenImage = GetOffscreenImage(pScreen); + *num = OffscreenImage->num; + return OffscreenImage->images; } @@ -1177,9 +1186,6 @@ xf86XVCloseScreen(int i, ScreenPtr pScreen) XvAdaptorPtr pa; int c; - /* Clear offscreen images */ - memset(&OffscreenImages[pScreen->myNum], 0, sizeof(OffscreenImages[0])); - if(!ScreenPriv) return TRUE; if(ScreenPriv->videoGC) { From e055bef055b6c726e9f3ef91a83585d13c80651d Mon Sep 17 00:00:00 2001 From: Jamey Sharp Date: Thu, 22 Apr 2010 06:08:29 +0200 Subject: [PATCH 02/10] xfree86: use screen privates for exclusive DGA clients Most DGA requests allow at most one client to be using DGA on each screen. Instead of keeping track of the current client in a MAXSCREEN-sized array, track it in a per-screen private. Signed-off-by: Jamey Sharp Acked-by: Tiago Vignatti --- hw/xfree86/dixmods/extmod/xf86dga2.c | 70 +++++++++++++++------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c index 5367bcc42..038551467 100644 --- a/hw/xfree86/dixmods/extmod/xf86dga2.c +++ b/hw/xfree86/dixmods/extmod/xf86dga2.c @@ -57,12 +57,12 @@ static void XDGAResetProc(ExtensionEntry *extEntry); static void DGAClientStateChange (CallbackListPtr*, pointer, pointer); -static ClientPtr DGAClients[MAXSCREENS]; - unsigned char DGAReqCode = 0; int DGAErrorBase; int DGAEventBase; +static int DGAScreenPrivateKeyIndex; +static DevPrivateKey DGAScreenPrivateKey = &DGAScreenPrivateKeyIndex; static int DGAClientPrivateKeyIndex; static DevPrivateKey DGAClientPrivateKey = &DGAClientPrivateKeyIndex; static int DGACallbackRefCount = 0; @@ -73,6 +73,11 @@ typedef struct { int minor; } DGAPrivRec, *DGAPrivPtr; +#define DGA_GETCLIENT(idx) ((ClientPtr) \ + dixLookupPrivate(&screenInfo.screens[idx]->devPrivates, DGAScreenPrivateKey)) +#define DGA_SETCLIENT(idx,p) \ + dixSetPrivate(&screenInfo.screens[idx]->devPrivates, DGAScreenPrivateKey, p) + #define DGA_GETPRIV(c) ((DGAPrivPtr) \ dixLookupPrivate(&(c)->devPrivates, DGAClientPrivateKey)) #define DGA_SETPRIV(c,p) \ @@ -93,9 +98,6 @@ XFree86DGAExtensionInit(INITARGS) StandardMinorOpcode))) { int i; - for(i = 0; i < MAXSCREENS; i++) - DGAClients[i] = NULL; - DGAReqCode = (unsigned char)extEntry->base; DGAErrorBase = extEntry->errorBase; DGAEventBase = extEntry->eventBase; @@ -282,7 +284,7 @@ DGAClientStateChange ( int i; for(i = 0; i < screenInfo.numScreens; i++) { - if(DGAClients[i] == pci->client) { + if(DGA_GETCLIENT(i) == pci->client) { client = pci->client; break; } @@ -294,7 +296,7 @@ DGAClientStateChange ( XDGAModeRec mode; PixmapPtr pPix; - DGAClients[i] = NULL; + DGA_SETCLIENT(i, NULL); DGASelectInput(i, NULL, 0); DGASetMode(i, 0, &mode, &pPix); @@ -311,10 +313,12 @@ ProcXDGASetMode(ClientPtr client) XDGAModeRec mode; xXDGAModeInfo info; PixmapPtr pPix; + ClientPtr owner; int size; if (stuff->screen > screenInfo.numScreens) return BadValue; + owner = DGA_GETCLIENT(stuff->screen); REQUEST_SIZE_MATCH(xXDGASetModeReq); rep.type = X_Reply; @@ -326,16 +330,15 @@ ProcXDGASetMode(ClientPtr client) if (!DGAAvailable(stuff->screen)) return DGAErrorBase + XF86DGANoDirectVideoMode; - if(DGAClients[stuff->screen] && - (DGAClients[stuff->screen] != client)) + if(owner && owner != client) return DGAErrorBase + XF86DGANoDirectVideoMode; if(!stuff->mode) { - if(DGAClients[stuff->screen]) { + if(owner) { if(--DGACallbackRefCount == 0) DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL); } - DGAClients[stuff->screen] = NULL; + DGA_SETCLIENT(stuff->screen, NULL); DGASelectInput(stuff->screen, NULL, 0); DGASetMode(stuff->screen, 0, &mode, &pPix); WriteToClient(client, sz_xXDGASetModeReply, (char*)&rep); @@ -345,12 +348,12 @@ ProcXDGASetMode(ClientPtr client) if(Success != DGASetMode(stuff->screen, stuff->mode, &mode, &pPix)) return BadValue; - if(!DGAClients[stuff->screen]) { + if(!owner) { if(DGACallbackRefCount++ == 0) AddCallback (&ClientStateCallback, DGAClientStateChange, NULL); } - DGAClients[stuff->screen] = client; + DGA_SETCLIENT(stuff->screen, client); if(pPix) { if(AddResource(stuff->pid, RT_PIXMAP, (pointer)(pPix))) { @@ -405,7 +408,7 @@ ProcXDGASetViewport(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if(DGAClients[stuff->screen] != client) + if(DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXDGASetViewportReq); @@ -425,7 +428,7 @@ ProcXDGAInstallColormap(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if(DGAClients[stuff->screen] != client) + if(DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXDGAInstallColormapReq); @@ -451,12 +454,12 @@ ProcXDGASelectInput(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if(DGAClients[stuff->screen] != client) + if(DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXDGASelectInputReq); - if(DGAClients[stuff->screen] == client) + if(DGA_GETCLIENT(stuff->screen) == client) DGASelectInput(stuff->screen, client, stuff->mask); return (client->noClientException); @@ -471,7 +474,7 @@ ProcXDGAFillRectangle(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if(DGAClients[stuff->screen] != client) + if(DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXDGAFillRectangleReq); @@ -491,7 +494,7 @@ ProcXDGACopyArea(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if(DGAClients[stuff->screen] != client) + if(DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXDGACopyAreaReq); @@ -512,7 +515,7 @@ ProcXDGACopyTransparentArea(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if(DGAClients[stuff->screen] != client) + if(DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXDGACopyTransparentAreaReq); @@ -534,7 +537,7 @@ ProcXDGAGetViewportStatus(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if(DGAClients[stuff->screen] != client) + if(DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXDGAGetViewportStatusReq); @@ -557,7 +560,7 @@ ProcXDGASync(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if(DGAClients[stuff->screen] != client) + if(DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXDGASyncReq); @@ -602,7 +605,7 @@ ProcXDGAChangePixmapMode(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if(DGAClients[stuff->screen] != client) + if(DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXDGAChangePixmapModeReq); @@ -633,7 +636,7 @@ ProcXDGACreateColormap(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if(DGAClients[stuff->screen] != client) + if(DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXDGACreateColormapReq); @@ -713,18 +716,19 @@ ProcXF86DGADirectVideo(ClientPtr client) int num; PixmapPtr pix; XDGAModeRec mode; + ClientPtr owner; REQUEST(xXF86DGADirectVideoReq); if (stuff->screen > screenInfo.numScreens) return BadValue; + owner = DGA_GETCLIENT(stuff->screen); REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq); if (!DGAAvailable(stuff->screen)) return DGAErrorBase + XF86DGANoDirectVideoMode; - if (DGAClients[stuff->screen] && - (DGAClients[stuff->screen] != client)) + if (owner && owner != client) return DGAErrorBase + XF86DGANoDirectVideoMode; if (stuff->enable & XF86DGADirectGraphics) { @@ -743,19 +747,19 @@ ProcXF86DGADirectVideo(ClientPtr client) /* We need to track the client and attach the teardown callback */ if (stuff->enable & (XF86DGADirectGraphics | XF86DGADirectKeyb | XF86DGADirectMouse)) { - if (!DGAClients[stuff->screen]) { + if (!owner) { if (DGACallbackRefCount++ == 0) AddCallback (&ClientStateCallback, DGAClientStateChange, NULL); } - DGAClients[stuff->screen] = client; + DGA_SETCLIENT(stuff->screen, client); } else { - if (DGAClients[stuff->screen]) { + if (owner) { if (--DGACallbackRefCount == 0) DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL); } - DGAClients[stuff->screen] = NULL; + DGA_SETCLIENT(stuff->screen, NULL); } return (client->noClientException); @@ -800,7 +804,7 @@ ProcXF86DGASetViewPort(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if (DGAClients[stuff->screen] != client) + if (DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq); @@ -864,7 +868,7 @@ ProcXF86DGAInstallColormap(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if (DGAClients[stuff->screen] != client) + if (DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq); @@ -913,7 +917,7 @@ ProcXF86DGAViewPortChanged(ClientPtr client) if (stuff->screen > screenInfo.numScreens) return BadValue; - if (DGAClients[stuff->screen] != client) + if (DGA_GETCLIENT(stuff->screen) != client) return DGAErrorBase + XF86DGADirectNotActivated; REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq); From a2c716eaf6b3a4ce75382394636a0a890b5dcfe0 Mon Sep 17 00:00:00 2001 From: Jamey Sharp Date: Thu, 22 Apr 2010 07:34:04 +0200 Subject: [PATCH 03/10] fb: track screens' installed colormaps as screen privates. Several DDXes allow each screen to have at most one (or in some cases, exactly one) installed colormap. These all use the same pattern: Declare a global-lifetime array of MAXSCREENS ColormapPtrs, and index it by screen number. This patch converts most of those to use screen privates instead. Signed-off-by: Jamey Sharp Acked-by: Tiago Vignatti --- fb/fbcmap.c | 16 ++++++++-------- hw/vfb/InitOutput.c | 23 +++++++++++++---------- hw/xnest/Color.c | 22 +++++++++------------- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/fb/fbcmap.c b/fb/fbcmap.c index 2ff3234b5..b775bc335 100644 --- a/fb/fbcmap.c +++ b/fb/fbcmap.c @@ -36,16 +36,18 @@ #error "You should be compiling fbcmap_mi.c instead of fbcmap.c!" #endif +static int cmapScrPrivateKeyIndex; +static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex; - -ColormapPtr FbInstalledMaps[MAXSCREENS]; +#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey)) +#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c)) int fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) { /* By the time we are processing requests, we can guarantee that there * is always a colormap installed */ - *pmaps = FbInstalledMaps[pScreen->myNum]->mid; + *pmaps = GetInstalledColormap(pScreen)->mid; return (1); } @@ -53,8 +55,7 @@ fbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) void fbInstallColormap(ColormapPtr pmap) { - int index = pmap->pScreen->myNum; - ColormapPtr oldpmap = FbInstalledMaps[index]; + ColormapPtr oldpmap = GetInstalledColormap(pmap->pScreen); if(pmap != oldpmap) { @@ -63,7 +64,7 @@ fbInstallColormap(ColormapPtr pmap) if(oldpmap != (ColormapPtr)None) WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid); /* Install pmap */ - FbInstalledMaps[index] = pmap; + SetInstalledColormap(pmap->pScreen, pmap); WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid); } } @@ -71,8 +72,7 @@ fbInstallColormap(ColormapPtr pmap) void fbUninstallColormap(ColormapPtr pmap) { - int index = pmap->pScreen->myNum; - ColormapPtr curpmap = FbInstalledMaps[index]; + ColormapPtr curpmap = GetInstalledColormap(pmap->pScreen); if(pmap == curpmap) { diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c index 60915fdbf..b2baa197f 100644 --- a/hw/vfb/InitOutput.c +++ b/hw/vfb/InitOutput.c @@ -427,14 +427,18 @@ ddxProcessArgument(int argc, char *argv[], int i) return 0; } -static ColormapPtr InstalledMaps[MAXSCREENS]; +static int cmapScrPrivateKeyIndex; +static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex; + +#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey)) +#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c)) static int vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) { /* By the time we are processing requests, we can guarantee that there * is always a colormap installed */ - *pmaps = InstalledMaps[pScreen->myNum]->mid; + *pmaps = GetInstalledColormap(pScreen)->mid; return (1); } @@ -442,8 +446,7 @@ vfbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) static void vfbInstallColormap(ColormapPtr pmap) { - int index = pmap->pScreen->myNum; - ColormapPtr oldpmap = InstalledMaps[index]; + ColormapPtr oldpmap = GetInstalledColormap(pmap->pScreen); if (pmap != oldpmap) { @@ -459,7 +462,7 @@ vfbInstallColormap(ColormapPtr pmap) if(oldpmap != (ColormapPtr)None) WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid); /* Install pmap */ - InstalledMaps[index] = pmap; + SetInstalledColormap(pmap->pScreen, pmap); WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid); entries = pmap->pVisual->ColormapEntries; @@ -500,7 +503,7 @@ vfbInstallColormap(ColormapPtr pmap) static void vfbUninstallColormap(ColormapPtr pmap) { - ColormapPtr curpmap = InstalledMaps[pmap->pScreen->myNum]; + ColormapPtr curpmap = GetInstalledColormap(pmap->pScreen); if(pmap == curpmap) { @@ -521,7 +524,7 @@ vfbStoreColors(ColormapPtr pmap, int ndef, xColorItem *pdefs) XWDColor *pXWDCmap; int i; - if (pmap != InstalledMaps[pmap->pScreen->myNum]) + if (pmap != GetInstalledColormap(pmap->pScreen)) { return; } @@ -830,10 +833,10 @@ vfbCloseScreen(int index, ScreenPtr pScreen) /* * XXX probably lots of stuff to clean. For now, - * clear InstalledMaps[] so that server reset works correctly. + * clear installed colormaps so that server reset works correctly. */ - for (i = 0; i < MAXSCREENS; i++) - InstalledMaps[i] = NULL; + for (i = 0; i < screenInfo.numScreens; i++) + SetInstalledColormap(screenInfo.screens[i], NULL); return pScreen->CloseScreen(index, pScreen); } diff --git a/hw/xnest/Color.c b/hw/xnest/Color.c index dc749478f..2e6de15e4 100644 --- a/hw/xnest/Color.c +++ b/hw/xnest/Color.c @@ -34,7 +34,11 @@ is" without express or implied warranty. #include "XNWindow.h" #include "Args.h" -static ColormapPtr InstalledMaps[MAXSCREENS]; +static int cmapScrPrivateKeyIndex; +static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex; + +#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey)) +#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c)) Bool xnestCreateColormap(ColormapPtr pCmap) @@ -332,11 +336,7 @@ xnestDirectUninstallColormaps(ScreenPtr pScreen) void xnestInstallColormap(ColormapPtr pCmap) { - int index; - ColormapPtr pOldCmap; - - index = pCmap->pScreen->myNum; - pOldCmap = InstalledMaps[index]; + ColormapPtr pOldCmap = GetInstalledColormap(pCmap->pScreen); if(pCmap != pOldCmap) { @@ -346,7 +346,7 @@ xnestInstallColormap(ColormapPtr pCmap) if(pOldCmap != (ColormapPtr)None) WalkTree(pCmap->pScreen, TellLostMap, (pointer)&pOldCmap->mid); - InstalledMaps[index] = pCmap; + SetInstalledColormap(pCmap->pScreen, pCmap); WalkTree(pCmap->pScreen, TellGainedMap, (pointer)&pCmap->mid); xnestSetInstalledColormapWindows(pCmap->pScreen); @@ -357,11 +357,7 @@ xnestInstallColormap(ColormapPtr pCmap) void xnestUninstallColormap(ColormapPtr pCmap) { - int index; - ColormapPtr pCurCmap; - - index = pCmap->pScreen->myNum; - pCurCmap = InstalledMaps[index]; + ColormapPtr pCurCmap = GetInstalledColormap(pCmap->pScreen); if(pCmap == pCurCmap) { @@ -382,7 +378,7 @@ int xnestListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapIDs) { if (xnestInstalledDefaultColormap) { - *pCmapIDs = InstalledMaps[pScreen->myNum]->mid; + *pCmapIDs = GetInstalledColormap(pScreen)->mid; return 1; } else From a94f5455c71363d5047668ee093901b9e1645cf1 Mon Sep 17 00:00:00 2001 From: Tiago Vignatti Date: Thu, 22 Apr 2010 20:20:43 +0300 Subject: [PATCH 04/10] mi: track screens' installed colormaps as screen privates Signed-off-by: Tiago Vignatti Reviewed-by: Jamey Sharp --- mi/micmap.c | 15 +++++++-------- mi/micmap.h | 8 +++++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/mi/micmap.c b/mi/micmap.c index e832be7fa..cc829fc10 100644 --- a/mi/micmap.c +++ b/mi/micmap.c @@ -40,13 +40,14 @@ #include "globals.h" #include "micmap.h" -ColormapPtr miInstalledMaps[MAXSCREENS]; +static int micmapScrPrivateKeyIndex; +DevPrivateKey micmapScrPrivateKey = &micmapScrPrivateKeyIndex; int miListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) { - if (miInstalledMaps[pScreen->myNum]) { - *pmaps = miInstalledMaps[pScreen->myNum]->mid; + if (GetInstalledmiColormap(pScreen)) { + *pmaps = GetInstalledmiColormap(pScreen)->mid; return (1); } return 0; @@ -55,8 +56,7 @@ miListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps) void miInstallColormap(ColormapPtr pmap) { - int index = pmap->pScreen->myNum; - ColormapPtr oldpmap = miInstalledMaps[index]; + ColormapPtr oldpmap = GetInstalledmiColormap(pmap->pScreen); if(pmap != oldpmap) { @@ -65,7 +65,7 @@ miInstallColormap(ColormapPtr pmap) if(oldpmap != (ColormapPtr)None) WalkTree(pmap->pScreen, TellLostMap, (char *)&oldpmap->mid); /* Install pmap */ - miInstalledMaps[index] = pmap; + SetInstalledmiColormap(pmap->pScreen, pmap); WalkTree(pmap->pScreen, TellGainedMap, (char *)&pmap->mid); } @@ -74,8 +74,7 @@ miInstallColormap(ColormapPtr pmap) void miUninstallColormap(ColormapPtr pmap) { - int index = pmap->pScreen->myNum; - ColormapPtr curpmap = miInstalledMaps[index]; + ColormapPtr curpmap = GetInstalledmiColormap(pmap->pScreen); if(pmap == curpmap) { diff --git a/mi/micmap.h b/mi/micmap.h index 5c8448a95..8ad94b9dd 100644 --- a/mi/micmap.h +++ b/mi/micmap.h @@ -4,7 +4,13 @@ #ifndef _MICMAP_H_ #define _MICMAP_H_ -extern _X_EXPORT ColormapPtr miInstalledMaps[MAXSCREENS]; +#define GetInstalledmiColormap(s) \ + ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, micmapScrPrivateKey)) +#define SetInstalledmiColormap(s,c) \ + (dixSetPrivate(&(s)->devPrivates, micmapScrPrivateKey, c)) + +extern _X_EXPORT DevPrivateKey micmapScrPrivateKey; + typedef Bool (* miInitVisualsProcPtr)(VisualPtr *, DepthPtr *, int *, int *, int *, VisualID *, unsigned long, int, From b61870595ba4df06006d24ed8c07cfe781bce1b7 Mon Sep 17 00:00:00 2001 From: Tiago Vignatti Date: Thu, 22 Apr 2010 20:20:48 +0300 Subject: [PATCH 05/10] xfree86: track screens' installed colormaps as screen privates Signed-off-by: Tiago Vignatti Reviewed-by: Jamey Sharp --- hw/xfree86/common/xf86DGA.c | 2 +- hw/xfree86/common/xf86cmap.c | 49 ++++++++++++++++++------------------ hw/xfree86/vgahw/vgaCmap.c | 14 +++++------ 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 804fd37c1..1a1032786 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -731,7 +731,7 @@ DGAInstallCmap(ColormapPtr cmap) /* We rely on the extension to check that DGA is active */ if(!pScreenPriv->dgaColormap) - pScreenPriv->savedColormap = miInstalledMaps[pScreen->myNum]; + pScreenPriv->savedColormap = GetInstalledmiColormap(pScreen); pScreenPriv->dgaColormap = cmap; diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c index f60d96e7d..e266ffb6d 100644 --- a/hw/xfree86/common/xf86cmap.c +++ b/hw/xfree86/common/xf86cmap.c @@ -63,10 +63,10 @@ #define SCREEN_EPILOGUE(pScreen, field, wrapper)\ ((pScreen)->field = wrapper) -#define LOAD_PALETTE(pmap, index) \ - ((pmap == miInstalledMaps[index]) && \ +#define LOAD_PALETTE(pmap) \ + ((pmap == GetInstalledmiColormap(pmap->pScreen)) && \ ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || \ - xf86Screens[index]->vtSema || pScreenPriv->isDGAmode)) + xf86Screens[pmap->pScreen->myNum]->vtSema || pScreenPriv->isDGAmode)) typedef struct _CMapLink { @@ -221,7 +221,7 @@ Bool xf86HandleColormaps( } /* Force the initial map to be loaded */ - miInstalledMaps[pScreen->myNum] = NULL; + SetInstalledmiColormap(pScreen, NULL); CMapInstallColormap(pDefMap); return TRUE; } @@ -425,11 +425,10 @@ static void CMapInstallColormap(ColormapPtr pmap) { ScreenPtr pScreen = pmap->pScreen; - int index = pScreen->myNum; CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate( &pScreen->devPrivates, CMapScreenKey); - if (pmap == miInstalledMaps[index]) + if (pmap == GetInstalledmiColormap(pmap->pScreen)) return; pScreen->InstallColormap = pScreenPriv->InstallColormap; @@ -438,15 +437,15 @@ CMapInstallColormap(ColormapPtr pmap) /* Important. We let the lower layers, namely DGA, overwrite the choice of Colormap to install */ - if (miInstalledMaps[index]) - pmap = miInstalledMaps[index]; + if (GetInstalledmiColormap(pmap->pScreen)) + pmap = GetInstalledmiColormap(pmap->pScreen); if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && (pmap->pVisual->class == TrueColor) && CMapColormapUseMax(pmap->pVisual, pScreenPriv)) return; - if(LOAD_PALETTE(pmap, index)) + if(LOAD_PALETTE(pmap)) CMapReinstallMap(pmap); } @@ -461,8 +460,8 @@ CMapEnterVT(int index, int flags) &pScreen->devPrivates, CMapScreenKey); if((*pScreenPriv->EnterVT)(index, flags)) { - if(miInstalledMaps[index]) - CMapReinstallMap(miInstalledMaps[index]); + if(GetInstalledmiColormap(pScreen)) + CMapReinstallMap(GetInstalledmiColormap(pScreen)); return TRUE; } return FALSE; @@ -477,8 +476,8 @@ CMapSwitchMode(int index, DisplayModePtr mode, int flags) &pScreen->devPrivates, CMapScreenKey); if((*pScreenPriv->SwitchMode)(index, mode, flags)) { - if(miInstalledMaps[index]) - CMapReinstallMap(miInstalledMaps[index]); + if(GetInstalledmiColormap(pScreen)) + CMapReinstallMap(GetInstalledmiColormap(pScreen)); return TRUE; } return FALSE; @@ -497,9 +496,9 @@ CMapSetDGAMode(int index, int num, DGADevicePtr dev) pScreenPriv->isDGAmode = DGAActive(index); - if(!pScreenPriv->isDGAmode && miInstalledMaps[index] + if(!pScreenPriv->isDGAmode && GetInstalledmiColormap(pScreen) && xf86Screens[pScreen->myNum]->vtSema) - CMapReinstallMap(miInstalledMaps[index]); + CMapReinstallMap(GetInstalledmiColormap(pScreen)); return ret; } @@ -649,7 +648,7 @@ CMapRefreshColors(ColormapPtr pmap, int defs, int* indices) } - if(LOAD_PALETTE(pmap, pmap->pScreen->myNum)) + if(LOAD_PALETTE(pmap)) (*pScrn->LoadPalette)(pScreenPriv->pScrn, defs, indices, colors, pmap->pVisual); @@ -802,7 +801,7 @@ CMapSetOverscan(ColormapPtr pmap, int defs, int *indices) } if (newOverscan) { pColPriv->overscan = overscan; - if (LOAD_PALETTE(pmap, pmap->pScreen->myNum)) { + if (LOAD_PALETTE(pmap)) { #ifdef DEBUGOVERSCAN ErrorF("SetOverscan() called from CmapSetOverscan\n"); #endif @@ -929,10 +928,10 @@ CMapChangeGamma( pLink = pLink->next; } - if(miInstalledMaps[pScreen->myNum] && + if(GetInstalledmiColormap(pScreen) && ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || pScrn->vtSema || pScreenPriv->isDGAmode)) { - ColormapPtr pMap = miInstalledMaps[pScreen->myNum]; + ColormapPtr pMap = GetInstalledmiColormap(pScreen); if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && (pMap->pVisual->class == TrueColor) && @@ -951,9 +950,9 @@ CMapChangeGamma( if(pLink) { /* need to trick CMapRefreshColors() into thinking this is the currently installed map */ - miInstalledMaps[pScreen->myNum] = pLink->cmap; + SetInstalledmiColormap(pScreen, pLink->cmap); CMapReinstallMap(pLink->cmap); - miInstalledMaps[pScreen->myNum] = pMap; + SetInstalledmiColormap(pScreen, pMap); } } else CMapReinstallMap(pMap); @@ -1035,10 +1034,10 @@ xf86ChangeGammaRamp( pLink = pLink->next; } - if(miInstalledMaps[pScreen->myNum] && + if(GetInstalledmiColormap(pScreen) && ((pScreenPriv->flags & CMAP_LOAD_EVEN_IF_OFFSCREEN) || pScrn->vtSema || pScreenPriv->isDGAmode)) { - ColormapPtr pMap = miInstalledMaps[pScreen->myNum]; + ColormapPtr pMap = GetInstalledmiColormap(pScreen); if (!(pScreenPriv->flags & CMAP_PALETTED_TRUECOLOR) && (pMap->pVisual->class == TrueColor) && @@ -1057,9 +1056,9 @@ xf86ChangeGammaRamp( if(pLink) { /* need to trick CMapRefreshColors() into thinking this is the currently installed map */ - miInstalledMaps[pScreen->myNum] = pLink->cmap; + SetInstalledmiColormap(pScreen, pLink->cmap); CMapReinstallMap(pLink->cmap); - miInstalledMaps[pScreen->myNum] = pMap; + SetInstalledmiColormap(pScreen, pMap); } } else CMapReinstallMap(pMap); diff --git a/hw/xfree86/vgahw/vgaCmap.c b/hw/xfree86/vgahw/vgaCmap.c index 5bd38b468..06eeb4ce1 100644 --- a/hw/xfree86/vgahw/vgaCmap.c +++ b/hw/xfree86/vgahw/vgaCmap.c @@ -50,7 +50,7 @@ vgaListInstalledColormaps(pScreen, pmaps) /* By the time we are processing requests, we can guarantee that there * is always a colormap installed */ - *pmaps = miInstalledMaps[pScreen->myNum]->mid; + *pmaps = GetInstalledmiColormap(pScreen)->mid; return(1); } @@ -62,13 +62,13 @@ vgaGetInstalledColormaps(pScreen, pmaps) /* By the time we are processing requests, we can guarantee that there * is always a colormap installed */ - *pmaps = miInstalledMaps[pScreen->myNum]; + *pmaps = GetInstalledmiColormap(pScreen); return(1); } int vgaCheckColorMap(ColormapPtr pmap) { - return (pmap != miInstalledMaps[pmap->pScreen->myNum]); + return (pmap != GetInstalledmiColormap(pmap->pScreen)); } @@ -217,7 +217,7 @@ void vgaInstallColormap(pmap) ColormapPtr pmap; { - ColormapPtr oldmap = miInstalledMaps[pmap->pScreen->myNum]; + ColormapPtr oldmap = GetInstalledmiColormap(pmap->pScreen); int entries; Pixel * ppix; xrgb * prgb; @@ -242,7 +242,7 @@ vgaInstallColormap(pmap) if ( oldmap != NOMAPYET) WalkTree( pmap->pScreen, TellLostMap, &oldmap->mid); - miInstalledMaps[pmap->pScreen->myNum] = pmap; + SetInstalledmiColormap(pmap->pScreen, pmap); for ( i=0; ipScreen->myNum] ) + if ( pmap != GetInstalledmiColormap(pmap->pScreen)) return; dixLookupResourceByType((pointer *)&defColormap, pmap->pScreen->defColormap, RT_COLORMAP, serverClient, DixInstallAccess); - if (defColormap == miInstalledMaps[pmap->pScreen->myNum]) + if (defColormap == GetInstalledmiColormap(pmap->pScreen)) return; (*pmap->pScreen->InstallColormap) (defColormap); From d8454ae488cfc073cd6010c9a08d53855a0c2612 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Mon, 12 Apr 2010 20:18:13 +0100 Subject: [PATCH 06/10] Xwin: Simplify screen option processing Use an instance of the XWin DDX-specific screen info structure to hold the current default values, to simplify greatly the code for applying options to all screens and remove all those loops over MAXSCREENS screens in the command line option processing Use g_iNumScreens for tracking the current initialized screen count Signed-off-by: Jon TURNEY Reviewed-by: Jamey Sharp Reviewed-by: Tiago Vignatti --- hw/xwin/InitOutput.c | 24 +- hw/xwin/win.h | 6 + hw/xwin/winglobals.c | 2 - hw/xwin/winprocarg.c | 615 ++++++++++--------------------------------- hw/xwin/winscrinit.c | 2 +- 5 files changed, 160 insertions(+), 489 deletions(-) diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index fd286de44..8c7ebf0ea 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -65,7 +65,6 @@ typedef HRESULT (*SHGETFOLDERPATHPROC)( extern int g_iNumScreens; extern winScreenInfo g_ScreenInfo[]; -extern int g_iLastScreen; extern char * g_pszCommandLine; extern Bool g_fSilentFatalError; @@ -115,9 +114,6 @@ void OsVendorVErrorF (const char *pszFormat, va_list va_args); #endif -void -winInitializeDefaultScreens (void); - static Bool winCheckDisplayNumber (void); @@ -716,22 +712,16 @@ OsVendorInit (void) /* Add a default screen if no screens were specified */ if (g_iNumScreens == 0) { - winDebug ("OsVendorInit - Creating bogus screen 0\n"); - - /* - * We need to initialize default screens if no arguments - * were processed. Otherwise, the default screens would - * already have been initialized by ddxProcessArgument (). - */ - winInitializeDefaultScreens (); + winDebug ("OsVendorInit - Creating default screen 0\n"); /* - * Add a screen 0 using the defaults set by - * winInitializeDefaultScreens () and any additional parameters - * processed by ddxProcessArgument (). + * We need to initialize the default screen 0 if no -screen + * arguments were processed. + * + * Add a screen 0 using the defaults set by winInitializeDefaultScreens() + * and any additional default screen parameters given */ - g_iNumScreens = 1; - g_iLastScreen = 0; + winInitializeScreens(1); /* We have to flag this as an explicit screen, even though it isn't */ g_ScreenInfo[0].fExplicitScreen = TRUE; diff --git a/hw/xwin/win.h b/hw/xwin/win.h index b1acd3e47..072c69121 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -1450,6 +1450,12 @@ winWindowsWMExtensionInit (void); Bool winInitCursor (ScreenPtr pScreen); +/* + * winprocarg.c + */ +void +winInitializeScreens(int maxscreens); + /* * END DDX and DIX Function Prototypes */ diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c index 926ce69b8..da7815560 100644 --- a/hw/xwin/winglobals.c +++ b/hw/xwin/winglobals.c @@ -42,7 +42,6 @@ int g_iNumScreens = 0; winScreenInfo g_ScreenInfo[MAXSCREENS]; -int g_iLastScreen = -1; #ifdef HAS_DEVWINDOWS int g_fdMessageQueue = WIN_FD_INVALID; #endif @@ -57,7 +56,6 @@ DevPrivateKey g_iPixmapPrivateKey = &g_iPixmapPrivateKeyIndex; static int g_iWindowPrivateKeyIndex; DevPrivateKey g_iWindowPrivateKey = &g_iWindowPrivateKeyIndex; unsigned long g_ulServerGeneration = 0; -Bool g_fInitializedDefaultScreens = FALSE; DWORD g_dwEnginesSupported = 0; HINSTANCE g_hInstance = 0; HWND g_hDlgDepthChange = NULL; diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c index 66da76f6c..540adf706 100755 --- a/hw/xwin/winprocarg.c +++ b/hw/xwin/winprocarg.c @@ -46,8 +46,6 @@ from The Open Group. extern int g_iNumScreens; extern winScreenInfo g_ScreenInfo[]; -extern int g_iLastScreen; -extern Bool g_fInitializedDefaultScreens; #ifdef XWIN_CLIPBOARD extern Bool g_fUnicodeClipboard; extern Bool g_fClipboard; @@ -129,25 +127,25 @@ winLogVersionInfo (void); void OsVendorVErrorF (const char *pszFormat, va_list va_args); #endif -void -winInitializeDefaultScreens (void); - /* * Process arguments on the command line */ -void -winInitializeDefaultScreens (void) -{ - int i; - DWORD dwWidth, dwHeight; +static int iLastScreen = -1; +static winScreenInfo defaultScreenInfo; - /* Bail out early if default screens have already been initialized */ - if (g_fInitializedDefaultScreens) +static void +winInitializeScreenDefaults(void) +{ + DWORD dwWidth, dwHeight; + static Bool fInitializedScreenDefaults = FALSE; + + /* Bail out early if default screen has already been initialized */ + if (fInitializedScreenDefaults) return; /* Zero the memory used for storing the screen info */ - ZeroMemory (g_ScreenInfo, MAXSCREENS * sizeof (winScreenInfo)); + memset(&defaultScreenInfo, 0, sizeof(winScreenInfo)); /* Get default width and height */ /* @@ -157,62 +155,85 @@ winInitializeDefaultScreens (void) dwWidth = GetSystemMetrics (SM_CXSCREEN); dwHeight = GetSystemMetrics (SM_CYSCREEN); - winErrorFVerb (2, "winInitializeDefaultScreens - w %d h %d\n", + winErrorFVerb (2, "winInitializeScreenDefaults - w %d h %d\n", (int) dwWidth, (int) dwHeight); /* Set a default DPI, if no parameter was passed */ if (monitorResolution == 0) monitorResolution = WIN_DEFAULT_DPI; - for (i = 0; i < MAXSCREENS; ++i) - { - g_ScreenInfo[i].dwScreen = i; - g_ScreenInfo[i].dwWidth = dwWidth; - g_ScreenInfo[i].dwHeight = dwHeight; - g_ScreenInfo[i].dwUserWidth = dwWidth; - g_ScreenInfo[i].dwUserHeight = dwHeight; - g_ScreenInfo[i].fUserGaveHeightAndWidth - = WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH; - g_ScreenInfo[i].fUserGavePosition = FALSE; - g_ScreenInfo[i].dwBPP = WIN_DEFAULT_BPP; - g_ScreenInfo[i].dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES; + defaultScreenInfo.dwWidth = dwWidth; + defaultScreenInfo.dwHeight = dwHeight; + defaultScreenInfo.dwUserWidth = dwWidth; + defaultScreenInfo.dwUserHeight = dwHeight; + defaultScreenInfo.fUserGaveHeightAndWidth = WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH; + defaultScreenInfo.fUserGavePosition = FALSE; + defaultScreenInfo.dwBPP = WIN_DEFAULT_BPP; + defaultScreenInfo.dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES; #ifdef XWIN_EMULATEPSEUDO - g_ScreenInfo[i].fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO; + defaultScreenInfo.fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO; #endif - g_ScreenInfo[i].dwRefreshRate = WIN_DEFAULT_REFRESH; - g_ScreenInfo[i].pfb = NULL; - g_ScreenInfo[i].fFullScreen = FALSE; - g_ScreenInfo[i].fDecoration = TRUE; + defaultScreenInfo.dwRefreshRate = WIN_DEFAULT_REFRESH; + defaultScreenInfo.pfb = NULL; + defaultScreenInfo.fFullScreen = FALSE; + defaultScreenInfo.fDecoration = TRUE; #ifdef XWIN_MULTIWINDOWEXTWM - g_ScreenInfo[i].fMWExtWM = FALSE; - g_ScreenInfo[i].fInternalWM = FALSE; + defaultScreenInfo.fMWExtWM = FALSE; + defaultScreenInfo.fInternalWM = FALSE; #endif - g_ScreenInfo[i].fRootless = FALSE; + defaultScreenInfo.fRootless = FALSE; #ifdef XWIN_MULTIWINDOW - g_ScreenInfo[i].fMultiWindow = FALSE; + defaultScreenInfo.fMultiWindow = FALSE; #endif #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - g_ScreenInfo[i].fMultiMonitorOverride = FALSE; + defaultScreenInfo.fMultiMonitorOverride = FALSE; #endif - g_ScreenInfo[i].fMultipleMonitors = FALSE; - g_ScreenInfo[i].fLessPointer = FALSE; - g_ScreenInfo[i].fScrollbars = FALSE; - g_ScreenInfo[i].fNoTrayIcon = FALSE; - g_ScreenInfo[i].iE3BTimeout = WIN_E3B_OFF; - g_ScreenInfo[i].dwWidth_mm = (dwWidth / WIN_DEFAULT_DPI) - * 25.4; - g_ScreenInfo[i].dwHeight_mm = (dwHeight / WIN_DEFAULT_DPI) - * 25.4; - g_ScreenInfo[i].fUseWinKillKey = WIN_DEFAULT_WIN_KILL; - g_ScreenInfo[i].fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL; - g_ScreenInfo[i].fIgnoreInput = FALSE; - g_ScreenInfo[i].fExplicitScreen = FALSE; + defaultScreenInfo.fMultipleMonitors = FALSE; + defaultScreenInfo.fLessPointer = FALSE; + defaultScreenInfo.fScrollbars = FALSE; + defaultScreenInfo.fNoTrayIcon = FALSE; + defaultScreenInfo.iE3BTimeout = WIN_E3B_OFF; + defaultScreenInfo.dwWidth_mm = (dwWidth / WIN_DEFAULT_DPI) * 25.4; + defaultScreenInfo.dwHeight_mm = (dwHeight / WIN_DEFAULT_DPI) * 25.4; + defaultScreenInfo.fUseWinKillKey = WIN_DEFAULT_WIN_KILL; + defaultScreenInfo.fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL; + defaultScreenInfo.fIgnoreInput = FALSE; + defaultScreenInfo.fExplicitScreen = FALSE; + + /* Note that the default screen has been initialized */ + fInitializedScreenDefaults = TRUE; +} + +static void +winInitializeScreen(int i) +{ + winErrorFVerb (2, "winInitializeScreen - %d\n",i); + + /* Initialize default screen values, if needed */ + winInitializeScreenDefaults(); + + /* Copy the default screen info */ + g_ScreenInfo[i] = defaultScreenInfo; + + /* Set the screen number */ + g_ScreenInfo[i].dwScreen = i; +} + +void +winInitializeScreens(int maxscreens) +{ + int i; + winErrorFVerb (2, "winInitializeScreens - %i\n", maxscreens); + + if (maxscreens > g_iNumScreens) + { + /* Set default values for any new screens */ + for (i = g_iNumScreens; i < maxscreens ; i++) + winInitializeScreen(i); + + /* Keep a count of the number of screens */ + g_iNumScreens = maxscreens; } - - /* Signal that the default screens have been initialized */ - g_fInitializedDefaultScreens = TRUE; - - winErrorFVerb (2, "winInitializeDefaultScreens - Returning\n"); } /* See Porting Layer Definition - p. 57 */ @@ -244,6 +265,7 @@ int ddxProcessArgument (int argc, char *argv[], int i) { static Bool s_fBeenHere = FALSE; + winScreenInfo *screenInfoPtr = NULL; /* Initialize once */ if (!s_fBeenHere) @@ -276,7 +298,7 @@ ddxProcessArgument (int argc, char *argv[], int i) */ winErrorFVerb (2, "ddxProcessArgument - Initializing default " "screens\n"); - winInitializeDefaultScreens (); + winInitializeScreenDefaults(); } } @@ -339,6 +361,14 @@ ddxProcessArgument (int argc, char *argv[], int i) return 0; } + /* + Initialize default values for any new screens + + Note that default values can't change after a -screen option is + seen, so it's safe to do this for each screen as it is introduced + */ + winInitializeScreens(nScreenNum+1); + /* look for @m where m is monitor number */ if (i + 2 < argc && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor)) @@ -505,14 +535,33 @@ ddxProcessArgument (int argc, char *argv[], int i) * before a screen number apply to all screens, whereas parameters * seen after a screen number apply to that screen number only. */ - g_iLastScreen = nScreenNum; - - /* Keep a count of the number of screens */ - ++g_iNumScreens; + iLastScreen = nScreenNum; return iArgsProcessed; } + + /* + * Is this parameter attached to a screen or global? + * + * If the parameter is for all screens (appears before + * any -screen option), store it in the default screen + * info + * + * If the parameter is for a single screen (appears + * after a -screen option), store it in the screen info + * for that screen + * + */ + if (iLastScreen == -1) + { + screenInfoPtr = &defaultScreenInfo; + } + else + { + screenInfoPtr = &(g_ScreenInfo[iLastScreen]); + } + /* * Look for the '-engine n' argument */ @@ -541,22 +590,7 @@ ddxProcessArgument (int argc, char *argv[], int i) return 0; } - /* Is this parameter attached to a screen or global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].dwEnginePreferred = dwEngine; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].dwEnginePreferred = dwEngine; - } + screenInfoPtr->dwEnginePreferred = dwEngine; /* Indicate that we have processed the argument */ return 2; @@ -567,30 +601,11 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-fullscreen")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - if (!g_ScreenInfo[j].fMultiMonitorOverride) - g_ScreenInfo[j].fMultipleMonitors = FALSE; + if (!screenInfoPtr->fMultiMonitorOverride) + screenInfoPtr->fMultipleMonitors = FALSE; #endif - g_ScreenInfo[j].fFullScreen = TRUE; - } - } - else - { - /* Parameter is for a single screen */ -#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) - g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; -#endif - g_ScreenInfo[g_iLastScreen].fFullScreen = TRUE; - } + screenInfoPtr->fFullScreen = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -601,22 +616,7 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-lesspointer")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].fLessPointer = TRUE; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].fLessPointer = TRUE; - } + screenInfoPtr->fLessPointer = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -627,30 +627,11 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-nodecoration")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - if (!g_ScreenInfo[j].fMultiMonitorOverride) - g_ScreenInfo[j].fMultipleMonitors = FALSE; + if (!screenInfoPtr->fMultiMonitorOverride) + screenInfoPtr->fMultipleMonitors = FALSE; #endif - g_ScreenInfo[j].fDecoration = FALSE; - } - } - else - { - /* Parameter is for a single screen */ -#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) - g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; -#endif - g_ScreenInfo[g_iLastScreen].fDecoration = FALSE; - } + screenInfoPtr->fDecoration = FALSE; /* Indicate that we have processed this argument */ return 1; @@ -662,26 +643,9 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-mwextwm")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - if (!g_ScreenInfo[j].fMultiMonitorOverride) - g_ScreenInfo[j].fMultipleMonitors = TRUE; - g_ScreenInfo[j].fMWExtWM = TRUE; - } - } - else - { - /* Parameter is for a single screen */ - if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) - g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; - g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE; - } + if (!screenInfoPtr->fMultiMonitorOverride) + screenInfoPtr->fMultipleMonitors = TRUE; + screenInfoPtr->fMWExtWM = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -691,28 +655,10 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-internalwm")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - if (!g_ScreenInfo[j].fMultiMonitorOverride) - g_ScreenInfo[j].fMultipleMonitors = TRUE; - g_ScreenInfo[j].fMWExtWM = TRUE; - g_ScreenInfo[j].fInternalWM = TRUE; - } - } - else - { - /* Parameter is for a single screen */ - if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) - g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; - g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE; - g_ScreenInfo[g_iLastScreen].fInternalWM = TRUE; - } + if (!screenInfoPtr->fMultiMonitorOverride) + screenInfoPtr->fMultipleMonitors = TRUE; + screenInfoPtr->fMWExtWM = TRUE; + screenInfoPtr->fInternalWM = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -724,30 +670,11 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-rootless")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - if (!g_ScreenInfo[j].fMultiMonitorOverride) - g_ScreenInfo[j].fMultipleMonitors = FALSE; + if (!screenInfoPtr->fMultiMonitorOverride) + screenInfoPtr->fMultipleMonitors = FALSE; #endif - g_ScreenInfo[j].fRootless = TRUE; - } - } - else - { - /* Parameter is for a single screen */ -#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) - g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; -#endif - g_ScreenInfo[g_iLastScreen].fRootless = TRUE; - } + screenInfoPtr->fRootless = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -759,30 +686,11 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-multiwindow")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - if (!g_ScreenInfo[j].fMultiMonitorOverride) - g_ScreenInfo[j].fMultipleMonitors = TRUE; + if (!screenInfoPtr->fMultiMonitorOverride) + screenInfoPtr->fMultipleMonitors = TRUE; #endif - g_ScreenInfo[j].fMultiWindow = TRUE; - } - } - else - { - /* Parameter is for a single screen */ -#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride) - g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; -#endif - g_ScreenInfo[g_iLastScreen].fMultiWindow = TRUE; - } + screenInfoPtr->fMultiWindow = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -795,28 +703,10 @@ ddxProcessArgument (int argc, char *argv[], int i) if (IS_OPTION ("-multiplemonitors") || IS_OPTION ("-multimonitors")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - g_ScreenInfo[j].fMultiMonitorOverride = TRUE; + screenInfoPtr->fMultiMonitorOverride = TRUE; #endif - g_ScreenInfo[j].fMultipleMonitors = TRUE; - } - } - else - { - /* Parameter is for a single screen */ -#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE; -#endif - g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE; - } + screenInfoPtr->fMultipleMonitors = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -828,28 +718,10 @@ ddxProcessArgument (int argc, char *argv[], int i) if (IS_OPTION ("-nomultiplemonitors") || IS_OPTION ("-nomultimonitors")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - g_ScreenInfo[j].fMultiMonitorOverride = TRUE; + screenInfoPtr->fMultiMonitorOverride = TRUE; #endif - g_ScreenInfo[j].fMultipleMonitors = FALSE; - } - } - else - { - /* Parameter is for a single screen */ -#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) - g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE; -#endif - g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE; - } + screenInfoPtr->fMultipleMonitors = FALSE; /* Indicate that we have processed this argument */ return 1; @@ -861,22 +733,7 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-scrollbars")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].fScrollbars = TRUE; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].fScrollbars = TRUE; - } + screenInfoPtr->fScrollbars = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -914,22 +771,7 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-ignoreinput")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].fIgnoreInput = TRUE; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].fIgnoreInput = TRUE; - } + screenInfoPtr->fIgnoreInput = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -962,22 +804,7 @@ ddxProcessArgument (int argc, char *argv[], int i) iE3BTimeout = WIN_DEFAULT_E3B_TIME; } - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].iE3BTimeout = iE3BTimeout; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].iE3BTimeout = iE3BTimeout; - } + screenInfoPtr->iE3BTimeout = iE3BTimeout; /* Indicate that we have processed this argument */ return iArgsProcessed; @@ -1000,23 +827,8 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Grab the argument */ dwBPP = atoi (argv[i]); - /* Is this parameter attached to a screen or global? */ - if (-1 == g_iLastScreen) - { - int j; + screenInfoPtr->dwBPP = dwBPP; - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].dwBPP = dwBPP; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].dwBPP = dwBPP; - } - /* Indicate that we have processed the argument */ return 2; } @@ -1038,23 +850,8 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Grab the argument */ dwRefreshRate = atoi (argv[i]); - /* Is this parameter attached to a screen or global? */ - if (-1 == g_iLastScreen) - { - int j; + screenInfoPtr->dwRefreshRate = dwRefreshRate; - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].dwRefreshRate = dwRefreshRate; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].dwRefreshRate = dwRefreshRate; - } - /* Indicate that we have processed the argument */ return 2; } @@ -1076,23 +873,8 @@ ddxProcessArgument (int argc, char *argv[], int i) /* Grab the argument */ dwNumBoxes = atoi (argv[i]); - /* Is this parameter attached to a screen or global? */ - if (-1 == g_iLastScreen) - { - int j; + screenInfoPtr->dwClipUpdatesNBoxes = dwNumBoxes; - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].dwClipUpdatesNBoxes = dwNumBoxes; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].dwClipUpdatesNBoxes = dwNumBoxes; - } - /* Indicate that we have processed the argument */ return 2; } @@ -1103,22 +885,7 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-emulatepseudo")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].fEmulatePseudo = TRUE; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].fEmulatePseudo = TRUE; - } + screenInfoPtr->fEmulatePseudo = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -1130,22 +897,7 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-nowinkill")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].fUseWinKillKey = FALSE; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].fUseWinKillKey = FALSE; - } + screenInfoPtr->fUseWinKillKey = FALSE; /* Indicate that we have processed this argument */ return 1; @@ -1156,22 +908,7 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-winkill")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].fUseWinKillKey = TRUE; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].fUseWinKillKey = TRUE; - } + screenInfoPtr->fUseWinKillKey = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -1182,22 +919,7 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-nounixkill")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].fUseUnixKillKey = FALSE; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = FALSE; - } + screenInfoPtr->fUseUnixKillKey = FALSE; /* Indicate that we have processed this argument */ return 1; @@ -1208,22 +930,7 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-unixkill")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].fUseUnixKillKey = TRUE; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = TRUE; - } + screenInfoPtr->fUseUnixKillKey = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -1234,22 +941,7 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-notrayicon")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].fNoTrayIcon = TRUE; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].fNoTrayIcon = TRUE; - } + screenInfoPtr->fNoTrayIcon = TRUE; /* Indicate that we have processed this argument */ return 1; @@ -1260,22 +952,7 @@ ddxProcessArgument (int argc, char *argv[], int i) */ if (IS_OPTION ("-trayicon")) { - /* Is this parameter attached to a screen or is it global? */ - if (-1 == g_iLastScreen) - { - int j; - - /* Parameter is for all screens */ - for (j = 0; j < MAXSCREENS; j++) - { - g_ScreenInfo[j].fNoTrayIcon = FALSE; - } - } - else - { - /* Parameter is for a single screen */ - g_ScreenInfo[g_iLastScreen].fNoTrayIcon = FALSE; - } + screenInfoPtr->fNoTrayIcon = FALSE; /* Indicate that we have processed this argument */ return 1; diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c index 953548ec7..4fa987cd9 100644 --- a/hw/xwin/winscrinit.c +++ b/hw/xwin/winscrinit.c @@ -196,7 +196,7 @@ winScreenInit (int index, /* * In this case, some of the defaults set in - * winInitializeDefaultScreens () are not correct ... + * winInitializeScreenDefaults() are not correct ... */ if (!pScreenInfo->fUserGaveHeightAndWidth) { From a7d398e545a4be5491248d5ccb303aa03ee1594f Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Fri, 16 Apr 2010 18:13:50 +0100 Subject: [PATCH 07/10] Xwin: make screens structures run-time adjustable Change g_ScreenInfo, an array of winScreenInfo elements, from a static array of MAXSCREENS elements, to a dynamically allocated one Fix up the validation that -screen option screen numbers are contiguous from zero (which possibly didn't work correctly before anyhow) Signed-off-by: Jon TURNEY Reviewed-by: Jamey Sharp Reviewed-by: Tiago Vignatti --- hw/xwin/InitOutput.c | 2 +- hw/xwin/win.h | 2 +- hw/xwin/winglobals.c | 2 +- hw/xwin/winprocarg.c | 7 +++++-- hw/xwin/winvalargs.c | 31 +++++++++++++++---------------- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 8c7ebf0ea..0ab692987 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -64,7 +64,7 @@ typedef HRESULT (*SHGETFOLDERPATHPROC)( */ extern int g_iNumScreens; -extern winScreenInfo g_ScreenInfo[]; +extern winScreenInfo * g_ScreenInfo; extern char * g_pszCommandLine; extern Bool g_fSilentFatalError; diff --git a/hw/xwin/win.h b/hw/xwin/win.h index 072c69121..5abaa031c 100644 --- a/hw/xwin/win.h +++ b/hw/xwin/win.h @@ -622,7 +622,7 @@ typedef struct { * Extern declares for general global variables */ -extern winScreenInfo g_ScreenInfo[]; +extern winScreenInfo * g_ScreenInfo; extern miPointerScreenFuncRec g_winPointerCursorFuncs; extern DWORD g_dwEvents; #ifdef HAS_DEVWINDOWS diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c index da7815560..d74011cc7 100644 --- a/hw/xwin/winglobals.c +++ b/hw/xwin/winglobals.c @@ -41,7 +41,7 @@ */ int g_iNumScreens = 0; -winScreenInfo g_ScreenInfo[MAXSCREENS]; +winScreenInfo * g_ScreenInfo = 0; #ifdef HAS_DEVWINDOWS int g_fdMessageQueue = WIN_FD_INVALID; #endif diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c index 540adf706..ad4b7e913 100755 --- a/hw/xwin/winprocarg.c +++ b/hw/xwin/winprocarg.c @@ -45,7 +45,7 @@ from The Open Group. */ extern int g_iNumScreens; -extern winScreenInfo g_ScreenInfo[]; +extern winScreenInfo * g_ScreenInfo; #ifdef XWIN_CLIPBOARD extern Bool g_fUnicodeClipboard; extern Bool g_fClipboard; @@ -227,6 +227,9 @@ winInitializeScreens(int maxscreens) if (maxscreens > g_iNumScreens) { + /* Reallocate the memory for DDX-specific screen info */ + g_ScreenInfo = realloc(g_ScreenInfo, maxscreens * sizeof (winScreenInfo)); + /* Set default values for any new screens */ for (i = g_iNumScreens; i < maxscreens ; i++) winInitializeScreen(i); @@ -353,7 +356,7 @@ ddxProcessArgument (int argc, char *argv[], int i) nScreenNum = atoi (argv[i + 1]); /* Validate the specified screen number */ - if (nScreenNum < 0 || nScreenNum >= MAXSCREENS) + if (nScreenNum < 0) { ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n", nScreenNum); diff --git a/hw/xwin/winvalargs.c b/hw/xwin/winvalargs.c index 038e097a5..6f8d1c994 100755 --- a/hw/xwin/winvalargs.c +++ b/hw/xwin/winvalargs.c @@ -40,17 +40,24 @@ */ extern int g_iNumScreens; -extern winScreenInfo g_ScreenInfo[]; +extern winScreenInfo * g_ScreenInfo; extern Bool g_fXdmcpEnabled; /* - * Prototypes + * Verify all screens have been explicitly specified */ +static BOOL +isEveryScreenExplicit(void) +{ + int i; -Bool -winValidateArgs (void); + for (i = 0; i < g_iNumScreens; i++) + if (!g_ScreenInfo[i].fExplicitScreen) + return FALSE; + return TRUE; +} /* * winValidateArgs - Look for invalid argument combinations @@ -62,6 +69,7 @@ winValidateArgs (void) int i; int iMaxConsecutiveScreen = 0; BOOL fHasNormalScreen0 = FALSE; + BOOL fImplicitScreenFound = FALSE; /* * Check for a malformed set of -screen parameters. @@ -70,23 +78,14 @@ winValidateArgs (void) * XWin -screen 0 -screen 2 * XWin -screen 1 -screen 2 */ - for (i = 0; i < MAXSCREENS; i++) - { - if (g_ScreenInfo[i].fExplicitScreen) - iMaxConsecutiveScreen = i + 1; - } - winErrorFVerb (2, "winValidateArgs - g_iNumScreens: %d " - "iMaxConsecutiveScreen: %d\n", - g_iNumScreens, iMaxConsecutiveScreen); - if (g_iNumScreens < iMaxConsecutiveScreen) + if (!isEveryScreenExplicit()) { ErrorF ("winValidateArgs - Malformed set of screen parameter(s). " "Screens must be specified consecutively starting with " "screen 0. That is, you cannot have only a screen 1, nor " "could you have screen 0 and screen 2. You instead must " - "have screen 0, or screen 0 and screen 1, respectively. Of " - "you can specify as many screens as you want from 0 up to " - "%d.\n", MAXSCREENS - 1); + "have screen 0, or screen 0 and screen 1, respectively. " + "You can specify as many screens as you want.\n"); return FALSE; } From 64fd39f2f0ffbbdc2d5929047d260263d0962141 Mon Sep 17 00:00:00 2001 From: Tiago Vignatti Date: Thu, 22 Apr 2010 15:48:48 +0300 Subject: [PATCH 08/10] xfree86: no need to assign numScreens again numScreens is always being assigned to 0 in dix for any server generation. Signed-off-by: Tiago Vignatti Reviewed-by: Peter Hutterer --- hw/xfree86/common/xf86Init.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c index 03a29ea0f..55d7a6209 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -552,9 +552,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) xf86Initialising = TRUE; if (serverGeneration == 1) { - - pScreenInfo->numScreens = 0; - if ((xf86ServerName = strrchr(argv[0], '/')) != 0) xf86ServerName++; else From 4f8dc1109dcdfa973466a038c16c07da5f6c16b4 Mon Sep 17 00:00:00 2001 From: Tiago Vignatti Date: Thu, 22 Apr 2010 15:43:11 +0300 Subject: [PATCH 09/10] dix and others: remove unused arraySize field from ScreenInfo Bizarre. This seems to never be used before. I left the field in ScreenInfo, with another name. So, stop looking at it. Signed-off-by: Tiago Vignatti Reviewed-by: Aaron Plattner --- dix/main.c | 1 - include/scrnintstr.h | 2 +- test/xi2/protocol-common.c | 1 - test/xtest.c | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/dix/main.c b/dix/main.c index f0235364f..e5667a611 100644 --- a/dix/main.c +++ b/dix/main.c @@ -190,7 +190,6 @@ int main(int argc, char *argv[], char *envp[]) FatalError("couldn't init server resources"); SetInputCheck(&alwaysCheckForInput[0], &alwaysCheckForInput[1]); - screenInfo.arraySize = MAXSCREENS; screenInfo.numScreens = 0; InitAtoms(); diff --git a/include/scrnintstr.h b/include/scrnintstr.h index c42119d0d..5a7c57d83 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -615,7 +615,7 @@ typedef struct _ScreenInfo { int numPixmapFormats; PixmapFormatRec formats[MAXFORMATS]; - int arraySize; + int unused2; int numScreens; ScreenPtr screens[MAXSCREENS]; int unused; diff --git a/test/xi2/protocol-common.c b/test/xi2/protocol-common.c index 2dff1ad6a..0afa55a40 100644 --- a/test/xi2/protocol-common.c +++ b/test/xi2/protocol-common.c @@ -141,7 +141,6 @@ static Bool device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) { return TRUE static Bool set_cursor_pos(DeviceIntPtr dev, ScreenPtr screen, int x, int y, Bool event) { return TRUE; } void init_simple(void) { - screenInfo.arraySize = MAXSCREENS; screenInfo.numScreens = 1; screenInfo.screens[0] = &screen; diff --git a/test/xtest.c b/test/xtest.c index 572f5d2df..cc1188d7d 100644 --- a/test/xtest.c +++ b/test/xtest.c @@ -49,7 +49,6 @@ static void xtest_init_devices(void) /* random stuff that needs initialization */ memset(&screen, 0, sizeof(screen)); - screenInfo.arraySize = MAXSCREENS; screenInfo.numScreens = 1; screenInfo.screens[0] = &screen; screen.myNum = 0; From edbc56c088462844f6445f5e6d7cbcfc58a207dc Mon Sep 17 00:00:00 2001 From: Tiago Vignatti Date: Mon, 26 Apr 2010 14:49:25 +0300 Subject: [PATCH 10/10] include: remove couple of unused structures fields and bump ABI Signed-off-by: Tiago Vignatti --- hw/xfree86/common/xf86Module.h | 6 +++--- include/dixstruct.h | 4 ---- include/scrnintstr.h | 2 -- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h index bbf5786c9..d61758f78 100644 --- a/hw/xfree86/common/xf86Module.h +++ b/hw/xfree86/common/xf86Module.h @@ -82,9 +82,9 @@ typedef enum { * mask is 0xFFFF0000. */ #define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4) -#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(7, 0) -#define ABI_XINPUT_VERSION SET_ABI_VERSION(9, 0) -#define ABI_EXTENSION_VERSION SET_ABI_VERSION(3, 0) +#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(8, 0) +#define ABI_XINPUT_VERSION SET_ABI_VERSION(10, 0) +#define ABI_EXTENSION_VERSION SET_ABI_VERSION(4, 0) #define ABI_FONT_VERSION SET_ABI_VERSION(0, 6) #define MODINFOSTRING1 0xef23fdc5 diff --git a/include/dixstruct.h b/include/dixstruct.h index 696b793ff..5b1a6981d 100644 --- a/include/dixstruct.h +++ b/include/dixstruct.h @@ -85,7 +85,6 @@ typedef struct _Window *SaveSetElt; #define SaveSetAssignMap(ss,m) #endif -/* The unused_ members are ABI spacing. Please reuse them. */ typedef struct _Client { int index; Mask clientAsMask; @@ -101,7 +100,6 @@ typedef struct _Client { * killed */ SaveSetElt *saveSet; int numSaved; - void *unused_screenPrivate[16]; int (**requestVector) ( ClientPtr /* pClient */); CARD32 req_len; /* length of current request */ @@ -116,8 +114,6 @@ typedef struct _Client { KeyCode minKC,maxKC; unsigned long replyBytesRemaining; - void *unused_appgroup; - void *unused_fontResFunc; int smart_priority; long smart_start_tick; long smart_stop_tick; diff --git a/include/scrnintstr.h b/include/scrnintstr.h index 5a7c57d83..553893677 100644 --- a/include/scrnintstr.h +++ b/include/scrnintstr.h @@ -615,10 +615,8 @@ typedef struct _ScreenInfo { int numPixmapFormats; PixmapFormatRec formats[MAXFORMATS]; - int unused2; int numScreens; ScreenPtr screens[MAXSCREENS]; - int unused; } ScreenInfo; extern _X_EXPORT ScreenInfo screenInfo;