Xnest: drop xnestWindowExposures micro-optimization

xnestWindowExposures() is a micro-optimization for the specific case that
a newly created window receives exposure events (from our upstream server)
inside the region we're already exposing on our own (miWindowExposures()):
it peeks the Xlib event queue for all expose events, checks whether their
areas are inside our exposure region and requeue's those that aren't.

Unfortunately, this depends on Xlib's internal queue mechamism, thus standing
in the way of moving to XCB (which doesn't have that).

Removing this doens't seem to make any practical difference, even with
demanding applications like GIMP. The only cost is potentially having some
initial window content painted twice, *if* the application really draws
something complicated right after creating the window.

*If* there'll really be a demand for such an optimization some day, it can
be reimplemented without any message queue: just redirecting all expose events
into recording them in a region, which is flushed out later. But for now,
there really doesn't seem to be any practical need for that.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-08-20 16:37:16 +02:00
parent 1f4cbdb448
commit 8c701832ea
3 changed files with 1 additions and 36 deletions

View File

@ -344,7 +344,7 @@ breakout:
pScreen->RealizeWindow = xnestRealizeWindow; pScreen->RealizeWindow = xnestRealizeWindow;
pScreen->UnrealizeWindow = xnestUnrealizeWindow; pScreen->UnrealizeWindow = xnestUnrealizeWindow;
pScreen->PostValidateTree = NULL; pScreen->PostValidateTree = NULL;
pScreen->WindowExposures = xnestWindowExposures; pScreen->WindowExposures = miWindowExposures;
pScreen->CopyWindow = xnestCopyWindow; pScreen->CopyWindow = xnestCopyWindow;
pScreen->ClipNotify = xnestClipNotify; pScreen->ClipNotify = xnestClipNotify;
pScreen->ClearToBackground = xnest_screen_ClearToBackground; pScreen->ClearToBackground = xnest_screen_ClearToBackground;

View File

@ -391,40 +391,6 @@ xnestClipNotify(WindowPtr pWin, int dx, int dy)
xnestShapeWindow(pWin); xnestShapeWindow(pWin);
} }
static Bool
xnestWindowExposurePredicate(Display * dpy, XEvent * event, XPointer ptr)
{
return (event->type == Expose && event->xexpose.window == *(Window *) ptr);
}
void
xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn)
{
XEvent event;
Window window;
BoxRec Box;
XSync(xnestDisplay, FALSE);
window = xnestWindow(pWin);
while (XCheckIfEvent(xnestDisplay, &event,
xnestWindowExposurePredicate, (char *) &window)) {
Box.x1 = pWin->drawable.x + wBorderWidth(pWin) + event.xexpose.x;
Box.y1 = pWin->drawable.y + wBorderWidth(pWin) + event.xexpose.y;
Box.x2 = Box.x1 + event.xexpose.width;
Box.y2 = Box.y1 + event.xexpose.height;
event.xexpose.type = ProcessedExpose;
if (RegionContainsRect(pRgn, &Box) != rgnIN)
XPutBackEvent(xnestDisplay, &event);
}
miWindowExposures(pWin, pRgn);
}
void void
xnestSetShape(WindowPtr pWin, int kind) xnestSetShape(WindowPtr pWin, int kind)
{ {

View File

@ -65,7 +65,6 @@ Bool xnestRealizeWindow(WindowPtr pWin);
Bool xnestUnrealizeWindow(WindowPtr pWin); Bool xnestUnrealizeWindow(WindowPtr pWin);
void xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion); void xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion);
void xnestClipNotify(WindowPtr pWin, int dx, int dy); void xnestClipNotify(WindowPtr pWin, int dx, int dy);
void xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn);
void xnestSetShape(WindowPtr pWin, int kind); void xnestSetShape(WindowPtr pWin, int kind);
void xnestShapeWindow(WindowPtr pWin); void xnestShapeWindow(WindowPtr pWin);