diff --git a/hw/xnest/Display.c b/hw/xnest/Display.c index f461e0480..6d16ab494 100644 --- a/hw/xnest/Display.c +++ b/hw/xnest/Display.c @@ -69,6 +69,9 @@ xnestOpenDisplay(int argc, char *argv[]) long mask; int i, j; + /* fill out the first screen and later copy it to all others */ + XnestScreenPtr xnscr = XnestScreenByIdx(0); + if (!xnestDoFullGeneration) return; @@ -76,16 +79,16 @@ xnestOpenDisplay(int argc, char *argv[]) xnestCloseDisplay(); - xnestDisplay = XOpenDisplay(xnestDisplayName); - if (xnestDisplay == NULL) + xnscr->upstreamDisplay = XOpenDisplay(xnestDisplayName); + if (xnscr->upstreamDisplay == NULL) FatalError("Unable to open display \"%s\".\n", XDisplayName(xnestDisplayName)); if (xnestSynchronize) - XSynchronize(xnestDisplay, True); + XSynchronize(xnscr->upstreamDisplay, True); mask = VisualScreenMask; - vi.screen = DefaultScreen(xnestDisplay); + vi.screen = DefaultScreen(xnscr->upstreamDisplay); xnestVisuals = XGetVisualInfo(xnestDisplay, mask, &vi, &xnestNumVisuals); if (xnestNumVisuals == 0 || xnestVisuals == NULL) FatalError("Unable to find any visuals.\n"); @@ -124,14 +127,14 @@ xnestOpenDisplay(int argc, char *argv[]) xnestVisuals[i].visual, AllocNone); - xnestDepths = XListDepths(xnestDisplay, DefaultScreen(xnestDisplay), + xnestDepths = XListDepths(xnestDisplay, DefaultScreen(xnscr->upstreamDisplay), &xnestNumDepths); - xnestPixmapFormats = XListPixmapFormats(xnestDisplay, + xnestPixmapFormats = XListPixmapFormats(xnscr->upstreamDisplay, &xnestNumPixmapFormats); - xnestBlackPixel = BlackPixel(xnestDisplay, DefaultScreen(xnestDisplay)); - xnestWhitePixel = WhitePixel(xnestDisplay, DefaultScreen(xnestDisplay)); + xnestBlackPixel = BlackPixel(xnscr->upstreamDisplay, DefaultScreen(xnscr->upstreamDisplay)); + xnestWhitePixel = WhitePixel(xnscr->upstreamDisplay, DefaultScreen(xnscr->upstreamDisplay)); if (xnestParentWindow != (Window) 0) xnestEventMask = StructureNotifyMask; @@ -146,11 +149,11 @@ xnestOpenDisplay(int argc, char *argv[]) if (xnestPixmapFormats[i].depth == 1 || xnestPixmapFormats[i].depth == xnestDepths[j]) { xnestDefaultDrawables[xnestPixmapFormats[i].depth] = - XCreatePixmap(xnestDisplay, DefaultRootWindow(xnestDisplay), + XCreatePixmap(xnscr->upstreamDisplay, DefaultRootWindow(xnscr->upstreamDisplay), 1, 1, xnestPixmapFormats[i].depth); } - xnestBitmapGC = XCreateGC(xnestDisplay, xnestDefaultDrawables[1], 0L, NULL); + xnestBitmapGC = XCreateGC(xnscr->upstreamDisplay, xnestDefaultDrawables[1], 0L, NULL); if (!(xnestUserGeometry & XValue)) xnestX = 0; @@ -160,38 +163,47 @@ xnestOpenDisplay(int argc, char *argv[]) if (xnestParentWindow == 0) { if (!(xnestUserGeometry & WidthValue)) - xnestWidth = 3 * DisplayWidth(xnestDisplay, - DefaultScreen(xnestDisplay)) / 4; + xnestWidth = 3 * DisplayWidth(xnscr->upstreamDisplay, + DefaultScreen(xnscr->upstreamDisplay)) / 4; if (!(xnestUserGeometry & HeightValue)) - xnestHeight = 3 * DisplayHeight(xnestDisplay, - DefaultScreen(xnestDisplay)) / 4; + xnestHeight = 3 * DisplayHeight(xnscr->upstreamDisplay, + DefaultScreen(xnscr->upstreamDisplay)) / 4; } if (!xnestUserBorderWidth) xnestBorderWidth = 1; xnestIconBitmap = - XCreateBitmapFromData(xnestDisplay, - DefaultRootWindow(xnestDisplay), + XCreateBitmapFromData(xnscr->upstreamDisplay, + DefaultRootWindow(xnscr->upstreamDisplay), (char *) icon_bits, icon_width, icon_height); xnestScreenSaverPixmap = - XCreatePixmapFromBitmapData(xnestDisplay, - DefaultRootWindow(xnestDisplay), + XCreatePixmapFromBitmapData(xnscr->upstreamDisplay, + DefaultRootWindow(xnscr->upstreamDisplay), (char *) screensaver_bits, screensaver_width, screensaver_height, xnestWhitePixel, xnestBlackPixel, - DefaultDepth(xnestDisplay, - DefaultScreen(xnestDisplay))); + DefaultDepth(xndscr->display, + DefaultScreen(xnscr->upstreamDisplay))); + + /* now copy over the remaining screens */ + for (i=1; idisplay = xnscr->upstreamDisplay; + s2->clonedFrom = 0; + } } void xnestCloseDisplay(void) { - if (!xnestDoFullGeneration || !xnestDisplay) + XnestScreenPtr xnscr = xnestScreenByIdx(0); + + if (!xnestDoFullGeneration || !xnscr->upstreamDisplay) return; /* @@ -203,5 +215,5 @@ xnestCloseDisplay(void) XFree(xnestVisuals); XFree(xnestDepths); XFree(xnestPixmapFormats); - XCloseDisplay(xnestDisplay); + XCloseDisplay(xnscr->upstreamDisplay); } diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index 71a021796..656df3a1c 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -75,26 +75,27 @@ xnestSaveScreen(ScreenPtr pScreen, int what) if (xnestSoftwareScreenSaver) return False; else { - Window saverWin = xnestScreenPriv(pScreen)->screenSaverWindow; + XnestScreenPtr xnscr = xnestScreenPriv(pScreen); + Window saverWin = xnscr->screenSaverWindow; switch (what) { case SCREEN_SAVER_ON: - XMapRaised(xnestDisplay, saverWin); + XMapRaised(xnscr->upstreamDisplay, saverWin); xnestSetScreenSaverColormapWindow(pScreen); break; case SCREEN_SAVER_OFF: - XUnmapWindow(xnestDisplay, saverWin); + XUnmapWindow(xnscr->upstreamDisplay, saverWin); xnestSetInstalledColormapWindows(pScreen); break; case SCREEN_SAVER_FORCER: lastEventTime = GetTimeInMillis(); - XUnmapWindow(xnestDisplay, saverWin); + XUnmapWindow(xnscr->upstreamDisplay, saverWin); xnestSetInstalledColormapWindows(pScreen); break; case SCREEN_SAVER_CYCLE: - XUnmapWindow(xnestDisplay, saverWin); + XUnmapWindow(xnscr->upstreamDisplay, saverWin); xnestSetInstalledColormapWindows(pScreen); break; } @@ -142,6 +143,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) VisualID defaultVisual; int rootDepth; miPointerScreenPtr PointPriv; + XnestScreenPtr xnscr = xnestScreenPriv(pScreen); if (!dixRegisterPrivateKey (&xnestWindowPrivateKeyRec, PRIVATE_WINDOW, sizeof(xnestPrivWin))) @@ -235,7 +237,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) rootDepth = visuals[xnestDefaultVisualIndex].nplanes; if (xnestParentWindow != 0) { - XGetWindowAttributes(xnestDisplay, xnestParentWindow, &gattributes); + XGetWindowAttributes(xnscr->upstreamDisplay, xnestParentWindow, &gattributes); xnestWidth = gattributes.width; xnestHeight = gattributes.height; } @@ -321,13 +323,13 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) &xnestCursorFuncs); PointPriv->spriteFuncs = &xnestPointerSpriteFuncs; - pScreen->mmWidth = xnestWidth * DisplayWidthMM(xnestDisplay, - DefaultScreen(xnestDisplay)) - / DisplayWidth(xnestDisplay, DefaultScreen(xnestDisplay)); + pScreen->mmWidth = xnestWidth * DisplayWidthMM(xnscr->upstreamDisplay, + DefaultScreen(xnscr->upstreamDisplay)) + / DisplayWidth(xnestDisplay, DefaultScreen(xnscr->upstreamDisplay)); pScreen->mmHeight = - xnestHeight * DisplayHeightMM(xnestDisplay, - DefaultScreen(xnestDisplay)) / - DisplayHeight(xnestDisplay, DefaultScreen(xnestDisplay)); + xnestHeight * DisplayHeightMM(xnscr->upstreamDisplay, + DefaultScreen(xnscr->upstreamDisplay)) / + DisplayHeight(xnscr->upstreamDisplay, DefaultScreen(xnscr->upstreamDisplay)); /* overwrite miCloseScreen with our own */ pScreen->CloseScreen = xnestCloseScreen; @@ -350,12 +352,12 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) if (xnestParentWindow != 0) { xnscr->rootWindow = xnestParentWindow; - XSelectInput(xnestDisplay, xnestParentWindow, xnestEventMask); + XSelectInput(xnscr->upstreamDisplay, xnestParentWindow, xnestEventMask); } else xnscr->rootWindow = - XCreateWindow(xnestDisplay, - DefaultRootWindow(xnestDisplay), + XCreateWindow(xnscr->upstreamDisplay, + DefaultRootWindow(xnscr->upstreamDisplay), xnestX + POSITION_OFFSET, xnestY + POSITION_OFFSET, xnestWidth, xnestHeight, @@ -377,27 +379,27 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) sizeHints.flags |= USPosition; if (xnestUserGeometry & WidthValue || xnestUserGeometry & HeightValue) sizeHints.flags |= USSize; - XSetStandardProperties(xnestDisplay, + XSetStandardProperties(xnscr->upstreamDisplay, xnscr->rootWindow, xnestWindowName, xnestWindowName, xnestIconBitmap, argv, argc, &sizeHints); - XMapWindow(xnestDisplay, xnscr->rootWindow); + XMapWindow(xnscr->upstreamDisplay, xnscr->rootWindow); valuemask = CWBackPixmap | CWColormap; attributes.background_pixmap = xnestScreenSaverPixmap; attributes.colormap = - DefaultColormap(xnestDisplay, DefaultScreen(xnestDisplay)); + DefaultColormap(xnscr->upstreamDisplay, DefaultScreen(xnscr->upstreamDisplay)); xnscr->screenSaverWindow = - XCreateWindow(xnestDisplay, + XCreateWindow(xnscr->upstreamDisplay, xnscr->rootWindow, 0, 0, xnestWidth, xnestHeight, 0, - DefaultDepth(xnestDisplay, - DefaultScreen(xnestDisplay)), - InputOutput, DefaultVisual(xnestDisplay, + DefaultDepth(xnscr->upstreamDisplay, + DefaultScreen(xnscr->upstreamDisplay)), + InputOutput, DefaultVisual(xnscr->upstreamDisplay, DefaultScreen - (xnestDisplay)), valuemask, + (xnscr->upstreamDisplay)), valuemask, &attributes); } diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c index 9f398aa2b..7de3ab35a 100644 --- a/hw/xnest/Window.c +++ b/hw/xnest/Window.c @@ -78,6 +78,7 @@ xnestCreateWindow(WindowPtr pWin) XSetWindowAttributes attributes; Visual *visual; ColormapPtr pCmap; + XnestScreenPtr xnscr = xnestScreenPriv(pWin->drawable.pScreen); if (pWin->drawable.class == InputOnly) { mask = 0L; @@ -115,7 +116,7 @@ xnestCreateWindow(WindowPtr pWin) } } - xnestWindowPriv(pWin)->window = XCreateWindow(xnestDisplay, + xnestWindowPriv(pWin)->window = XCreateWindow(xnscr->upstreamDisplay, xnestWindowParent(pWin), pWin->origin.x - wBorderWidth(pWin), @@ -148,12 +149,14 @@ xnestCreateWindow(WindowPtr pWin) Bool xnestDestroyWindow(WindowPtr pWin) { + XnestScreenPtr xnscr = xnestScreenPriv(pWin->drawable.pScreen); + if (pWin->nextSib) xnestWindowPriv(pWin->nextSib)->sibling_above = xnestWindowPriv(pWin)->sibling_above; RegionDestroy(xnestWindowPriv(pWin)->bounding_shape); RegionDestroy(xnestWindowPriv(pWin)->clip_shape); - XDestroyWindow(xnestDisplay, xnestWindow(pWin)); + XDestroyWindow(xnscr->upstreamDisplay, xnestWindow(pWin)); xnestWindowPriv(pWin)->window = None; if (pWin->optional && pWin->optional->colormap && pWin->parent) @@ -177,10 +180,11 @@ xnestConfigureWindow(WindowPtr pWin, unsigned int mask) { unsigned int valuemask; XWindowChanges values; + XnestScreenPtr xnscr = xnestScreenPriv(pWin->drawable.pScreen); if (mask & CWParent && xnestWindowPriv(pWin)->parent != xnestWindowParent(pWin)) { - XReparentWindow(xnestDisplay, xnestWindow(pWin), + XReparentWindow(xnscr->upstreamDisplay, xnestWindow(pWin), xnestWindowParent(pWin), pWin->origin.x - wBorderWidth(pWin), pWin->origin.y - wBorderWidth(pWin)); @@ -227,7 +231,7 @@ xnestConfigureWindow(WindowPtr pWin, unsigned int mask) } if (valuemask) - XConfigureWindow(xnestDisplay, xnestWindow(pWin), valuemask, &values); + XConfigureWindow(xnscr->upstreamDisplay, xnestWindow(pWin), valuemask, &values); if (mask & CWStackingOrder && xnestWindowPriv(pWin)->sibling_above != xnestWindowSiblingAbove(pWin)) { @@ -239,7 +243,7 @@ xnestConfigureWindow(WindowPtr pWin, unsigned int mask) /* the top sibling */ valuemask = CWStackMode; values.stack_mode = Above; - XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, &values); + XConfigureWindow(xnscr->upstreamDisplay, xnestWindow(pSib), valuemask, &values); xnestWindowPriv(pSib)->sibling_above = None; /* the rest of siblings */ @@ -247,7 +251,7 @@ xnestConfigureWindow(WindowPtr pWin, unsigned int mask) valuemask = CWSibling | CWStackMode; values.sibling = xnestWindowSiblingAbove(pSib); values.stack_mode = Below; - XConfigureWindow(xnestDisplay, xnestWindow(pSib), valuemask, + XConfigureWindow(xnscr->upstreamDisplay, xnestWindow(pSib), valuemask, &values); xnestWindowPriv(pSib)->sibling_above = xnestWindowSiblingAbove(pSib); @@ -259,6 +263,7 @@ Bool xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask) { XSetWindowAttributes attributes; + XnestScreenPtr xnscr = xnestScreenPriv(pWin->drawable.pScreen); if (mask & CWBackPixmap) switch (pWin->backgroundState) { @@ -342,7 +347,7 @@ xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask) mask &= ~CWCursor; if (mask) - XChangeWindowAttributes(xnestDisplay, xnestWindow(pWin), + XChangeWindowAttributes(xnscr->upstreamDisplay, xnestWindow(pWin), mask, &attributes); return True; @@ -351,9 +356,11 @@ xnestChangeWindowAttributes(WindowPtr pWin, unsigned long mask) Bool xnestRealizeWindow(WindowPtr pWin) { + XnestScreenPtr xnscr = xnestScreenPriv(pWin->drawable.pScreen); + xnestConfigureWindow(pWin, CWStackingOrder); xnestShapeWindow(pWin); - XMapWindow(xnestDisplay, xnestWindow(pWin)); + XMapWindow(xnscr->upstreamDisplay, xnestWindow(pWin)); return True; } @@ -361,7 +368,9 @@ xnestRealizeWindow(WindowPtr pWin) Bool xnestUnrealizeWindow(WindowPtr pWin) { - XUnmapWindow(xnestDisplay, xnestWindow(pWin)); + XnestScreenPtr xnscr = xnestScreenPriv(pWin->drawable.pScreen); + + XUnmapWindow(xnscr->upstreamDisplay, xnestWindow(pWin)); return True; } @@ -390,6 +399,7 @@ xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn) XEvent event; Window window; BoxRec Box; + XnestScreenPtr xnscr = xnestScreenPriv(pWin->drawable.pScreen); XSync(xnestDisplay, False); @@ -406,7 +416,7 @@ xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn) event.xexpose.type = ProcessedExpose; if (RegionContainsRect(pRgn, &Box) != rgnIN) - XPutBackEvent(xnestDisplay, &event); + XPutBackEvent(xnscr->upstreamDisplay, &event); } miWindowExposures(pWin, pRgn); @@ -456,6 +466,7 @@ xnestShapeWindow(WindowPtr pWin) BoxPtr pBox; XRectangle rect; int i; + XnestScreenPtr xnscr = xnestScreenPriv(pWin->drawable.pScreen); if (!xnestRegionEqual(xnestWindowPriv(pWin)->bounding_shape, wBoundingShape(pWin))) { @@ -475,14 +486,14 @@ xnestShapeWindow(WindowPtr pWin) rect.height = pBox[i].y2 - pBox[i].y1; XUnionRectWithRegion(&rect, reg, reg); } - XShapeCombineRegion(xnestDisplay, xnestWindow(pWin), + XShapeCombineRegion(xnscr->upstreamDisplay, xnestWindow(pWin), ShapeBounding, 0, 0, reg, ShapeSet); XDestroyRegion(reg); } else { RegionEmpty(xnestWindowPriv(pWin)->bounding_shape); - XShapeCombineMask(xnestDisplay, xnestWindow(pWin), + XShapeCombineMask(xnscr->upstreamDisplay, xnestWindow(pWin), ShapeBounding, 0, 0, None, ShapeSet); } } @@ -502,14 +513,14 @@ xnestShapeWindow(WindowPtr pWin) rect.height = pBox[i].y2 - pBox[i].y1; XUnionRectWithRegion(&rect, reg, reg); } - XShapeCombineRegion(xnestDisplay, xnestWindow(pWin), + XShapeCombineRegion(xnscr->upstreamDisplay, xnestWindow(pWin), ShapeClip, 0, 0, reg, ShapeSet); XDestroyRegion(reg); } else { RegionEmpty(xnestWindowPriv(pWin)->clip_shape); - XShapeCombineMask(xnestDisplay, xnestWindow(pWin), + XShapeCombineMask(xnscr->upstreamDisplay, xnestWindow(pWin), ShapeClip, 0, 0, None, ShapeSet); } } diff --git a/hw/xnest/multiscreen.h b/hw/xnest/multiscreen.h index 2985e95a6..eb7e41788 100644 --- a/hw/xnest/multiscreen.h +++ b/hw/xnest/multiscreen.h @@ -12,6 +12,8 @@ #include "screenint.h" typedef struct xnest_screen { + int clonedFrom; + Display *upstreamDisplay; Window rootWindow; Window screenSaverWindow; ScreenPtr pScreen;