summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2010-05-22 00:26:28 -0700
committerJamey Sharp <jamey@minilop.net>2010-06-03 14:03:23 -0700
commite7fae9ecc42ab5e73b89117722dbf4117d928f9a (patch)
treeb7897e7a64fe01e3989ec1e7a5a7db69797126e6
parent80b5d3a3264d2c5167e5ac85a3b04af0f89cece1 (diff)
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)
-rw-r--r--Xext/panoramiX.c2
-rw-r--r--Xext/panoramiXprocs.c14
-rw-r--r--Xext/saver.c6
-rw-r--r--Xi/closedev.c2
-rw-r--r--Xi/exevents.c6
-rw-r--r--Xi/xichangecursor.c2
-rw-r--r--composite/compinit.c2
-rw-r--r--composite/compoverlay.c2
-rw-r--r--dix/devices.c6
-rw-r--r--dix/dispatch.c13
-rw-r--r--dix/enterleave.c12
-rw-r--r--dix/events.c34
-rw-r--r--dix/globals.c2
-rw-r--r--dix/main.c5
-rw-r--r--dix/window.c21
-rw-r--r--fb/fb.h2
-rw-r--r--hw/dmx/dmxextension.c16
-rw-r--r--hw/dmx/input/dmxconsole.c2
-rw-r--r--hw/dmx/input/dmxinputinit.c2
-rw-r--r--hw/kdrive/src/kdrive.c2
-rw-r--r--hw/xfree86/common/xf86Helper.c2
-rw-r--r--hw/xfree86/common/xf86RandR.c2
-rw-r--r--hw/xfree86/common/xf86xv.c2
-rw-r--r--hw/xfree86/dixmods/extmod/xf86vmode.c2
-rw-r--r--hw/xfree86/dri/dri.c2
-rw-r--r--hw/xfree86/dri2/dri2.c2
-rw-r--r--hw/xfree86/modes/xf86RandR12.c6
-rw-r--r--hw/xfree86/modes/xf86Rotate.c4
-rw-r--r--hw/xfree86/xaa/xaaCpyWin.c2
-rw-r--r--hw/xfree86/xaa/xaaOverlay.c2
-rw-r--r--hw/xfree86/xaa/xaaOverlayDF.c2
-rw-r--r--hw/xquartz/darwin.c2
-rw-r--r--hw/xquartz/quartz.c2
-rw-r--r--hw/xquartz/xpr/xprFrame.c2
-rw-r--r--hw/xquartz/xpr/xprScreen.c4
-rw-r--r--hw/xwin/winkeybd.c2
-rwxr-xr-xhw/xwin/winwin32rootlesswindow.c2
-rw-r--r--hw/xwin/winwindow.c2
-rw-r--r--include/globals.h1
-rw-r--r--include/scrnintstr.h1
-rw-r--r--mi/midispcur.c8
-rw-r--r--mi/miexpose.c2
-rw-r--r--mi/mioverlay.c4
-rw-r--r--miext/rootless/rootlessCommon.c4
-rw-r--r--miext/rootless/rootlessCommon.h2
-rw-r--r--miext/rootless/rootlessScreen.c2
-rw-r--r--miext/rootless/rootlessWindow.c18
-rw-r--r--randr/rrscreen.c10
-rw-r--r--randr/rrxinerama.c2
-rw-r--r--render/render.c2
-rw-r--r--xfixes/cursor.c2
-rw-r--r--xkb/xkbInit.c3
52 files changed, 130 insertions, 128 deletions
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 594da0e95..e1cef87a5 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -837,7 +837,7 @@ PanoramiXConsolidate(void)
837 837
838 for (i = 0; i < PanoramiXNumScreens; i++) { 838 for (i = 0; i < PanoramiXNumScreens; i++) {
839 ScreenPtr pScreen = screenInfo.screens[i]; 839 ScreenPtr pScreen = screenInfo.screens[i];
840 root->info[i].id = WindowTable[i]->drawable.id; 840 root->info[i].id = pScreen->root->drawable.id;
841 root->u.win.class = InputOutput; 841 root->u.win.class = InputOutput;
842 root->u.win.root = TRUE; 842 root->u.win.root = TRUE;
843 saver->info[i].id = pScreen->screensaver.wid; 843 saver->info[i].id = pScreen->screensaver.wid;
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 08ea3ec90..6b199cf7b 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -129,7 +129,7 @@ int PanoramiXCreateWindow(ClientPtr client)
129 orig_visual = stuff->visual; 129 orig_visual = stuff->visual;
130 orig_x = stuff->x; 130 orig_x = stuff->x;
131 orig_y = stuff->y; 131 orig_y = stuff->y;
132 parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id) || 132 parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) ||
133 (stuff->parent == screenInfo.screens[0]->screensaver.wid); 133 (stuff->parent == screenInfo.screens[0]->screensaver.wid);
134 FOR_NSCREENS_BACKWARD(j) { 134 FOR_NSCREENS_BACKWARD(j) {
135 stuff->wid = newWin->info[j].id; 135 stuff->wid = newWin->info[j].id;
@@ -328,7 +328,7 @@ int PanoramiXReparentWindow(ClientPtr client)
328 328
329 x = stuff->x; 329 x = stuff->x;
330 y = stuff->y; 330 y = stuff->y;
331 parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id) || 331 parentIsRoot = (stuff->parent == screenInfo.screens[0]->root->drawable.id) ||
332 (stuff->parent == screenInfo.screens[0]->screensaver.wid); 332 (stuff->parent == screenInfo.screens[0]->screensaver.wid);
333 FOR_NSCREENS_BACKWARD(j) { 333 FOR_NSCREENS_BACKWARD(j) {
334 stuff->window = win->info[j].id; 334 stuff->window = win->info[j].id;
@@ -475,7 +475,7 @@ int PanoramiXConfigureWindow(ClientPtr client)
475 } 475 }
476 } 476 }
477 477
478 if(pWin->parent && ((pWin->parent == WindowTable[0]) || 478 if(pWin->parent && ((pWin->parent == screenInfo.screens[0]->root) ||
479 (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid))) 479 (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid)))
480 { 480 {
481 if ((Mask)stuff->mask & CWX) { 481 if ((Mask)stuff->mask & CWX) {
@@ -544,7 +544,7 @@ int PanoramiXGetGeometry(ClientPtr client)
544 rep.type = X_Reply; 544 rep.type = X_Reply;
545 rep.length = 0; 545 rep.length = 0;
546 rep.sequenceNumber = client->sequence; 546 rep.sequenceNumber = client->sequence;
547 rep.root = WindowTable[0]->drawable.id; 547 rep.root = screenInfo.screens[0]->root->drawable.id;
548 rep.depth = pDraw->depth; 548 rep.depth = pDraw->depth;
549 rep.width = pDraw->width; 549 rep.width = pDraw->width;
550 rep.height = pDraw->height; 550 rep.height = pDraw->height;
@@ -562,7 +562,7 @@ int PanoramiXGetGeometry(ClientPtr client)
562 WindowPtr pWin = (WindowPtr)pDraw; 562 WindowPtr pWin = (WindowPtr)pDraw;
563 rep.x = pWin->origin.x - wBorderWidth (pWin); 563 rep.x = pWin->origin.x - wBorderWidth (pWin);
564 rep.y = pWin->origin.y - wBorderWidth (pWin); 564 rep.y = pWin->origin.y - wBorderWidth (pWin);
565 if((pWin->parent == WindowTable[0]) || 565 if((pWin->parent == screenInfo.screens[0]->root) ||
566 (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid)) 566 (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid))
567 { 567 {
568 rep.x += panoramiXdataPtr[0].x; 568 rep.x += panoramiXdataPtr[0].x;
@@ -596,7 +596,7 @@ int PanoramiXTranslateCoords(ClientPtr client)
596 rep.sameScreen = xTrue; 596 rep.sameScreen = xTrue;
597 rep.child = None; 597 rep.child = None;
598 598
599 if((pWin == WindowTable[0]) || 599 if((pWin == screenInfo.screens[0]->root) ||
600 (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid)) 600 (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
601 { 601 {
602 x = stuff->srcX - panoramiXdataPtr[0].x; 602 x = stuff->srcX - panoramiXdataPtr[0].x;
@@ -634,7 +634,7 @@ int PanoramiXTranslateCoords(ClientPtr client)
634 } 634 }
635 rep.dstX = x - pDst->drawable.x; 635 rep.dstX = x - pDst->drawable.x;
636 rep.dstY = y - pDst->drawable.y; 636 rep.dstY = y - pDst->drawable.y;
637 if((pDst == WindowTable[0]) || 637 if((pDst == screenInfo.screens[0]->root) ||
638 (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid)) 638 (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
639 { 639 {
640 rep.dstX += panoramiXdataPtr[0].x; 640 rep.dstX += panoramiXdataPtr[0].x;
diff --git a/Xext/saver.c b/Xext/saver.c
index da61fbe60..696c4aa22 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -503,7 +503,7 @@ SendScreenSaverNotify (ScreenPtr pScreen, int state, Bool forced)
503 ev.type = ScreenSaverNotify + ScreenSaverEventBase; 503 ev.type = ScreenSaverNotify + ScreenSaverEventBase;
504 ev.state = state; 504 ev.state = state;
505 ev.timestamp = currentTime.milliseconds; 505 ev.timestamp = currentTime.milliseconds;
506 ev.root = WindowTable[pScreen->myNum]->drawable.id; 506 ev.root = pScreen->root->drawable.id;
507 ev.window = pScreen->screensaver.wid; 507 ev.window = pScreen->screensaver.wid;
508 ev.kind = kind; 508 ev.kind = kind;
509 ev.forced = forced; 509 ev.forced = forced;
@@ -580,7 +580,7 @@ CreateSaverWindow (ScreenPtr pScreen)
580 if (GrabInProgress && GrabInProgress != pAttr->client->index) 580 if (GrabInProgress && GrabInProgress != pAttr->client->index)
581 return FALSE; 581 return FALSE;
582 582
583 pWin = CreateWindow (pSaver->wid, WindowTable[pScreen->myNum], 583 pWin = CreateWindow (pSaver->wid, pScreen->root,
584 pAttr->x, pAttr->y, pAttr->width, pAttr->height, 584 pAttr->x, pAttr->y, pAttr->width, pAttr->height,
585 pAttr->borderWidth, pAttr->class, 585 pAttr->borderWidth, pAttr->class,
586 pAttr->mask, (XID *)pAttr->values, 586 pAttr->mask, (XID *)pAttr->values,
@@ -866,7 +866,7 @@ ScreenSaverSetAttributes (ClientPtr client)
866 if (ret != Success) 866 if (ret != Success)
867 return ret; 867 return ret;
868 pScreen = pDraw->pScreen; 868 pScreen = pDraw->pScreen;
869 pParent = WindowTable[pScreen->myNum]; 869 pParent = pScreen->root;
870 870
871 ret = XaceHook(XACE_SCREENSAVER_ACCESS, client, pScreen, DixSetAttrAccess); 871 ret = XaceHook(XACE_SCREENSAVER_ACCESS, client, pScreen, DixSetAttrAccess);
872 if (ret != Success) 872 if (ret != Success)
diff --git a/Xi/closedev.c b/Xi/closedev.c
index 159ead55c..e319c737a 100644
--- a/Xi/closedev.c
+++ b/Xi/closedev.c
@@ -156,7 +156,7 @@ ProcXCloseDevice(ClientPtr client)
156 * Delete passive grabs from all windows for this device. */ 156 * Delete passive grabs from all windows for this device. */
157 157
158 for (i = 0; i < screenInfo.numScreens; i++) { 158 for (i = 0; i < screenInfo.numScreens; i++) {
159 pWin = WindowTable[i]; 159 pWin = screenInfo.screens[i]->root;
160 DeleteDeviceEvents(d, pWin, client); 160 DeleteDeviceEvents(d, pWin, client);
161 p1 = pWin->firstChild; 161 p1 = pWin->firstChild;
162 DeleteEventsFromChildren(d, p1, client); 162 DeleteEventsFromChildren(d, p1, client);
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 41b396c28..56d9bf7fd 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -926,7 +926,7 @@ ProcessRawEvent(RawDeviceEvent *ev, DeviceIntPtr device)
926 } 926 }
927 927
928 for (i = 0; i < screenInfo.numScreens; i++) 928 for (i = 0; i < screenInfo.numScreens; i++)
929 DeliverEventsToWindow(device, WindowTable[i], xi, 1, 929 DeliverEventsToWindow(device, screenInfo.screens[i]->root, xi, 1,
930 GetEventFilter(device, xi), NULL); 930 GetEventFilter(device, xi), NULL);
931 free(xi); 931 free(xi);
932 } 932 }
@@ -1042,7 +1042,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
1042 1042
1043 /* see comment in EnqueueEvents regarding the next three lines */ 1043 /* see comment in EnqueueEvents regarding the next three lines */
1044 if (ev->any.type == ET_Motion) 1044 if (ev->any.type == ET_Motion)
1045 ev->device_event.root = WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id; 1045 ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id;
1046 1046
1047 eventinfo.device = device; 1047 eventinfo.device = device;
1048 eventinfo.event = ev; 1048 eventinfo.event = ev;
@@ -2120,7 +2120,7 @@ SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count)
2120 WindowPtr pWin, p1; 2120 WindowPtr pWin, p1;
2121 2121
2122 for (i = 0; i < screenInfo.numScreens; i++) { 2122 for (i = 0; i < screenInfo.numScreens; i++) {
2123 pWin = WindowTable[i]; 2123 pWin = screenInfo.screens[i]->root;
2124 if (!pWin) 2124 if (!pWin)
2125 continue; 2125 continue;
2126 DeliverEventsToWindow(dev, pWin, ev, count, mask, NullGrab); 2126 DeliverEventsToWindow(dev, pWin, ev, count, mask, NullGrab);
diff --git a/Xi/xichangecursor.c b/Xi/xichangecursor.c
index e72cfac03..215339331 100644
--- a/Xi/xichangecursor.c
+++ b/Xi/xichangecursor.c
@@ -93,7 +93,7 @@ int ProcXIChangeCursor(ClientPtr client)
93 93
94 if (stuff->cursor == None) 94 if (stuff->cursor == None)
95 { 95 {
96 if (pWin == WindowTable[pWin->drawable.pScreen->myNum]) 96 if (pWin == pWin->drawable.pScreen->root)
97 pCursor = rootCursor; 97 pCursor = rootCursor;
98 else 98 else
99 pCursor = (CursorPtr)None; 99 pCursor = (CursorPtr)None;
diff --git a/composite/compinit.c b/composite/compinit.c
index a81cc740f..e4b68c822 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -141,7 +141,7 @@ compScreenUpdate (ScreenPtr pScreen)
141 compCheckTree (pScreen); 141 compCheckTree (pScreen);
142 if (cs->damaged) 142 if (cs->damaged)
143 { 143 {
144 compWindowUpdate (WindowTable[pScreen->myNum]); 144 compWindowUpdate (pScreen->root);
145 cs->damaged = FALSE; 145 cs->damaged = FALSE;
146 } 146 }
147} 147}
diff --git a/composite/compoverlay.c b/composite/compoverlay.c
index 2158cdb5a..67b566c7f 100644
--- a/composite/compoverlay.c
+++ b/composite/compoverlay.c
@@ -124,7 +124,7 @@ Bool
124compCreateOverlayWindow (ScreenPtr pScreen) 124compCreateOverlayWindow (ScreenPtr pScreen)
125{ 125{
126 CompScreenPtr cs = GetCompScreen(pScreen); 126 CompScreenPtr cs = GetCompScreen(pScreen);
127 WindowPtr pRoot = WindowTable[pScreen->myNum]; 127 WindowPtr pRoot = pScreen->root;
128 WindowPtr pWin; 128 WindowPtr pWin;
129 XID attrs[] = { None, TRUE }; /* backPixmap, overrideRedirect */ 129 XID attrs[] = { None, TRUE }; /* backPixmap, overrideRedirect */
130 int result; 130 int result;
diff --git a/dix/devices.c b/dix/devices.c
index 250a4980d..998d22a4b 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -360,9 +360,9 @@ EnableDevice(DeviceIntPtr dev, BOOL sendevent)
360 /* Sprites appear on first root window, so we can hardcode it */ 360 /* Sprites appear on first root window, so we can hardcode it */
361 if (dev->spriteInfo->spriteOwner) 361 if (dev->spriteInfo->spriteOwner)
362 { 362 {
363 InitializeSprite(dev, WindowTable[0]); 363 InitializeSprite(dev, screenInfo.screens[0]->root);
364 /* mode doesn't matter */ 364 /* mode doesn't matter */
365 EnterWindow(dev, WindowTable[0], NotifyAncestor); 365 EnterWindow(dev, screenInfo.screens[0]->root, NotifyAncestor);
366 } 366 }
367 else if ((other = NextFreePointerDevice()) == NULL) 367 else if ((other = NextFreePointerDevice()) == NULL)
368 { 368 {
@@ -2435,7 +2435,7 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
2435 if (dev->spriteInfo->sprite) 2435 if (dev->spriteInfo->sprite)
2436 currentRoot = dev->spriteInfo->sprite->spriteTrace[0]; 2436 currentRoot = dev->spriteInfo->sprite->spriteTrace[0];
2437 else /* new device auto-set to floating */ 2437 else /* new device auto-set to floating */
2438 currentRoot = WindowTable[0]; 2438 currentRoot = screenInfo.screens[0]->root;
2439 2439
2440 /* we need to init a fake sprite */ 2440 /* we need to init a fake sprite */
2441 screen = currentRoot->drawable.pScreen; 2441 screen = currentRoot->drawable.pScreen;
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 27cb22022..c0efce5bf 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -562,7 +562,7 @@ CreateConnectionBlock(void)
562 VisualPtr pVisual; 562 VisualPtr pVisual;
563 563
564 pScreen = screenInfo.screens[i]; 564 pScreen = screenInfo.screens[i];
565 root.windowId = WindowTable[i]->drawable.id; 565 root.windowId = pScreen->root->drawable.id;
566 root.defaultColormap = pScreen->defColormap; 566 root.defaultColormap = pScreen->defColormap;
567 root.whitePixel = pScreen->whitePixel; 567 root.whitePixel = pScreen->whitePixel;
568 root.blackPixel = pScreen->blackPixel; 568 root.blackPixel = pScreen->blackPixel;
@@ -912,7 +912,7 @@ GetGeometry(ClientPtr client, xGetGeometryReply *rep)
912 rep->type = X_Reply; 912 rep->type = X_Reply;
913 rep->length = 0; 913 rep->length = 0;
914 rep->sequenceNumber = client->sequence; 914 rep->sequenceNumber = client->sequence;
915 rep->root = WindowTable[pDraw->pScreen->myNum]->drawable.id; 915 rep->root = pDraw->pScreen->root->drawable.id;
916 rep->depth = pDraw->depth; 916 rep->depth = pDraw->depth;
917 rep->width = pDraw->width; 917 rep->width = pDraw->width;
918 rep->height = pDraw->height; 918 rep->height = pDraw->height;
@@ -972,7 +972,7 @@ ProcQueryTree(ClientPtr client)
972 return rc; 972 return rc;
973 memset(&reply, 0, sizeof(xQueryTreeReply)); 973 memset(&reply, 0, sizeof(xQueryTreeReply));
974 reply.type = X_Reply; 974 reply.type = X_Reply;
975 reply.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; 975 reply.root = pWin->drawable.pScreen->root->drawable.id;
976 reply.sequenceNumber = client->sequence; 976 reply.sequenceNumber = client->sequence;
977 if (pWin->parent) 977 if (pWin->parent)
978 reply.parent = pWin->parent->drawable.id; 978 reply.parent = pWin->parent->drawable.id;
@@ -2055,7 +2055,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
2055 } 2055 }
2056 else 2056 else
2057 { 2057 {
2058 pBoundingDraw = (DrawablePtr)WindowTable[pDraw->pScreen->myNum]; 2058 pBoundingDraw = (DrawablePtr)pDraw->pScreen->root;
2059 } 2059 }
2060 2060
2061 xgi.visual = wVisual (pWin); 2061 xgi.visual = wVisual (pWin);
@@ -3666,9 +3666,9 @@ SendConnSetup(ClientPtr client, char *reason)
3666 { 3666 {
3667 unsigned int j; 3667 unsigned int j;
3668 xDepth *pDepth; 3668 xDepth *pDepth;
3669 WindowPtr pRoot = screenInfo.screens[i]->root;
3669 3670
3670 root->currentInputMask = WindowTable[i]->eventMask | 3671 root->currentInputMask = pRoot->eventMask | wOtherEventMasks(pRoot);
3671 wOtherEventMasks (WindowTable[i]);
3672 pDepth = (xDepth *)(root + 1); 3672 pDepth = (xDepth *)(root + 1);
3673 for (j = 0; j < root->nDepths; j++) 3673 for (j = 0; j < root->nDepths; j++)
3674 { 3674 {
@@ -3916,7 +3916,6 @@ AddScreen(
3916 any of the strings pointed to by argv. They may be passed to 3916 any of the strings pointed to by argv. They may be passed to
3917 multiple screens. 3917 multiple screens.
3918 */ 3918 */
3919 WindowTable[i] = NullWindow;
3920 screenInfo.screens[i] = pScreen; 3919 screenInfo.screens[i] = pScreen;
3921 screenInfo.numScreens++; 3920 screenInfo.numScreens++;
3922 if (!(*pfnInit)(i, pScreen, argc, argv)) 3921 if (!(*pfnInit)(i, pScreen, argc, argv))
diff --git a/dix/enterleave.c b/dix/enterleave.c
index c08cc3100..eefa7ab8e 100644
--- a/dix/enterleave.c
+++ b/dix/enterleave.c
@@ -1077,7 +1077,7 @@ CoreFocusPointerRootNoneSwitch(DeviceIntPtr dev,
1077 1077
1078 for (i = 0; i < nscreens; i++) 1078 for (i = 0; i < nscreens; i++)
1079 { 1079 {
1080 root = WindowTable[i]; 1080 root = screenInfo.screens[i]->root;
1081 if (!HasOtherPointer(root, GetPairedDevice(dev)) && !FirstFocusChild(root)) 1081 if (!HasOtherPointer(root, GetPairedDevice(dev)) && !FirstFocusChild(root))
1082 { 1082 {
1083 /* If pointer was on PointerRootWin and changes to NoneWin, and 1083 /* If pointer was on PointerRootWin and changes to NoneWin, and
@@ -1138,7 +1138,7 @@ CoreFocusToPointerRootOrNone(DeviceIntPtr dev,
1138 1138
1139 for (i = 0; i < nscreens; i++) 1139 for (i = 0; i < nscreens; i++)
1140 { 1140 {
1141 root = WindowTable[i]; 1141 root = screenInfo.screens[i]->root;
1142 if (!HasFocus(root) && !FirstFocusChild(root)) 1142 if (!HasFocus(root) && !FirstFocusChild(root))
1143 { 1143 {
1144 CoreFocusEvent(dev, FocusIn, mode, B ? NotifyPointerRoot : NotifyDetailNone, root); 1144 CoreFocusEvent(dev, FocusIn, mode, B ? NotifyPointerRoot : NotifyDetailNone, root);
@@ -1169,7 +1169,7 @@ CoreFocusFromPointerRootOrNone(DeviceIntPtr dev,
1169 1169
1170 for (i = 0; i < nscreens; i++) 1170 for (i = 0; i < nscreens; i++)
1171 { 1171 {
1172 root = WindowTable[i]; 1172 root = screenInfo.screens[i]->root;
1173 if (!HasFocus(root) && !FirstFocusChild(root)) 1173 if (!HasFocus(root) && !FirstFocusChild(root))
1174 { 1174 {
1175 /* If pointer was on PointerRootWin and changes to NoneWin, and 1175 /* If pointer was on PointerRootWin and changes to NoneWin, and
@@ -1279,7 +1279,7 @@ DeviceFocusEvents(DeviceIntPtr dev,
1279 NotifyPointer); 1279 NotifyPointer);
1280 /* Notify all the roots */ 1280 /* Notify all the roots */
1281 for (i = 0; i < nscreens; i++) 1281 for (i = 0; i < nscreens; i++)
1282 DeviceFocusEvent(dev, XI_FocusOut, mode, out, WindowTable[i]); 1282 DeviceFocusEvent(dev, XI_FocusOut, mode, out, screenInfo.screens[i]->root);
1283 } 1283 }
1284 else 1284 else
1285 { 1285 {
@@ -1293,7 +1293,7 @@ DeviceFocusEvents(DeviceIntPtr dev,
1293 } 1293 }
1294 /* Notify all the roots */ 1294 /* Notify all the roots */
1295 for (i = 0; i < nscreens; i++) 1295 for (i = 0; i < nscreens; i++)
1296 DeviceFocusEvent(dev, XI_FocusIn, mode, in, WindowTable[i]); 1296 DeviceFocusEvent(dev, XI_FocusIn, mode, in, screenInfo.screens[i]->root);
1297 if (to == PointerRootWin) 1297 if (to == PointerRootWin)
1298 DeviceFocusInEvents(dev, RootWindow(dev), sprite->win, mode, NotifyPointer); 1298 DeviceFocusInEvents(dev, RootWindow(dev), sprite->win, mode, NotifyPointer);
1299 } 1299 }
@@ -1305,7 +1305,7 @@ DeviceFocusEvents(DeviceIntPtr dev,
1305 DeviceFocusOutEvents(dev, sprite->win, RootWindow(dev), mode, 1305 DeviceFocusOutEvents(dev, sprite->win, RootWindow(dev), mode,
1306 NotifyPointer); 1306 NotifyPointer);
1307 for (i = 0; i < nscreens; i++) 1307 for (i = 0; i < nscreens; i++)
1308 DeviceFocusEvent(dev, XI_FocusOut, mode, out, WindowTable[i]); 1308 DeviceFocusEvent(dev, XI_FocusOut, mode, out, screenInfo.screens[i]->root);
1309 if (to->parent != NullWindow) 1309 if (to->parent != NullWindow)
1310 DeviceFocusInEvents(dev, RootWindow(dev), to, mode, NotifyNonlinearVirtual); 1310 DeviceFocusInEvents(dev, RootWindow(dev), to, mode, NotifyNonlinearVirtual);
1311 DeviceFocusEvent(dev, XI_FocusIn, mode, NotifyNonlinear, to); 1311 DeviceFocusEvent(dev, XI_FocusIn, mode, NotifyNonlinear, to);
diff --git a/dix/events.c b/dix/events.c
index 9e05dc96c..01865969b 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -556,9 +556,10 @@ XineramaSetWindowPntrs(DeviceIntPtr pDev, WindowPtr pWin)
556{ 556{
557 SpritePtr pSprite = pDev->spriteInfo->sprite; 557 SpritePtr pSprite = pDev->spriteInfo->sprite;
558 558
559 if(pWin == WindowTable[0]) { 559 if(pWin == screenInfo.screens[0]->root) {
560 memcpy(pSprite->windows, WindowTable, 560 int i;
561 PanoramiXNumScreens*sizeof(WindowPtr)); 561 for (i = 0; i < PanoramiXNumScreens; i++)
562 pSprite->windows[i] = screenInfo.screens[i]->root;
562 } else { 563 } else {
563 PanoramiXRes *win; 564 PanoramiXRes *win;
564 int rc, i; 565 int rc, i;
@@ -619,7 +620,7 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
619 pSprite->hotShape = NullRegion; 620 pSprite->hotShape = NullRegion;
620 621
621 pSprite->confined = FALSE; 622 pSprite->confined = FALSE;
622 pSprite->confineWin = (pWin == WindowTable[0]) ? NullWindow : pWin; 623 pSprite->confineWin = (pWin == screenInfo.screens[0]->root) ? NullWindow : pWin;
623 624
624 CheckPhysLimits(pDev, pSprite->current, generateEvents, FALSE, NULL); 625 CheckPhysLimits(pDev, pSprite->current, generateEvents, FALSE, NULL);
625} 626}
@@ -875,7 +876,7 @@ CheckVirtualMotion(
875#ifdef PANORAMIX 876#ifdef PANORAMIX
876 if (noPanoramiXExtension) /* No typo. Only set the root win if disabled */ 877 if (noPanoramiXExtension) /* No typo. Only set the root win if disabled */
877#endif 878#endif
878 RootWindow(pDev) = WindowTable[pSprite->hot.pScreen->myNum]; 879 RootWindow(pDev) = pSprite->hot.pScreen->root;
879} 880}
880 881
881static void 882static void
@@ -1123,7 +1124,7 @@ EnqueueEvent(InternalEvent *ev, DeviceIntPtr device)
1123 * updated yet. 1124 * updated yet.
1124 */ 1125 */
1125 if (ev->any.type == ET_Motion) 1126 if (ev->any.type == ET_Motion)
1126 ev->device_event.root = WindowTable[pSprite->hotPhys.pScreen->myNum]->drawable.id; 1127 ev->device_event.root = pSprite->hotPhys.pScreen->root->drawable.id;
1127 1128
1128 eventinfo.event = ev; 1129 eventinfo.event = ev;
1129 eventinfo.device = device; 1130 eventinfo.device = device;
@@ -1339,7 +1340,7 @@ playmore:
1339 } 1340 }
1340 else 1341 else
1341 ConfineCursorToWindow(dev, 1342 ConfineCursorToWindow(dev,
1342 WindowTable[dev->spriteInfo->sprite->hotPhys.pScreen->myNum], 1343 dev->spriteInfo->sprite->hotPhys.pScreen->root,
1343 TRUE, FALSE); 1344 TRUE, FALSE);
1344 PostNewCursor(dev); 1345 PostNewCursor(dev);
1345 } 1346 }
@@ -1369,7 +1370,7 @@ ScreenRestructured (ScreenPtr pScreen)
1369 } 1370 }
1370 else 1371 else
1371 ConfineCursorToWindow(pDev, 1372 ConfineCursorToWindow(pDev,
1372 WindowTable[pDev->spriteInfo->sprite->hotPhys.pScreen->myNum], 1373 pDev->spriteInfo->sprite->hotPhys.pScreen->root,
1373 TRUE, FALSE); 1374 TRUE, FALSE);
1374 } 1375 }
1375} 1376}
@@ -2766,7 +2767,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
2766 if (pSprite->hot.pScreen != pSprite->hotPhys.pScreen) 2767 if (pSprite->hot.pScreen != pSprite->hotPhys.pScreen)
2767 { 2768 {
2768 pSprite->hot.pScreen = pSprite->hotPhys.pScreen; 2769 pSprite->hot.pScreen = pSprite->hotPhys.pScreen;
2769 RootWindow(pDev) = WindowTable[pSprite->hot.pScreen->myNum]; 2770 RootWindow(pDev) = pSprite->hot.pScreen->root;
2770 } 2771 }
2771 } 2772 }
2772 2773
@@ -2849,7 +2850,7 @@ WindowsRestructured(void)
2849 2850
2850#ifdef PANORAMIX 2851#ifdef PANORAMIX
2851/* This was added to support reconfiguration under Xdmx. The problem is 2852/* This was added to support reconfiguration under Xdmx. The problem is
2852 * that if the 0th screen (i.e., WindowTable[0]) is moved to an origin 2853 * that if the 0th screen (i.e., screenInfo.screens[0]) is moved to an origin
2853 * other than 0,0, the information in the private sprite structure must 2854 * other than 0,0, the information in the private sprite structure must
2854 * be updated accordingly, or XYToWindow (and other routines) will not 2855 * be updated accordingly, or XYToWindow (and other routines) will not
2855 * compute correctly. */ 2856 * compute correctly. */
@@ -2892,7 +2893,7 @@ void ReinitializeRootWindow(WindowPtr win, int xoff, int yoff)
2892 } else 2893 } else
2893 ConfineCursorToWindow( 2894 ConfineCursorToWindow(
2894 pDev, 2895 pDev,
2895 WindowTable[pSprite->hotPhys.pScreen->myNum], 2896 pSprite->hotPhys.pScreen->root,
2896 TRUE, FALSE); 2897 TRUE, FALSE);
2897 2898
2898 } 2899 }
@@ -3051,7 +3052,7 @@ UpdateSpriteForScreen(DeviceIntPtr pDev, ScreenPtr pScreen)
3051 3052
3052 pSprite = pDev->spriteInfo->sprite; 3053 pSprite = pDev->spriteInfo->sprite;
3053 3054
3054 win = WindowTable[pScreen->myNum]; 3055 win = pScreen->root;
3055 3056
3056 pSprite->hotPhys.pScreen = pScreen; 3057 pSprite->hotPhys.pScreen = pScreen;
3057 pSprite->hot = pSprite->hotPhys; 3058 pSprite->hot = pSprite->hotPhys;
@@ -3124,7 +3125,7 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
3124 XineramaConfineCursorToWindow(pDev, 3125 XineramaConfineCursorToWindow(pDev,
3125 pSprite->confineWin, TRUE); 3126 pSprite->confineWin, TRUE);
3126 else 3127 else
3127 XineramaConfineCursorToWindow(pDev, WindowTable[0], TRUE); 3128 XineramaConfineCursorToWindow(pDev, screenInfo.screens[0]->root, TRUE);
3128 /* if the pointer wasn't confined, the DDX won't get 3129 /* if the pointer wasn't confined, the DDX won't get
3129 told of the pointer warp so we reposition it here */ 3130 told of the pointer warp so we reposition it here */
3130 if(!syncEvents.playingEvents) 3131 if(!syncEvents.playingEvents)
@@ -3139,8 +3140,7 @@ NewCurrentScreen(DeviceIntPtr pDev, ScreenPtr newScreen, int x, int y)
3139 } else 3140 } else
3140#endif 3141#endif
3141 if (newScreen != pSprite->hotPhys.pScreen) 3142 if (newScreen != pSprite->hotPhys.pScreen)
3142 ConfineCursorToWindow(pDev, WindowTable[newScreen->myNum], 3143 ConfineCursorToWindow(pDev, newScreen->root, TRUE, FALSE);
3143 TRUE, FALSE);
3144} 3144}
3145 3145
3146#ifdef PANORAMIX 3146#ifdef PANORAMIX
@@ -3215,7 +3215,7 @@ XineramaWarpPointer(ClientPtr client)
3215 3215
3216 winX = source->drawable.x; 3216 winX = source->drawable.x;
3217 winY = source->drawable.y; 3217 winY = source->drawable.y;
3218 if(source == WindowTable[0]) { 3218 if(source == screenInfo.screens[0]->root) {
3219 winX -= panoramiXdataPtr[0].x; 3219 winX -= panoramiXdataPtr[0].x;
3220 winY -= panoramiXdataPtr[0].y; 3220 winY -= panoramiXdataPtr[0].y;
3221 } 3221 }
@@ -3231,7 +3231,7 @@ XineramaWarpPointer(ClientPtr client)
3231 if (dest) { 3231 if (dest) {
3232 x = dest->drawable.x; 3232 x = dest->drawable.x;
3233 y = dest->drawable.y; 3233 y = dest->drawable.y;
3234 if(dest == WindowTable[0]) { 3234 if(dest == screenInfo.screens[0]->root) {
3235 x -= panoramiXdataPtr[0].x; 3235 x -= panoramiXdataPtr[0].x;
3236 y -= panoramiXdataPtr[0].y; 3236 y -= panoramiXdataPtr[0].y;
3237 } 3237 }
diff --git a/dix/globals.c b/dix/globals.c
index c24a94fbe..28e7d072d 100644
--- a/dix/globals.c
+++ b/dix/globals.c
@@ -83,8 +83,6 @@ ClientPtr serverClient;
83int currentMaxClients; /* current size of clients array */ 83int currentMaxClients; /* current size of clients array */
84long maxBigRequestSize = MAX_BIG_REQUEST_SIZE; 84long maxBigRequestSize = MAX_BIG_REQUEST_SIZE;
85 85
86WindowPtr WindowTable[MAXSCREENS];
87
88unsigned long globalSerialNumber = 0; 86unsigned long globalSerialNumber = 0;
89unsigned long serverGeneration = 0; 87unsigned long serverGeneration = 0;
90 88
diff --git a/dix/main.c b/dix/main.c
index 3e500ba4d..982fedd6b 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -249,7 +249,7 @@ int main(int argc, char *argv[], char *envp[])
249#endif 249#endif
250 250
251 for (i = 0; i < screenInfo.numScreens; i++) 251 for (i = 0; i < screenInfo.numScreens; i++)
252 InitRootWindow(WindowTable[i]); 252 InitRootWindow(screenInfo.screens[i]->root);
253 253
254 InitCoreDevices(); 254 InitCoreDevices();
255 InitInput(argc, argv); 255 InitInput(argc, argv);
@@ -303,7 +303,8 @@ int main(int argc, char *argv[], char *envp[])
303 303
304 CloseInput(); 304 CloseInput();
305 305
306 memset(WindowTable, 0, sizeof(WindowTable)); 306 for (i = 0; i < screenInfo.numScreens; i++)
307 screenInfo.screens[i]->root = NullWindow;
307 CloseDownDevices(); 308 CloseDownDevices();
308 CloseDownEvents(); 309 CloseDownEvents();
309 310
diff --git a/dix/window.c b/dix/window.c
index bdad749e8..71edd4681 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -210,7 +210,7 @@ PrintWindowTree(void)
210 for (i=0; i<screenInfo.numScreens; i++) 210 for (i=0; i<screenInfo.numScreens; i++)
211 { 211 {
212 ErrorF("[dix] WINDOW %d\n", i); 212 ErrorF("[dix] WINDOW %d\n", i);
213 pWin = WindowTable[i]; 213 pWin = screenInfo.screens[i]->root;
214 miPrintRegion(&pWin->clipList); 214 miPrintRegion(&pWin->clipList);
215 p1 = pWin->firstChild; 215 p1 = pWin->firstChild;
216 PrintChildren(p1, 4); 216 PrintChildren(p1, 4);
@@ -256,7 +256,7 @@ TraverseTree(WindowPtr pWin, VisitWindowProcPtr func, pointer data)
256int 256int
257WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, pointer data) 257WalkTree(ScreenPtr pScreen, VisitWindowProcPtr func, pointer data)
258{ 258{
259 return(TraverseTree(WindowTable[pScreen->myNum], func, data)); 259 return(TraverseTree(pScreen->root, func, data));
260} 260}
261 261
262/* hack for forcing backing store on all windows */ 262/* hack for forcing backing store on all windows */
@@ -366,7 +366,7 @@ CreateRootWindow(ScreenPtr pScreen)
366 pScreen->screensaver.ExternalScreenSaver = NULL; 366 pScreen->screensaver.ExternalScreenSaver = NULL;
367 screenIsSaved = SCREEN_SAVER_OFF; 367 screenIsSaved = SCREEN_SAVER_OFF;
368 368
369 WindowTable[pScreen->myNum] = pWin; 369 pScreen->root = pWin;
370 370
371 pWin->drawable.pScreen = pScreen; 371 pWin->drawable.pScreen = pScreen;
372 pWin->drawable.type = DRAWABLE_WINDOW; 372 pWin->drawable.type = DRAWABLE_WINDOW;
@@ -1327,7 +1327,7 @@ ChangeWindowAttributes(WindowPtr pWin, Mask vmask, XID *vlist, ClientPtr client)
1327 */ 1327 */
1328 if ( cursorID == None) 1328 if ( cursorID == None)
1329 { 1329 {
1330 if (pWin == WindowTable[pWin->drawable.pScreen->myNum]) 1330 if (pWin == pWin->drawable.pScreen->root)
1331 pCursor = rootCursor; 1331 pCursor = rootCursor;
1332 else 1332 else
1333 pCursor = (CursorPtr) None; 1333 pCursor = (CursorPtr) None;
@@ -2964,7 +2964,7 @@ HandleSaveSet(ClientPtr client)
2964 pWin = SaveSetWindow(client->saveSet[j]); 2964 pWin = SaveSetWindow(client->saveSet[j]);
2965#ifdef XFIXES 2965#ifdef XFIXES
2966 if (SaveSetToRoot(client->saveSet[j])) 2966 if (SaveSetToRoot(client->saveSet[j]))
2967 pParent = WindowTable[pWin->drawable.pScreen->myNum]; 2967 pParent = pWin->drawable.pScreen->root;
2968 else 2968 else
2969#endif 2969#endif
2970 { 2970 {
@@ -3250,7 +3250,6 @@ SaveScreens(int on, int mode)
3250static Bool 3250static Bool
3251TileScreenSaver(ScreenPtr pScreen, int kind) 3251TileScreenSaver(ScreenPtr pScreen, int kind)
3252{ 3252{
3253 int i = pScreen->myNum;
3254 int j; 3253 int j;
3255 int result; 3254 int result;
3256 XID attributes[3]; 3255 XID attributes[3];
@@ -3266,9 +3265,9 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
3266 attri = 0; 3265 attri = 0;
3267 switch (kind) { 3266 switch (kind) {
3268 case SCREEN_IS_TILED: 3267 case SCREEN_IS_TILED:
3269 switch (WindowTable[i]->backgroundState) { 3268 switch (pScreen->root->backgroundState) {
3270 case BackgroundPixel: 3269 case BackgroundPixel:
3271 attributes[attri++] = WindowTable[i]->background.pixel; 3270 attributes[attri++] = pScreen->root->background.pixel;
3272 mask |= CWBackPixel; 3271 mask |= CWBackPixel;
3273 break; 3272 break;
3274 case BackgroundPixmap: 3273 case BackgroundPixmap:
@@ -3280,7 +3279,7 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
3280 } 3279 }
3281 break; 3280 break;
3282 case SCREEN_IS_BLACK: 3281 case SCREEN_IS_BLACK:
3283 attributes[attri++] = WindowTable[i]->drawable.pScreen->blackPixel; 3282 attributes[attri++] = pScreen->root->drawable.pScreen->blackPixel;
3284 mask |= CWBackPixel; 3283 mask |= CWBackPixel;
3285 break; 3284 break;
3286 } 3285 }
@@ -3329,12 +3328,12 @@ TileScreenSaver(ScreenPtr pScreen, int kind)
3329 3328
3330 pWin = pScreen->screensaver.pWindow = 3329 pWin = pScreen->screensaver.pWindow =
3331 CreateWindow(pScreen->screensaver.wid, 3330 CreateWindow(pScreen->screensaver.wid,
3332 WindowTable[i], 3331 pScreen->root,
3333 -RANDOM_WIDTH, -RANDOM_WIDTH, 3332 -RANDOM_WIDTH, -RANDOM_WIDTH,
3334 (unsigned short)pScreen->width + RANDOM_WIDTH, 3333 (unsigned short)pScreen->width + RANDOM_WIDTH,
3335 (unsigned short)pScreen->height + RANDOM_WIDTH, 3334 (unsigned short)pScreen->height + RANDOM_WIDTH,
3336 0, InputOutput, mask, attributes, 0, serverClient, 3335 0, InputOutput, mask, attributes, 0, serverClient,
3337 wVisual (WindowTable[i]), &result); 3336 wVisual (pScreen->root), &result);
3338 3337
3339 if (cursor) 3338 if (cursor)
3340 FreeResource (cursorID, RT_NONE); 3339 FreeResource (cursorID, RT_NONE);
diff --git a/fb/fb.h b/fb/fb.h
index 91c91eeb2..e2222a5c7 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -740,7 +740,7 @@ typedef struct {
740 740
741#define fbWindowEnabled(pWin) \ 741#define fbWindowEnabled(pWin) \
742 REGION_NOTEMPTY((pWin)->drawable.pScreen, \ 742 REGION_NOTEMPTY((pWin)->drawable.pScreen, \
743 &WindowTable[(pWin)->drawable.pScreen->myNum]->borderClip) 743 &(pWin)->drawable.pScreen->root->borderClip)
744 744
745#define fbDrawableEnabled(pDrawable) \ 745#define fbDrawableEnabled(pDrawable) \
746 ((pDrawable)->type == DRAWABLE_PIXMAP ? \ 746 ((pDrawable)->type == DRAWABLE_PIXMAP ? \
diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c
index c8e8dae65..678f29054 100644
--- a/hw/dmx/dmxextension.c
+++ b/hw/dmx/dmxextension.c
@@ -297,7 +297,7 @@ void dmxFlushPendingSyncs(void)
297void dmxUpdateScreenResources(ScreenPtr pScreen, int x, int y, int w, int h) 297void dmxUpdateScreenResources(ScreenPtr pScreen, int x, int y, int w, int h)
298{ 298{
299 DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; 299 DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
300 WindowPtr pRoot = WindowTable[pScreen->myNum]; 300 WindowPtr pRoot = pScreen->root;
301 WindowPtr pChild; 301 WindowPtr pChild;
302 Bool anyMarked = FALSE; 302 Bool anyMarked = FALSE;
303 303
@@ -402,7 +402,7 @@ static void dmxConfigureScreenWindow(int idx,
402static void dmxConfigureRootWindow(int idx, int x, int y, int w, int h) 402static void dmxConfigureRootWindow(int idx, int x, int y, int w, int h)
403{ 403{
404 DMXScreenInfo *dmxScreen = &dmxScreens[idx]; 404 DMXScreenInfo *dmxScreen = &dmxScreens[idx];
405 WindowPtr pRoot = WindowTable[idx]; 405 WindowPtr pRoot = screenInfo.screens[idx]->root;
406 406
407 /* NOTE: Either this function or the ones that it calls must handle 407 /* NOTE: Either this function or the ones that it calls must handle
408 * the case where w == 0 || h == 0. Currently, the functions that 408 * the case where w == 0 || h == 0. Currently, the functions that
@@ -437,7 +437,7 @@ static void dmxSetRootWindowOrigin(int idx, int x, int y)
437{ 437{
438 DMXScreenInfo *dmxScreen = &dmxScreens[idx]; 438 DMXScreenInfo *dmxScreen = &dmxScreens[idx];
439 ScreenPtr pScreen = screenInfo.screens[idx]; 439 ScreenPtr pScreen = screenInfo.screens[idx];
440 WindowPtr pRoot = WindowTable[idx]; 440 WindowPtr pRoot = pScreen->root;
441 WindowPtr pChild; 441 WindowPtr pChild;
442 int xoff; 442 int xoff;
443 int yoff; 443 int yoff;
@@ -458,7 +458,7 @@ static void dmxSetRootWindowOrigin(int idx, int x, int y)
458 XineramaReinitData(pScreen); 458 XineramaReinitData(pScreen);
459 459
460 /* Adjust each of the root window's children */ 460 /* Adjust each of the root window's children */
461 if (!idx) ReinitializeRootWindow(WindowTable[0], xoff, yoff); 461 if (!idx) ReinitializeRootWindow(screenInfo.screens[0]->root, xoff, yoff);
462 pChild = pRoot->firstChild; 462 pChild = pRoot->firstChild;
463 while (pChild) { 463 while (pChild) {
464 /* Adjust child window's position */ 464 /* Adjust child window's position */
@@ -634,7 +634,7 @@ int dmxConfigureDesktop(DMXDesktopAttributesPtr attribs)
634 int i; 634 int i;
635 for (i = 0; i < dmxNumScreens; i++) { 635 for (i = 0; i < dmxNumScreens; i++) {
636 ScreenPtr pScreen = screenInfo.screens[i]; 636 ScreenPtr pScreen = screenInfo.screens[i];
637 WindowPtr pChild = WindowTable[i]->firstChild; 637 WindowPtr pChild = pScreen->root->firstChild;
638 while (pChild) { 638 while (pChild) {
639 /* Adjust child window's position */ 639 /* Adjust child window's position */
640 pScreen->MoveWindow(pChild, 640 pScreen->MoveWindow(pChild,
@@ -914,7 +914,7 @@ static void dmxBECreateResources(pointer value, XID id, RESTYPE type,
914static void dmxBECreateWindowTree(int idx) 914static void dmxBECreateWindowTree(int idx)
915{ 915{
916 DMXScreenInfo *dmxScreen = &dmxScreens[idx]; 916 DMXScreenInfo *dmxScreen = &dmxScreens[idx];
917 WindowPtr pRoot = WindowTable[idx]; 917 WindowPtr pRoot = screenInfo.screens[idx]->root;
918 dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot); 918 dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pRoot);
919 WindowPtr pWin; 919 WindowPtr pWin;
920 920
@@ -982,7 +982,7 @@ static void dmxBECreateWindowTree(int idx)
982static void dmxForceExposures(int idx) 982static void dmxForceExposures(int idx)
983{ 983{
984 ScreenPtr pScreen = screenInfo.screens[idx]; 984 ScreenPtr pScreen = screenInfo.screens[idx];
985 WindowPtr pRoot = WindowTable[idx]; 985 WindowPtr pRoot = pScreen->root;
986 Bool anyMarked = FALSE; 986 Bool anyMarked = FALSE;
987 WindowPtr pChild; 987 WindowPtr pChild;
988 988
@@ -1510,7 +1510,7 @@ static void dmxBEDestroyScratchGCs(int scrnNum)
1510 * destroy a window as well as all of it's children. */ 1510 * destroy a window as well as all of it's children. */
1511static void dmxBEDestroyWindowTree(int idx) 1511static void dmxBEDestroyWindowTree(int idx)
1512{ 1512{
1513 WindowPtr pWin = WindowTable[idx]; 1513 WindowPtr pWin = screenInfo.screens[idx]->root;
1514 WindowPtr pChild = pWin; 1514 WindowPtr pChild = pWin;
1515 1515
1516 while (1) { 1516 while (1) {
diff --git a/hw/dmx/input/dmxconsole.c b/hw/dmx/input/dmxconsole.c
index 9542efacd..bf34169ab 100644
--- a/hw/dmx/input/dmxconsole.c
+++ b/hw/dmx/input/dmxconsole.c
@@ -204,7 +204,7 @@ static void dmxConsoleDrawWindows(pointer private)
204 XUnionRectWithRegion(&rect, whole, whole); 204 XUnionRectWithRegion(&rect, whole, whole);
205 205
206 for (i = 0; i < dmxNumScreens; i++) { 206 for (i = 0; i < dmxNumScreens; i++) {
207 WindowPtr pRoot = WindowTable[i]; 207 WindowPtr pRoot = screenInfo.screens[i]->root;
208 WindowPtr pChild; 208 WindowPtr pChild;
209 209
210#if DMX_WINDOW_DEBUG 210#if DMX_WINDOW_DEBUG
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index 1242be1bd..814fc1a89 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -570,7 +570,7 @@ static void dmxUpdateWindowInformation(DMXInputInfo *dmxInput,
570 int i; 570 int i;
571 571
572#ifdef PANORAMIX 572#ifdef PANORAMIX
573 if (!noPanoramiXExtension && pWindow && pWindow->parent != WindowTable[0]) 573 if (!noPanoramiXExtension && pWindow && pWindow->parent != screenInfo.screens[0]->root)
574 return; 574 return;
575#endif 575#endif
576#if DMX_WINDOW_DEBUG 576#if DMX_WINDOW_DEBUG
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 9d1b38376..10df02dbc 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -95,7 +95,7 @@ KdOsFuncs *kdOsFuncs;
95void 95void
96KdSetRootClip (ScreenPtr pScreen, BOOL enable) 96KdSetRootClip (ScreenPtr pScreen, BOOL enable)
97{ 97{
98 WindowPtr pWin = WindowTable[pScreen->myNum]; 98 WindowPtr pWin = pScreen->root;
99 WindowPtr pChild; 99 WindowPtr pChild;
100 Bool WasViewable; 100 Bool WasViewable;
101 Bool anyMarked = FALSE; 101 Bool anyMarked = FALSE;
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index d4b935157..1aad2d100 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1062,7 +1062,7 @@ xf86SetBlackWhitePixels(ScreenPtr pScreen)
1062static void 1062static void
1063xf86SetRootClip (ScreenPtr pScreen, Bool enable) 1063xf86SetRootClip (ScreenPtr pScreen, Bool enable)
1064{ 1064{
1065 WindowPtr pWin = WindowTable[pScreen->myNum]; 1065 WindowPtr pWin = pScreen->root;
1066 WindowPtr pChild; 1066 WindowPtr pChild;
1067 Bool WasViewable = (Bool)(pWin->viewable); 1067 Bool WasViewable = (Bool)(pWin->viewable);
1068 Bool anyMarked = FALSE; 1068 Bool anyMarked = FALSE;
diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c
index 455a02cc2..77053b8c2 100644
--- a/hw/xfree86/common/xf86RandR.c
+++ b/hw/xfree86/common/xf86RandR.c
@@ -159,7 +159,7 @@ xf86RandRSetMode (ScreenPtr pScreen,
159 int oldmmHeight = pScreen->mmHeight; 159 int oldmmHeight = pScreen->mmHeight;
160 int oldVirtualX = scrp->virtualX; 160 int oldVirtualX = scrp->virtualX;
161 int oldVirtualY = scrp->virtualY; 161 int oldVirtualY = scrp->virtualY;
162 WindowPtr pRoot = WindowTable[pScreen->myNum]; 162 WindowPtr pRoot = pScreen->root;
163 Bool ret = TRUE; 163 Bool ret = TRUE;
164 164
165 if (pRoot && scrp->vtSema) 165 if (pRoot && scrp->vtSema)
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 2b33f2585..efed677af 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -1881,7 +1881,7 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes)
1881void 1881void
1882xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes) 1882xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
1883{ 1883{
1884 DrawablePtr root = &WindowTable[pScreen->myNum]->drawable; 1884 DrawablePtr root = &pScreen->root->drawable;
1885 ChangeGCVal pval[2]; 1885 ChangeGCVal pval[2];
1886 BoxPtr pbox = REGION_RECTS(clipboxes); 1886 BoxPtr pbox = REGION_RECTS(clipboxes);
1887 int i, nbox = REGION_NUM_RECTS(clipboxes); 1887 int i, nbox = REGION_NUM_RECTS(clipboxes);
diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index 754fe372c..448762879 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -347,7 +347,7 @@ SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced)
347 ev.type = XF86VidModeNotify + XF86VidModeEventBase; 347 ev.type = XF86VidModeNotify + XF86VidModeEventBase;
348 ev.state = state; 348 ev.state = state;
349 ev.timestamp = currentTime.milliseconds; 349 ev.timestamp = currentTime.milliseconds;
350 ev.root = WindowTable[pScreen->myNum]->drawable.id; 350 ev.root = pScreen->root->drawable.id;
351 ev.kind = kind; 351 ev.kind = kind;
352 ev.forced = forced; 352 ev.forced = forced;
353 WriteEventsToClient (pEv->client, 1, (xEvent *) &ev); 353 WriteEventsToClient (pEv->client, 1, (xEvent *) &ev);
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 77f7fe295..f7cea5ede 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -1187,7 +1187,7 @@ DRIDriverClipNotify(ScreenPtr pScreen)
1187 1187
1188 if (pDRIPriv->nrWindows > 0) { 1188 if (pDRIPriv->nrWindows > 0) {
1189 pDRIPriv->nrWalked = 0; 1189 pDRIPriv->nrWalked = 0;
1190 TraverseTree(WindowTable[pScreen->myNum], DRIDCNTreeTraversal, 1190 TraverseTree(pScreen->root, DRIDCNTreeTraversal,
1191 (pointer)pDRIWindows); 1191 (pointer)pDRIWindows);
1192 } 1192 }
1193 1193
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 556285383..9ec4caa54 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -607,7 +607,7 @@ DRI2CanFlip(DrawablePtr pDraw)
607 if (pDraw->type == DRAWABLE_PIXMAP) 607 if (pDraw->type == DRAWABLE_PIXMAP)
608 return TRUE; 608 return TRUE;
609 609
610 pRoot = WindowTable[pScreen->myNum]; 610 pRoot = pScreen->root;
611 pRootPixmap = pScreen->GetWindowPixmap(pRoot); 611 pRootPixmap = pScreen->GetWindowPixmap(pRoot);
612 612
613 pWin = (WindowPtr) pDraw; 613 pWin = (WindowPtr) pDraw;
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 9dfce3fed..8d598d6e7 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -517,7 +517,7 @@ xf86RandR12SetMode (ScreenPtr pScreen,
517 int oldHeight = pScreen->height; 517 int oldHeight = pScreen->height;
518 int oldmmWidth = pScreen->mmWidth; 518 int oldmmWidth = pScreen->mmWidth;
519 int oldmmHeight = pScreen->mmHeight; 519 int oldmmHeight = pScreen->mmHeight;
520 WindowPtr pRoot = WindowTable[pScreen->myNum]; 520 WindowPtr pRoot = pScreen->root;
521 DisplayModePtr currentMode = NULL; 521 DisplayModePtr currentMode = NULL;
522 Bool ret = TRUE; 522 Bool ret = TRUE;
523 PixmapPtr pspix = NULL; 523 PixmapPtr pspix = NULL;
@@ -685,7 +685,7 @@ xf86RandR12ScreenSetSize (ScreenPtr pScreen,
685 XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); 685 XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
686 ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen); 686 ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
687 xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); 687 xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
688 WindowPtr pRoot = WindowTable[pScreen->myNum]; 688 WindowPtr pRoot = pScreen->root;
689 PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen); 689 PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen);
690 Bool ret = FALSE; 690 Bool ret = FALSE;
691 int c; 691 int c;
@@ -739,7 +739,7 @@ finish:
739 if (pRoot && pScrn->vtSema) 739 if (pRoot && pScrn->vtSema)
740 (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE); 740 (*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
741#if RANDR_12_INTERFACE 741#if RANDR_12_INTERFACE
742 if (xf86RandR12Key && WindowTable[pScreen->myNum] && ret) 742 if (xf86RandR12Key && pScreen->root && ret)
743 RRScreenSizeNotify (pScreen); 743 RRScreenSizeNotify (pScreen);
744#endif 744#endif
745 return ret; 745 return ret;
diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c
index 2714fee51..e3683a8ed 100644
--- a/hw/xfree86/modes/xf86Rotate.c
+++ b/hw/xfree86/modes/xf86Rotate.c
@@ -76,9 +76,9 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
76{ 76{
77 ScrnInfoPtr scrn = crtc->scrn; 77 ScrnInfoPtr scrn = crtc->scrn;
78 ScreenPtr screen = scrn->pScreen; 78 ScreenPtr screen = scrn->pScreen;
79 WindowPtr root = WindowTable[screen->myNum]; 79 WindowPtr root = screen->root;
80 PixmapPtr dst_pixmap = crtc->rotatedPixmap; 80 PixmapPtr dst_pixmap = crtc->rotatedPixmap;
81 PictFormatPtr format = compWindowFormat (WindowTable[screen->myNum]); 81 PictFormatPtr format = compWindowFormat (screen->root);
82 int error; 82 int error;
83 PicturePtr src, dst; 83 PicturePtr src, dst;
84 int n = REGION_NUM_RECTS(region); 84 int n = REGION_NUM_RECTS(region);
diff --git a/hw/xfree86/xaa/xaaCpyWin.c b/hw/xfree86/xaa/xaaCpyWin.c
index d37c8ec1e..d58db8ea1 100644
--- a/hw/xfree86/xaa/xaaCpyWin.c
+++ b/hw/xfree86/xaa/xaaCpyWin.c
@@ -47,7 +47,7 @@ XAACopyWindow(
47 return; 47 return;
48 } 48 }
49 49
50 pwinRoot = WindowTable[pScreen->myNum]; 50 pwinRoot = pScreen->root;
51 51
52 REGION_NULL(pScreen, &rgnDst); 52 REGION_NULL(pScreen, &rgnDst);
53 53
diff --git a/hw/xfree86/xaa/xaaOverlay.c b/hw/xfree86/xaa/xaaOverlay.c
index 2af808396..14de9bd34 100644
--- a/hw/xfree86/xaa/xaaOverlay.c
+++ b/hw/xfree86/xaa/xaaOverlay.c
@@ -54,7 +54,7 @@ XAACopyWindow8_32(
54 return; 54 return;
55 } 55 }
56 56
57 pwinRoot = WindowTable[pScreen->myNum]; 57 pwinRoot = pScreen->root;
58 58
59 if(doUnderlay) 59 if(doUnderlay)
60 freeReg = miOverlayCollectUnderlayRegions(pWin, &borderClip); 60 freeReg = miOverlayCollectUnderlayRegions(pWin, &borderClip);
diff --git a/hw/xfree86/xaa/xaaOverlayDF.c b/hw/xfree86/xaa/xaaOverlayDF.c
index 3b848ac84..b186cb5cd 100644
--- a/hw/xfree86/xaa/xaaOverlayDF.c
+++ b/hw/xfree86/xaa/xaaOverlayDF.c
@@ -324,7 +324,7 @@ XAAOverCopyWindow(
324 RegionRec rgnDst; 324 RegionRec rgnDst;
325 BoxPtr pbox; 325 BoxPtr pbox;
326 int i, nbox, dx, dy; 326 int i, nbox, dx, dy;
327 WindowPtr pRoot = WindowTable[pScreen->myNum]; 327 WindowPtr pRoot = pScreen->root;
328 328
329 329
330 if (!pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) { 330 if (!pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) {
diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 580fe4ae0..825afa0de 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -793,7 +793,7 @@ void AbortDDX( void )
793void 793void
794xf86SetRootClip (ScreenPtr pScreen, int enable) 794xf86SetRootClip (ScreenPtr pScreen, int enable)
795{ 795{
796 WindowPtr pWin = WindowTable[pScreen->myNum]; 796 WindowPtr pWin = pScreen->root;
797 WindowPtr pChild; 797 WindowPtr pChild;
798 Bool WasViewable = (Bool)(pWin->viewable); 798 Bool WasViewable = (Bool)(pWin->viewable);
799 Bool anyMarked = TRUE; 799 Bool anyMarked = TRUE;
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 36d18eba3..ac7fedd13 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -276,7 +276,7 @@ void QuartzUpdateScreens(void) {
276 sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY; 276 sy = dixScreenOrigins[pScreen->myNum].y + darwinMainScreenY;
277 277
278 /* Adjust the root window. */ 278 /* Adjust the root window. */
279 pRoot = WindowTable[pScreen->myNum]; 279 pRoot = pScreen->root;
280 AppleWMSetScreenOrigin(pRoot); 280 AppleWMSetScreenOrigin(pRoot);
281 pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL); 281 pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
282 miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND); 282 miPaintWindow(pRoot, &pRoot->borderClip, PW_BACKGROUND);
diff --git a/hw/xquartz/xpr/xprFrame.c b/hw/xquartz/xpr/xprFrame.c
index 53dde7acc..6dc2c87fa 100644
--- a/hw/xquartz/xpr/xprFrame.c
+++ b/hw/xquartz/xpr/xprFrame.c
@@ -576,7 +576,7 @@ xprHideWindows(Bool hide)
576 576
577 for (screen = 0; screen < screenInfo.numScreens; screen++) { 577 for (screen = 0; screen < screenInfo.numScreens; screen++) {
578 RootlessFrameID prevWid = NULL; 578 RootlessFrameID prevWid = NULL;
579 pRoot = WindowTable[screenInfo.screens[screen]->myNum]; 579 pRoot = screenInfo.screens[screen]->root;
580 580
581 for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) { 581 for (pWin = pRoot->firstChild; pWin; pWin = pWin->nextSib) {
582 RootlessWindowRec *winRec = WINREC(pWin); 582 RootlessWindowRec *winRec = WINREC(pWin);
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index d574721b3..87e97d4e2 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -397,7 +397,7 @@ xprUpdateScreen(ScreenPtr pScreen)
397 rootlessGlobalOffsetX = darwinMainScreenX; 397 rootlessGlobalOffsetX = darwinMainScreenX;
398 rootlessGlobalOffsetY = darwinMainScreenY; 398 rootlessGlobalOffsetY = darwinMainScreenY;
399 399
400 AppleWMSetScreenOrigin(WindowTable[pScreen->myNum]); 400 AppleWMSetScreenOrigin(pScreen->root);
401 401
402 RootlessRepositionWindows(pScreen); 402 RootlessRepositionWindows(pScreen);
403 RootlessUpdateScreenPixmap(pScreen); 403 RootlessUpdateScreenPixmap(pScreen);
@@ -416,7 +416,7 @@ xprInitInput(int argc, char **argv)
416 rootlessGlobalOffsetY = darwinMainScreenY; 416 rootlessGlobalOffsetY = darwinMainScreenY;
417 417
418 for (i = 0; i < screenInfo.numScreens; i++) 418 for (i = 0; i < screenInfo.numScreens; i++)
419 AppleWMSetScreenOrigin(WindowTable[i]); 419 AppleWMSetScreenOrigin(screenInfo.screens[i]->root);
420} 420}
421 421
422/* 422/*
diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c
index ad9e66a0b..6d91ce0d6 100644
--- a/hw/xwin/winkeybd.c
+++ b/hw/xwin/winkeybd.c
@@ -262,7 +262,7 @@ winRestoreModeKeyStates (void)
262 262
263 /* Only process events if the rootwindow is mapped. The keyboard events 263 /* Only process events if the rootwindow is mapped. The keyboard events
264 * will cause segfaults otherwise */ 264 * will cause segfaults otherwise */
265 if (WindowTable && WindowTable[0] && WindowTable[0]->mapped == FALSE) 265 if (screenInfo.screens[0]->root && screenInfo.screens[0]->root->mapped == FALSE)
266 processEvents = FALSE; 266 processEvents = FALSE;
267 267
268 /* Force to process all pending events in the mi event queue */ 268 /* Force to process all pending events in the mi event queue */
diff --git a/hw/xwin/winwin32rootlesswindow.c b/hw/xwin/winwin32rootlesswindow.c
index 3a49ead69..214e8954b 100755
--- a/hw/xwin/winwin32rootlesswindow.c
+++ b/hw/xwin/winwin32rootlesswindow.c
@@ -407,7 +407,7 @@ void
407winMWExtWMRestackWindows (ScreenPtr pScreen) 407winMWExtWMRestackWindows (ScreenPtr pScreen)
408{ 408{
409 winScreenPriv(pScreen); 409 winScreenPriv(pScreen);
410 WindowPtr pRoot = WindowTable[pScreen->myNum]; 410 WindowPtr pRoot = pScreen->root;
411 WindowPtr pWin = NULL; 411 WindowPtr pWin = NULL;
412 WindowPtr pWinPrev = NULL; 412 WindowPtr pWinPrev = NULL;
413 win32RootlessWindowPtr pRLWin = NULL; 413 win32RootlessWindowPtr pRLWin = NULL;
diff --git a/hw/xwin/winwindow.c b/hw/xwin/winwindow.c
index d0c360f34..9348d5c1c 100644
--- a/hw/xwin/winwindow.c
+++ b/hw/xwin/winwindow.c
@@ -144,7 +144,7 @@ winCopyWindowNativeGDI (WindowPtr pWin,
144#endif 144#endif
145 145
146 /* Get a pointer to the root window */ 146 /* Get a pointer to the root window */
147 pwinRoot = WindowTable[pWin->drawable.pScreen->myNum]; 147 pwinRoot = pWin->drawable.pScreen->root;
148 148
149 /* Create a region for the destination */ 149 /* Create a region for the destination */
150 prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1); 150 prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
diff --git a/include/globals.h b/include/globals.h
index 6959fc71a..7de262fe3 100644
--- a/include/globals.h
+++ b/include/globals.h
@@ -19,7 +19,6 @@ extern _X_EXPORT char *defaultFontPath;
19extern _X_EXPORT int monitorResolution; 19extern _X_EXPORT int monitorResolution;
20extern _X_EXPORT int defaultColorVisualClass; 20extern _X_EXPORT int defaultColorVisualClass;
21 21
22extern _X_EXPORT WindowPtr WindowTable[MAXSCREENS];
23extern _X_EXPORT int GrabInProgress; 22extern _X_EXPORT int GrabInProgress;
24extern _X_EXPORT Bool noTestExtensions; 23extern _X_EXPORT Bool noTestExtensions;
25 24
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 1460bc4c6..f8171ca5c 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -478,6 +478,7 @@ typedef struct _Screen {
478 pointer devPrivate; 478 pointer devPrivate;
479 short numVisuals; 479 short numVisuals;
480 VisualPtr visuals; 480 VisualPtr visuals;
481 WindowPtr root;
481 ScreenSaverStuffRec screensaver; 482 ScreenSaverStuffRec screensaver;
482 483
483 /* Random screen procedures */ 484 /* Random screen procedures */
diff --git a/mi/midispcur.c b/mi/midispcur.c
index c279010e6..87eb27d4e 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -405,7 +405,7 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
405 } 405 }
406 pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, 406 pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
407 miDCScreenKey); 407 miDCScreenKey);
408 pWin = WindowTable[pScreen->myNum]; 408 pWin = pScreen->root;
409 pBuffer = MIDCBUFFER(pDev, pScreen); 409 pBuffer = MIDCBUFFER(pDev, pScreen);
410 410
411#ifdef ARGB_CURSOR 411#ifdef ARGB_CURSOR
@@ -448,7 +448,7 @@ miDCSaveUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
448 pBuffer = MIDCBUFFER(pDev, pScreen); 448 pBuffer = MIDCBUFFER(pDev, pScreen);
449 449
450 pSave = pBuffer->pSave; 450 pSave = pBuffer->pSave;
451 pWin = WindowTable[pScreen->myNum]; 451 pWin = pScreen->root;
452 if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h) 452 if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h)
453 { 453 {
454 if (pSave) 454 if (pSave)
@@ -482,7 +482,7 @@ miDCRestoreUnderCursor (DeviceIntPtr pDev, ScreenPtr pScreen,
482 pBuffer = MIDCBUFFER(pDev, pScreen); 482 pBuffer = MIDCBUFFER(pDev, pScreen);
483 pSave = pBuffer->pSave; 483 pSave = pBuffer->pSave;
484 484
485 pWin = WindowTable[pScreen->myNum]; 485 pWin = pScreen->root;
486 if (!pSave) 486 if (!pSave)
487 return FALSE; 487 return FALSE;
488 488
@@ -513,7 +513,7 @@ miDCDeviceInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
513 goto failure; 513 goto failure;
514 514
515 dixSetPrivate(&pDev->devPrivates, miDCSpriteKey + pScreen->myNum, pBuffer); 515 dixSetPrivate(&pDev->devPrivates, miDCSpriteKey + pScreen->myNum, pBuffer);
516 pWin = WindowTable[pScreen->myNum]; 516 pWin = pScreen->root;
517 517
518 pBuffer->pSourceGC = miDCMakeGC(pWin); 518 pBuffer->pSourceGC = miDCMakeGC(pWin);
519 if (!pBuffer->pSourceGC) 519 if (!pBuffer->pSourceGC)
diff --git a/mi/miexpose.c b/mi/miexpose.c
index 57968dd2a..9249ca9f9 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -426,7 +426,7 @@ miSendExposures( WindowPtr pWin, RegionPtr pRgn, int dx, int dy)
426 if(!pWin->parent) { 426 if(!pWin->parent) {
427 x = panoramiXdataPtr[scrnum].x; 427 x = panoramiXdataPtr[scrnum].x;
428 y = panoramiXdataPtr[scrnum].y; 428 y = panoramiXdataPtr[scrnum].y;
429 pWin = WindowTable[0]; 429 pWin = screenInfo.screens[0]->root;
430 realWin = pWin->drawable.id; 430 realWin = pWin->drawable.id;
431 } else if (scrnum) { 431 } else if (scrnum) {
432 PanoramiXRes *win; 432 PanoramiXRes *win;
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index 1a3ac4185..da3ff4ae7 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -306,7 +306,7 @@ miOverlayReparentWindow(WindowPtr pWin, WindowPtr pPriorParent)
306{ 306{
307 if(IN_UNDERLAY(pWin) || HasUnderlayChildren(pWin)) { 307 if(IN_UNDERLAY(pWin) || HasUnderlayChildren(pWin)) {
308 /* This could probably be more optimal */ 308 /* This could probably be more optimal */
309 RebuildTree(WindowTable[pWin->drawable.pScreen->myNum]->firstChild); 309 RebuildTree(pWin->drawable.pScreen->root->firstChild);
310 } 310 }
311} 311}
312 312
@@ -1610,7 +1610,7 @@ miOverlayChangeBorderWidth(
1610void 1610void
1611miOverlaySetRootClip(ScreenPtr pScreen, Bool enable) 1611miOverlaySetRootClip(ScreenPtr pScreen, Bool enable)
1612{ 1612{
1613 WindowPtr pRoot = WindowTable[pScreen->myNum]; 1613 WindowPtr pRoot = pScreen->root;
1614 miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pRoot); 1614 miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pRoot);
1615 1615
1616 MARK_UNDERLAY(pRoot); 1616 MARK_UNDERLAY(pRoot);
diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c
index 39a3eed0f..dd3f953ca 100644
--- a/miext/rootless/rootlessCommon.c
+++ b/miext/rootless/rootlessCommon.c
@@ -447,7 +447,7 @@ RootlessRedisplay(WindowPtr pWindow)
447void 447void
448RootlessRepositionWindows(ScreenPtr pScreen) 448RootlessRepositionWindows(ScreenPtr pScreen)
449{ 449{
450 WindowPtr root = WindowTable[pScreen->myNum]; 450 WindowPtr root = pScreen->root;
451 WindowPtr win; 451 WindowPtr win;
452 452
453 if (root != NULL) { 453 if (root != NULL) {
@@ -468,7 +468,7 @@ RootlessRepositionWindows(ScreenPtr pScreen)
468void 468void
469RootlessRedisplayScreen(ScreenPtr pScreen) 469RootlessRedisplayScreen(ScreenPtr pScreen)
470{ 470{
471 WindowPtr root = WindowTable[pScreen->myNum]; 471 WindowPtr root = pScreen->root;
472 472
473 if (root != NULL) { 473 if (root != NULL) {
474 WindowPtr win; 474 WindowPtr win;
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index f44c4e8cf..8a4b81321 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -213,7 +213,7 @@ extern RegionRec rootlessHugeRoot;
213 213
214// Returns TRUE if this window is a root window 214// Returns TRUE if this window is a root window
215#define IsRoot(pWin) \ 215#define IsRoot(pWin) \
216 ((pWin) == WindowTable[(pWin)->drawable.pScreen->myNum]) 216 ((pWin) == (pWin)->drawable.pScreen->root)
217 217
218 218
219/* 219/*
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 7a24af842..d24ca04ad 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -493,7 +493,7 @@ static void expose_1 (WindowPtr pWin) {
493void 493void
494RootlessScreenExpose (ScreenPtr pScreen) 494RootlessScreenExpose (ScreenPtr pScreen)
495{ 495{
496 expose_1 (WindowTable[pScreen->myNum]); 496 expose_1 (pScreen->root);
497} 497}
498 498
499 499
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 22a548a0f..5955cd99c 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -1517,7 +1517,7 @@ RootlessOrderAllWindows (void)
1517 RL_DEBUG_MSG("RootlessOrderAllWindows() "); 1517 RL_DEBUG_MSG("RootlessOrderAllWindows() ");
1518 for (i = 0; i < screenInfo.numScreens; i++) { 1518 for (i = 0; i < screenInfo.numScreens; i++) {
1519 if (screenInfo.screens[i] == NULL) continue; 1519 if (screenInfo.screens[i] == NULL) continue;
1520 pWin = WindowTable[i]; 1520 pWin = screenInfo.screens[i]->root;
1521 if (pWin == NULL) continue; 1521 if (pWin == NULL) continue;
1522 1522
1523 for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib) { 1523 for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib) {
@@ -1533,7 +1533,7 @@ void
1533RootlessEnableRoot (ScreenPtr pScreen) 1533RootlessEnableRoot (ScreenPtr pScreen)
1534{ 1534{
1535 WindowPtr pRoot; 1535 WindowPtr pRoot;
1536 pRoot = WindowTable[pScreen->myNum]; 1536 pRoot = pScreen->root;
1537 1537
1538 RootlessEnsureFrame (pRoot); 1538 RootlessEnsureFrame (pRoot);
1539 (*pScreen->ClearToBackground) (pRoot, 0, 0, 0, 0, TRUE); 1539 (*pScreen->ClearToBackground) (pRoot, 0, 0, 0, 0, TRUE);
@@ -1546,7 +1546,7 @@ RootlessDisableRoot (ScreenPtr pScreen)
1546 WindowPtr pRoot; 1546 WindowPtr pRoot;
1547 RootlessWindowRec *winRec; 1547 RootlessWindowRec *winRec;
1548 1548
1549 pRoot = WindowTable[pScreen->myNum]; 1549 pRoot = pScreen->root;
1550 winRec = WINREC (pRoot); 1550 winRec = WINREC (pRoot);
1551 1551
1552 if (NULL == winRec) 1552 if (NULL == winRec)
@@ -1572,8 +1572,10 @@ RootlessHideAllWindows (void)
1572 for (i = 0; i < screenInfo.numScreens; i++) 1572 for (i = 0; i < screenInfo.numScreens; i++)
1573 { 1573 {
1574 pScreen = screenInfo.screens[i]; 1574 pScreen = screenInfo.screens[i];
1575 pWin = WindowTable[i]; 1575 if (pScreen == NULL)
1576 if (pScreen == NULL || pWin == NULL) 1576 continue;
1577 pWin = pScreen->root;
1578 if (pWin == NULL)
1577 continue; 1579 continue;
1578 1580
1579 for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib) 1581 for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib)
@@ -1609,8 +1611,10 @@ RootlessShowAllWindows (void)
1609 for (i = 0; i < screenInfo.numScreens; i++) 1611 for (i = 0; i < screenInfo.numScreens; i++)
1610 { 1612 {
1611 pScreen = screenInfo.screens[i]; 1613 pScreen = screenInfo.screens[i];
1612 pWin = WindowTable[i]; 1614 if (pScreen == NULL)
1613 if (pScreen == NULL || pWin == NULL) 1615 continue;
1616 pWin = pScreen->root;
1617 if (pWin == NULL)
1614 continue; 1618 continue;
1615 1619
1616 for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib) 1620 for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib)
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index a940f8aae..a2a0f36a6 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -73,7 +73,7 @@ RREditConnectionInfo (ScreenPtr pScreen)
73void 73void
74RRSendConfigNotify (ScreenPtr pScreen) 74RRSendConfigNotify (ScreenPtr pScreen)
75{ 75{
76 WindowPtr pWin = WindowTable[pScreen->myNum]; 76 WindowPtr pWin = pScreen->root;
77 xEvent event; 77 xEvent event;
78 78
79 event.u.u.type = ConfigureNotify; 79 event.u.u.type = ConfigureNotify;
@@ -97,7 +97,7 @@ RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
97 rrScrPriv (pScreen); 97 rrScrPriv (pScreen);
98 xRRScreenChangeNotifyEvent se; 98 xRRScreenChangeNotifyEvent se;
99 RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL; 99 RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
100 WindowPtr pRoot = WindowTable[pScreen->myNum]; 100 WindowPtr pRoot = pScreen->root;
101 101
102 se.type = RRScreenChangeNotify + RREventBase; 102 se.type = RRScreenChangeNotify + RREventBase;
103 se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0); 103 se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0);
@@ -620,7 +620,7 @@ ProcRRGetScreenInfo (ClientPtr client)
620 rep.setOfRotations = RR_Rotate_0; 620 rep.setOfRotations = RR_Rotate_0;
621 rep.sequenceNumber = client->sequence; 621 rep.sequenceNumber = client->sequence;
622 rep.length = 0; 622 rep.length = 0;
623 rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; 623 rep.root = pWin->drawable.pScreen->root->drawable.id;
624 rep.timestamp = currentTime.milliseconds; 624 rep.timestamp = currentTime.milliseconds;
625 rep.configTimestamp = currentTime.milliseconds; 625 rep.configTimestamp = currentTime.milliseconds;
626 rep.nSizes = 0; 626 rep.nSizes = 0;
@@ -649,7 +649,7 @@ ProcRRGetScreenInfo (ClientPtr client)
649 rep.setOfRotations = output->crtc->rotations; 649 rep.setOfRotations = output->crtc->rotations;
650 rep.sequenceNumber = client->sequence; 650 rep.sequenceNumber = client->sequence;
651 rep.length = 0; 651 rep.length = 0;
652 rep.root = WindowTable[pWin->drawable.pScreen->myNum]->drawable.id; 652 rep.root = pWin->drawable.pScreen->root->drawable.id;
653 rep.timestamp = pScrPriv->lastSetTime.milliseconds; 653 rep.timestamp = pScrPriv->lastSetTime.milliseconds;
654 rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; 654 rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
655 rep.rotation = output->crtc->rotation; 655 rep.rotation = output->crtc->rotation;
@@ -961,7 +961,7 @@ sendReply:
961 961
962 rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; 962 rep.newTimestamp = pScrPriv->lastSetTime.milliseconds;
963 rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds; 963 rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds;
964 rep.root = WindowTable[pDraw->pScreen->myNum]->drawable.id; 964 rep.root = pDraw->pScreen->root->drawable.id;
965 965
966 if (client->swapped) 966 if (client->swapped)
967 { 967 {
diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index 457b2b40f..c1bd5bb33 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -216,7 +216,7 @@ ProcRRXineramaGetScreenSize(ClientPtr client)
216 return rc; 216 return rc;
217 217
218 pScreen = pWin->drawable.pScreen; 218 pScreen = pWin->drawable.pScreen;
219 pRoot = WindowTable[pScreen->myNum]; 219 pRoot = pScreen->root;
220 220
221 rep.type = X_Reply; 221 rep.type = X_Reply;
222 rep.length = 0; 222 rep.length = 0;
diff --git a/render/render.c b/render/render.c
index b58dd3ebe..d34250227 100644
--- a/render/render.c
+++ b/render/render.c
@@ -2681,7 +2681,7 @@ PanoramiXRenderCreatePicture (ClientPtr client)
2681 newPict->info[0].id = stuff->pid; 2681 newPict->info[0].id = stuff->pid;
2682 2682
2683 if (refDraw->type == XRT_WINDOW && 2683 if (refDraw->type == XRT_WINDOW &&
2684 stuff->drawable == WindowTable[0]->drawable.id) 2684 stuff->drawable == screenInfo.screens[0]->root->drawable.id)
2685 { 2685 {
2686 newPict->u.pict.root = TRUE; 2686 newPict->u.pict.root = TRUE;
2687 } 2687 }
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index d3a207ddb..5f08db7a5 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -690,7 +690,7 @@ ReplaceCursor (CursorPtr pCursor,
690 } 690 }
691 } 691 }
692 /* this "knows" that WindowHasNewCursor doesn't depend on it's argument */ 692 /* this "knows" that WindowHasNewCursor doesn't depend on it's argument */
693 WindowHasNewCursor (WindowTable[0]); 693 WindowHasNewCursor (screenInfo.screens[0]->root);
694} 694}
695 695
696static Bool 696static Bool
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index 93175c538..0f3ffa468 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -43,6 +43,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
43#include "inputstr.h" 43#include "inputstr.h"
44#include "opaque.h" 44#include "opaque.h"
45#include "property.h" 45#include "property.h"
46#include "scrnintstr.h"
46#define XKBSRV_NEED_FILE_FUNCS 47#define XKBSRV_NEED_FILE_FUNCS
47#include <xkbsrv.h> 48#include <xkbsrv.h>
48#include "xkbgeom.h" 49#include "xkbgeom.h"
@@ -210,7 +211,7 @@ char * pval;
210 ErrorF("[xkb] Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n", 211 ErrorF("[xkb] Internal Error! bad size (%d!=%d) for _XKB_RULES_NAMES\n",
211 out,len); 212 out,len);
212 } 213 }
213 dixChangeWindowProperty(serverClient, WindowTable[0], name, XA_STRING, 8, 214 dixChangeWindowProperty(serverClient, screenInfo.screens[0]->root, name, XA_STRING, 8,
214 PropModeReplace, len, pval, TRUE); 215 PropModeReplace, len, pval, TRUE);
215 free(pval); 216 free(pval);
216 return TRUE; 217 return TRUE;