Subject: Re: bug#43672: 28.0.50; select-frame-set-input-focus does not set focus first time called

From: martin rudalics <[email-masked]>
Date: Mon, 28 Sep 2020 19:59:08 +0200

> When calling
 >
 >        (select-frame-set-input-focus some-frame)
 >
 > the frame is raised, but does not recieve the focus. I have to call
 > twice to 'select-frame-set-input-focus' for the frame to get
 > focused. Docs says "focused if possible", so I am not sure if it some
 > bug or/and how much does it depend on my window manager used; but
 > calling it twice consecutively works.
 >
 > I have attached an example code. To reproduce, emacs -Q, an eval
 > attached code.

These two settings don't make much sense

           (child-frame (make-frame   '((visible . 0)
                                        (undecorated . 0)

For the moment let's stick to the simpler

(defvar child-frame nil)

(defun make-child-frame ()
   (interactive)
   (setq child-frame
	(make-frame `((parent-frame . ,(selected-frame))
		      (left . 10)
		      (top . 10)
		      (width . 20)
		      (height . 10))))
   (select-frame-set-input-focus child-frame))

(defun delete-child-frame ()
   (interactive)
   (delete-frame child-frame))

If you call 'make-child-frame', does the child frame get selected?

If not, we have to try some workaround, maybe a (sit-for 0) before the
'select-frame-set-input-focus' call.

martin