;;;; Make sawmill remember the currently focused window when exiting a ;;;; workspace and then refocus it when re-entering that workspace. ;;;; ;;;; Copyright (C) 1999 Kevin Sivits ;;;; There is no warranty and no restriction on redistribution. ;;; Currently a window is brought to the top when refocused. This is ;;; done because if a window overlaps the upper right hand corner ;;; of the focused window and you are in focus follow mouse mode, the ;;; overlapping window will get the focus instead. ;;; If this behavior bothers you, set the value to nil. (defvar raise-on-refocus-sivits t) ;;; alist of previously focused windows (defvar focus-alist-sivits nil) (defun return-focus-sivits () (let ((new-workspace (assoc current-workspace focus-alist-sivits))) (when (and (not (null new-workspace)) (not (null (cdr new-workspace))) (equal (window-get (cdr new-workspace) 'workspace) (car new-workspace))) (if raise-on-refocus-sivits (raise-window (cdr new-workspace))) (if (not (eq focus-mode 'click)) (warp-cursor-to-window (cdr new-workspace)) (set-input-focus (cdr new-workspace)))))) (defun save-focus-sivits () (let ((old-workspace (assoc current-workspace focus-alist-sivits))) (if (null old-workspace) (if (input-focus) (setq focus-alist-sivits (cons (cons current-workspace (input-focus)) focus-alist-sivits))) (rplacd old-workspace (input-focus))))) (add-hook 'leave-workspace-hook 'save-focus-sivits) (add-hook 'enter-workspace-hook 'return-focus-sivits)