Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does getWindowProperty32 return IO (Maybe [CLong]) #79

Closed
ss7m opened this issue Sep 5, 2021 · 2 comments
Closed

Why does getWindowProperty32 return IO (Maybe [CLong]) #79

ss7m opened this issue Sep 5, 2021 · 2 comments

Comments

@ss7m
Copy link

ss7m commented Sep 5, 2021

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).

@liskin
Copy link
Member

liskin commented Sep 5, 2021

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.

@ss7m
Copy link
Author

ss7m commented Sep 5, 2021

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.)

@ss7m ss7m closed this as completed Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants