Dmitry Gutov writes: > Hi! > > Thanks for the report. > > On 14.06.2022 23:17, miha--- via Bug reports for GNU Emacs, the Swiss > army knife of text editors wrote: >> To reproduce, customize pop-up-frames to non-nil and set up your window >> manager such that it doesn't automatically set input focus on newly >> created frames. > > TBH I'm not sure how to setup GNOME Shell to do this. > >> Now in an xref-mode buffer, press RET on a search result >> (xref-goto-xref) and notice that the newly created frame doesn't receive >> input focus. That is because xref-goto-xref uses `display-buffer', >> followed by a `select-window'. >> >> To contrast this behaviour with grep-mode, pressing RET in a grep-mode >> buffer (compile-goto-error) does set input focus to the newly created >> frame. That is because compile-goto-error uses `pop-to-buffer`, which >> also calls `select-frame-set-input-focus'. > > Window management in Emacs is a tricky business, and the current > implementation is a result of https://debbugs.gnu.org/28814 which > implemented a particular kind of behavior and > https://debbugs.gnu.org/33870 which did try to make it more customizable > through display-buffer-alist. See both discussions for more detail. > > I don't have the time at the moment to try to rework it myself. > > Patches welcome, though. But please mind the original implementation > intent. Please see the attached patch. The only thing it adds is setting frame input focus if necessary before calling `select-window'. Other behaviour should remain the same as before. (The code and the comment is lifted from the function `pop-to-buffer'.) Best regards.