[clfswm-cvs] r57 - in clfswm: . src

pbrochard at common-lisp.net pbrochard at common-lisp.net
Thu Mar 27 14:09:51 UTC 2008


Author: pbrochard
Date: Thu Mar 27 09:09:49 2008
New Revision: 57

Modified:
   clfswm/ChangeLog
   clfswm/src/bindings.lisp
   clfswm/src/clfswm-internal.lisp
   clfswm/src/clfswm-layout.lisp
   clfswm/src/clfswm-util.lisp
Log:
Use :first-only to raise only the first child (useful with no-layout).


Modified: clfswm/ChangeLog
==============================================================================
--- clfswm/ChangeLog	(original)
+++ clfswm/ChangeLog	Thu Mar 27 09:09:49 2008
@@ -1,3 +1,14 @@
+2008-03-27  Philippe Brochard  <hocwp at free.fr>
+
+	* src/clfswm-layout.lisp (no-layout): Use :first-only to raise only the
+	first child.
+
+	* src/clfswm-internal.lisp (hide-all): Split hide-all-children in hide-all 
+	and hide-all-children.
+	(raise-if-needed): New function.
+	(show-child): Use a first-p parameter to raise windows only when they are
+	first child.
+
 2008-03-26  Philippe Brochard  <hocwp at free.fr>
 
 	* src/clfswm-internal.lisp (select-next/previous-level): Don't use show-all-children 

Modified: clfswm/src/bindings.lisp
==============================================================================
--- clfswm/src/bindings.lisp	(original)
+++ clfswm/src/bindings.lisp	Thu Mar 27 09:09:49 2008
@@ -83,8 +83,7 @@
 ;;handle-configure-request
 
 (defun move-frame (frame orig-x orig-y)
-  (dolist (child (frame-child frame))
-    (hide-all-children child))
+  (hide-all-children frame)
   (with-slots (window) frame
     (let ((done nil)
 	  (dx (- (xlib:drawable-x window) orig-x))
@@ -115,7 +114,8 @@
     (unless father
       (setf child (find-frame-window window *current-root*)
 	    father (find-father-frame child *current-root*))
-      (move-frame child root-x root-y))
+      (when child
+	(move-frame child root-x root-y)))
     (when (and child father (focus-all-children child father))
       (show-all-children)
       (setf to-replay nil))

Modified: clfswm/src/clfswm-internal.lisp
==============================================================================
--- clfswm/src/clfswm-internal.lisp	(original)
+++ clfswm/src/clfswm-internal.lisp	Thu Mar 27 09:09:49 2008
@@ -327,37 +327,44 @@
 		(xlib:drawable-height window) rh)
 	  raise-p))))
    
-  
 
-(defgeneric show-child (child father))
-(defgeneric hide-child (child))
 
-(defmethod show-child ((frame frame) father)
+
+
+(defun raise-if-needed (window raise-p first-p)
+  (when (or (eql raise-p t)
+	    (and (eql raise-p :first-only) first-p))
+    (raise-window window)))
+
+(defgeneric show-child (child father first-p))
+
+(defmethod show-child ((frame frame) father first-p)
   (with-xlib-protect
       (with-slots (window) frame
 	(let ((raise-p (adapt-child-to-father frame father)))
 	  (when (or *show-root-frame-p* (not (equal frame *current-root*)))
 	    (setf (xlib:window-background window) (get-color "Black"))
 	    (xlib:map-window window)
-	    (when raise-p
-	      (raise-window window))
+	    (raise-if-needed window raise-p first-p)
 	    (display-frame-info frame))))))
 
 
-(defmethod hide-child ((frame frame))
-  (with-xlib-protect
-      (with-slots (window) frame
-	(xlib:unmap-window window))))
-
-
-(defmethod show-child ((window xlib:window) father)
+(defmethod show-child ((window xlib:window) father first-p)
   (with-xlib-protect
       (let ((raise-p nil))
 	(when (eql (window-type window) :normal)
 	  (setf raise-p (adapt-child-to-father window father)))
 	(xlib:map-window window)
-	(when raise-p
-	  (raise-window window)))))
+	(raise-if-needed window raise-p first-p))))
+
+
+
+(defgeneric hide-child (child))
+
+(defmethod hide-child ((frame frame))
+  (with-xlib-protect
+      (with-slots (window) frame
+	(xlib:unmap-window window))))
 
 (defmethod hide-child ((window xlib:window))
   (hide-window window))
@@ -403,25 +410,29 @@
 
 (defun show-all-children ()
   "Show all children from *current-root*"
-  (labels ((rec (root father first-p)
-	     (show-child root father)
+  (labels ((rec (root father first-p first-father)
+	     (show-child root father first-p)
 	     (select-child root (if (equal root *current-child*) t
-				    (if first-p :maybe nil)))
+				    (if (and first-p first-father) :maybe nil)))
 	     (when (frame-p root)
 	       (let ((first-child (first (frame-child root))))
 		 (dolist (child (reverse (frame-child root)))
-		   (rec child root (and first-p (equal child first-child))))))))
-    (rec *current-root* nil t)
+		   (rec child root (equal child first-child) first-p))))))
+    (rec *current-root* nil t t)
     (set-focus-to-current-child)))
 
 
 
-
 (defun hide-all-children (root)
-  (hide-child root)
+  "Hide all root children"
   (when (frame-p root)
     (dolist (child (frame-child root))
-      (hide-all-children child))))
+      (hide-all child))))
+
+(defun hide-all (root)
+  "Hide root and all its children"
+  (hide-child root)
+  (hide-all-children root))
 
 
 
@@ -431,7 +442,7 @@
   (let ((frame-is-root? (and (equal *current-root* *current-child*)
 			     (not (equal *current-root* *root-frame*)))))
     (if frame-is-root?
-	(hide-all-children *current-root*)
+	(hide-all *current-root*)
 	(select-current-frame nil))
     (let ((father (find-father-frame *current-child*)))
       (when (frame-p father)
@@ -490,13 +501,13 @@
 
 (defun enter-frame ()
   "Enter in the selected frame - ie make it the root frame"
-  (hide-all-children *current-root*)
+  (hide-all *current-root*)
   (setf *current-root* *current-child*)
   (show-all-children))
 
 (defun leave-frame ()
   "Leave the selected frame - ie make its father the root frame"
-  (hide-all-children *current-root*)
+  (hide-all *current-root*)
   (awhen (find-father-frame *current-root*)
 	 (when (frame-p it)
 	   (setf *current-root* it)))
@@ -505,13 +516,13 @@
 
 (defun switch-to-root-frame ()
   "Switch to the root frame"
-  (hide-all-children *current-root*)
+  (hide-all *current-root*)
   (setf *current-root* *root-frame*)
   (show-all-children))
 
 (defun switch-and-select-root-frame ()
   "Switch and select the root frame"
-  (hide-all-children *current-root*)
+  (hide-all *current-root*)
   (setf *current-root* *root-frame*)
   (setf *current-child* *current-root*)
   (show-all-children))
@@ -519,7 +530,7 @@
 
 (defun toggle-show-root-frame ()
   "Show/Hide the root frame"
-  (hide-all-children *current-root*)
+  (hide-all *current-root*)
   (setf *show-root-frame-p* (not *show-root-frame-p*))
   (show-all-children))
 

Modified: clfswm/src/clfswm-layout.lisp
==============================================================================
--- clfswm/src/clfswm-layout.lisp	(original)
+++ clfswm/src/clfswm-layout.lisp	Thu Mar 27 09:09:49 2008
@@ -33,6 +33,7 @@
 ;;;      child in screen size (integer) as 5 values (rx, ry, rw, rh, raise-p).
 ;;;      This method can use the float size of the child (x, y ,w , h).
 ;;;      It can be specialised for xlib:window or frame
+;;;      Raise-p is nil or :first-only or t
 ;;;   2- Define a seter function for your layout
 ;;;   3- Register your new layout with register-layout.
 
@@ -71,7 +72,11 @@
 
 (defmethod no-layout ((child xlib:window) father)
   (with-slots (rx ry rw rh) father
-    (values (1+ rx)  (1+ ry) (- rw 2) (- rh 2) nil)))
+    (values (1+ rx)
+	    (1+ ry)
+	    (- rw 2)
+	    (- rh 2)
+	    :first-only)))
 
 (defmethod no-layout ((child frame) father)
   (with-slots ((cx x) (cy y) (cw w) (ch h)) child
@@ -80,7 +85,7 @@
 	      (round (+ (* cy frh) fry))
 	      (round (* cw frw))
 	      (round (* ch frh))
-	      t))))
+	      :first-only))))
 
 (defun set-no-layout ()
   "Maximize windows in there frame - leave frame to there size (no layout)"

Modified: clfswm/src/clfswm-util.lisp
==============================================================================
--- clfswm/src/clfswm-util.lisp	(original)
+++ clfswm/src/clfswm-util.lisp	Thu Mar 27 09:09:49 2008
@@ -163,14 +163,14 @@
 (defun cut-current-child ()
   "Cut the current child to the selection"
   (copy-current-child)
-  (hide-all-children *current-child*)
+  (hide-all *current-child*)
   (remove-child-in-frame *current-child* (find-father-frame *current-child* *current-root*))
   (setf *current-child* *current-root*)
   (show-all-children))
 
 (defun remove-current-child ()
   "Remove the current child from its father frame"
-  (hide-all-children *current-child*)
+  (hide-all *current-child*)
   (remove-child-in-frame *current-child* (find-father-frame *current-child* *current-root*))
   (setf *current-child* *current-root*)
   (leave-second-mode))
@@ -332,7 +332,7 @@
 ;;; Focus by functions
 (defun focus-frame-by (frame)
   (when (frame-p frame)
-    (hide-all-children *current-root*)
+    (hide-all *current-root*)
     (focus-all-children frame (or (find-father-frame frame *current-root*)
 				(find-father-frame frame)
 				*root-frame*))))
@@ -369,7 +369,7 @@
 
 ;;; Delete by functions
 (defun delete-frame-by (frame)
-  (hide-all-children *current-root*)
+  (hide-all *current-root*)
   (unless (equal frame *root-frame*)
     (when (equal frame *current-root*)
       (setf *current-root* *root-frame*))
@@ -392,7 +392,7 @@
 ;;; Move by function
 (defun move-current-child-by (child frame-dest)
   (when (and child (frame-p frame-dest))
-    (hide-all-children *current-root*)
+    (hide-all *current-root*)
     (remove-child-in-frame child (find-father-frame child))
     (pushnew child (frame-child frame-dest))
     (focus-all-children child frame-dest)))
@@ -415,7 +415,7 @@
 ;;; Copy by function
 (defun copy-current-child-by (child frame-dest)
   (when (and child (frame-p frame-dest))
-    (hide-all-children *current-root*)
+    (hide-all *current-root*)
     (pushnew child (frame-child frame-dest))
     (focus-all-children child frame-dest)))
 



More information about the clfswm-cvs mailing list