cocoa_common: handle all pending events instead of just one