https://www.phoronix.com/scan.php?page=news_item&px=Chrome-8...
Native applications these days have the option to use pipewire and xdg-desktop-portal for screen-sharing, and it doesn't matter whether they use that from a Wayland window or an Xwayland window. Both Firefox (under Wayland) and Chromium (under Xwayland) use this method today.
Unfortunately Teams does not use that method and instead calls an X function directly, which crashes, as I wrote in the sibling comment.
To be able to maximize vncviewer you do need a compositor running under Xephyr too. I picked i3 to be the most minimal. Again, i3 can be told to run in the Xephyr window by setting `DISPLAY`.
One caveat is that I still use Teams under Wayland to join calls for the audio, so this setup means I need two Teams instances to join the same call. This works for meetings but not for individual calls. Of course if you want to use the Xephyr'd Teams to do audio too there shouldn't be any problem; I just prefer having easy access to the Teams window to mute myself, etc instead of having to reach into the Xephyr window and unmaximize the vncviewer window.
People on the #sway IRC channel on Freenode suggested an alternative might be to use v4l2loopback to create a "camera" device that is sourced from the screen and then have Teams use it as a webcam, but I couldn't get v4l2 to work on my distro (it kept insisting my distro's ffmpeg couldn't encode video even though it could) so I didn't investigate further.
Anyway, a less convoluted setup might be to use the browser version of Teams in a browser where it allows you to screen-share, ie Chromium and not Firefox. IIRC when I tried it a few months ago people on the call said they could only see me broadcasting a black screen, but I know the browser is fine so it had to have been a Teams issue. Maybe it's fixed now.
Hopefully these applications will catch up soon. As another example, Zoom's native Electron application uses a GNOME-specific method of screen-sharing which doesn't work in non-GNOME DEs, but I've heard the browser version works fine.
- An unofficial Teams app (https://github.com/IsmaelMartinez/teams-for-linux) which works great - screen sharing works without problems, no crashing, and native notifications!.
- Use teams in qutebrowser: the dev (The-Compiler) added support for screensharing and it works great. Just like the unofficial app above, it also has native notifications, not the weird popup notifications of the official app.