~ilmu/vegur

ed6ca93be542cbd9d8d00211dbb2298692e3e049 — ilmu 1 year, 8 months ago 09cb31a
Fixed bug caused by fprev and fnext not being reliable.
2 files changed, 25 insertions(+), 10 deletions(-)

M bootstrap-figs/stumpwm/commands.lisp
M bootstrap-figs/stumpwm/internals.lisp
M bootstrap-figs/stumpwm/commands.lisp => bootstrap-figs/stumpwm/commands.lisp +16 -7
@@ 93,15 93,24 @@ concepts can be avoided by user who just opens, closes and rearranges windows.
"Split the current frame into 2 frames in the desired direction."
  (split-frame-in-dir (current-group) dir 1/2))

#| Case analysis

Last window -> If move in valid direction: close split, otherwise: noop.
Not last window -> If move in invalid direction: open split and move-window, otherwise: move-window.

|#

(defcommand (move tile-group) (dir) ((:direction "Direction: "))
  "Split the frame if necessary to move in direction. Closes split if it leaves empty frame."
  (when (detect-monitor-edge (current-group) dir)
    (dirsplit dir))
  (move-window dir)
  (fprev)
  (when (detect-empty-frame (current-group))
    (remove-split))
  (fnext))
  (if (detect-last-window (current-group))
      (unless (detect-monitor-edge (current-group) dir)
	(let ((last-frame (tile-group-current-frame (current-group))))
	  (move-window dir)
	  (remove-split (current-group) last-frame)))
      (progn
	(when (detect-monitor-edge (current-group) dir)
	  (dirsplit dir))
	(move-window dir))))

;; such a soup of accessors, find some simple example to work from... really need repl!
;;( (frame-windows (current-group) (tile-group-current-frame (current-group)))

M bootstrap-figs/stumpwm/internals.lisp => bootstrap-figs/stumpwm/internals.lisp +9 -3
@@ 116,12 116,18 @@ desktop when starting."
	    (frame-number (tile-group-current-frame group)))
	t
	(progn
	  (fprev)
	  (fselect frame)
	  nil))))

(defun detect-empty-frame (group)
(defun detect-last-window (group &optional (frame nil))
  "Checks if the current frame has only one window"
  (= 0 (length (frame-windows (current-group) (tile-group-current-frame (current-group))))))
  (unless frame (setf frame (tile-group-current-frame (current-group))))
  (= 1 (length (frame-windows (current-group) frame))))

(defun detect-empty-frame (group &optional (frame nil))
  "Checks if the current frame has only one window"
  (unless frame (setf frame (tile-group-current-frame (current-group))))
  (= 0 (length (frame-windows (current-group) frame))))

(defcommand test-detection () ()
  (when (detect-monitor-edge (current-group) :up)