From: WoodHacker
Subject: Stopping a program
Date: 
Message-ID: <1129291851.419266.281920@g14g2000cwa.googlegroups.com>
Can anyone help me with this?   I'm working with Xlib in SBCL and want
to quit the window back to the REPL.   Obviously, I can do this through
the window manager with client-message by pressing the window close
button.   But I want to do it from a menu Exit command, which calls a
function outside the message loop.   If I call Xlib:close-display, I
get an error that I'm trying to use a closed display - which indicates
that the window messsaging loop is still running after the display
closes (??).  If I add (sb-ext:quit), that shuts everything down, but
I'm no longer in the REPL.  What I want to do is stop the loop, close
the display, and return to the REPL.

Any hints on how to do this?

From: Wade Humeniuk
Subject: Re: Stopping a program
Date: 
Message-ID: <phO3f.23153$S4.8629@edtnps84>
WoodHacker wrote:
> Can anyone help me with this?   I'm working with Xlib in SBCL and want
> to quit the window back to the REPL.   Obviously, I can do this through
> the window manager with client-message by pressing the window close
> button.   But I want to do it from a menu Exit command, which calls a
> function outside the message loop.   If I call Xlib:close-display, I
> get an error that I'm trying to use a closed display - which indicates
> that the window messsaging loop is still running after the display
> closes (??).  If I add (sb-ext:quit), that shuts everything down, but
> I'm no longer in the REPL.  What I want to do is stop the loop, close
> the display, and return to the REPL.
> 
> Any hints on how to do this?
> 

Briefly reading the manual

http://common-lisp.net/project/cmucl/doc/clx/

Subsection 12

http://common-lisp.net/project/cmucl/doc/clx/12_Events_and_Input.html

Subsection 12.5

http://common-lisp.net/project/cmucl/doc/clx/12_5_Sending_Events.html

I assume you send a :destroy-notify using clx:send-event.  This, I assume
will put an event on the client event queue and will close the display.

http://common-lisp.net/project/cmucl/doc/clx/12_12_5_Window_State_Events.html#:destroy-notify

Wade
From: WoodHacker
Subject: Re: Stopping a program
Date: 
Message-ID: <1129322349.702221.308380@g43g2000cwa.googlegroups.com>
Works like a charm.   Thanks......

(When all else fails, read the docs....)
From: Pascal Bourguignon
Subject: Re: Stopping a program
Date: 
Message-ID: <878xwwuw52.fsf@thalassa.informatimago.com>
"WoodHacker" <·······@comcast.net> writes:

> Can anyone help me with this?   I'm working with Xlib in SBCL and want
> to quit the window back to the REPL.   Obviously, I can do this through
> the window manager with client-message by pressing the window close
> button.   But I want to do it from a menu Exit command, which calls a
> function outside the message loop.   If I call Xlib:close-display, I
> get an error that I'm trying to use a closed display - which indicates
> that the window messsaging loop is still running after the display
> closes (??).  If I add (sb-ext:quit), that shuts everything down, but
> I'm no longer in the REPL.  What I want to do is stop the loop, close
> the display, and return to the REPL.
>
> Any hints on how to do this?

Defer the event!

;; Pseudo-code:

(defun dispatch (event)
    ...
    (defer-event :close-window window)
    ...)

(loop
    (dispatch (get-event))
    (process-defered-events))

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
You never feed me.
Perhaps I'll sleep on your face.
That will sure show you.