<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">XPending returns an integer and I was
using it in a boolean context which led to unintended blocking.
Fix coming.<br>
<br>
On 11/07/2012 12:27 PM, Laurent wrote:<br>
</div>
<blockquote
cite="mid:CABNTSaGRCDES679JVw=M4cYskNHOV9ZY50stOqjM6wEknqiTJg@mail.gmail.com"
type="cite">Thank you all very much for your answers, they are
very helpful.<br>
<br>
AFAICT, after some light testing, Jon's code does what I want, but
Kevin's one is still blocking.<br>
Also, both versions seem to suffer a heavy cost of a few seconds
of initialization compared to the basic XNextEvent version.<br>
<br>
Laurent<br>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Wed, Nov 7, 2012 at 7:24 PM, Jon
Rafkind <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:rafkind@cs.utah.edu" target="_blank">rafkind@cs.utah.edu</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>Here is some goofy code from my barely-started window
manager<br>
<br>
(define (run)<br>
(define (make-root-node)<br>
(send (new RootNode (window x-root))<br>
add-windows<br>
(get-all-windows)))<br>
(printf "Welcome to smokey\n")<br>
(XSetInputFocus x-display None 0 0)<br>
(let ((events (make-channel)))<br>
;; (run-events-thread events)<br>
(start-x11-event-thread x-display events)<br>
(let server-loop ((root (make-root-node)))<br>
(sync (handle-evt events (lambda (event)<br>
;; (printf "Event
~a\n" event)<br>
(server-loop<br>
(send root
handle-event event))))))))
<div class="im"><br>
<br>
On 11/07/2012 11:13 AM, Kevin Tew wrote:<br>
</div>
</div>
<div>
<div class="h5">
<blockquote type="cite">
<div>yeah I'm putting it in a subdirectory.<br>
<br>
I'm also trying to get XConnectionNumber to work
first.<br>
<br>
Kevin<br>
<br>
On 11/07/2012 11:09 AM, Jon Rafkind wrote:<br>
</div>
<blockquote type="cite">
<div>xlambda :p<br>
<br>
would you like to commit it to the repo?<br>
<br>
On 11/07/2012 10:23 AM, Kevin Tew wrote:<br>
</div>
<blockquote type="cite">
<div>I've attached my in-progress port of xmonad
to x11-racket.<br>
<br>
Kevin<br>
<br>
On 11/07/2012 10:16 AM, Kevin Tew wrote:<br>
</div>
<blockquote type="cite">
<div>Racket threads are green or user threads,
they are not scheduled by the operating
system.<br>
Blocking on a socket in XNextEvent blocks
the entire Racket VM.<br>
<br>
<br>
You need to use XConnectionNumber to get the
X socket file descriptor number and then
create a port that you can sync on with
Racket's sync functionality.<br>
<br>
I'm not sure how you would create the port
using the ffi.<br>
<br>
See<br>
<a moz-do-not-send="true"
href="http://fixunix.com/xwindows/91558-xconnectionnumber-select.html"
target="_blank">http://fixunix.com/xwindows/91558-xconnectionnumber-select.html</a>.<br>
<br>
Kevin<br>
<br>
On 11/07/2012 09:58 AM, Laurent wrote:<br>
</div>
<blockquote type="cite">Hi,<br>
<br>
I don't know if this issue is due to me,
Racket, Xlib FFI or Xlib in itself, but I'm
struggling with it. Hopefully someone knows.<br>
<br>
In a multi-threaded application using Jon's
Xlib FFI ( <a moz-do-not-send="true"
href="https://github.com/kazzmir/x11-racket"
target="_blank">https://github.com/kazzmir/x11-racket</a>
), I'm using one thread for processing X
events with XNextEvent, which is a blocking
call (apparently on a socket).<br>
I have another thread that listens to a tcp
port, and does not need to do any X call.<br>
<br>
The problem is that the second thread blocks
on 'read' even if there is something in the
queue to read, unless some X event unblocks
XNextEvent, in which case both threads run,
until there is no X event left (and
XNextEvent blocks again).<br>
<br>
I have called XInitThreads prior to any
other X call to enable threads (and the
return values says it's ok).<br>
<br>
Any idea anyone?<br>
<br>
Thanks,<br>
Laurent<br>
<br>
<br>
<fieldset></fieldset>
<br>
<pre>____________________
Racket Users list:
<a moz-do-not-send="true" href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a>
</pre>
</blockquote>
<br>
<br>
<fieldset></fieldset>
<br>
<pre>____________________
Racket Users list:
<a moz-do-not-send="true" href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>