[racket] Racket GUI with Xlib

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Nov 25 11:44:29 EST 2012

My guess is that RWind blocks the thread that is also the eventspace's
main thread.

If you run the code in a new eventspace, does that avoid the problem?

 #lang racket/gui
 (parameterize ([current-eventspace (make-eventspace)])
   (define f (new frame% [label "Test Frame"]))
   (define bt (new button% [parent f][label "Hide me"]
                   [callback (λ _ (send f show #f))]))
   (send f show #t))

If you just run the above program with `racket', then it won't wait for
the frame to be closed. But if you load it from the `racket' REPL, then
the frame should work right in a "background" eventspace, and my guess
is that RWind will work the same way as the `racket' REPL.

At Sun, 25 Nov 2012 17:32:29 +0100, Laurent wrote:
> Hi all,
> I'm trying to use Racket's GUI while using Jon's Xlib bindings inside my
> racket window manager, but there seems to be a resource conflict.
> Let the following standard module code:
> #lang racket/gui
> (define f (new frame% [label "Test Frame"]))
> (define bt (new button% [parent f][label "Hide me"]
>                 [callback (λ _ (send f show #f))]))
> (send f show #t)
> If I run this code from a keybinding or from the client console directly
> inside RWind, the frame and the button show up, and I can hide the frame
> with another keybinding or from the console.
> However I cannot click the button with the mouse or with the keyboard.
> If I run this code inside a thread, same problem.
> The frame looks completely frozen, like a still image.
> But if I run the same code from a terminal, in a separate racket instance,
> everything works fine.
> I guess Racket's GUI is doing some stuff that may be incompatible as is
> with my program, but I'm not sure what. The fact that the frame can be
> shown or hidden makes me doubt that's it's an issue with event processing.
> Does this ring a bell to someone, or does anyone have an idea that could
> help me solve this?
> Thanks,
> Laurent
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.