I am running :
fedora32
mate desktop environment
wayland
marco window manager
xterm
emacs -nw (text mode)
emacs dired+ mode
emacs "openwith" mode
When I start up "emacs -nw" in the xterm it uses "dired+" mode to give a directory listing. The emacs "openwith" package has associations for ".pdf" and other file extensions. What "openwith" does is when I put the cursor on a line in the directory listing and press "f" or "v" to find or view the file, openwith launches an external program (e.g. "okular") to view the pdf file.
The problem is that when the external program (e.g. "okular") exits,
the window manager focus does not return to the xterm running emacs.
This does not only happen with this pair of programs (xterm and okular).
In general, when you exit a program
(any program, not just one launched from emacs and xterm as described above),
you can not rely on the window focus returning to where you last were.
It is annoying.
I am pretty sure there used to be some kind of stack holding the window focus
so it would return to the previously focused windows in turn.
This problem is not present in mate with the compiz window manager, but that has other problems.