Fix window locks to avoid deadlocks
Use a thread to run the xwindow event loop
Fix xwindow update and lock system
Remove unneeded XSync call