Check result of reading _NET_WORKAREA before using #102
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It seems like not all window managers set _NET_WORKAREA. For example in
dwm this property isn't set when X first starts (but running certain
graphical applications such as firefox seem to cause the property to
become set). This change prevents a crash when bsnes is run in an
environment where _NET_WORKAREA has not been set.
Prior to this change, running bsnes as the first program under the dwm
window manager would result in the following error:
The program 'hiro' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadAtom (invalid Atom parameter)'.
This was the result of calling XGetWindowProperty with an Atom which
does not name a defined Atom.
Reproducing/Testing
I can reliably reproduce the problem on an Archlinux machine and on a NixOS machine, both using dwm as their window manager. In a fresh X session, running bsnes consistently results in the aforementioned crash. After launching a graphical application such as firefox, bsnes starts without error.
I've tried reproducing the problem on a ubuntu machine with xfce4 as its wm. Launching bsnes in a fresh X session works. I assume this is because xfce4 implements _NET_WORKAREA.