From 4d8ed3198825e2f46b1e79ff7bb4bd7ff5598f85 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 20 Aug 2024 16:37:16 +0200 Subject: [PATCH] (!1654) 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 a48e79dc2..49736c012 100644 --- a/hw/xnest/Screen.c +++ b/hw/xnest/Screen.c @@ -348,7 +348,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 8060553ac..06e4a5fd7 100644 --- a/hw/xnest/Window.c +++ b/hw/xnest/Window.c @@ -395,40 +395,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);