|
Focus newly mapped window: msg#00147window-managers.sawfish
I have a little problem. I want to set up a shortcut key to either raise, focus and got to a window that already exists or to execute a command, then raise, focus and goto the new window. Here's what I've got: (bind-keys global-keymap "M-C-e" '(tshanno-start-or-raise-focus "emacs &" "emacs") "M-C-g" '(tshanno-start-or-raise-focus "galeon &" "Galeon") "M-C-n" '(tshanno-start-or-raise-focus "netscape &" "Netscape")) (defun tshanno-start-or-raise-focus (tshanno-window-command tshanno-windowtwo-name) "Start program if an instance doesn't exist, then raise, focus and goto window." (interactive) (setq tshanno-junkthree-name "junk") (setq tshanno-junkthree-name (tshanno-window-name-match tshanno-windowtwo-name tshanno-junkthree-name)) (if (string= tshanno-junkthree-name "junk") (tshanno-start-command tshanno-window-command tshanno-windowtwo-name)) (tshanno-raise-focus tshanno-junkthree-name)) (defun tshanno-window-name-match (tshanno-windowthree-name tshanno-junkfour-name) "Return \"junk\" if window with name containing 'tshanno-windowthree-name' doesn't exist, otherwise return full window name" (setq tshanno-junkfour-name "junk") (let ((windows (managed-windows))) (mapc (lambda (w) (if (string-match (concat ".*" tshanno-windowthree-name ".*") (window-name w)) (setq tshanno-junkfour-name (window-name w)))) windows)) tshanno-junkfour-name) (defun tshanno-raise-focus (tshanno-junkone-name) "Raise and focus window with name 'tshanno-junkone-name'" (let ((w (get-window-by-name tshanno-junkone-name))) (if (window-get w 'iconified) (uniconify-window w)) (raise-window w) (set-input-focus w) (if (window-visible-p w) (show-window w)) (select-workspace (nearest-workspace-with-window w current-workspace)) (warp-cursor (car (window-position w)) (cdr (window-position w))))) (defun tshanno-start-command (tshanno-window-command tshanno-windowone-name) "Start command 'tshanno-window-command'" (system tshanno-window-command)) The above works pretty well but the problem is that sawfish tries to raise, focus and goto the new window created by the command before the window is actually mapped. The result is that I have to, for instance, press M-C-e twice if emacs isn't already running: once to start emacs, once more to raise, focus and goto the window. Any potential solutions would be appreciated. Tom S. -- Quote of the Day for Sunday, March 23, 2003 I have never made but one prayer to God, a very short one: 'O Lord, make my enemies ridiculous.' And God granted it. -- Voltaire |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | F-R-E-E 30 day supply of H G H 6974zXyj5-140Z-13: 00147, whbrp |
|---|---|
| Next by Date: | Sawfish and Gnome 2.2: 00147, PhaseBurn |
| Previous by Thread: | F-R-E-E 30 day supply of H G H 6974zXyj5-140Z-13i: 00147, whbrp |
| Next by Thread: | Sawfish and Gnome 2.2: 00147, PhaseBurn |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |