x11-xcb: lock window before checking dirtiness
cocoa: remove redundant code