From 3078ea3bfd90447079618711b07abc0e14f7dbbe Mon Sep 17 00:00:00 2001 From: David Reveman Date: Wed, 9 Jul 2008 18:06:28 -0400 Subject: [PATCH] Add support for using back-end server root window. --- hw/dmx/dmx.c | 3 +- hw/dmx/dmx.h | 2 ++ hw/dmx/dmxdbus.c | 1 + hw/dmx/dmxextension.c | 3 ++ hw/dmx/dmxextension.h | 1 + hw/dmx/dmxscrinit.c | 70 +++++++++++++++++++-------------------- hw/dmx/dmxwindow.c | 40 ++++++++++++++-------- hw/dmx/input/dmxbackend.c | 10 +----- hw/dmx/input/dmxcommon.c | 14 ++++---- 9 files changed, 78 insertions(+), 66 deletions(-) diff --git a/hw/dmx/dmx.c b/hw/dmx/dmx.c index 0e9755e8d..796fb54c1 100644 --- a/hw/dmx/dmx.c +++ b/hw/dmx/dmx.c @@ -529,7 +529,8 @@ static int ProcDMXAddScreen(ClientPtr client) } } - status = dmxAttachScreen(physicalScreen, &attr, NULL, NULL, 0, NULL, 0, 0); + status = dmxAttachScreen(physicalScreen, &attr, 0, NULL, NULL, 0, NULL, + 0, 0); xfree(name); diff --git a/hw/dmx/dmx.h b/hw/dmx/dmx.h index 7afc80a67..3e9ce2940 100644 --- a/hw/dmx/dmx.h +++ b/hw/dmx/dmx.h @@ -141,6 +141,8 @@ typedef struct _DMXScreenInfo { char *authData; int authDataLen; + int beUseRoot; + /*---------- Screen window information ----------*/ Window scrnWin; /**< "Screen" window on backend display */ diff --git a/hw/dmx/dmxdbus.c b/hw/dmx/dmxdbus.c index d199f40d3..93ad94982 100644 --- a/hw/dmx/dmxdbus.c +++ b/hw/dmx/dmxdbus.c @@ -136,6 +136,7 @@ handle_attach_screen (DBusMessage *message, ret = dmxAttachScreen (screen, &attr, + TRUE, auth_type, data, size, diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c index 06d2d94f9..a645594ce 100644 --- a/hw/dmx/dmxextension.c +++ b/hw/dmx/dmxextension.c @@ -1710,6 +1710,7 @@ static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n) int dmxAttachScreen (int idx, DMXScreenAttributesPtr attr, + int useRoot, const char *authType, const char *authData, int authDataLen, @@ -1763,6 +1764,8 @@ dmxAttachScreen (int idx, /* Save old info */ oldDMXScreen = *dmxScreen; + dmxScreen->beUseRoot = useRoot; + /* Copy the display name to the new screen */ dmxScreen->display = strdup(attr->displayName); diff --git a/hw/dmx/dmxextension.h b/hw/dmx/dmxextension.h index dcd7eb6a4..3390a4cc1 100644 --- a/hw/dmx/dmxextension.h +++ b/hw/dmx/dmxextension.h @@ -124,6 +124,7 @@ typedef void (*dmxErrorSetProcPtr) (void *error, extern int dmxAttachScreen (int idx, DMXScreenAttributesPtr attr, + int useRoot, const char *authType, const char *authData, int authDataLen, diff --git a/hw/dmx/dmxscrinit.c b/hw/dmx/dmxscrinit.c index df97787bf..45bcfa784 100644 --- a/hw/dmx/dmxscrinit.c +++ b/hw/dmx/dmxscrinit.c @@ -1421,32 +1421,34 @@ void dmxBEScreenInit(int idx, ScreenPtr pScreen) /* Create root window for screen */ mask = CWBackPixel | CWEventMask | CWColormap | CWOverrideRedirect; attribs.background_pixel = dmxScreen->beBlackPixel; - attribs.event_mask = (KeyPressMask - | KeyReleaseMask - | ButtonPressMask - | ButtonReleaseMask - | EnterWindowMask - | LeaveWindowMask - | PointerMotionMask - | KeymapStateMask - | FocusChangeMask); + attribs.event_mask = StructureNotifyMask; attribs.colormap = dmxScreen->beDefColormaps[dmxScreen->beDefVisualIndex]; attribs.override_redirect = True; - - dmxScreen->scrnWin = - XCreateWindow(dmxScreen->beDisplay, - DefaultRootWindow(dmxScreen->beDisplay), - dmxScreen->scrnX, - dmxScreen->scrnY, - dmxScreen->scrnWidth, - dmxScreen->scrnHeight, - 0, - pScreen->rootDepth, - InputOutput, - dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual, - mask, - &attribs); + if (!dmxScreen->beUseRoot) + { + dmxScreen->scrnWin = + XCreateWindow(dmxScreen->beDisplay, + DefaultRootWindow(dmxScreen->beDisplay), + dmxScreen->scrnX, + dmxScreen->scrnY, + dmxScreen->scrnWidth, + dmxScreen->scrnHeight, + 0, + pScreen->rootDepth, + InputOutput, + dmxScreen->beVisuals[dmxScreen->beDefVisualIndex].visual, + mask, + &attribs); + } + else + { + dmxScreen->scrnWin = DefaultRootWindow (dmxScreen->beDisplay); + XSetWindowBackground (dmxScreen->beDisplay, dmxScreen->scrnWin, + attribs.background_pixel); + XSelectInput (dmxScreen->beDisplay, dmxScreen->scrnWin, + attribs.event_mask); + } dmxPropertyWindow(dmxScreen); /* @@ -1473,10 +1475,6 @@ void dmxBEScreenInit(int idx, ScreenPtr pScreen) } #ifdef RANDR - XSelectInput (dmxScreen->beDisplay, - DefaultRootWindow (dmxScreen->beDisplay), - StructureNotifyMask); - if (dmxScreen->beRandr) XRRSelectInput (dmxScreen->beDisplay, DefaultRootWindow (dmxScreen->beDisplay), @@ -1486,11 +1484,8 @@ void dmxBEScreenInit(int idx, ScreenPtr pScreen) RROutputPropertyNotifyMask); #endif - XMapWindow (dmxScreen->beDisplay, dmxScreen->scrnWin); - - XSetInputFocus (dmxScreen->beDisplay, dmxScreen->scrnWin, - RevertToPointerRoot, - CurrentTime); + if (!dmxScreen->beUseRoot) + XMapWindow (dmxScreen->beDisplay, dmxScreen->scrnWin); if (dmxShadowFB) { mask = (GCFunction @@ -1965,10 +1960,13 @@ void dmxBECloseScreen(ScreenPtr pScreen) XLIB_EPILOGUE (dmxScreen); dmxScreen->noCursor = (Cursor)0; - XLIB_PROLOGUE (dmxScreen); - XUnmapWindow(dmxScreen->beDisplay, dmxScreen->scrnWin); - XDestroyWindow(dmxScreen->beDisplay, dmxScreen->scrnWin); - XLIB_EPILOGUE (dmxScreen); + if (!dmxScreen->beUseRoot) + { + XLIB_PROLOGUE (dmxScreen); + XUnmapWindow(dmxScreen->beDisplay, dmxScreen->scrnWin); + XDestroyWindow(dmxScreen->beDisplay, dmxScreen->scrnWin); + XLIB_EPILOGUE (dmxScreen); + } dmxScreen->scrnWin = (Window)0; if (dmxShadowFB) { diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c index 941d31217..a2e9e972b 100644 --- a/hw/dmx/dmxwindow.c +++ b/hw/dmx/dmxwindow.c @@ -84,12 +84,33 @@ Window dmxCreateRootWindow(WindowPtr pWindow) dmxWinPrivPtr pWinPriv = DMX_GET_WINDOW_PRIV(pWindow); Window parent; Visual *visual; - unsigned long mask; + unsigned long mask = 0; XSetWindowAttributes attribs; ColormapPtr pCmap; dmxColormapPrivPtr pCmapPriv; Window win = None; + mask = CWEventMask; + attribs.event_mask = ExposureMask; + + /* Incorporate new attributes, if needed */ + if (pWinPriv->attribMask) { + dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs); + mask |= pWinPriv->attribMask; + } + + if (dmxScreen->beUseRoot) + { + XLIB_PROLOGUE (dmxScreen); + XChangeWindowAttributes (dmxScreen->beDisplay, + DefaultRootWindow (dmxScreen->beDisplay), + mask, &attribs); + XLIB_EPILOGUE (dmxScreen); + dmxSync (dmxScreen, False); + + return DefaultRootWindow (dmxScreen->beDisplay); + } + /* Create root window */ parent = dmxScreen->scrnWin; /* This is our "Screen" window */ @@ -98,18 +119,11 @@ Window dmxCreateRootWindow(WindowPtr pWindow) pCmap = (ColormapPtr)LookupIDByType(wColormap(pWindow), RT_COLORMAP); pCmapPriv = DMX_GET_COLORMAP_PRIV(pCmap); - mask = CWEventMask | CWBackingStore | CWColormap | CWBorderPixel; - attribs.event_mask = ExposureMask; + mask |= CWBackingStore | CWColormap | CWBorderPixel; attribs.backing_store = NotUseful; attribs.colormap = pCmapPriv->cmap; attribs.border_pixel = 0; - /* Incorporate new attributes, if needed */ - if (pWinPriv->attribMask) { - dmxDoChangeWindowAttributes(pWindow, &pWinPriv->attribMask, &attribs); - mask |= pWinPriv->attribMask; - } - XLIB_PROLOGUE (dmxScreen); win = XCreateWindow(dmxScreen->beDisplay, parent, @@ -137,7 +151,7 @@ void dmxResizeScreenWindow(ScreenPtr pScreen, unsigned int m; XWindowChanges c; - if (!dmxScreen->beDisplay) + if (!dmxScreen->beDisplay || dmxScreen->beUseRoot) return; /* Handle resizing on back-end server */ @@ -164,7 +178,7 @@ void dmxResizeRootWindow(WindowPtr pRoot, XWindowChanges c; /* Handle resizing on back-end server */ - if (dmxScreen->beDisplay) { + if (dmxScreen->beDisplay && !dmxScreen->beUseRoot) { m = CWX | CWY | CWWidth | CWHeight; c.x = x; c.y = y; @@ -179,7 +193,7 @@ void dmxResizeRootWindow(WindowPtr pRoot, if (w == 0 || h == 0) { if (pWinPriv->mapped) { - if (dmxScreen->beDisplay) + if (dmxScreen->beDisplay && !dmxScreen->beUseRoot) { XLIB_PROLOGUE (dmxScreen); dmxSetIgnore (dmxScreen, NextRequest (dmxScreen->beDisplay)); @@ -189,7 +203,7 @@ void dmxResizeRootWindow(WindowPtr pRoot, pWinPriv->mapped = FALSE; } } else if (!pWinPriv->mapped) { - if (dmxScreen->beDisplay) + if (dmxScreen->beDisplay && !dmxScreen->beUseRoot) { XLIB_PROLOGUE (dmxScreen); dmxSetIgnore (dmxScreen, NextRequest (dmxScreen->beDisplay)); diff --git a/hw/dmx/input/dmxbackend.c b/hw/dmx/input/dmxbackend.c index 6097be611..2ff23309c 100644 --- a/hw/dmx/input/dmxbackend.c +++ b/hw/dmx/input/dmxbackend.c @@ -621,15 +621,7 @@ void dmxBackendInit(DevicePtr pDev) /* Finish initialization using computed values or constants. */ dmxBackendComputeCenter(priv); - priv->eventMask = (KeyPressMask - | KeyReleaseMask - | ButtonPressMask - | ButtonReleaseMask - | EnterWindowMask - | LeaveWindowMask - | PointerMotionMask - | KeymapStateMask - | FocusChangeMask); + priv->eventMask = StructureNotifyMask; priv->myScreen = dmxScreen->index; priv->lastX = priv->centerX; priv->lastY = priv->centerY; diff --git a/hw/dmx/input/dmxcommon.c b/hw/dmx/input/dmxcommon.c index 1765e0dc8..b42d9dc4f 100644 --- a/hw/dmx/input/dmxcommon.c +++ b/hw/dmx/input/dmxcommon.c @@ -292,10 +292,10 @@ int dmxCommonKbdOn(DevicePtr pDev) GETPRIVFROMPDEV; if (priv->be) dmxCommonSaveState(priv); priv->eventMask |= DMX_KEYBOARD_EVENT_MASK; - //XSelectInput(priv->display, priv->window, priv->eventMask); -// if (priv->be) -// XSetInputFocus(priv->display, priv->window, RevertToPointerRoot, -// CurrentTime); + XSelectInput(priv->display, priv->window, priv->eventMask); + if (priv->be) + XSetInputFocus(priv->display, priv->window, RevertToPointerRoot, + CurrentTime); return -1; } @@ -304,7 +304,7 @@ void dmxCommonKbdOff(DevicePtr pDev) { GETPRIVFROMPDEV; priv->eventMask &= ~DMX_KEYBOARD_EVENT_MASK; - //XSelectInput(priv->display, priv->window, priv->eventMask); + XSelectInput(priv->display, priv->window, priv->eventMask); dmxCommonRestoreState(priv); } @@ -460,10 +460,10 @@ void dmxCommonMouGetMap(DevicePtr pDev, unsigned char *map, int *nButtons) static void *dmxCommonXSelect(DMXScreenInfo *dmxScreen, void *closure) { - /* myPrivate *priv = closure; + myPrivate *priv = closure; XLIB_PROLOGUE (dmxScreen); XSelectInput(dmxScreen->beDisplay, dmxScreen->scrnWin, priv->eventMask); - XLIB_EPILOGUE (dmxScreen);*/ + XLIB_EPILOGUE (dmxScreen); return NULL; }