[Sawfish] single-window-mode approach

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

Hi all,

the first feature I'd like to backport from 0.38 is the single-window-mode.
Old code runs just fine, but I'm not acutally satisfied with it, so I approached 
on making something better.

changes to original:
- lower ignored windows when mode is active instead of doing nothing*
- handle avoided windows (just like ignored)*
- re-raise ignored and avoided windows when mode is inactive
- hook into after-add-window-hook for better "single-window" experience

* I know it's not optimal for ignored at least, but it helps getting all the 
attention of the single-window (as desired if one uses that).

stuff I have in mind:
- alist for each workspace (would allow "single-window-mode" per WS)
- single-window window-matcher, init a single-window-mode on current WS or 
move window to first empty WS (or create if none) and init toggle-window-mode 
- maybe VP mode?
- more?

Feel free to leave comments,

### OLD code ###

  (define (toggle-single-window-mode w)
    (let ((iconify-group-mode 'none)
	  (raise-windows-on-uniconify nil)
       (lambda (x)
	 (when (and (windows-share-workspace-p w x)
		    (not (window-get x 'ignored)))
	   (unless fun
	     (setq fun (if (window-get x 'iconified)
	   (fun x))) w)))

### NEW code ###

(define single-window-mode nil)
(define single-window-mode-window)

(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
	    (setq single-window-mode-window w)
	    (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)
	(when (windows-share-workspace-p w x)
	  (if (or (window-get x 'ignore)
		  (window-get x 'avoid))
	      (raise-window x)
	    (uniconify-window x)))))

      (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))))))

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

### End ###

Sawfish ML

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