Permalink
Browse files

* user.lisp ("quit"): new command

* stumpwm.lisp (stumpwm-internal-loop): catch a :quit tag
  • Loading branch information...
sabetts
sabetts committed Apr 28, 2006
1 parent 523d088 commit 2622ca3a94a5cae4283b2786e0a4d4072f61209d
Showing with 36 additions and 29 deletions.
  1. +3 −0 NEWS
  2. +30 −29 stumpwm.lisp
  3. +3 −0 user.lisp
View
3 NEWS
@@ -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
View
@@ -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."
View
@@ -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.