xmonad/X11

Shouldn't openDisplay take a Maybe String instead of a String?

jolmg opened this issue · 3 comments

jolmg commented

XOpenDisplay is documented to accept a NULL argument to indicate it should use the DISPLAY environment variable value[1]. It seems like that'd be the most common way to use it, so I'm a little surprised that it's not supported in this binding.

[1] https://www.x.org/releases/X11R7.7/doc/libX11/libX11/libX11.html#XOpenDisplay

Technically yes, but for whatever reason the binding was written to treat an empty string that way instead. As issues with the Haskell X11 bindings go, this is one of the more minor itches.

(History note: we inherited the X11 binding, it predates xmonad. Which is also why so much stuff is crammed into an Extras module, which originally was a separate package of additional functionality xmonad needed. Ideally the whole thing would be redone properly, including moving the contents of the Extras module to their proper places.)

jolmg commented

I see. I hadn't tried it out. I only saw the definition and since (nullPtr ==) <$> withCString "" return is False, I thought it wouldn't work with an empty string. On trying to open a window, I see it works though.

I guess XOpenDisplay also uses DISPLAY when the given string is empty.

jolmg commented

Yup, I've confirmed XOpenDisplay("") acts like XOpenDisplay(NULL).