Re: [Sawfish] single-window-mode approach

[ Thread Index | Date Index | More lists.tuxfamily.org/sawfish Archives ]


Sorry for quick self-reply, but this versions exists single-window-mode if the 
single-window-mode-window is closed.

Chris

### code ###

(defvar single-window-mode nil)
(defvar single-window-mode-window nil)
(defvar single-window-mode-workspace nil)

(define (toggle-single-window-mode w)
  (let ((iconify-group-mode 'none)
	(raise-windows-on-uniconify nil))

    (if single-window-mode
	(setq single-window-mode nil)
      (setq single-window-mode t))

    (define (fun x)
      (if single-window-mode
	  (progn
	    (setq single-window-mode-window w)
	    (setq single-window-mode-workspace current-workspace)
	    (when (windows-share-workspace-p w x)
	      (if (or (window-get x 'ignore)
		      (window-get x 'avoid))
		  (lower-window x)
		(iconify-window x))))
	(setq single-window-mode-window nil)
	(setq single-window-mode-workspace nil)
	(when (windows-share-workspace-p w x)
	  (if (or (window-get x 'ignore)
		  (window-get x 'avoid))
	      (raise-window x)
	    (uniconify-window x)))))

    (map-other-window-groups
      (lambda (x)
	(fun x)) w)))

(define (single-window-mode-after-add-window w)
  (when single-window-mode
    (let ((group (windows-in-group single-window-mode-window)))
      (when (and (not (memq w group))
 		 (windows-share-workspace-p single-window-mode-window w))
	(if (or (window-get w 'ignore)
	        (window-get w 'avoid))
	    (lower-window w)
	  (iconify-window w))))))

(define (single-window-mode-destroy-notify w)
  (when (and single-window-mode
             (eq w single-window-mode-window))
    (setq single-window-mode nil)
    (setq single-window-mode-window nil)
    (unless (eq current-workspace single-window-mode-workspace)
      (select-workspace single-window-mode-workspace))
    (setq single-window-mode-workspace nil)
    (map-windows (lambda (x)
		    (when (window-on-current-workspace-p x)
		      (if (or (window-get x 'ignore)
			      (window-get x 'avoid))
			  (raise-window x)
			(uniconify-window x)))))))

(add-hook 'after-add-window-hook single-window-mode-after-add-window t)
(add-hook 'destroy-notify-hook single-window-mode-destroy-notify t)

### end ###

---
--
Sawfish ML


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/