int focus_state
= focus_frame ? focus_frame->output_data.x->focus_state : 0;
- if (!((xi_event->evtype == XI_Enter
- || xi_event->evtype == XI_Leave)
- && (focus_state & FOCUS_EXPLICIT)))
+ if (!((((xi_event->evtype == XI_Enter
+ || xi_event->evtype == XI_Leave)
+ && (((XIEnterEvent *) xi_event)->detail
+ != XINotifyInferior)
+ && (focus_state & FOCUS_EXPLICIT))
+ || xi_event->evtype == XI_FocusIn
+ || xi_event->evtype == XI_FocusOut)))
x_focus_changed ((xi_event->evtype == XI_Enter
|| xi_event->evtype == XI_FocusIn
? FocusIn : FocusOut),