Hmm, I think I now know how to work with XEventPtr's with allocaXEvent event, what I have now is this:
raiseWin :: Win -> IO ();
raiseWin w = let {
d = disp w;
r = root w;
xID = xid w;
} in
do {
ctime <- Monad.liftM (\(Time.TOD t _) -> fromIntegral t) Time.getClockTime;
atom <- Xlib.Atom.internAtom d "_NET_ACTIVE_WINDOW" True;
Xlib.Event.allocaXEvent $ \ePtr -> do {
Xlib.Extras.setEventType ePtr XTypes.clientMessage;
Xlib.Extras.setClientMessageEvent ePtr xID atom 32 2 ctime;
Xlib.Event.sendEvent d r False
(Xlib.substructureNotifyMask .|. Xlib.substructureRedirectMask) ePtr;
};
};
where root in the Win record is derived from:
(root, parent, _)
<- Xlib.Extras.queryTree d xid;
The code compiles and type checks, it just doesn't... work, it does nothing. Replacing the code with:
raiseWin w =
System.Process.rawSystem "xdotool" ["windowactivate", show x] >> return () where {
x = xid w;
}
Makes it work without errors, inspecting the code of xdotool makes it reveal to use the "_NET_ACTIVE_WINDOW" client message to the root hole? Any idea what I could be doing wrongly, is this the correct root window?