Unified X11 window event mask modification code