DerKoun / bsnes-hd

bsnes fork that adds HD video features
GNU General Public License v3.0
624 stars 35 forks source link

Check result of reading _NET_WORKAREA before using #102

Open gridbugs opened 2 years ago

gridbugs commented 2 years ago

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.

DerKoun commented 2 years ago

I'll likely merge this with the next release