[clfswm-devel] Focus and new window
Philippe Brochard
pbrochard at common-lisp.net
Sat Apr 5 21:27:52 UTC 2008
Xavier Maillard writes:
> Hi,
>
Hi,
> How can I control the focus with new created window ?
>
> I do not like the default to put the focus on a newly created
> window and I want to be able to control that behaviour.
>
> Typical use case:
>
> In emacs, I create a terminal. I do not want to change to that
> new window *but* stay on the emacs window from where I send
> orders to that xterm.
>
This is typically the goal of new window hook. In clfswm it's the
first child of a frame who takes the focus. You just need to swap
children when they are created.
If you want to make this permanent, just change the default new window
hook (in clfswm-nw-hook.lisp):
--------------------------------------------------
(defun default-frame-nw-hook (frame window)
"Open the next window in the current frame"
(declare (ignore frame))
(leave-if-not-frame *current-child*)
(when (frame-p *current-child*)
(pushnew window (frame-child *current-child*))
(when (second (frame-child *current-child*)) ; <- here
(rotatef (first (frame-child *current-child*)) (second (frame-child *current-child*)))))
(default-window-placement *current-child* window))
--------------------------------------------------
If you just want this behaviour for a particular frame, define a new
hook and register it:
--------------------------------------------------
;;; Open a new window but leave the focus on the current child
(defun leave-focus-frame-nw-hook (frame window)
"Open the next window in the current frame and leave the focus on the current child"
(declare (ignore frame))
(leave-if-not-frame *current-child*)
(when (frame-p *current-child*)
(pushnew window (frame-child *current-child*))
(when (second (frame-child *current-child*))
(rotatef (first (frame-child *current-child*))
(second (frame-child *current-child*)))))
(default-window-placement *current-child* window))
(defun set-leave-focus-frame-nw-hook ()
"Open the next window in the current frame and leave the focus on the current child"
(set-nw-hook #'leave-focus-frame-nw-hook))
(register-nw-hook 'set-leave-focus-frame-nw-hook)
--------------------------------------------------
After registering it, it is available from the new window hook menu
(by default: second mode -> f -> n -> e)
I've let this hook in the code. Just pull the last commit.
Hope that'll help,
Regards,
Philipe
--
Philippe Brochard <pbrochard at common-lisp.net>
http://hocwp.free.fr
More information about the clfswm-devel
mailing list