vdagent-x11: ensure no events are pending before returning to the main loop
vdagent-x11: ensure no events are pending before returning to the main loop

Note: Our event loop is only called when there is data to be read from the
X11 socket. If events have arrived and have already been read by libX11 from
the socket triggered by other libX11 calls from this file, the select for
read in the main loop, won't see these and our event loop won't get called!

Thus we must make sure that all queued events have been consumed, whenever
we return to the main loop. IOW all (externally callable) functions in this
file must end with calling XPending and consuming all queued events.

Calling XPending when-ever we return to the mainloop also ensures any
pending writes are flushed.

elmarco/vdagent-gtk,elmarco/vdagent-gtk,elmarco/vdagent-gtk