Subject: bug#40639: 26.3; Child frame border color not rendered when child frame has no minibuffer

From: martin rudalics <[email-masked]>
Date: Wed, 15 Apr 2020 19:20:45 +0200

> Starting from emacs -q run this:
 >
 > (set-face-background 'internal-border "red")
 > (select-window
 >   (display-buffer-in-child-frame
 >    (get-buffer-create "*scratch*")
 >    '((child-frame-parameters
 >       .
 >       ((left . 100)
 >        (top  . 100)
 >        (height . 10)
 >        (width . 100)
 >        (minibuffer . nil)
 >        (internal-border-width . 300))))))
 >
 > The child frame will pop up and its large border covers a large parts of
 > the buffer, but it is the same color as the background, not the red we
 > have set above. The only way I found to fix the color is to click on the
 > child frame. Calling the likes of select-frame, x-focus-frame,
 > select-frame-set-input-focus does not help. When the minibuffer
 > parameter is set to t the border is drawn as expected.
 >
 > If the call to select-window is left out the border will have the wrong
 > color regardless of minibuffer setting. Clicking the child frame will
 > likewise change it to red.
 >
 > It could be that this is related to my unorthodox wm setup: I am running
 > xfce with i3wm replacing xfwm4.

I'm aware of this bug and see it frequently when debugging child frame
issues.  Unfortunately, I don't know what's causing it because I have no
idea how face remapping is supposed to work internally.  What happens is
that when x_clear_under_internal_border runs this part

       int face_id =
	!NILP (Vface_remapping_alist)
	? lookup_basic_face (NULL, f, INTERNAL_BORDER_FACE_ID)
	: INTERNAL_BORDER_FACE_ID;
       struct face *face = FACE_FROM_ID_OR_NULL (f, face_id);

       block_input ();

       if (face)
	{
	  unsigned long color = face->background;

the value of color for a new normal frame is for a few calls white but
switches to red before the frame appears on the display.  A child frame
usually must be explicitly focused before its border becomes red (I
don't necessarily need the mouse for that purpose, C-x 5 o works too).

Maybe our experts in face remapping have an idea.

martin