[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmonad
Subject:    Re: [xmonad] darcs patch: Split out the X event get function from xmonad.
From:       Lally Singh <lally.singh () gmail ! com>
Date:       2015-02-26 22:36:05
Message-ID: CAFjuTDAY+Kpf6DUfGKDbbaQF+fJKT3-jfCCG=mmAR+yw+DHDXw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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.

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.  <
https://github.com/lally/config/blob/xmonad-cairo/xmonad/Support/Launch.hs#L184>
 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.

As Brandon says, it's mostly about getting select(2) to wait on more than 1
fd at a time.



On Thu, Feb 26, 2015 at 11:24 AM, adam vogt <vogt.adam@gmail.com> wrote:

> Hi Lally,
>
> I think the way you're proposing a change is just fine.
>
> Does your patch work properly for you? You left out a call to
> nextEvent which xmonad currently does. I would have written:
>
> defaultEventGetter :: XEventPtr -> X Event
> defaultEventGetter evPtr = do
>  d <- asks display
>  io $ do
>     nextEvent d evPtr
>     getEvent evPtr
>
> Secondly, I would have added eventGetter as a field in XConfig, since
> it doesn't scale to have
>
> xmonad
> xmonad'
> xmonad''
>
> etc. functions.
>
> Finally, do you have an example of something you can do with the
> eventGetter that cannot be done with handleEventHook?
>
>
> Regards,
> Adam
>
> On Thu, Feb 26, 2015 at 10:29 AM, Lally Singh <lally.singh@gmail.com>
> wrote:
> > Hello!
> >
> >  Please tell me what you think, of both the patch and the process I'm
> > sending this in-by.  First time for both.
> >
> > Thanks!
> >
> > 1 patch for repository http://code.haskell.org/xmonad:
> >
> > Thu Feb 26 10:22:06 EST 2015  lally.singh@gmail.com
> >   * Split out the X event get function from xmonad.
> >
> >   This lets xmonad users specify their own functions that get the next X
> > event,
> >   and consequently have access to the Display and run in xmonad's thread.
> > Useful
> >   for providing such access to other threads.
> >
> >
> >
> > New patches:
> >
> > [Split out the X event get function from xmonad.
> > lally.singh@gmail.com**20150226152206
> >  Ignore-this: de10517364b9c642552ff62ebb614d28
> >
> >  This lets xmonad users specify their own functions that get the next X
> > event,
> >  and consequently have access to the Display and run in xmonad's thread.
> > Useful
> >  for providing such access to other threads.
> >
> > ] {
> > hunk ./src/XMonad/Main.hs 49
> >  -- The main entry point
> >  --
> >  xmonad :: (LayoutClass l Window, Read (l Window)) => XConfig l -> IO ()
> > -xmonad initxmc = do
> > +xmonad initxmc = xmonad' defaultEventGetter initxmc
> > +
> > +-- | Default X event getter.
> > +defaultEventGetter :: Display -> XEventPtr -> X Event
> > +defaultEventGetter _ = io . getEvent
> > +
> > +-- | Actual entry point, with a parameter for the X event getter.  The
> > getter
> > +-- has access to the X event loop.
> > +xmonad' :: (LayoutClass l Window, Read (l Window)) => (Display ->
> XEventPtr
> > -> X Event) -> XConfig l -> IO ()
> > +xmonad' eventGetter initxmc = do
> >      -- setup locale information from environment
> >      setLocale LC_ALL Nothing
> >      -- ignore SIGPIPE and SIGCHLD
> > hunk ./src/XMonad/Main.hs 158
> >              userCode $ startupHook initxmc
> >
> >              -- main loop, for all you HOF/recursion fans out there.
> > -            forever $ prehandle =<< io (nextEvent dpy e >> getEvent e)
> > +            forever $ prehandle =<< eventGetter dpy e
> >
> >      return ()
> >        where
> > }
> >
> >
> > _______________________________________________
> > xmonad mailing list
> > xmonad@haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad
> >
>

[Attachment #5 (text/html)]

<div dir="ltr">Ah, that&#39;s what I get for trying to hastily port a larger set of \
changes by hand.   I&#39;ll re-make the patch with your excellent suggestions.  \
<div><br></div><div>My event getter calls select(2) on both the display&#39;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.   &lt;<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>&gt; \
> 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&#39;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">&lt;<a href="mailto:vogt.adam@gmail.com" \
> target="_blank">vogt.adam@gmail.com</a>&gt;</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&#39;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 -&gt; X Event<br>
defaultEventGetter evPtr = do<br>
  d &lt;- 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&#39;t scale to have<br>
<br>
xmonad<br>
xmonad&#39;<br>
xmonad&#39;&#39;<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 &lt;<a \
href="mailto:lally.singh@gmail.com">lally.singh@gmail.com</a>&gt; wrote:<br> &gt; \
Hello!<br> &gt;<br>
&gt;   Please tell me what you think, of both the patch and the process I&#39;m<br>
&gt; sending this in-by.   First time for both.<br>
&gt;<br>
&gt; Thanks!<br>
&gt;<br>
&gt; 1 patch for repository <a href="http://code.haskell.org/xmonad" \
target="_blank">http://code.haskell.org/xmonad</a>:<br> &gt;<br>
&gt; Thu Feb 26 10:22:06 EST 2015   <a \
href="mailto:lally.singh@gmail.com">lally.singh@gmail.com</a><br> &gt;     * Split \
out the X event get function from xmonad.<br> &gt;<br>
&gt;     This lets xmonad users specify their own functions that get the next X<br>
&gt; event,<br>
&gt;     and consequently have access to the Display and run in xmonad&#39;s \
thread.<br> &gt; Useful<br>
&gt;     for providing such access to other threads.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; New patches:<br>
&gt;<br>
&gt; [Split out the X event get function from xmonad.<br>
&gt; <a href="mailto:lally.singh@gmail.com">lally.singh@gmail.com</a>**20150226152206<br>
 &gt;   Ignore-this: de10517364b9c642552ff62ebb614d28<br>
&gt;<br>
&gt;   This lets xmonad users specify their own functions that get the next X<br>
&gt; event,<br>
&gt;   and consequently have access to the Display and run in xmonad&#39;s \
thread.<br> &gt; Useful<br>
&gt;   for providing such access to other threads.<br>
&gt;<br>
&gt; ] {<br>
&gt; hunk ./src/XMonad/Main.hs 49<br>
&gt;   -- The main entry point<br>
&gt;   --<br>
&gt;   xmonad :: (LayoutClass l Window, Read (l Window)) =&gt; XConfig l -&gt; IO \
()<br> &gt; -xmonad initxmc = do<br>
&gt; +xmonad initxmc = xmonad&#39; defaultEventGetter initxmc<br>
&gt; +<br>
&gt; +-- | Default X event getter.<br>
&gt; +defaultEventGetter :: Display -&gt; XEventPtr -&gt; X Event<br>
&gt; +defaultEventGetter _ = io . getEvent<br>
&gt; +<br>
&gt; +-- | Actual entry point, with a parameter for the X event getter.   The<br>
&gt; getter<br>
&gt; +-- has access to the X event loop.<br>
&gt; +xmonad&#39; :: (LayoutClass l Window, Read (l Window)) =&gt; (Display -&gt; \
XEventPtr<br> &gt; -&gt; X Event) -&gt; XConfig l -&gt; IO ()<br>
&gt; +xmonad&#39; eventGetter initxmc = do<br>
&gt;         -- setup locale information from environment<br>
&gt;         setLocale LC_ALL Nothing<br>
&gt;         -- ignore SIGPIPE and SIGCHLD<br>
&gt; hunk ./src/XMonad/Main.hs 158<br>
&gt;                     userCode $ startupHook initxmc<br>
&gt;<br>
&gt;                     -- main loop, for all you HOF/recursion fans out there.<br>
&gt; -                  forever $ prehandle =&lt;&lt; io (nextEvent dpy e &gt;&gt; \
getEvent e)<br> &gt; +                  forever $ prehandle =&lt;&lt; eventGetter dpy \
e<br> &gt;<br>
&gt;         return ()<br>
&gt;            where<br>
&gt; }<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; xmonad mailing list<br>
&gt; <a href="mailto:xmonad@haskell.org">xmonad@haskell.org</a><br>
&gt; <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad" \
target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad</a><br> \
&gt;<br> </blockquote></div><br></div>



_______________________________________________
xmonad mailing list
xmonad@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/xmonad


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic