xmonad / X11

A Haskell binding to the X11 graphics library.

Home Page:http://hackage.haskell.org/package/X11

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why does getWindowProperty32 return IO (Maybe [CLong])

ss7m opened this issue · comments

commented

On most machines, a CLong would be 64 bits rather than 32 bits. This causes issues where for any 32 bit property, getWindowProperty32 will be reading more bytes than are actually present. Sensible C types were chosen for getWindowProperty8 and getWindowProperty16, so I'm wondeirng if there's a reason to use CLong for 32 bit properties rather than CInt (or even something like Word32).

The XGetWindowProperty manpage says:

If the returned format is 32, the returned data is represented as a long array and should be cast to that type to obtain the elements.

so that probably explains why it's a CLong rather than a CInt. Lots of things in Xlib are long (and thus 64-bit on x64_64/amd64) even though they were meant to be 32-bit.

commented

I guess I should have RTFM. (Along with the authors of every code example I've seen where people use 32 bit integers for these properties.)