Closed slotThe closed 2 years ago
Will merge in a few days if no one objects
I haven't had time to go through the code in detail but the general idea looks all right, so don't expect me to object. There's also nothing stopping you from adding the safe alternatives to X11 if you feel that's right, but it'd mean some painful dependency bumps so it'd have to be worth it long-term.
There's also nothing stopping you from adding the safe alternatives to X11 if you feel that's right, but it'd mean some painful dependency bumps so it'd have to be worth it long-term.
Exactly; I think I'd only do this if I was actually planning on a safe API for X11 but I'm not really going to do anything close to that anytime soon
Description
Since X11 is unlikely to get safe bindings anytime soon, I figured this was better than nothing.
X.Prelude: Add safeGetWindowAttributes
Move the function from X.U.DebugWindow, where it was defined already. This is a safe version of getWindowAttributes, returning a Maybe instead of throwing an exception, in case the window attributes could not be retrieved.
Prefer safe alternatives to getWindowAttributes
Whenever possible, prefer the safe wrappers withWindowAttributes or safeGetWindowAttributes to getWindowAttributes.
Places where these are not applicable are limited to layouts, where there is not good "default value" to give back in case these calls fail. In these cases, we let the exception handling of the layout mechanism handle it and fall back to the Full layout.
Fixes: https://github.com/xmonad/xmonad-contrib/issues/146
Checklist
[x] I've read CONTRIBUTING.md
[x] I've considered how to best test these changes (property, unit, manually, ...) and concluded: it compiles...!
[ ] I updated the
CHANGES.md
file I'm not sure this warrants an entry since it's not a user-facing change.