[clfswm-cvs] r158 - in clfswm: . doc src

pbrochard at common-lisp.net pbrochard at common-lisp.net
Tue Sep 2 20:40:36 UTC 2008


Author: pbrochard
Date: Tue Sep  2 16:40:35 2008
New Revision: 158

Modified:
   clfswm/ChangeLog
   clfswm/TODO
   clfswm/doc/keys.html
   clfswm/doc/keys.txt
   clfswm/doc/menu.html
   clfswm/doc/menu.txt
   clfswm/src/bindings-second-mode.lisp
   clfswm/src/bindings.lisp
   clfswm/src/clfswm-corner.lisp
   clfswm/src/clfswm-menu.lisp
   clfswm/src/clfswm-util.lisp
   clfswm/src/clfswm.lisp
   clfswm/src/menu-def.lisp
   clfswm/src/package.lisp
Log:
main, main-unprotected: Handle error in a superior main function. Now CLFSWM can't break the X session. It just reinitialize the display and run a new main loop. reload-clfswm: New function to reload CLFSWM. Rename quit-clfswm to exit-clfswm.

Modified: clfswm/ChangeLog
==============================================================================
--- clfswm/ChangeLog	(original)
+++ clfswm/ChangeLog	Tue Sep  2 16:40:35 2008
@@ -1,5 +1,18 @@
 2008-09-02  Philippe Brochard  <pbrochard at common-lisp.net>
 
+	* src/clfswm-menu.lisp (init-menu): New function.
+
+	* src/clfswm-util.lisp (reload-clfswm): New function to reload
+	CLFSWM.
+	(exit-clfswm): Rename quit-clfswm to exit-clfswm.
+
+	* src/clfswm.lisp (main, main-unprotected): Handle error in a
+	superior main function. Now CLFSWM can't break the X session. It
+	just reinitialize the display and run a new main loop.
+
+	* src/clfswm-corner.lisp: Make *clfswm-terminal* and
+	*vt-keyboard-on* global to avoid warnings when loading clfswm.
+
 	* src/clfswm-layout.lisp: Add a specific GIMP layout menu.
 	(help-on-gimp-layout): Describe how to use the GIMP layout.
 

Modified: clfswm/TODO
==============================================================================
--- clfswm/TODO	(original)
+++ clfswm/TODO	Tue Sep  2 16:40:35 2008
@@ -7,13 +7,6 @@
 ===============
 Should handle these soon.
 
-- From stumpwm: [Philippe]
- "In other news stumpwm should catch unhandled errors, restart, and
- print an error message. And there is now a soft-restart command. With
- this in place I suspect you will need to restart stumpwm very rarely
- and it won't spontaneously bring down X."
-  => Reset all -> place clfswm in its starting state.
-
 - Sloppy focus strict -> focus windows only in the current frame
   Sloppy select -> select frame on mouse enter.
 
@@ -35,7 +28,6 @@
 
 - cd/pwd a la shell to navigate throw frames. [Philippe]
 
-
 - Zoom
 
 Concept:

Modified: clfswm/doc/keys.html
==============================================================================
--- clfswm/doc/keys.html	(original)
+++ clfswm/doc/keys.html	Tue Sep  2 16:40:35 2008
@@ -49,7 +49,7 @@
           Home
         </td>
         <td style="color:#0000ff" nowrap>
-          Quit clfswm
+          Exit clfswm
         </td>
       </tr>
       <tr>
@@ -758,7 +758,7 @@
           Home
         </td>
         <td style="color:#0000ff" nowrap>
-          Quit clfswm
+          Exit clfswm
         </td>
       </tr>
       <tr>

Modified: clfswm/doc/keys.txt
==============================================================================
--- clfswm/doc/keys.txt	(original)
+++ clfswm/doc/keys.txt	Tue Sep  2 16:40:35 2008
@@ -7,7 +7,7 @@
 --------------
 
   Mod-1                F1              Open the help and info window
-  Mod-1 Control Shift  Home            Quit clfswm
+  Mod-1 Control Shift  Home            Exit clfswm
   Mod-1                Right           Select the next sister frame
   Mod-1                Left            Select the previous sister frame
   Mod-1                Down            Select the previous level in frame
@@ -80,7 +80,7 @@
                        Return          Leave second mode
                        Escape          Leave second mode
                        T               Tile with spaces the current frame
-  Mod-1 Control Shift  Home            Quit clfswm
+  Mod-1 Control Shift  Home            Exit clfswm
   Mod-1                Right           Select the next sister frame
   Mod-1                Left            Select the previous sister frame
   Mod-1                Down            Select the previous level in frame

Modified: clfswm/doc/menu.html
==============================================================================
--- clfswm/doc/menu.html	(original)
+++ clfswm/doc/menu.html	Tue Sep  2 16:40:35 2008
@@ -38,6 +38,9 @@
     <p>
       y: <a href="#UTILITY-MENU">< Utility menu ></a>
     </p>
+    <p>
+      *: <a href="#CLFSWM-MENU">< CLFSWM menu ></a>
+    </p>
     <hr>
     <h3>
       <a name="CHILD-MENU"></a><a href="#MAIN">Child-Menu</a>
@@ -126,6 +129,9 @@
     <p>
       f: <a href="#FRAME-MAIN-WINDOW-LAYOUT-MENU">< Main window layout menu ></a>
     </p>
+    <p>
+      g: <a href="#FRAME-GIMP-LAYOUT-MENU">< The GIMP layout menu ></a>
+    </p>
     <hr>
     <h3>
       <a name="FRAME-FAST-LAYOUT-MENU"></a><a href="#FRAME-LAYOUT-MENU">Frame-Fast-Layout-Menu</a>
@@ -202,6 +208,46 @@
     </p>
     <hr>
     <h3>
+      <a name="FRAME-GIMP-LAYOUT-MENU"></a><a href="#FRAME-LAYOUT-MENU">Frame-Gimp-Layout-Menu</a>
+    </h3>
+    <p>
+      g: The GIMP Layout
+    </p>
+    <p>
+      p: Restore the previous layout
+    </p>
+    <p>
+      h: Help on the GIMP layout
+    </p>
+    <p>
+      -=- Main window layout -=-
+    </p>
+    <p>
+      r: Main window right: Main windows on the right. Others on the left.
+    </p>
+    <p>
+      l: Main window left: Main windows on the left. Others on the right.
+    </p>
+    <p>
+      t: Main window top: Main windows on the top. Others on the bottom.
+    </p>
+    <p>
+      b: Main window bottom: Main windows on the bottom. Others on the top.
+    </p>
+    <p>
+      -=- Actions on main windows list -=-
+    </p>
+    <p>
+      a: Add the current window in the main window list
+    </p>
+    <p>
+      v: Remove the current window from the main window list
+    </p>
+    <p>
+      c: Clear the main window list
+    </p>
+    <hr>
+    <h3>
       <a name="FRAME-NW-HOOK-MENU"></a><a href="#FRAME-MENU">Frame-Nw-Hook-Menu</a>
     </h3>
     <p>
@@ -451,6 +497,16 @@
       exclam: Run a program from the query input
     </p>
     <hr>
+    <h3>
+      <a name="CLFSWM-MENU"></a><a href="#MAIN">Clfswm-Menu</a>
+    </h3>
+    <p>
+      r: Reload clfswm
+    </p>
+    <p>
+      x: Exit clfswm
+    </p>
+    <hr>
     <p>
       <small>
         This documentation was produced with the CLFSWM auto-doc functions. To reproduce it, use the produce-menu-doc-html-in-file or

Modified: clfswm/doc/menu.txt
==============================================================================
--- clfswm/doc/menu.txt	(original)
+++ clfswm/doc/menu.txt	Tue Sep  2 16:40:35 2008
@@ -9,6 +9,7 @@
 n: < Action by name menu >
 u: < Action by number menu >
 y: < Utility menu >
+*: < CLFSWM menu >
 
 Child-Menu
 r: Rename the current child
@@ -41,6 +42,7 @@
 d: < Tile in one direction layout menu >
 e: < Tile with some space on one side menu >
 f: < Main window layout menu >
+g: < The GIMP layout menu >
 
 Frame-Fast-Layout-Menu
 s: Switch between two layouts
@@ -70,6 +72,20 @@
 v: Remove the current window from the main window list
 c: Clear the main window list
 
+Frame-Gimp-Layout-Menu
+g: The GIMP Layout
+p: Restore the previous layout
+h: Help on the GIMP layout
+-=- Main window layout -=-
+r: Main window right: Main windows on the right. Others on the left.
+l: Main window left: Main windows on the left. Others on the right.
+t: Main window top: Main windows on the top. Others on the bottom.
+b: Main window bottom: Main windows on the bottom. Others on the top.
+-=- Actions on main windows list -=-
+a: Add the current window in the main window list
+v: Remove the current window from the main window list
+c: Clear the main window list
+
 Frame-Nw-Hook-Menu
 a: Open the next window in the current frame
 b: Open the next window in the current root
@@ -162,6 +178,10 @@
 colon: Eval a lisp form from the query input
 exclam: Run a program from the query input
 
+Clfswm-Menu
+r: Reload clfswm
+x: Exit clfswm
+
 
 This documentation was produced with the CLFSWM auto-doc functions. To reproduce it, use the produce-menu-doc-in-file or
 the produce-all-docs function from the Lisp REPL.

Modified: clfswm/src/bindings-second-mode.lisp
==============================================================================
--- clfswm/src/bindings-second-mode.lisp	(original)
+++ clfswm/src/bindings-second-mode.lisp	Tue Sep  2 16:40:35 2008
@@ -100,7 +100,7 @@
 
 (define-second-key ("t") 'tile-space-current-frame)
 
-(define-second-key ("Home" :mod-1 :control :shift) 'quit-clfswm)
+(define-second-key ("Home" :mod-1 :control :shift) 'exit-clfswm)
 
 (define-second-key ("Right" :mod-1) 'select-next-sister)
 (define-second-key ("Left" :mod-1) 'select-previous-sister)

Modified: clfswm/src/bindings.lisp
==============================================================================
--- clfswm/src/bindings.lisp	(original)
+++ clfswm/src/bindings.lisp	Tue Sep  2 16:40:35 2008
@@ -33,11 +33,7 @@
 
 (define-main-key ("F1" :mod-1) 'help-on-clfswm)
 
-(defun quit-clfswm ()
-  "Quit clfswm"
-  (throw 'exit-main-loop nil))
-
-(define-main-key ("Home" :mod-1 :control :shift) 'quit-clfswm)
+(define-main-key ("Home" :mod-1 :control :shift) 'exit-clfswm)
 
 (define-main-key ("Right" :mod-1) 'select-next-sister)
 (define-main-key ("Left" :mod-1) 'select-previous-sister)
@@ -180,13 +176,13 @@
 ;;
 ;;;;(define-main-key ("F1" :mod-1) 'help-on-clfswm)
 ;;;;
-;;(defun quit-clfswm ()
+;;(defun exit-clfswm ()
 ;;  "Quit clfswm"
 ;;  (throw 'exit-main-loop nil))
 ;;
 ;;
 ;;
-;;(define-main-key ("Home" :mod-1 :control :shift) 'quit-clfswm)
+;;(define-main-key ("Home" :mod-1 :control :shift) 'exit-clfswm)
 ;;
 ;;(define-main-key (#\t :mod-1) 'second-key-mode)
 ;;(define-main-key ("less" :control) 'second-key-mode)

Modified: clfswm/src/clfswm-corner.lisp
==============================================================================
--- clfswm/src/clfswm-corner.lisp	(original)
+++ clfswm/src/clfswm-corner.lisp	Tue Sep  2 16:40:35 2008
@@ -109,46 +109,42 @@
     (setf *current-root* parent))
   t)
 
-(let ((vt-keyboard-on nil))
-  (defun init-virtual-keyboard ()
-    (setf vt-keyboard-on nil))
-  (defun present-virtual-keyboard ()
-    "Present a virtual keyboard"
-    (stop-button-event)
-    (do-shell (if vt-keyboard-on
-		  *virtual-keyboard-kill-cmd*
-		  *virtual-keyboard-cmd*))
-    (setf vt-keyboard-on (not vt-keyboard-on))
-    t))
-
-
-(let ((terminal nil))
-  (defun init-clfswm-terminal ()
-    (setf terminal nil))
-  (defun present-clfswm-terminal ()
-    "Hide/Unhide a terminal"
-    (stop-button-event)
-    (let ((found nil))
-      (dolist (win (xlib:query-tree *root*))
-	(when (string-equal (xlib:wm-name win) *clfswm-terminal-name*)
-	  (setf found t)
-	  (unless (equal terminal win)
-	    (setf terminal win)
-	    (hide-window terminal))))
-      (unless found
-	(do-shell *clfswm-terminal-cmd*)
-	(loop :with done = nil :until done
-	   :do (dolist (win (xlib:query-tree *root*))
-		 (when (string-equal (xlib:wm-name win) *clfswm-terminal-name*)
-		   (setf terminal win
-			 done t))))
-	(hide-window terminal)))
-    (cond ((window-hidden-p terminal) (unhide-window terminal)
-	   (focus-window terminal)
-	   (raise-window terminal))
-	  (t (hide-window terminal)
-	     (show-all-children nil)))
-    t))
+
+(defun present-virtual-keyboard ()
+  "Present a virtual keyboard"
+  (stop-button-event)
+  (do-shell (if *vt-keyboard-on*
+		*virtual-keyboard-kill-cmd*
+		*virtual-keyboard-cmd*))
+  (setf *vt-keyboard-on* (not *vt-keyboard-on*))
+  t)
+
+
+
+(defun present-clfswm-terminal ()
+  "Hide/Unhide a terminal"
+  (stop-button-event)
+  (let ((found nil))
+    (dolist (win (xlib:query-tree *root*))
+      (when (string-equal (xlib:wm-name win) *clfswm-terminal-name*)
+	(setf found t)
+	(unless (equal *clfswm-terminal* win)
+	  (setf *clfswm-terminal* win)
+	  (hide-window *clfswm-terminal*))))
+    (unless found
+      (do-shell *clfswm-terminal-cmd*)
+      (loop :with done = nil :until done
+	 :do (dolist (win (xlib:query-tree *root*))
+	       (when (string-equal (xlib:wm-name win) *clfswm-terminal-name*)
+		 (setf *clfswm-terminal* win
+		       done t))))
+      (hide-window *clfswm-terminal*)))
+  (cond ((window-hidden-p *clfswm-terminal*) (unhide-window *clfswm-terminal*)
+	 (focus-window *clfswm-terminal*)
+	 (raise-window *clfswm-terminal*))
+	(t (hide-window *clfswm-terminal*)
+	   (show-all-children nil)))
+  t)
 
 
 (defun ask-close/kill-current-window ()

Modified: clfswm/src/clfswm-menu.lisp
==============================================================================
--- clfswm/src/clfswm-menu.lisp	(original)
+++ clfswm/src/clfswm-menu.lisp	Tue Sep  2 16:40:35 2008
@@ -99,6 +99,8 @@
 
 
 
+(defun init-menu ()
+  (setf *menu* (make-menu :name 'main :doc "Main menu")))
 
 
 

Modified: clfswm/src/clfswm-util.lisp
==============================================================================
--- clfswm/src/clfswm-util.lisp	(original)
+++ clfswm/src/clfswm-util.lisp	Tue Sep  2 16:40:35 2008
@@ -34,6 +34,19 @@
 
 
 
+(defun exit-clfswm ()
+  "Exit clfswm"
+  (throw 'exit-clfswm nil))
+
+
+(defun reload-clfswm ()
+  "Reload clfswm"
+  (format t "~&-*- Reloading CLFSWM -*-~%")
+  (asdf:oos 'asdf:load-op :clfswm)
+  (throw 'exit-main-loop nil))
+
+
+
 
 (defun rename-current-child ()
   "Rename the current child"

Modified: clfswm/src/clfswm.lisp
==============================================================================
--- clfswm/src/clfswm.lisp	(original)
+++ clfswm/src/clfswm.lisp	Tue Sep  2 16:40:35 2008
@@ -215,12 +215,12 @@
 					    :height (xlib:screen-height *screen*)
 					    :depth (xlib:screen-root-depth *screen*)
 					    :drawable *root*)
-	*in-second-mode* nil)
+	*in-second-mode* nil
+	*clfswm-terminal* nil
+	*vt-keyboard-on* nil)
   (xgrab-init-pointer)
   (xgrab-init-keyboard)
   (init-last-child)
-  (init-virtual-keyboard)
-  (init-clfswm-terminal)
   (xlib:map-window *no-focus-window*)
   (dbg *display*)
   (setf (xlib:window-event-mask *root*) (xlib:make-event-mask :substructure-redirect
@@ -242,7 +242,7 @@
   (show-all-children *current-root*)
   (grab-main-keys)
   (xlib:display-finish-output *display*))
-
+  
 
 
 (defun xdg-config-home ()
@@ -269,25 +269,28 @@
 
 
 
-(defun main (&key (display (or (getenv "DISPLAY") ":0")) protocol
-	     (base-dir (directory-namestring (or *load-truename* ""))))
+(defun main-unprotected (&key (display (or (getenv "DISPLAY") ":0")) protocol
+			 (base-dir (directory-namestring (or *load-truename* "")))
+			 error-msg)
   (setf *contrib-dir* base-dir)
   (read-conf-file)
   (handler-case
       (open-display display protocol)
     (xlib:access-error (c)
-      (format t "~&~A~&Maybe another window manager is running.~%" c)
+      (format t "~&~A~&Maybe another window manager is running. [1]~%" c)
       (force-output)
-      (return-from main 'init-display-error)))
+      (return-from main-unprotected 'init-display-error)))
   (handler-case
       (init-display)
     (xlib:access-error (c)
       (ungrab-main-keys)
       (xlib:destroy-window *no-focus-window*)
       (xlib:close-display *display*)
-      (format t "~&~A~&Maybe another window manager is running.~%" c)
+      (format t "~&~A~&Maybe another window manager is running. [2]~%" c)
       (force-output)
-      (return-from main 'init-display-error)))
+      (return-from main-unprotected 'init-display-error)))
+  (when error-msg
+    (info-mode error-msg))
   (unwind-protect
        (catch 'exit-main-loop
 	 (main-loop))
@@ -295,6 +298,22 @@
     (xlib:destroy-window *no-focus-window*)
     (xlib:free-pixmap *pixmap-buffer*)
     (xlib:close-display *display*)))
-      
+
+
+
+(defun main (&key (display (or (getenv "DISPLAY") ":0")) protocol
+	     (base-dir (directory-namestring (or *load-truename* ""))))
+  (let (error-msg)
+    (catch 'exit-clfswm
+      (loop
+	 (handler-case
+	     (main-unprotected :display display :protocol protocol :base-dir base-dir
+			       :error-msg error-msg)
+	   (error (c)
+	     (let ((msg (format nil "CLFSWM Error: ~A." c)))
+	       (format t "~&~A~%Reinitializing...~%" msg)
+	       (setf error-msg (list (list msg *info-color-title*)
+				     "Reinitializing...")))))))))
+
 
 

Modified: clfswm/src/menu-def.lisp
==============================================================================
--- clfswm/src/menu-def.lisp	(original)
+++ clfswm/src/menu-def.lisp	Tue Sep  2 16:40:35 2008
@@ -27,6 +27,8 @@
 
 (in-package :clfswm)
 
+(init-menu)
+
 ;;; Here is a small example of menu manipulation:
 
 ;;(add-menu-key 'main "a" 'help-on-second-mode)
@@ -45,10 +47,6 @@
 
 ;;(define-second-key ("a") 'open-menu)
 
-
-
-
-
 (add-sub-menu 'main "c" 'child-menu "Child menu")
 (add-sub-menu 'main "f" 'frame-menu "Frame menu")
 (add-sub-menu 'main "w" 'window-menu "Window menu")
@@ -56,6 +54,7 @@
 (add-sub-menu 'main "n" 'action-by-name-menu "Action by name menu")
 (add-sub-menu 'main "u" 'action-by-number-menu "Action by number menu")
 (add-sub-menu 'main "y" 'utility-menu "Utility menu")
+(add-sub-menu 'main #\* 'clfswm-menu "CLFSWM menu")
 
 
 
@@ -169,3 +168,7 @@
 (add-menu-key 'utility-menu "colon" 'eval-from-query-string)
 (add-menu-key 'utility-menu "exclam" 'run-program-from-query-string)
 
+
+(add-menu-key 'clfswm-menu "r" 'reload-clfswm)
+(add-menu-key 'clfswm-menu "x" 'exit-clfswm)
+

Modified: clfswm/src/package.lisp
==============================================================================
--- clfswm/src/package.lisp	(original)
+++ clfswm/src/package.lisp	Tue Sep  2 16:40:35 2008
@@ -28,7 +28,9 @@
 (defpackage clfswm
   (:use :common-lisp :my-html :tools :version)
   ;;(:shadow :defun)
-  (:export :main))
+  (:export :main
+	   :reload-clfswm
+	   :exit-clfswm))
 
 
 
@@ -155,7 +157,7 @@
 (defstruct menu-item key value)
 
 
-(defvar *menu* (make-menu :name 'main :doc "Main menu"))
+(defparameter *menu* (make-menu :name 'main :doc "Main menu"))
 
 
 ;;; Main mode hooks (set in clfswm.lisp)
@@ -222,6 +224,10 @@
 
 (defparameter *in-second-mode* nil)
 
+
+(defparameter *vt-keyboard-on* nil)
+(defparameter *clfswm-terminal* nil)
+
 ;; For debug - redefine defun
 ;;(shadow :defun)
 ;;



More information about the clfswm-cvs mailing list