>> Hmm, that is actually less effect than I expected. I recall now that >> some non-relevant MapNotify events get sent in this case [1]. These >> make x_wait_for_event (f, MapNotify) return earlier than the previous >> busy wait. I should check my assumptions more carefully, the problem was actually that I didn't set the timeout correctly; the whole seconds part was being dropped. Fixed with the following (full patches are attached as well). - tmo = make_timespec (0, (long int) (timeout * 1000 * 1000 * 1000)); + time_t timeout_seconds = (time_t) timeout; + tmo = make_timespec + (timeout_seconds, (long int) ((timeout - timeout_seconds) + * 1000 * 1000 * 1000)); And here are the resulting timings (the last is less than 100 because I got bored of waiting). (let ((x-wait-for-event-timeout nil)) (benchmark 1 '(make-frame-command)))"Elapsed time: 0.117144s (0.042904s in 1 GCs)" (let ((x-wait-for-event-timeout 0.1)) ; default (benchmark 1 '(make-frame-command)))"Elapsed time: 0.210824s (0.043483s in 1 GCs)" (let ((x-wait-for-event-timeout 100.0)) (benchmark 1 '(make-frame-command)))"Elapsed time: 38.288529s (0.043459s in 1 GCs)" martin rudalics writes: > Shouldn't it work to wait only for VisibilityNotify events for the given > frame? Thanks for the nudge. Waiting for VisibilityNotify works too (after fixing the timeout bug), by the way, but it's MapNotify which has the Lisp visibile effect.