xmonad / X11

A Haskell binding to the X11 graphics library.
http://hackage.haskell.org/package/X11
Other
105 stars 48 forks source link

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

Closed jolmg closed 5 years ago

jolmg commented 5 years ago

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

geekosaur commented 5 years ago

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 5 years ago

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 5 years ago

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