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

rawGetWindowProperty should perhaps return an array instead of a list #52

Open
colonelpanic8 opened this issue May 12, 2017 · 3 comments

Comments

@colonelpanic8
Copy link
Contributor

for very large properties such as "_NET_WM_ICON" lists can be slow enough that it makes certain things unfeasible.

@mgkurtz
Copy link

mgkurtz commented Apr 27, 2024

A compatible solution could be to provide a more generic

peekWindowProperty  Storable a  (Int  Ptr a  IO b)  Int  Display  Atom  Window  IO (Maybe b)
peekWindowProperty peekFunction bits d atom w =
    -- Implementation like current implementation of `rawGetWindowProperty`,
    -- but with `peekArray` replaced by `peekFunction`.

rawGetWindowProperty  Storable a  Int  Display  Atom  Window  IO (Maybe [a])
rawGetWindowProperty = peekWindowProperty peekArray

This could then be used with Data.StorableVector.peek or a function based on Data.Vector.Storable.unsafeFromForeignPtr0. The same interface would also allow to use Foreign.C.String.peekCStringLen to obtain a String directly.

@mgkurtz
Copy link

mgkurtz commented Apr 28, 2024

A probably more natural solution would be to directly return the pointer to the data and the data’s length as in

getWindowPropertyPtr  Storable a  Int  Display  Atom  Window  IO (Maybe (ForeignPtr a, Int))

with xFree registered as finalizer for the returned pointer.

@colonelpanic8
Copy link
Contributor Author

@mgkurtz yeah i think I prefer the second option you preferred here.

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