[Xmonad] darcs patch: NamedWindows: removed getClassHint that is the cause o...

Stefan O'Rear stefanor at cox.net
Thu Jul 12 02:06:14 EDT 2007

On Thu, Jul 12, 2007 at 07:55:40AM +0200, Andrea Rossato wrote:
> Hi,
> this patch soft of fixes the crash issue. It removes the work aroung I
> proposed for non latin window's names: using the reasourse name provided by
> getClassHint. This one is causing the problem. So, we need to fix this
> first.
> To XMonad core team: I don't know if this patch must be applied: probably it
> can be used by Tabbed users till when getClassHint is fixed. I don't know...
> you see!

Ah, getClassHint, one of the "extremely fishy functions from

data ClassHint = ClassHint
                        { resName  :: String
                        , resClass :: String

instance Storable ClassHint where
    sizeOf _ = #{size XClassHint}

    -- I really hope this is right too :) :
    alignment _ = alignment (undefined :: CInt)

    peek p = do
        p_res_name  <- (#{peek XClassHint, res_name}   p) :: IO CString
        p_res_class <- (#{peek XClassHint, res_class}  p) :: IO CString
        res_name    <- peekCString p_res_name
        res_class   <- peekCString p_res_class
        xFree p_res_name
        xFree p_res_class
        return $ ClassHint res_name res_class

getClassHint :: Display -> Window -> IO ClassHint
getClassHint d w 
    =  alloca $ \ p -> do
           xGetClassHint d w p
           peek p

foreign import ccall unsafe "XlibExtras.h XGetClassHint"
    xGetClassHint :: Display -> Window -> Ptr ClassHint -> IO Status

Giving peek side effects is just so *wrong* :)

According to my copy of the Xlib sources, those free calls are erroneous
if the window does not have a WM_CLASS property; xprop confirms this is
the case with glxgears.

(Now if only the manual described this corner case!  Having to look in
/usr/src/libx11-1.0.3/src/GetHints.c is a Bad Sign :) )

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/xmonad/attachments/20070711/bf9a21c7/attachment.bin

More information about the Xmonad mailing list