Move each screen's root-window pointer into ScreenRec.

Many references to the WindowTable array already had the corresponding
screen pointer handy, which meant they usually looked like
"WindowTable[pScreen->myNum]". Adding a field to ScreenRec instead of
keeping this information in a parallel array simplifies those
expressions, and eliminates a MAXSCREENS-sized array.

Since dix uses this data, a screen private entry isn't appropriate.

xf86-video-dummy currently uses WindowTable, so it needs to be updated
to reflect this change.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com> (i686 GNU/Linux)
This commit is contained in:
Jamey Sharp 2010-05-22 00:26:28 -07:00
commit e7fae9ecc4
52 changed files with 130 additions and 128 deletions

View file

@ -360,9 +360,9 @@ EnableDevice(DeviceIntPtr dev, BOOL sendevent)
/* Sprites appear on first root window, so we can hardcode it */
if (dev->spriteInfo->spriteOwner)
{
InitializeSprite(dev, WindowTable[0]);
InitializeSprite(dev, screenInfo.screens[0]->root);
/* mode doesn't matter */
EnterWindow(dev, WindowTable[0], NotifyAncestor);
EnterWindow(dev, screenInfo.screens[0]->root, NotifyAncestor);
}
else if ((other = NextFreePointerDevice()) == NULL)
{
@ -2435,7 +2435,7 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
if (dev->spriteInfo->sprite)
currentRoot = dev->spriteInfo->sprite->spriteTrace[0];
else /* new device auto-set to floating */
currentRoot = WindowTable[0];
currentRoot = screenInfo.screens[0]->root;
/* we need to init a fake sprite */
screen = currentRoot->drawable.pScreen;

View file

@ -562,7 +562,7 @@ CreateConnectionBlock(void)
VisualPtr pVisual;
pScreen = screenInfo.screens[i];
root.windowId = WindowTable[i]->drawable.id;
root.windowId = pScreen->root->drawable.id;
root.defaultColormap = pScreen->defColormap;
root.whitePixel = pScreen->whitePixel;
root.blackPixel = pScreen->blackPixel;
@ -912,7 +912,7 @@ GetGeometry(ClientPtr client, xGetGeometryReply *rep)
rep->type = X_Reply;
rep->length = 0;
rep->sequenceNumber = client->sequence;
rep->root = WindowTable[pDraw->pScreen->myNum]->drawable.id;
rep->root = pDraw->pScreen->root->drawable.id;
rep->depth = pDraw->depth;
rep->width = pDraw->width;
rep->height = pDraw->height;
@ -972,7 +972,7 @@ ProcQueryTree(ClientPtr client)
return rc;
memset(&reply, 0, sizeof(xQueryTreeReply));
reply.type = X_Reply;
reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id;
reply.root = pWin->drawable.pScreen->root->drawable.id;
reply.sequenceNumber = client->sequence;
if (pWin->parent)
reply.parent = pWin->parent->drawable.id;
@ -2055,7 +2055,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
}
else
{
pBoundingDraw = (DrawablePtr)WindowTable[pDraw->pScreen->myNum];
pBoundingDraw = (DrawablePtr)pDraw->pScreen->root;
}
xgi.visual = wVisual (pWin);
@ -3666,9 +3666,9 @@ SendConnSetup(ClientPtr client, char *reason)
{
unsigned int j;
xDepth *pDepth;
WindowPtr pRoot = screenInfo.screens[i]->root;
root->currentInputMask = WindowTable[i]->eventMask |
wOtherEventMasks (WindowTable[i]);
root->currentInputMask = pRoot->eventMask | wOtherEventMasks(pRoot);
pDepth = (xDepth *)(root + 1);
for (j = 0; j < root->nDepths; j++)
{
@ -3916,7 +3916,6 @@ AddScreen(
any of the strings pointed to by argv. They may be passed to
multiple screens.
*/
WindowTable[i] = NullWindow;
screenInfo.screens[i] = pScreen;
screenInfo.numScreens++;
if (!(*pfnInit)(i, pScreen, argc, argv))

View file

@ -1077,7 +1077,7 @@ CoreFocusPointerRootNoneSwitch(DeviceIntPtr dev,
for (i = 0; i < nscreens; i++)
{
root = WindowTable[i];
root = screenInfo.screens[i]->root;
if (!HasOtherPointer(root, GetPairedDevice(dev)) && !FirstFocusChild(root))
{
/* If pointer was on PointerRootWin and changes to NoneWin, and
@ -1138,7 +1138,7 @@ CoreFocusToPointerRootOrNone(DeviceIntPtr dev,
for (i = 0; i < nscreens; i++)
{
root = WindowTable[i];
root = screenInfo.screens[i]->root;
if (!HasFocus(root) && !FirstFocusChild(root))
{
CoreFocusEvent(dev, FocusIn, mode, B ? NotifyPointerRoot : NotifyDetailNone, root);
@ -1169,7 +1169,7 @@ CoreFocusFromPointerRootOrNone(DeviceIntPtr dev,
for (i = 0; i < nscreens; i++)
{
root = WindowTable[i];
root = screenInfo.screens[i]->root;
if (!HasFocus(root) && !FirstFocusChild(root))
{
/* If pointer was on PointerRootWin and changes to NoneWin, and
@ -1279,7 +1279,7 @@ DeviceFocusEvents(DeviceIntPtr dev,
NotifyPointer);
/* Notify all the roots */
for (i = 0; i < nscreens; i++)
DeviceFocusEvent(dev, XI_FocusOut, mode, out, WindowTable[i]);
DeviceFocusEvent(dev, XI_FocusOut, mode, out, screenInfo.screens[i]->root);
}
else
{
@ -1293,7 +1293,7 @@ DeviceFocusEvents(DeviceIntPtr dev,
}
/* Notify all the roots */
for (i = 0; i < nscreens; i++)
DeviceFocusEvent(dev, XI_FocusIn, mode, in, WindowTable[i]);
DeviceFocusEvent(dev, XI_FocusIn, mode, in, screenInfo.screens[i]->root);
if (to == PointerRootWin)
DeviceFocusInEvents(dev, RootWindow(dev), sprite->win, mode, NotifyPointer);
}
@ -1305,7 +1305,7 @@ DeviceFocusEvents(DeviceIntPtr dev,
DeviceFocusOutEvents(dev, sprite->win, RootWindow(dev), mode,
NotifyPointer);
for (i = 0; i < nscreens; i++)
DeviceFocusEvent(dev, XI_FocusOut, mode, out, WindowTable[i]);
DeviceFocusEvent(dev, XI_FocusOut, mode, out, screenInfo.screens[i]->root);
if (to->parent != NullWindow)
DeviceFocusInEvents(dev, RootWindow(dev), to, mode, NotifyNonlinearVirtual);
DeviceFocusEvent(dev, XI_FocusIn, mode, NotifyNonlinear, to);

View file

@ -556,9 +556,10 @@ XineramaSetWindowPntrs(DeviceIntPtr pDev, WindowPtr pWin)
{
SpritePtr pSprite = pDev->spriteInfo->sprite;
if(pWin == WindowTable[0]) {
memcpy(pSprite->windows, WindowTable,
PanoramiXNumScreens*sizeof(WindowPtr));
if(pWin == screenInfo.screens[0]->root) {
int i;
for (i = 0; i < PanoramiXNumScreens; i++)
pSprite->windows[i] = screenInfo.screens[i]->root;
} else {
PanoramiXRes *win;
int rc, i;
@ -619,7 +620,7 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
pSprite->hotShape = NullRegion;
pSprite->confined = FALSE;
pSprite->confineWin = (pWin == WindowTable[0]) ? NullWindow : pWin;
pSprite->confineWin = (pWin == screenInfo.screens[0]->root) ? NullWindow : pWin;
CheckPhysLimits(pDev, pSprite->current, generateEvents, FALSE, NULL);
}
@ -875,7 +876,7 @@ CheckVirtualMotion(
#ifdef PANORAMIX
if (noPanoramiXExtension) /* No typo. Only set the root win if disabled */
#endif
RootWindow(pDev) = WindowTable[pSprite->hot.pScreen->myNum];
RootWindow(pDev) = pSprite->hot.pScreen->root;
}
static void
@ -1123,7 +1124,7 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
* updated yet.
*/
if (ev->any.type == ET_Motion)
ev->device_event.root = WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id;
ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id;
eventinfo.event = ev;
eventinfo.device = device;
@ -1339,7 +1340,7 @@ playmore:
}
else
ConfineCursorToWindow(dev,
WindowTable[dev->spriteInfo->sprite->hotPhys.pScreen->myNum],
dev->spriteInfo->sprite->hotPhys.pScreen->root,
TRUE, FALSE);
PostNewCursor(dev);
}
@ -1369,7 +1370,7 @@ ScreenRestructured (ScreenPtr pScreen)
}
else
ConfineCursorToWindow(pDev,
WindowTable[pDev->spriteInfo->sprite->hotPhys.pScreen->myNum],
pDev->spriteInfo->sprite->hotPhys.pScreen->root,
TRUE, FALSE);
}
}
@ -2766,7 +2767,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
if (pSprite->hot.pScreen != pSprite->hotPhys.pScreen)
{
pSprite->hot.pScreen = pSprite->hotPhys.pScreen;
RootWindow(pDev) = WindowTable[pSprite->hot.pScreen->myNum];
RootWindow(pDev) = pSprite->hot.pScreen->root;
}
}
@ -2849,7 +2850,7 @@ WindowsRestructured(void)
#ifdef PANORAMIX
/* This was added to support reconfiguration under Xdmx. The problem is
* that if the 0th screen (i.e., WindowTable[0]) is moved to an origin
* that if the 0th screen (i.e., screenInfo.screens[0]) is moved to an origin
* other than 0,0, the information in the private sprite structure must
* be updated accordingly, or XYToWindow (and other routines) will not
* compute correctly. */
@ -2892,7 +2893,7 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
} else
ConfineCursorToWindow(
pDev,
WindowTable[pSprite->hotPhys.pScreen->myNum],
pSprite->hotPhys.pScreen->root,
TRUE, FALSE);
}
@ -3051,7 +3052,7 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen)
pSprite = pDev->spriteInfo->sprite;
win = WindowTable[pScreen->myNum];
win = pScreen->root;
pSprite->hotPhys.pScreen = pScreen;
pSprite->hot = pSprite->hotPhys;
@ -3124,7 +3125,7 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
XineramaConfineCursorToWindow(pDev,
pSprite->confineWin, TRUE);
else
XineramaConfineCursorToWindow(pDev, WindowTable[0], TRUE);
XineramaConfineCursorToWindow(pDev, screenInfo.screens[0]->root, TRUE);
/* if the pointer wasn't confined, the DDX won't get
told of the pointer warp so we reposition it here */
if(!syncEvents.playingEvents)
@ -3139,8 +3140,7 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
} else
#endif
if (newScreen != pSprite->hotPhys.pScreen)
ConfineCursorToWindow(pDev, WindowTable[newScreen->myNum],
TRUE, FALSE);
ConfineCursorToWindow(pDev, newScreen->root, TRUE, FALSE);
}
#ifdef PANORAMIX
@ -3215,7 +3215,7 @@ XineramaWarpPointer(ClientPtr client)
winX = source->drawable.x;
winY = source->drawable.y;
if(source == WindowTable[0]) {
if(source == screenInfo.screens[0]->root) {
winX -= panoramiXdataPtr[0].x;
winY -= panoramiXdataPtr[0].y;
}
@ -3231,7 +3231,7 @@ XineramaWarpPointer(ClientPtr client)
if (dest) {
x = dest->drawable.x;
y = dest->drawable.y;
if(dest == WindowTable[0]) {
if(dest == screenInfo.screens[0]->root) {
x -= panoramiXdataPtr[0].x;
y -= panoramiXdataPtr[0].y;
}

View file

@ -83,8 +83,6 @@ ClientPtr serverClient;
int currentMaxClients; /* current size of clients array */
long maxBigRequestSize = MAX_BIG_REQUEST_SIZE;
WindowPtr WindowTable[MAXSCREENS];
unsigned long globalSerialNumber = 0;
unsigned long serverGeneration = 0;

View file

@ -249,7 +249,7 @@ int main(int argc, char *argv[], char *envp[])
#endif
for (i = 0; i < screenInfo.numScreens; i++)
InitRootWindow(WindowTable[i]);
InitRootWindow(screenInfo.screens[i]->root);
InitCoreDevices();
InitInput(argc, argv);
@ -303,7 +303,8 @@ int main(int argc, char *argv[], char *envp[])
CloseInput();
memset(WindowTable, 0, sizeof(WindowTable));
for (i = 0; i < screenInfo.numScreens; i++)
screenInfo.screens[i]->root = NullWindow;
CloseDownDevices();
CloseDownEvents();

View file

@ -210,7 +210,7 @@ PrintWindowTree(void)
for (i=0; i<screenInfo.numScreens; i++)
{
ErrorF("[dix] WINDOW %d\n", i);
pWin = WindowTable[i];
pWin = screenInfo.screens[i]->root;
miPrintRegion(&pWin->clipList);
p1 = pWin->firstChild;
PrintChildren(p1, 4);
@ -256,7 +256,7 @@ TraverseTree(WindowPtr pWin, VisitWindowProcPtr func, pointer data)
int
WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, pointer data)
{
return(TraverseTree(WindowTable[pScreen->myNum], func, data));
return(TraverseTree(pScreen->root, func, data));
}
/* hack for forcing backing store on all windows */
@ -366,7 +366,7 @@ CreateRootWindow(ScreenPtr pScreen)
pScreen->screensaver.ExternalScreenSaver = NULL;
screenIsSaved = SCREEN_SAVER_OFF;
WindowTable[pScreen->myNum] = pWin;
pScreen->root = pWin;
pWin->drawable.pScreen = pScreen;
pWin->drawable.type = DRAWABLE_WINDOW;
@ -1327,7 +1327,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
*/
if ( cursorID == None)
{
if (pWin == WindowTable[pWin->drawable.pScreen->myNum])
if (pWin == pWin->drawable.pScreen->root)
pCursor = rootCursor;
else
pCursor = (CursorPtr) None;
@ -2964,7 +2964,7 @@ HandleSaveSet(ClientPtr client)
pWin = SaveSetWindow(client->saveSet[j]);
#ifdef XFIXES
if (SaveSetToRoot(client->saveSet[j]))
pParent = WindowTable[pWin->drawable.pScreen->myNum];
pParent = pWin->drawable.pScreen->root;
else
#endif
{
@ -3250,7 +3250,6 @@ SaveScreens(int on, int mode)
static Bool
TileScreenSaver(ScreenPtr pScreen, int kind)
{
int i = pScreen->myNum;
int j;
int result;
XID attributes[3];
@ -3266,9 +3265,9 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
attri = 0;
switch (kind) {
case SCREEN_IS_TILED:
switch (WindowTable[i]->backgroundState) {
switch (pScreen->root->backgroundState) {
case BackgroundPixel:
attributes[attri++] = WindowTable[i]->background.pixel;
attributes[attri++] = pScreen->root->background.pixel;
mask |= CWBackPixel;
break;
case BackgroundPixmap:
@ -3280,7 +3279,7 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
}
break;
case SCREEN_IS_BLACK:
attributes[attri++] = WindowTable[i]->drawable.pScreen->blackPixel;
attributes[attri++] = pScreen->root->drawable.pScreen->blackPixel;
mask |= CWBackPixel;
break;
}
@ -3329,12 +3328,12 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
pWin = pScreen->screensaver.pWindow =
CreateWindow(pScreen->screensaver.wid,
WindowTable[i],
pScreen->root,
-RANDOM_WIDTH, -RANDOM_WIDTH,
(unsigned short)pScreen->width + RANDOM_WIDTH,
(unsigned short)pScreen->height + RANDOM_WIDTH,
0, InputOutput, mask, attributes, 0, serverClient,
wVisual (WindowTable[i]), &result);
wVisual (pScreen->root), &result);
if (cursor)
FreeResource (cursorID, RT_NONE);