(defun select-frame-set-input-focus (frame)
"Select FRAME, raise it, and set input focus, if possible."
(select-frame frame)
(raise-frame frame)
;; Ensure, if possible, that frame gets input focus.
(cond ((eq window-system 'x) (x-focus-frame frame))
((eq window-system 'w32) (w32-focus-frame frame)))
(cond (focus-follows-mouse
(set-mouse-position (selected-frame)
(1- (frame-width)) 0)))))
FWIW, I think the name of the variable is misleading, to some extent:
it was introduced to overcome a difficulty with certain window
managers on X, but that difficulty is not really in the fact that
focus follows the mouse pointer; rather, the focus policy is a
_symptom_ of another problem which prevents Emacs from giving focus to
the frame as part of x-focus-frame call. I'm not an expert on X, so
perhaps Jan or someone else could comment on what really happens on X
wrt this.
There are window managers that does not allow focus changes outside the window
that has the mouse in it, if focus follows mouse. Metacity and sawfish calls
this mode focus-follows-mouse-strict. In that case, the code above moves the
mouse to the new window so it gets the focus. It is not documented what
window managers should do in this situation, so different implementations exist.
There is another focus follows mouse version, usually called sloppy. It means
that if the mouse moves out of a window on to the background (root), it will
still have the focus. And then there are window managers that moves the mouse
by themselves to newly created windows. So I have never seen any difference
in behavious in Emacs if I change the value of focus-follows-mouse, but this
is just because I run window managers with a certain behaviour.
So focus-follows-mouse need only be set for those window managers that don't
allow focus changes when focus follow mouse is in effect. I don't know
exactly which window managers this might be, but I can try some I have.
Nowdays, bot Gnome and KDE has focus follows click by default, and most window
managers gives focus to new windows, so I guess setting focus-follows-mouse is
rarely needed.
Jan D.
_______________________________________________
emacs-pretest-bug mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-pretest-bug