From 071d5a77e541a551636f3caa532862181fb20483 Mon Sep 17 00:00:00 2001 From: Philippe Brochard Date: Fri, 4 Mar 2011 22:02:21 +0100 Subject: [PATCH] src/clfswm-internal.lisp (show-all-children): Perform only one recusion on the clfswm tree: calculate geometry and place child in one pass. --- ChangeLog | 6 ++++++ src/clfswm-circulate-mode.lisp | 6 ++---- src/clfswm-corner.lisp | 2 +- src/clfswm-expose-mode.lisp | 6 +++--- src/clfswm-internal.lisp | 45 +++++++++++++++++++++--------------------- src/clfswm-layout.lisp | 2 +- src/clfswm-nw-hooks.lisp | 6 +++--- src/clfswm-util.lisp | 43 +++++++++++++++++++++------------------- src/clfswm.lisp | 2 +- 9 files changed, 62 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index a6a4718..1fed0ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-03-04 Philippe Brochard + + * src/clfswm-internal.lisp (show-all-children): Perform only one + recusion on the clfswm tree: calculate geometry and place child in + one pass. + 2011-03-03 Philippe Brochard * src/clfswm-internal.lisp (show-all-children): Rethink of display diff --git a/src/clfswm-circulate-mode.lisp b/src/clfswm-circulate-mode.lisp index 235a242..efbddfc 100644 --- a/src/clfswm-circulate-mode.lisp +++ b/src/clfswm-circulate-mode.lisp @@ -98,9 +98,7 @@ *current-child* (frame-selected-child *circulate-parent*)))) (when frame-is-root? (setf *current-root* *current-child*)))) - (show-all-children (if frame-is-root? - *current-child* - (find-parent-frame *current-child*))) + (show-all-children) (draw-circulate-mode-window))) (defun reorder-subchild (direction) @@ -112,7 +110,7 @@ (with-slots (child) selected-child (let ((elem (first (last child)))) (setf child (cons elem (child-remove elem child))) - (show-all-children selected-child) + (show-all-children) (draw-circulate-mode-window))))))) diff --git a/src/clfswm-corner.lisp b/src/clfswm-corner.lisp index 4f346f0..24b030a 100644 --- a/src/clfswm-corner.lisp +++ b/src/clfswm-corner.lisp @@ -98,7 +98,7 @@ Corner is one of :bottom-right :bottom-left :top-right :top-left" (focus-window win)) (raise-window win)) (t (hide-window win) - (show-all-children nil))) + (show-all-children))) win) diff --git a/src/clfswm-expose-mode.lisp b/src/clfswm-expose-mode.lisp index 6c462c8..091c1d2 100644 --- a/src/clfswm-expose-mode.lisp +++ b/src/clfswm-expose-mode.lisp @@ -156,7 +156,7 @@ (with-all-frames (first-restore-frame frame) (setf (frame-data-slot frame :old-layout) (frame-layout frame) (frame-layout frame) #'tile-space-layout)) - (show-all-children *current-root*) + (show-all-children) (expose-mode-display-accel-windows) (let ((grab-keyboard-p (xgrab-keyboard-p)) (grab-pointer-p (xgrab-pointer-p))) @@ -185,7 +185,7 @@ (with-all-frames (first-restore-frame frame) (setf (frame-layout frame) (frame-data-slot frame :old-layout) (frame-data-slot frame :old-layout) nil)) - (show-all-children *current-root*) + (show-all-children) (banish-pointer) (unless grab-keyboard-p (xungrab-keyboard) @@ -227,6 +227,6 @@ (unless (child-equal-p *current-child* orig-root) (hide-all *current-root*) (setf *current-root* orig-root)) - (show-all-children *current-root*)))) + (show-all-children)))) diff --git a/src/clfswm-internal.lisp b/src/clfswm-internal.lisp index 22f6ff9..5168ace 100644 --- a/src/clfswm-internal.lisp +++ b/src/clfswm-internal.lisp @@ -615,7 +615,8 @@ (defmethod set-child-stack-order (window child) (declare (ignore child)) - (raise-window window)) + (raise-window window) + (xlib:display-finish-output *display*)) @@ -729,33 +730,31 @@ -(defun show-all-children (&optional (display-child *current-child*)) - "Show all children from *current-root*. Start the effective display -only for display-child and its children" +(defun show-all-children () + "Show all children from *current-root*." (let ((geometry-change nil) (previous nil)) - (labels ((rec-geom (root parent selected-p selected-parent-p) - (when (adapt-child-to-parent root parent) + (labels ((rec (child parent selected-p selected-parent-p) + (when (adapt-child-to-parent child parent) (setf geometry-change t)) - (select-child root (cond ((child-equal-p root *current-child*) t) - ((and selected-p selected-parent-p) :maybe) - (t nil))) - (when (frame-p root) - (let ((selected-child (frame-selected-child root))) - (dolist (child (reverse (frame-child root))) - (rec-geom child root (child-equal-p child selected-child) (and selected-p selected-parent-p)))))) - (rec (child parent n) + (select-child child (cond ((child-equal-p child *current-child*) t) + ((and selected-p selected-parent-p) :maybe) + (t nil))) (when (frame-p child) - (dolist (sub-child (frame-child child)) - (rec sub-child child (1+ n)))) + (let ((selected-child (frame-selected-child child))) + (dolist (sub-child (frame-child child)) + (rec sub-child child (child-equal-p sub-child selected-child) (and selected-p selected-parent-p))))) (show-child child parent previous) (setf previous child))) - (rec-geom *current-root* nil t t) - (rec display-child nil 0) + (rec *current-root* nil t t) (set-focus-to-current-child) geometry-change))) + + + + (defun hide-all-children (root) "Hide all root children" (when (frame-p root) @@ -850,7 +849,7 @@ For window: set current child to window or its parent according to window-parent "Enter in the selected frame - ie make it the root frame" (hide-all *current-root*) (setf *current-root* *current-child*) - (show-all-children *current-root*)) + (show-all-children)) (defun leave-frame () "Leave the selected frame - ie make its parent the root frame" @@ -858,7 +857,7 @@ For window: set current child to window or its parent according to window-parent (awhen (find-parent-frame *current-root*) (when (frame-p it) (setf *current-root* it))) - (show-all-children *current-root*)) + (show-all-children)) ;;; Other actions (select-next-child, select-next-brother...) are in @@ -914,7 +913,7 @@ For window: set current child to window or its parent according to window-parent (hide-all *current-root*) (setf *current-root* *root-frame*) (unless show-later - (show-all-children *current-root*))) + (show-all-children))) (defun switch-and-select-root-frame (&key (show-later nil)) "Switch and select the root frame" @@ -922,14 +921,14 @@ For window: set current child to window or its parent according to window-parent (setf *current-root* *root-frame*) (setf *current-child* *current-root*) (unless show-later - (show-all-children *current-root*))) + (show-all-children))) (defun toggle-show-root-frame () "Show/Hide the root frame" (hide-all *current-root*) (setf *show-root-frame-p* (not *show-root-frame-p*)) - (show-all-children *current-root*)) + (show-all-children)) (defun remove-child-in-frame (child frame) diff --git a/src/clfswm-layout.lisp b/src/clfswm-layout.lisp index c72e95b..a27cc12 100644 --- a/src/clfswm-layout.lisp +++ b/src/clfswm-layout.lisp @@ -56,7 +56,7 @@ (defun set-layout-once (layout-name) (set-layout-dont-leave layout-name) - (show-all-children *current-root*) + (show-all-children) (fixe-real-size-current-child) (set-layout-dont-leave #'no-layout)) diff --git a/src/clfswm-nw-hooks.lisp b/src/clfswm-nw-hooks.lisp index bc176f0..0ac8f0e 100644 --- a/src/clfswm-nw-hooks.lisp +++ b/src/clfswm-nw-hooks.lisp @@ -164,7 +164,7 @@ (set-layout-once #'tile-space-layout) (setf *current-child* new-frame) (default-window-placement new-frame window) - (show-all-children *current-root*) + (show-all-children) t))) @@ -207,7 +207,7 @@ (setf *current-child* frame) (focus-all-children window frame) (default-window-placement frame window) - (show-all-children *current-root*) + (show-all-children) t)) ;;; Open a new window in a named frame @@ -254,7 +254,7 @@ (setf *current-child* frame) (focus-all-children window frame) (default-window-placement frame window) - (show-all-children *current-root*)) + (show-all-children)) (throw 'nw-hook-loop t))) nil) diff --git a/src/clfswm-util.lisp b/src/clfswm-util.lisp index ec0188f..b5837b0 100644 --- a/src/clfswm-util.lisp +++ b/src/clfswm-util.lisp @@ -273,7 +273,7 @@ (setf (frame-data-slot *current-child* :unmaximized-coords) (list x y w h) x 0 y 0 w 1 h 1)))) - (show-all-children (find-parent-frame *current-child*)) + (show-all-children) (leave-second-mode))) @@ -405,7 +405,7 @@ (focus-all-children frame (or (find-parent-frame frame *current-root*) (find-parent-frame frame) *root-frame*)) - (show-all-children *current-root*))) + (show-all-children))) (defun focus-frame-by-name () @@ -423,7 +423,7 @@ (defun open-frame-by (frame) (when (frame-p frame) (push (create-frame :name (query-string "Frame name")) (frame-child frame)) - (show-all-children *current-root*))) + (show-all-children))) @@ -447,7 +447,7 @@ (when (child-equal-p frame *current-child*) (setf *current-child* *current-root*)) (remove-child-in-frame frame (find-parent-frame frame))) - (show-all-children *current-root*)) + (show-all-children)) (defun delete-frame-by-name () @@ -468,7 +468,7 @@ (remove-child-in-frame child (find-parent-frame child)) (pushnew child (frame-child frame-dest)) (focus-all-children child frame-dest) - (show-all-children *current-root*))) + (show-all-children))) (defun move-current-child-by-name () "Move current child in a named frame" @@ -491,7 +491,7 @@ (hide-all *current-root*) (pushnew child (frame-child frame-dest)) (focus-all-children child frame-dest) - (show-all-children *current-root*))) + (show-all-children))) (defun copy-current-child-by-name () "Copy current child in a named frame" @@ -544,7 +544,7 @@ (move-window window orig-x orig-y #'display-frame-info (list frame)) (setf (frame-x frame) (x-px->fl (xlib:drawable-x window) parent) (frame-y frame) (y-px->fl (xlib:drawable-y window) parent))) - (show-all-children frame))) + (show-all-children))) (defun resize-frame (frame parent orig-x orig-y) @@ -554,7 +554,7 @@ (resize-window window orig-x orig-y #'display-frame-info (list frame)) (setf (frame-w frame) (w-px->fl (xlib:drawable-width window) parent) (frame-h frame) (h-px->fl (xlib:drawable-height window) parent))) - (show-all-children frame))) + (show-all-children))) @@ -582,13 +582,15 @@ mouse-fun is #'move-frame or #'resize-frame" (unless (equal (type-of child) 'frame) (setf child (find-frame-window child *current-root*))) (setf parent (find-parent-frame child))))) + (when (and child parent + (focus-all-children child parent + (not (and (child-equal-p *current-child* *current-root*) + (xlib:window-p *current-root*))))) + (when (show-all-children) + (setf to-replay nil))) (when (equal (type-of child) 'frame) (funcall mouse-fn child parent root-x root-y)) - (when (and child parent (focus-all-children child parent - (not (and (child-equal-p *current-child* *current-root*) - (xlib:window-p *current-root*))))) - (when (show-all-children *current-root*) - (setf to-replay nil)))) + (show-all-children)) (if to-replay (replay-button-event) (stop-button-event))))) @@ -630,6 +632,8 @@ For window: set current child to window or its parent according to window-parent (place-frame child parent root-x root-y 10 10) (map-window (frame-window child)) (pushnew child (frame-child *current-root*))) + (focus-all-children child parent window-parent) + (show-all-children) (typecase child (xlib:window (if (managed-window-p child parent) @@ -638,8 +642,7 @@ For window: set current child to window or its parent according to window-parent ((eql mouse-fn #'resize-frame) #'resize-window)) child root-x root-y))) (frame (funcall mouse-fn child parent root-x root-y))) - (focus-all-children child parent window-parent) - (show-all-children *current-root*))) + (show-all-children))) (move/resize-never-managed (child raise-fun) (funcall raise-fun child) (funcall (cond ((eql mouse-fn #'move-frame) #'move-window) @@ -734,7 +737,7 @@ For window: set current child to window or its parent according to window-parent (setf *current-root* jump-child *current-child* *current-root*) (focus-all-children *current-child* *current-child*) - (show-all-children *current-root*)))) + (show-all-children)))) (defun bind-or-jump (n) "Bind or jump to a slot (a frame or a window)" @@ -1026,7 +1029,7 @@ For window: set current child to window or its parent according to window-parent (setf dest (find-parent-frame dest))) (unless (child-equal-p child dest) (move-child-to child dest) - (show-all-children *current-root*)))))) + (show-all-children)))))) (stop-button-event)) @@ -1037,7 +1040,7 @@ For window: set current child to window or its parent according to window-parent "Hide/show the frame window" (when (frame-p frame) (setf (frame-show-window-p *current-child*) value) - (show-all-children *current-root*)) + (show-all-children)) (leave-second-mode)) @@ -1135,7 +1138,7 @@ For window: set current child to window or its parent according to window-parent (setf *current-root* last-child *current-child* *current-root*) (focus-all-children *current-child* *current-child*) - (show-all-children *current-root*)) + (show-all-children)) (setf last-child current-child)))) @@ -1565,7 +1568,7 @@ For window: set current child to window or its parent according to window-parent (when maximized (setf *current-root* parent)) (focus-all-children window parent) - (show-all-children *current-root*)) + (show-all-children)) (funcall run-fn)))) diff --git a/src/clfswm.lisp b/src/clfswm.lisp index b9bea4c..6855ec3 100644 --- a/src/clfswm.lisp +++ b/src/clfswm.lisp @@ -209,7 +209,7 @@ *current-child* *current-root*) (call-hook *init-hook*) (process-existing-windows *screen*) - (show-all-children *current-root*) + (show-all-children) (grab-main-keys) (xlib:display-finish-output *display*)) -- 2.11.4.GIT