x11 drawing logic