<div dir="ltr">Ah, that's what I get for trying to hastily port a larger set of changes by hand.  I'll re-make the patch with your excellent suggestions. <div><br></div><div>My event getter calls select(2) on both the display's FD and a pipe.  The pipe has a byte written when a queue has a closure on it, which the event getter runs with the X state.  <<a href="https://github.com/lally/config/blob/xmonad-cairo/xmonad/Support/Launch.hs#L184">https://github.com/lally/config/blob/xmonad-cairo/xmonad/Support/Launch.hs#L184</a>>  Another thread runs a local webserver, with the hope to let other apps pull JSON state descriptions of what windows are where (with some x property tagging) to try and attach semantics to the windows.  </div><div><br></div><div>As Brandon says, it's mostly about getting select(2) to wait on more than 1 fd at a time.</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 26, 2015 at 11:24 AM, adam vogt <span dir="ltr"><<a href="mailto:vogt.adam@gmail.com" target="_blank">vogt.adam@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Lally,<br>
<br>
I think the way you're proposing a change is just fine.<br>
<br>
Does your patch work properly for you? You left out a call to<br>
nextEvent which xmonad currently does. I would have written:<br>
<br>
defaultEventGetter :: XEventPtr -> X Event<br>
defaultEventGetter evPtr = do<br>
 d <- asks display<br>
 io $ do<br>
    nextEvent d evPtr<br>
    getEvent evPtr<br>
<br>
Secondly, I would have added eventGetter as a field in XConfig, since<br>
it doesn't scale to have<br>
<br>
xmonad<br>
xmonad'<br>
xmonad''<br>
<br>
etc. functions.<br>
<br>
Finally, do you have an example of something you can do with the<br>
eventGetter that cannot be done with handleEventHook?<br>
<br>
<br>
Regards,<br>
Adam<br>
<div><div class="h5"><br>
On Thu, Feb 26, 2015 at 10:29 AM, Lally Singh <<a href="mailto:lally.singh@gmail.com">lally.singh@gmail.com</a>> wrote:<br>
> Hello!<br>
><br>
>  Please tell me what you think, of both the patch and the process I'm<br>
> sending this in-by.  First time for both.<br>
><br>
> Thanks!<br>
><br>
> 1 patch for repository <a href="http://code.haskell.org/xmonad" target="_blank">http://code.haskell.org/xmonad</a>:<br>
><br>
> Thu Feb 26 10:22:06 EST 2015  <a href="mailto:lally.singh@gmail.com">lally.singh@gmail.com</a><br>
>   * Split out the X event get function from xmonad.<br>
><br>
>   This lets xmonad users specify their own functions that get the next X<br>
> event,<br>
>   and consequently have access to the Display and run in xmonad's thread.<br>
> Useful<br>
>   for providing such access to other threads.<br>
><br>
><br>
><br>
> New patches:<br>
><br>
> [Split out the X event get function from xmonad.<br>
> <a href="mailto:lally.singh@gmail.com">lally.singh@gmail.com</a>**20150226152206<br>
>  Ignore-this: de10517364b9c642552ff62ebb614d28<br>
><br>
>  This lets xmonad users specify their own functions that get the next X<br>
> event,<br>
>  and consequently have access to the Display and run in xmonad's thread.<br>
> Useful<br>
>  for providing such access to other threads.<br>
><br>
> ] {<br>
> hunk ./src/XMonad/Main.hs 49<br>
>  -- The main entry point<br>
>  --<br>
>  xmonad :: (LayoutClass l Window, Read (l Window)) => XConfig l -> IO ()<br>
> -xmonad initxmc = do<br>
> +xmonad initxmc = xmonad' defaultEventGetter initxmc<br>
> +<br>
> +-- | Default X event getter.<br>
> +defaultEventGetter :: Display -> XEventPtr -> X Event<br>
> +defaultEventGetter _ = io . getEvent<br>
> +<br>
> +-- | Actual entry point, with a parameter for the X event getter.  The<br>
> getter<br>
> +-- has access to the X event loop.<br>
> +xmonad' :: (LayoutClass l Window, Read (l Window)) => (Display -> XEventPtr<br>
> -> X Event) -> XConfig l -> IO ()<br>
> +xmonad' eventGetter initxmc = do<br>
>      -- setup locale information from environment<br>
>      setLocale LC_ALL Nothing<br>
>      -- ignore SIGPIPE and SIGCHLD<br>
> hunk ./src/XMonad/Main.hs 158<br>
>              userCode $ startupHook initxmc<br>
><br>
>              -- main loop, for all you HOF/recursion fans out there.<br>
> -            forever $ prehandle =<< io (nextEvent dpy e >> getEvent e)<br>
> +            forever $ prehandle =<< eventGetter dpy e<br>
><br>
>      return ()<br>
>        where<br>
> }<br>
><br>
><br>
</div></div>> _______________________________________________<br>
> xmonad mailing list<br>
> <a href="mailto:xmonad@haskell.org">xmonad@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad</a><br>
><br>
</blockquote></div><br></div>