Skip to content

Commit

Permalink
* user.lisp ("quit"): new command
Browse files Browse the repository at this point in the history
* stumpwm.lisp (stumpwm-internal-loop): catch a :quit tag
  • Loading branch information
sabetts committed Apr 28, 2006
1 parent 523d088 commit 2622ca3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 29 deletions.
3 changes: 3 additions & 0 deletions NEWS
Expand Up @@ -2,6 +2,9 @@

This file documents user visible changes between versions of StumpWM

* Changes since 0.0.5
** quit command

* Changes since 0.0.3

** Frame support
Expand Down
59 changes: 30 additions & 29 deletions stumpwm.lisp
Expand Up @@ -68,35 +68,36 @@ loaded."

(defun stumpwm-internal-loop ()
"The internal loop that waits for events and handles them."
(loop
(run-hook *internal-loop-hook*)
(handler-case
(progn
(if (> *timeout* 0)
(progn
(let* ((time-before (get-universal-time))
(nevents (xlib:event-listen *display* *timeout*))
(time-left (- *timeout* (- (get-universal-time) time-before))))
(if (<= time-left 0)
(progn
(unmap-all-frame-indicators)
(unmap-all-message-windows)
(setf *timeout* 0))
(setf *timeout* time-left))
(when nevents
(xlib:process-event *display* :handler #'handle-event))))
;; Otherwise, simply wait for an event
(xlib:process-event *display* :handler #'handle-event :timeout nil))
;; flush any pending output. You'd think process-event would, but
;; it seems not.
(xlib:display-finish-output *display*))
(error (c)
(ecase *top-level-error-action*
(:message
(let ((s (format nil "~&Caught ~s at the top level. Please report this." c)))
(write-line s)
(echo-string (current-screen) s)))
(:break (invoke-debugger c)))))))
(catch :quit
(loop
(run-hook *internal-loop-hook*)
(handler-case
(progn
(if (> *timeout* 0)
(progn
(let* ((time-before (get-universal-time))
(nevents (xlib:event-listen *display* *timeout*))
(time-left (- *timeout* (- (get-universal-time) time-before))))
(if (<= time-left 0)
(progn
(unmap-all-frame-indicators)
(unmap-all-message-windows)
(setf *timeout* 0))
(setf *timeout* time-left))
(when nevents
(xlib:process-event *display* :handler #'handle-event))))
;; Otherwise, simply wait for an event
(xlib:process-event *display* :handler #'handle-event :timeout nil))
;; flush any pending output. You'd think process-event would, but
;; it seems not.
(xlib:display-finish-output *display*))
(error (c)
(ecase *top-level-error-action*
(:message
(let ((s (format nil "~&Caught ~s at the top level. Please report this." c)))
(write-line s)
(echo-string (current-screen) s)))
(:break (invoke-debugger c))))))))

(defun parse-display-string (display)
"Parse an X11 DISPLAY string and return the host and display from it."
Expand Down
3 changes: 3 additions & 0 deletions user.lisp
Expand Up @@ -499,5 +499,8 @@ aborted."
(define-key *root-map* key "other")
(sync-keys)))

(define-stumpwm-command "quit" (screen)
(declare (ignore screen))
(throw :quit nil))

;;(define-stumpwm-command "escape"

0 comments on commit 2622ca3

Please sign in to comment.