This sounds like a bug that was fixed some time ago - the desktop window is stealing focus when it gets created, so every time the display reconnects to the PC.
Because you're on Debian with Plasma 5.27.5, you don't have that fix though.
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
This sounds like a bug that was fixed some time ago - the desktop window is stealing focus when it gets created, so every time the display reconnects to the PC.
Because you're on Debian with Plasma 5.27.5, you don't have that fix though.
Update: no luck. I tried with every level of stealing focus prevention, but after a few hours Kodi it's still losing focus. Guess I'll stick with X11 for the time being.
KDE does have focus stealing prevention, Have you messed with that at all? https://docs.kde.org/stable5/en/kwin/kcontrol/windowbehaviour/index.html#focus-focusstealing The only thing I can think of is maybe some notification steals the focus and doesnt give it back to the window.
No, but I will give it a try. Thanks for the suggestion.
Does anyone have any clue?
My best guess would be some relatively passive notification stealing focus.
As reddeadhead mentioned, there's specific "don't steal focus" settings. I've had good luck with them.