problem with xlib binding

Frederik Eaton frederik at a5.repetae.net
Sat May 7 16:05:12 EDT 2005


Hi,

Hmm, have the new xlib bindings been tested? For instance, when I run
the following program:

----------------------------------------------------------------
module Main where

import Graphics.X11.Xlib
import Graphics.X11.Xlib.Display

main :: IO ()
main = do
    display <- openDisplay ""
    root <- rootWindow display $ defaultScreen display
    getGeometry display root
    closeDisplay display
    return ()
----------------------------------------------------------------

It prints out:

xtest: user error (Error bad status 1 raised in function getGeometry)

>From the code it looks like the haskell getGeometry is calling
XGetGeometry - which has type

Status XGetGeometry(...)

- and interpreting the 1 return value as an error (via the internal
wrapper 'throwUnlessSuccess' which takes 0 for success).

But the Xlib Programming Manual says "Some errors, such as failure to
open a font, are indicated by return values of type Status on the
appropriate routine ... The returned values are *zero* on failure and
*nonzero* on success." (emphasis added)

So unless I'm really misinterpreting things, the binding to each and
every one of the 13 functions that uses 'throwUnlessSuccess' is wrong.

Well, before I realized this I'd gone ahead and written a reasonably
significant program against the binding assuming that at least the
basics would work, but it seems there is some distance to go before
the library is usable. One would think that with a "Stability:
provisional" library every function has been run successfully at least
once, but I can't imagine that this is the case here. Is there even a
working Haskell equivalent of 'basicwin' from the Xlib Programming
Manual to test things out? This would also be a helpful example for
users.

Regards,

Frederik

-- 
http://ofb.net/~frederik/


More information about the Libraries mailing list