File fvwm3-siebenmann.patch of Package fvwm3

https://github.com/fvwmorg/fvwm3/issues/818#issuecomment-1401144381

I'm currently running a fvwm3 built with this frankly terrifying
hack patch and it hasn't exploded and doesn't seem to have any of
the expose issues. Given the code duplication
(eg _fev_pred_check_peek_one() is a changed version of the original
just for the new FWeedAndHandleIfEvents) and other issues I wouldn't
even try to use this as is as a long term, maintainable change,
but maybe it can be useful as a starting point.

---
 libs/FEvent.c |   40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

--- libs/FEvent.c
+++ libs/FEvent.c	2025-09-10 08:37:24.312988826 +0000
@@ -153,6 +153,20 @@ static Bool _fev_pred_check_peek(
 	return False;
 }
 
+static Bool _fev_pred_check_peek_one(
+        Display *display, XEvent *event, XPointer arg)
+{
+	_fev_check_peek_args *cpa = (_fev_check_peek_args *)arg;
+
+	cpa->found = cpa->predicate(display, event, cpa->arg);
+	if (cpa->found == True)
+	{
+		cpa->event = *event;
+		return True;
+	}
+	return False;
+}
+
 static Bool _fev_pred_weed_if(Display *display, XEvent *event, XPointer arg)
 {
 	_fev_weed_args *weed_args = (_fev_weed_args *)arg;
@@ -534,20 +548,28 @@ int FWeedAndHandleIfEvents(
 	int (*handler) (Display *display, XEvent *event, XPointer arg),
 	XPointer arg)
 {
-	_fev_weed_args weed_args;
+	_fev_check_peek_args cpa;
 	XEvent e;
+	Bool found;
+	int count = 0;
 
 	assert(fev_is_invalid_event_type_set);
-	memset(&weed_args, 0, sizeof(weed_args));
-	weed_args.weed_predicate = weed_predicate;
-	weed_args.arg = arg;
-	if (FCheckPeekIfEvent(display, &e, _fev_pred_weed_if,
-			      (XPointer)&weed_args)) {
+	memset(&cpa, 0, sizeof(cpa));
+	cpa.predicate = weed_predicate;
+	cpa.arg = arg;
+	cpa.found = False;
+	do {
+		found = XCheckIfEvent(display, &e, _fev_pred_check_peek_one, (char *)&cpa);
+		if (!found) {
+			break;
+		}
+		count ++;
 		handler(display, &e, arg);
-	}
-	_fev_pred_weed_if_finish(&weed_args);
+		/* ... ?? cks */
+		fev_update_last_timestamp(&e);
+	} while(1);
 
-	return weed_args.count;
+	return count;
 }
 
 int FWeedIfWindowEvents(
openSUSE Build Service is sponsored by