Wayland is even more strict, you ask it for screen sharing and it gives you the stream. If the compositor doesn't support screen sharing you're out of luck, there's just no way to read the contents of a window.
With X11 if the window manager doesn't have the relevant support you can always ask the server.