Fixed X11 synchronization when message queue is

enabled and synchronize access to the 'waiting_for_input' variable