On second thought, skip this section. It seems to break things, possibly
via a stack overflow (it seems my assumption that XCheckTypedWindowEvent
wouldn't touch ev except with the searched event type is wrong, or else
my assumption that handleShapeNotify() is only called with shape events
is wrong).
> diff --git a/src/event.c b/src/event.c
> index 6f51a76..7b58f1d 100644
> --- a/src/event.c
> +++ b/src/event.c
> @@ -1159,16 +1159,14 @@ static void handleShapeNotify(XEvent * event)
> {
> XShapeEvent *shev = (XShapeEvent *) event;
> WWindow *wwin;
> - XEvent ev;
> -
> - while (XCheckTypedWindowEvent(dpy, shev->window, event->type, &ev)) {
> - XShapeEvent *sev = (XShapeEvent *) & ev;
> + XShapeEvent ev;
>
> - if (sev->kind == ShapeBounding) {
> - if (sev->shaped == shev->shaped) {
> - *shev = *sev;
> + while (XCheckTypedWindowEvent(dpy, shev->window, event->type, (XEvent
> *)&ev)) {
> + if (ev.kind == ShapeBounding) {
> + if (ev.shaped == shev->shaped) {
> + *shev = ev;
> } else {
> - XPutBackEvent(dpy, &ev);
> + XPutBackEvent(dpy, (XEvent *)&ev);
> break;
> }
> }
The issue here is that C99 strict aliasing rules prohibit the
"XShapeEvent *sev = (XShapeEvent *) & ev" construct to allow certain
compiler optimizations. We could compile with -fno-strict-aliasing
(which disables those optimizations), or we could make the aliasing
explicit with a union as in the attached patch. I guess this sort of
ad-hoc union is the "correct" way to handle X events that aren't
included in the core XEvent union in C99.
diff --git a/src/event.c b/src/event.c
index 6f51a76..46e2ea9 100644
--- a/src/event.c
+++ b/src/event.c
@@ -1159,16 +1159,17 @@ static void handleShapeNotify(XEvent * event)
{
XShapeEvent *shev = (XShapeEvent *) event;
WWindow *wwin;
- XEvent ev;
-
- while (XCheckTypedWindowEvent(dpy, shev->window, event->type, &ev)) {
- XShapeEvent *sev = (XShapeEvent *) & ev;
-
- if (sev->kind == ShapeBounding) {
- if (sev->shaped == shev->shaped) {
- *shev = *sev;
+ union {
+ XEvent xevent;
+ XShapeEvent xshape;
+ } ev;
+
+ while (XCheckTypedWindowEvent(dpy, shev->window, event->type,
&ev.xevent)) {
+ if (ev.xshape.kind == ShapeBounding) {
+ if (ev.xshape.shaped == shev->shaped) {
+ *shev = ev.xshape;
} else {
- XPutBackEvent(dpy, &ev);
+ XPutBackEvent(dpy, &ev.xevent);
break;
}
}