Depends on D5747.
Please note that the code you wrote will give you an incorrect PID for all XWayland windows. Instead of going through the ClientConnection I suggest to use KWin::Toplevel::pid(). That one returns the correct pid for all X windows. But it would crash for Wayland windows currently. So make this method virtual and override it in ShellClient and add the code for getting the pid from the surface in ShellClient.
Why was this change pushed although it had a "This has commit embargo till 5.10 is branched." comment? Yes I accepted it, but obviously the embargo still holds. Even more the commit builds up on changes in KWayland which are not pushed.
May I ask why it takes 4 h without anybody noticing that the commit broke the build? Does it have to be the maintainer who cleans up after an incorrect push?
Please note that I'm going to revert all changes which are built up on a broken API change in KWayland. We need to take quality serious, so if the KWayland regression doesn't get fixed asap I will have to revert everything.