Because of C++'s operator precedence, '!' logically negated all_event_masks only instead of the whole expression.
This resulted in the condition always being false and XTest never being used.
Adding a pair of brackets fixes it.
BUG: 362941
BUG: 375017