As far as I know, this is not part of wayland core, namely you would need an specific and out of core wayland interface
AND a wayland compositor which supports such interface.
Go to the wayland authority repo for interfaces, see if there is such interface (there could be many in dev), then find a wayland compositor which supports such interface(s) (or code such compositor). Then write your app code to query if a wayland compositor supports such interface:
- if not, gracefully fail.
- if it does, screenshot your surfaces.
That said, it is more an internal feature of a wayland compositor itself. So it seems more appropriate that a wayland compositor supports or not such feature, and if so, optionaly allows an application to remote control of feature via a specific out-of-core wayland interface.
I would feel better if it stays into the wayland compositior without the possibility for an external apps to snapshot everything.
That said, you could fiddle with platform specific stuff to shorcut the wayland compositor (on linux, drm mode settings and framebuffers).