summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2004-08-15 00:43:39 +0000
committerKeith Packard <keithp@keithp.com>2004-08-15 00:43:39 +0000
commit943308517905d16bda1bb27cd745bd291a84dbf6 (patch)
tree7653867ea1f694805a57d2bfb714d865d0bb2969
parent597fdae93e6e1b7e4052097baf3d91e7a134c162 (diff)
Redraw window borders when switching window pixmaps around
Make cw "own" the window pixmaps by wrapping GetWindowPixmap/SetWindowPixmap.
-rw-r--r--composite/compwindow.c20
-rw-r--r--miext/cw/cw.c39
-rw-r--r--miext/cw/cw.h12
-rw-r--r--miext/cw/cw_render.c12
4 files changed, 69 insertions, 14 deletions
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 314593f25..f630008a6 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -69,6 +69,23 @@ typedef struct _compPixmapVisit {
PixmapPtr pPixmap;
} CompPixmapVisitRec, *CompPixmapVisitPtr;
+static Bool
+compRepaintBorder (ClientPtr pClient, pointer closure)
+{
+ WindowPtr pWindow = LookupWindow ((XID) closure, pClient);
+
+ if (pWindow)
+ {
+ RegionRec exposed;
+
+ REGION_NULL(pScreen, &exposed);
+ REGION_SUBTRACT(pScreen, &exposed, &pWindow->borderClip, &pWindow->winSize);
+ (*pWindow->drawable.pScreen->PaintWindowBorder)(pWindow, &exposed, PW_BORDER);
+ REGION_UNINIT(pScreen, &exposed);
+ }
+ return TRUE;
+}
+
static int
compSetPixmapVisitWindow (WindowPtr pWindow, pointer data)
{
@@ -85,6 +102,9 @@ compSetPixmapVisitWindow (WindowPtr pWindow, pointer data)
*/
SetWinSize (pWindow);
SetBorderSize (pWindow);
+ if (HasBorder (pWindow))
+ QueueWorkProc (compRepaintBorder, serverClient,
+ (pointer) pWindow->drawable.id);
return WT_WALKCHILDREN;
}
diff --git a/miext/cw/cw.c b/miext/cw/cw.c
index 5867c3ec1..aa32033de 100644
--- a/miext/cw/cw.c
+++ b/miext/cw/cw.c
@@ -40,6 +40,7 @@
int cwGCIndex;
int cwScreenIndex;
+int cwWindowIndex;
#ifdef RENDER
int cwPictureIndex;
#endif
@@ -105,16 +106,16 @@ static GCFuncs cwCheapGCFuncs = {
DrawablePtr
cwGetBackingDrawable(DrawablePtr pDrawable, int *x_off, int *y_off)
{
- if (cwDrawableIsRedirWindow(pDrawable)) {
- WindowPtr pWin = (WindowPtr)pDrawable;
- PixmapPtr pPixmap = (*pDrawable->pScreen->GetWindowPixmap)(pWin);
+ PixmapPtr pPixmap;
+
+ if (pDrawable->type == DRAWABLE_WINDOW &&
+ (pPixmap = getCwPixmap ((WindowPtr) pDrawable)))
+ {
*x_off = pDrawable->x - pPixmap->screen_x;
*y_off = pDrawable->y - pPixmap->screen_y;
-
return &pPixmap->drawable;
} else {
*x_off = *y_off = 0;
-
return pDrawable;
}
}
@@ -727,6 +728,28 @@ cwCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
SCREEN_EPILOGUE(pScreen, CopyWindow, cwCopyWindow);
}
+static PixmapPtr
+cwGetWindowPixmap (WindowPtr pWin)
+{
+ PixmapPtr pPixmap = getCwPixmap (pWin);
+
+ if (!pPixmap)
+ {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ SCREEN_PROLOGUE(pScreen, GetWindowPixmap);
+ if (pScreen->GetWindowPixmap)
+ pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ SCREEN_EPILOGUE(pScreen, GetWindowPixmap, cwGetWindowPixmap);
+ }
+ return pPixmap;
+}
+
+static void
+cwSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
+{
+ setCwPixmap (pWindow, pPixmap);
+}
+
/* Screen initialization/teardown */
void
miInitializeCompositeWrapper(ScreenPtr pScreen)
@@ -739,6 +762,7 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
if (cwScreenIndex < 0)
return;
cwGCIndex = AllocateGCPrivateIndex();
+ cwWindowIndex = AllocateWindowPrivateIndex();
#ifdef RENDER
cwPictureIndex = AllocatePicturePrivateIndex();
#endif
@@ -746,6 +770,8 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
}
if (!AllocateGCPrivate(pScreen, cwGCIndex, 0))
return;
+ if (!AllocateWindowPrivate(pScreen, cwWindowIndex, 0))
+ return;
#ifdef RENDER
if (!AllocatePicturePrivate(pScreen, cwPictureIndex, 0))
return;
@@ -764,6 +790,9 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
SCREEN_EPILOGUE(pScreen, PaintWindowBorder, cwPaintWindowBorder);
SCREEN_EPILOGUE(pScreen, CopyWindow, cwCopyWindow);
+ SCREEN_EPILOGUE(pScreen, SetWindowPixmap, cwSetWindowPixmap);
+ SCREEN_EPILOGUE(pScreen, GetWindowPixmap, cwGetWindowPixmap);
+
#ifdef RENDER
if (GetPictureScreen (pScreen))
cwInitializeRender(pScreen);
diff --git a/miext/cw/cw.h b/miext/cw/cw.h
index 8c3cca64c..2e26e097e 100644
--- a/miext/cw/cw.h
+++ b/miext/cw/cw.h
@@ -60,10 +60,15 @@ typedef struct {
extern int cwPictureIndex;
+extern int cwWindowIndex;
+
+#define cwWindowPrivate(pWindow) ((pWindow)->devPrivates[cwWindowIndex].ptr)
+#define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow))
+#define setCwPixmap(pWindow,pPixmap) (cwWindowPrivate(pWindow) = (pointer) (pPixmap))
+
#define cwDrawableIsRedirWindow(pDraw) \
((pDraw)->type == DRAWABLE_WINDOW && \
- ((*(pDraw)->pScreen->GetWindowPixmap)((WindowPtr)(pDraw)) != \
- (*(pDraw)->pScreen->GetScreenPixmap)((pDraw)->pScreen)))
+ getCwPixmap((WindowPtr) (pDraw)) != NULL)
typedef struct {
/*
@@ -78,6 +83,9 @@ typedef struct {
PaintWindowBorderProcPtr PaintWindowBorder;
CopyWindowProcPtr CopyWindow;
+ GetWindowPixmapProcPtr GetWindowPixmap;
+ SetWindowPixmapProcPtr SetWindowPixmap;
+
#ifdef RENDER
DestroyPictureProcPtr DestroyPicture;
ChangePictureClipProcPtr ChangePictureClip;
diff --git a/miext/cw/cw_render.c b/miext/cw/cw_render.c
index ab698dca6..01e2bc468 100644
--- a/miext/cw/cw_render.c
+++ b/miext/cw/cw_render.c
@@ -65,9 +65,8 @@
static cwPicturePtr
cwCreatePicturePrivate (PicturePtr pPicture)
{
- ScreenPtr pScreen = pPicture->pDrawable->pScreen;
WindowPtr pWindow = (WindowPtr) pPicture->pDrawable;
- PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWindow);
+ PixmapPtr pPixmap = getCwPixmap (pWindow);
int error;
cwPicturePtr pPicturePrivate;
@@ -118,12 +117,11 @@ cwGetBackingPicture (PicturePtr pPicture, int *x_off, int *y_off)
if (pPicturePrivate)
{
DrawablePtr pDrawable = pPicture->pDrawable;
- ScreenPtr pScreen = pDrawable->pScreen;
- WindowPtr pWin = (WindowPtr) pDrawable;
- PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+ WindowPtr pWindow = (WindowPtr) pDrawable;
+ PixmapPtr pPixmap = getCwPixmap (pWindow);
- *x_off = pWin->drawable.x - pPixmap->screen_x;
- *y_off = pWin->drawable.y - pPixmap->screen_y;
+ *x_off = pDrawable->x - pPixmap->screen_x;
+ *y_off = pDrawable->y - pPixmap->screen_y;
return pPicturePrivate->pBackingPicture;
}