diff options
Diffstat (limited to 'miext/rootless/rootlessCommon.c')
-rw-r--r-- | miext/rootless/rootlessCommon.c | 188 |
1 files changed, 100 insertions, 88 deletions
diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c index 861e8e858..d8f43bd1b 100644 --- a/miext/rootless/rootlessCommon.c +++ b/miext/rootless/rootlessCommon.c @@ -33,8 +33,8 @@ #include <dix-config.h> #endif -#include <stddef.h> /* For NULL */ -#include <limits.h> /* For CHAR_BIT */ +#include <stddef.h> /* For NULL */ +#include <limits.h> /* For CHAR_BIT */ #include "rootlessCommon.h" #include "colormapst.h" @@ -44,7 +44,7 @@ unsigned int rootless_CopyWindow_threshold = 0; int rootlessGlobalOffsetX = 0; int rootlessGlobalOffsetY = 0; -RegionRec rootlessHugeRoot = {{-32767, -32767, 32767, 32767}, NULL}; +RegionRec rootlessHugeRoot = { {-32767, -32767, 32767, 32767}, NULL }; /* Following macro from miregion.c */ @@ -55,7 +55,6 @@ RegionRec rootlessHugeRoot = {{-32767, -32767, 32767, 32767}, NULL}; ((r1)->y2 <= (r2)->y1) || \ ((r1)->y1 >= (r2)->y2) ) ) - /* * TopLevelParent * Returns the top-level parent of pWindow. @@ -71,13 +70,12 @@ TopLevelParent(WindowPtr pWindow) return pWindow; top = pWindow; - while (top && ! IsTopLevel(top)) + while (top && !IsTopLevel(top)) top = top->parent; return top; } - /* * IsFramedWindow * Returns TRUE if this window is visible inside a frame @@ -99,48 +97,51 @@ IsFramedWindow(WindowPtr pWin) } Bool -RootlessResolveColormap (ScreenPtr pScreen, int first_color, - int n_colors, uint32_t *colors) +RootlessResolveColormap(ScreenPtr pScreen, int first_color, + int n_colors, uint32_t * colors) { - int last, i; - ColormapPtr map; - - map = RootlessGetColormap (pScreen); - if (map == NULL || map->class != PseudoColor) return FALSE; - - last = min (map->pVisual->ColormapEntries, first_color + n_colors); - for (i = max (0, first_color); i < last; i++) { - Entry *ent = map->red + i; - uint16_t red, green, blue; - - if (!ent->refcnt) continue; - if (ent->fShared) { - red = ent->co.shco.red->color; - green = ent->co.shco.green->color; - blue = ent->co.shco.blue->color; - } else { - red = ent->co.local.red; - green = ent->co.local.green; - blue = ent->co.local.blue; - } - - colors[i - first_color] = (0xFF000000UL - | ((uint32_t) red & 0xff00) << 8 - | (green & 0xff00) - | (blue >> 8)); + int last, i; + ColormapPtr map; + + map = RootlessGetColormap(pScreen); + if (map == NULL || map->class != PseudoColor) + return FALSE; + + last = min(map->pVisual->ColormapEntries, first_color + n_colors); + for (i = max(0, first_color); i < last; i++) { + Entry *ent = map->red + i; + uint16_t red, green, blue; + + if (!ent->refcnt) + continue; + if (ent->fShared) { + red = ent->co.shco.red->color; + green = ent->co.shco.green->color; + blue = ent->co.shco.blue->color; + } + else { + red = ent->co.local.red; + green = ent->co.local.green; + blue = ent->co.local.blue; + } + + colors[i - first_color] = (0xFF000000UL + | ((uint32_t) red & 0xff00) << 8 + | (green & 0xff00) + | (blue >> 8)); } - return TRUE; + return TRUE; } - /* * RootlessStartDrawing * Prepare a window for direct access to its backing buffer. * Each top-level parent has a Pixmap representing its backing buffer, * which all of its children inherit. */ -void RootlessStartDrawing(WindowPtr pWindow) +void +RootlessStartDrawing(WindowPtr pWindow) { ScreenPtr pScreen = pWindow->drawable.pScreen; WindowPtr top = TopLevelParent(pWindow); @@ -164,8 +165,7 @@ void RootlessStartDrawing(WindowPtr pWindow) GetScratchPixmapHeader(pScreen, winRec->width, winRec->height, top->drawable.depth, top->drawable.bitsPerPixel, - winRec->bytesPerRow, - winRec->pixelData); + winRec->bytesPerRow, winRec->pixelData); SetPixmapBaseToScreen(winRec->pixmap, top->drawable.x - bw, top->drawable.y - bw); @@ -173,55 +173,67 @@ void RootlessStartDrawing(WindowPtr pWindow) } curPixmap = pScreen->GetWindowPixmap(pWindow); - if (curPixmap == winRec->pixmap) - { - RL_DEBUG_MSG("Window %p already has winRec->pixmap %p; not pushing\n", pWindow, winRec->pixmap); + if (curPixmap == winRec->pixmap) { + RL_DEBUG_MSG("Window %p already has winRec->pixmap %p; not pushing\n", + pWindow, winRec->pixmap); } - else - { - PixmapPtr oldPixmap = dixLookupPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey); - if (oldPixmap != NULL) - { + else { + PixmapPtr oldPixmap = + dixLookupPrivate(&pWindow->devPrivates, + rootlessWindowOldPixmapPrivateKey); + if (oldPixmap != NULL) { if (oldPixmap == curPixmap) - RL_DEBUG_MSG("Window %p's curPixmap %p is the same as its oldPixmap; strange\n", pWindow, curPixmap); + RL_DEBUG_MSG + ("Window %p's curPixmap %p is the same as its oldPixmap; strange\n", + pWindow, curPixmap); else - RL_DEBUG_MSG("Window %p's existing oldPixmap %p being lost!\n", pWindow, oldPixmap); + RL_DEBUG_MSG("Window %p's existing oldPixmap %p being lost!\n", + pWindow, oldPixmap); } - dixSetPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey, curPixmap); + dixSetPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey, + curPixmap); pScreen->SetWindowPixmap(pWindow, winRec->pixmap); } } - /* * RootlessStopDrawing * Stop drawing to a window's backing buffer. If flush is true, * damaged regions are flushed to the screen. */ -static int RestorePreDrawingPixmapVisitor(WindowPtr pWindow, pointer data) +static int +RestorePreDrawingPixmapVisitor(WindowPtr pWindow, pointer data) { - RootlessWindowRec *winRec = (RootlessWindowRec*)data; + RootlessWindowRec *winRec = (RootlessWindowRec *) data; ScreenPtr pScreen = pWindow->drawable.pScreen; PixmapPtr exPixmap = pScreen->GetWindowPixmap(pWindow); - PixmapPtr oldPixmap = dixLookupPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey); - if (oldPixmap == NULL) - { + PixmapPtr oldPixmap = + dixLookupPrivate(&pWindow->devPrivates, + rootlessWindowOldPixmapPrivateKey); + if (oldPixmap == NULL) { if (exPixmap == winRec->pixmap) - RL_DEBUG_MSG("Window %p appears to be in drawing mode (ex-pixmap %p equals winRec->pixmap, which is being freed) but has no oldPixmap!\n", pWindow, exPixmap); + RL_DEBUG_MSG + ("Window %p appears to be in drawing mode (ex-pixmap %p equals winRec->pixmap, which is being freed) but has no oldPixmap!\n", + pWindow, exPixmap); } - else - { + else { if (exPixmap != winRec->pixmap) - RL_DEBUG_MSG("Window %p appears to be in drawing mode (oldPixmap %p) but ex-pixmap %p not winRec->pixmap %p!\n", pWindow, oldPixmap, exPixmap, winRec->pixmap); + RL_DEBUG_MSG + ("Window %p appears to be in drawing mode (oldPixmap %p) but ex-pixmap %p not winRec->pixmap %p!\n", + pWindow, oldPixmap, exPixmap, winRec->pixmap); if (oldPixmap == winRec->pixmap) - RL_DEBUG_MSG("Window %p's oldPixmap %p is winRec->pixmap, which has just been freed!\n", pWindow, oldPixmap); + RL_DEBUG_MSG + ("Window %p's oldPixmap %p is winRec->pixmap, which has just been freed!\n", + pWindow, oldPixmap); pScreen->SetWindowPixmap(pWindow, oldPixmap); - dixSetPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey, NULL); + dixSetPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey, + NULL); } return WT_WALKCHILDREN; } -void RootlessStopDrawing(WindowPtr pWindow, Bool flush) +void +RootlessStopDrawing(WindowPtr pWindow, Bool flush) { ScreenPtr pScreen = pWindow->drawable.pScreen; WindowPtr top = TopLevelParent(pWindow); @@ -237,7 +249,7 @@ void RootlessStopDrawing(WindowPtr pWindow, Bool flush) SCREENREC(pScreen)->imp->StopDrawing(winRec->wid, flush); FreeScratchPixmapHeader(winRec->pixmap); - TraverseTree(top, RestorePreDrawingPixmapVisitor, (pointer)winRec); + TraverseTree(top, RestorePreDrawingPixmapVisitor, (pointer) winRec); winRec->pixmap = NULL; winRec->is_drawing = FALSE; @@ -252,7 +264,6 @@ void RootlessStopDrawing(WindowPtr pWindow, Bool flush) } } - /* * RootlessDamageRegion * Mark a damaged region as requiring redisplay to screen. @@ -296,16 +307,20 @@ RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion) /* Damaged region only has a single rect, so we can just compare that against the region */ - in = RegionContainsRect(&pWindow->borderClip, - RegionRects (pRegion)); + in = RegionContainsRect(&pWindow->borderClip, RegionRects(pRegion)); if (in == rgnIN) { - /* clip totally contains pRegion */ - - SCREENREC(pWindow->drawable.pScreen)->imp-> - DamageRects(winRec->wid, - RegionNumRects(pRegion), - RegionRects(pRegion), - -winRec->x, -winRec->y); + /* clip totally contains pRegion */ + + SCREENREC(pWindow->drawable.pScreen)->imp->DamageRects(winRec-> + wid, + RegionNumRects + (pRegion), + RegionRects + (pRegion), + -winRec-> + x, + -winRec-> + y); RootlessQueueRedisplay(pTop->drawable.pScreen); goto out; @@ -322,24 +337,26 @@ RootlessDamageRegion(WindowPtr pWindow, RegionPtr pRegion) RegionNull(&clipped); RegionIntersect(&clipped, &pWindow->borderClip, pRegion); - SCREENREC(pWindow->drawable.pScreen)->imp-> - DamageRects(winRec->wid, - RegionNumRects(&clipped), - RegionRects(&clipped), - -winRec->x, -winRec->y); + SCREENREC(pWindow->drawable.pScreen)->imp->DamageRects(winRec->wid, + RegionNumRects + (&clipped), + RegionRects + (&clipped), + -winRec->x, + -winRec->y); RegionUninit(&clipped); RootlessQueueRedisplay(pTop->drawable.pScreen); } -out: + out: #ifdef ROOTLESSDEBUG { BoxRec *box = RegionRects(pRegion), *end; int numBox = RegionNumRects(pRegion); - for (end = box+numBox; box < end; box++) { + for (end = box + numBox; box < end; box++) { RL_DEBUG_MSG("Damage rect: %i, %i, %i, %i\n", box->x1, box->x2, box->y1, box->y2); } @@ -348,7 +365,6 @@ out: return; } - /* * RootlessDamageBox * Mark a damaged box as requiring redisplay to screen. @@ -363,10 +379,9 @@ RootlessDamageBox(WindowPtr pWindow, BoxPtr pBox) RootlessDamageRegion(pWindow, ®ion); - RegionUninit(®ion); /* no-op */ + RegionUninit(®ion); /* no-op */ } - /* * RootlessDamageRect * Mark a damaged rectangle as requiring redisplay to screen. @@ -390,10 +405,9 @@ RootlessDamageRect(WindowPtr pWindow, int x, int y, int w, int h) RootlessDamageRegion(pWindow, ®ion); - RegionUninit(®ion); /* no-op */ + RegionUninit(®ion); /* no-op */ } - /* * RootlessRedisplay * Stop drawing and redisplay the damaged region of a window. @@ -404,7 +418,6 @@ RootlessRedisplay(WindowPtr pWindow) RootlessStopDrawing(pWindow, TRUE); } - /* * RootlessRepositionWindows * Reposition all windows on a screen to their correct positions. @@ -425,7 +438,6 @@ RootlessRepositionWindows(ScreenPtr pScreen) } } - /* * RootlessRedisplayScreen * Walk every window on a screen and redisplay the damaged regions. |