+/* Return the desired face id for the mode line of a window, depending
+ on whether the window is selected or not, or if the window is the
+ scrolling window for the currently active minibuffer window.
+
+ Due to the way display_mode_lines manipulates with the contents of
+ selected_window, this macro needs three arguments: SELW which is
+ compared against the current value of selected_window, MBW which is
+ compared against minibuf_window (if SELW doesn't match), and SCRW
+ which is compared against Vminibuf_selected_window (if MBW matches). */
+
+#define CURRENT_MODE_LINE_FACE_ID_3(SELW, MBW, SCRW) \
+ ((!mode_line_in_non_selected_windows \
+ || (SELW) == XWINDOW (selected_window) \
+ || (minibuf_level > 0 \
+ && !NILP (Vminibuf_selected_window) \
+ && (MBW) == XWINDOW (minibuf_window) \
+ && (SCRW) == XWINDOW (Vminibuf_selected_window))) \
+ ? MODE_LINE_FACE_ID \
+ : MODE_LINE_INACTIVE_FACE_ID)
+
+
+/* Return the desired face id for the mode line of window W. */
+
+#define CURRENT_MODE_LINE_FACE_ID(W) \
+ (CURRENT_MODE_LINE_FACE_ID_3((W), XWINDOW (selected_window), (W)))
+