summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston Sequoia <jeremyhu@apple.com>2023-01-01 10:57:46 -0800
committerJeremy Huddleston Sequoia <jeremyhu@apple.com>2023-01-20 17:10:54 +0000
commit16e7cdba489b7e419b3732cb56f26de2b71d3504 (patch)
treedaae7ba367ba9938b6f737671839a0231e803893
parent820b1dc461157b54fd49a787dbaf9d68a92debd9 (diff)
rootless: Use screen_x and screen_y instead of pixmap pointer hacks
This updates rootless to treat pixmaps consistently with COMPOSITE, using the screen_x and screen_y values rather than doing hacky math. This will allow for proper bounds checking on a given PixmapRec. Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
-rw-r--r--dix/dispatch.c2
-rw-r--r--exa/exa.c2
-rw-r--r--exa/exa_accel.c2
-rw-r--r--fb/fb.h2
-rw-r--r--fb/fbpixmap.c2
-rw-r--r--fb/fbwindow.c2
-rw-r--r--glamor/glamor_copy.c2
-rw-r--r--glamor/glamor_pixmap.c2
-rw-r--r--include/pixmapstr.h2
-rw-r--r--mi/miexpose.c2
-rw-r--r--miext/damage/damage.c8
-rw-r--r--miext/rootless/rootlessCommon.h18
-rw-r--r--miext/rootless/rootlessWindow.c12
-rw-r--r--present/present_scmd.c2
14 files changed, 28 insertions, 32 deletions
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 9c26753a9..efcec5c81 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -2182,7 +2182,7 @@ DoGetImage(ClientPtr client, int format, Drawable drawable,
PixmapPtr pPix = (*pDraw->pScreen->GetWindowPixmap) (pWin);
pBoundingDraw = &pPix->drawable;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
relx -= pPix->screen_x;
rely -= pPix->screen_y;
#endif
diff --git a/exa/exa.c b/exa/exa.c
index b16875845..42047fa2d 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -125,7 +125,7 @@ exaGetDrawablePixmap(DrawablePtr pDrawable)
void
exaGetDrawableDeltas(DrawablePtr pDrawable, PixmapPtr pPixmap, int *xp, int *yp)
{
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
if (pDrawable->type == DRAWABLE_WINDOW) {
*xp = -pPixmap->screen_x;
*yp = -pPixmap->screen_y;
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index e632331da..2a31bd3c7 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -963,7 +963,7 @@ exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
RegionInit(&rgnDst, NullBox, 0);
RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
if (pPixmap->screen_x || pPixmap->screen_y)
RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
#endif
diff --git a/fb/fb.h b/fb/fb.h
index 8ab050d0f..08143a0d4 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -441,7 +441,7 @@ typedef struct {
#define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
#define __fbPixDrawableY(pPix) ((pPix)->drawable.y)
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
#define __fbPixOffXWin(pPix) (__fbPixDrawableX(pPix) - (pPix)->screen_x)
#define __fbPixOffYWin(pPix) (__fbPixDrawableY(pPix) - (pPix)->screen_y)
#else
diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c
index af5d7bec0..89e3370a6 100644
--- a/fb/fbpixmap.c
+++ b/fb/fbpixmap.c
@@ -76,7 +76,7 @@ fbCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
fbInitializeDrawable(&pPixmap->drawable);
#endif
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
pPixmap->screen_x = 0;
pPixmap->screen_y = 0;
#endif
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index fca871d62..df33af948 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -116,7 +116,7 @@ fbCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
if (pPixmap->screen_x || pPixmap->screen_y)
RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
#endif
diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index 1ab2be6c0..fa2d783a1 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -781,7 +781,7 @@ glamor_copy_window(WindowPtr window, DDXPointRec old_origin, RegionPtr src_regio
RegionIntersect(&dst_region, &window->borderClip, src_region);
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
if (pixmap->screen_x || pixmap->screen_y)
RegionTranslate(&dst_region, -pixmap->screen_x, -pixmap->screen_y);
#endif
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 9aa169cdc..2c8cc3ba0 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -39,7 +39,7 @@ void
glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
int *x, int *y)
{
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
if (drawable->type == DRAWABLE_WINDOW) {
*x = -pixmap->screen_x;
*y = -pixmap->screen_y;
diff --git a/include/pixmapstr.h b/include/pixmapstr.h
index faf54fa4d..54fc26508 100644
--- a/include/pixmapstr.h
+++ b/include/pixmapstr.h
@@ -78,7 +78,7 @@ typedef struct _Pixmap {
int refcnt;
int devKind; /* This is the pitch of the pixmap, typically width*bpp/8. */
DevUnion devPrivate; /* When !NULL, devPrivate.ptr points to the raw pixel data. */
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
short screen_x;
short screen_y;
#endif
diff --git a/mi/miexpose.c b/mi/miexpose.c
index e54b18b30..6b6938a75 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -461,7 +461,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
tile_x_off = pWin->drawable.x;
tile_y_off = pWin->drawable.y;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
draw_x_off = pixmap->screen_x;
draw_y_off = pixmap->screen_y;
tile_x_off -= draw_x_off;
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index f3ae4ebbc..48e6af673 100644
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -142,7 +142,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
RegionRec pixClip;
int draw_x, draw_y;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
int screen_x = 0, screen_y = 0;
#endif
@@ -150,7 +150,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
if (!RegionNotEmpty(pRegion))
return;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
/*
* When drawing to a pixmap which is storing window contents,
* the region presented is in pixmap relative coordinates which
@@ -201,7 +201,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
draw_x = pDamage->pDrawable->x;
draw_y = pDamage->pDrawable->y;
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
/*
* Need to move everyone to screen coordinates
* XXX what about off-screen pixmaps with non-zero x/y?
@@ -274,7 +274,7 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
if (pDamageRegion == pRegion && (draw_x || draw_y))
RegionTranslate(pDamageRegion, draw_x, draw_y);
}
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
if (screen_x || screen_y)
RegionTranslate(pRegion, -screen_x, -screen_y);
#endif
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index d9a4d05e9..40400b395 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -226,20 +226,10 @@ extern RegionRec rootlessHugeRoot;
* Can't access the bits before the first word of the drawable's data in
* rootless mode, so make sure our base address is always 32-bit aligned.
*/
-#define SetPixmapBaseToScreen(pix, _x, _y) { \
- PixmapPtr _pPix = (PixmapPtr) (pix); \
- _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
- ((int)(_x) * _pPix->drawable.bitsPerPixel/8 + \
- (int)(_y) * _pPix->devKind); \
- if (_pPix->drawable.bitsPerPixel != FB_UNIT) { \
- size_t _diff = ((size_t) _pPix->devPrivate.ptr) & \
- (FB_UNIT / CHAR_BIT - 1); \
- _pPix->devPrivate.ptr = (char *) (_pPix->devPrivate.ptr) - \
- _diff; \
- _pPix->drawable.x = _diff / \
- (_pPix->drawable.bitsPerPixel / CHAR_BIT); \
- } \
-}
+#define SetPixmapBaseToScreen(pix, _x, _y) do { \
+ pix->screen_x = _x; \
+ pix->screen_y = _y; \
+} while(0)
// Returns TRUE if this window is visible inside a frame
// (e.g. it is visible and has a top-level or root parent)
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 0a2d9391a..643dedff6 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -705,11 +705,17 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
else {
RootlessStartDrawing(pWin);
- miCopyRegion((DrawablePtr) pWin, (DrawablePtr) pWin,
+ PixmapPtr pPixmap = pScreen->GetWindowPixmap(pWin);
+ DrawablePtr pDrawable = &pPixmap->drawable;
+
+ if (pPixmap->screen_x || pPixmap->screen_y) {
+ RegionTranslate(&rgnDst, -pPixmap->screen_x, -pPixmap->screen_y);
+ }
+
+ miCopyRegion(pDrawable, pDrawable,
0, &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
- /* prgnSrc has been translated to dst position */
- RootlessDamageRegion(pWin, prgnSrc);
+ RootlessDamageRegion(pWin, &rgnDst);
}
out:
diff --git a/present/present_scmd.c b/present/present_scmd.c
index 46fd9a1fd..200ded348 100644
--- a/present/present_scmd.c
+++ b/present/present_scmd.c
@@ -137,7 +137,7 @@ present_check_flip(RRCrtcPtr crtc,
/* Does the window match the pixmap exactly? */
if (window->drawable.x != 0 || window->drawable.y != 0 ||
-#ifdef COMPOSITE
+#if defined(COMPOSITE) || defined(ROOTLESS)
window->drawable.x != pixmap->screen_x || window->drawable.y != pixmap->screen_y ||
#endif
window->drawable.width != pixmap->drawable.width ||