frontend-tools: Fix crash on non X11 windowing systems
Description
On non X11 windowing systems OBS will crash when the automatic scene switcher is enabled and the current foreground window is changed due to invalid Window parameters being passed to various X11 functions:
X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 20 (X_GetProperty)
Resource id in failed request: 0x0
Serial number of failed request: 29
Current serial number in output stream: 29
Motivation and Context
Add error handling to avoid passing invalid windows to various X11 functions and thus crashes of OBS.
How Has This Been Tested?
OBS no longer crashes on Ubuntu 22 with the Wayland windowing system when the automatic scene switcher is enabled and the foreground window is changed.
The automatic scene switcher still works as expected on Ubuntu 22 with the X11 windowing system.
Types of changes
- Bug fix (non-breaking change which fixes an issue)
Checklist:
- [x] My code has been run through clang-format.
- [x] I have read the contributing document.
- [x] My code is not on the master branch.
- [x] The code has been tested.
- [x] All commit messages are properly formatted and commits squashed where appropriate.
- [ ] I have included updates to all appropriate documentation.
It seems like we should disable this whenever the obs_nix_get_platform is wayland, is there a specific reason you are not doing that instead?
It seems like we should disable this whenever the
obs_nix_get_platformis wayland, is there a specific reason you are not doing that instead?
Seems like a few windows are still supported in the automatic scene switcher even with Wayland as the active windowing system on Ubuntu. (For example, VS code)
Just guessing, but I assume those windows are likely using XWayland instead of Wayland directly.
So the tool might still have some, although rather limited, use.
Sounds fine to me, thanks.