W window has a _NET_WM_PID
property set by the applicaiton. To really validate if the application has set this correctly is more work (see reference).
Run command and click the window
$ xprop _NET_WM_PID
_NET_WM_PID(CARDINAL) = 11524
Get process info
$ ps -p 11524 -f
UID PID PPID C STIME TTY TIME CMD
a211278l 11524 1 1 11:10 tty2 00:00:06 /usr/bin/gnome-system-log