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

setClientMessageEvent doesn't call setEventType

nponeccop opened this issue · comments

So the type field remains zero and the function doesn't work as intended.

Also the types are terribly wrong. Here is a working example:

goFullScreen :: XID -> IO ()
goFullScreen xid = do
                display <- openDisplay ":0.0"
                let root = defaultRootWindow display
                stateAtom <- internAtom display "_NET_WM_STATE" False
                fsAtom <- internAtom display "_NET_WM_STATE_FULLSCREEN" False
                allocaXEvent $ \event -> do
                        setEventType event clientMessage
                        setClientMessageEvent event xid stateAtom 32 1 fsAtom
                        sendEvent display root False (substructureNotifyMask .|. substructureRedirectMask) event
                       return ()

Note that setEventType should have been inside setClientMessageEvent as it's the case with other setXxxEvent functions.

1 and fsAtom are passed as last 2 arguments, clearly they are not Atom and Time. Originally they are all uniformly long and there are more than 2 of them. A proper fix IMO would be to replace the single function with 3 separate in the spirit of changeProperty8/16/32 and get rid of extra parameters like format.

Er? You say other setXxxEvent functions set the event type, but they don't from my reading of the source, and from looking through the xmonad code it looks like every place a setXxxEvent is called there's also a setEventType call. So I wouldn't want to change setClientMessageEvent unless we changed all the other setXxxEvent functions as well.

As for the types, yes, these X11 bindings are very untyped. I'm open to applying a patch that adds some newtype goodness if you're up for it.

It turned out that the function I looked at (setSelectionNotify) is the only setXxxEvent function that does call setEventType. It is also inconsistently doesn't follow the common naming convention - it sets XSelectionEvent but it isn't called setSelectionEvent.