From 8c701832ea5bd2a8dbc2782a85f46867ab7e2187 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 20 Aug 2024 16:37:16 +0200 Subject: [PATCH] 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 --- hw/xnest/Screen.c | 2 +- hw/xnest/Window.c | 34 ---------------------------------- hw/xnest/XNWindow.h | 1 - 3 files changed, 1 insertion(+), 36 deletions(-) diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c index 51c32817e..279ba2431 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -344,7 +344,7 @@ breakout: pScreen->RealizeWindow = xnestRealizeWindow; pScreen->UnrealizeWindow = xnestUnrealizeWindow; pScreen->PostValidateTree = NULL; - pScreen->WindowExposures = xnestWindowExposures; + pScreen->WindowExposures = miWindowExposures; pScreen->CopyWindow = xnestCopyWindow; pScreen->ClipNotify = xnestClipNotify; pScreen->ClearToBackground = xnest_screen_ClearToBackground; diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c index 527dce153..4d02c1ced 100644 --- a/hw/xnest/Window.c +++ b/hw/xnest/Window.c @@ -391,40 +391,6 @@ xnestClipNotify(WindowPtr pWin, int dx, int dy) 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 xnestSetShape(WindowPtr pWin, int kind) { diff --git a/hw/xnest/XNWindow.h b/hw/xnest/XNWindow.h index 68b829711..db6491ebb 100644 --- a/hw/xnest/XNWindow.h +++ b/hw/xnest/XNWindow.h @@ -65,7 +65,6 @@ Bool xnestRealizeWindow(WindowPtr pWin); Bool xnestUnrealizeWindow(WindowPtr pWin); void xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion); void xnestClipNotify(WindowPtr pWin, int dx, int dy); -void xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn); void xnestSetShape(WindowPtr pWin, int kind); void xnestShapeWindow(WindowPtr pWin);