greg(a)alphatech.com (Greg Klanderman) writes:
Hrvoje> Maybe `set-frame-focus' would be a better name.
I can do this. I assume Ben meant a C primitive, not a lisp function
using the same bind focus-follows-mouse and sit-for 0 hack.
Yup. From the outside, `set-frame-focus' would do what `select-frame'
used to do.
This should be easy, and I will clean up those messy externs while
I'm at it. Then I'll update the docs not to mention that
abomination.
:-) Please do.
BTW Hrvoje, thanks for cleaning up my docs patch.
>> Also, do there exist forms save-selected-frame and
>> with-selected-frame? If not, there should be.
Hrvoje>
Hrvoje> I can code and document these.
OK. Ben do you intend these to just be macros using select-frame
and unwind-protect?
(defmacro save-selected-frame (&rest body)
"Execute forms in BODY, then restore the selected frame.
The value returned is the value of the last form in BODY.
The frame selection is not accompanied by changes to the actual window
manager focus and is not affected by the value of `focus-follows-mouse'.
See also `with-selected-frame'."
(let ((old-frame (gensym "ssf")))
`(let ((,old-frame (selected-frame))
(focus-follows-mouse t))
(unwind-protect
(progn ,@body)
(select-frame ,old-frame)))))
The macro binds `focus-follows-mouse' to t to avoid focus flicker even
if focus-follows-mouse is nil. There is a potential problem with code
within BODY that might want to check focus-follows-mouse, but I don't
think the problem is serious enough to be worth solving (it might be
solved by introducing an `overriding-focus-follows-mouse' or something
like that.)
Here is an implementation of `with-selected-frame':
(defmacro with-selected-frame (frame &rest body)
"Execute forms in BODY with FRAME as the selected frame.
The value returned is the value of the last form in BODY.
The frame selection is not accompanied by changes to the actual window
manager focus and is not affected by the value of `focus-follows-mouse'.
See also `with-selected-frame'."
`(save-selected-frame
(select-frame ,frame)
,@body))
If you like these, I'll send out a patch. I'll also expand the news
entry to cover all this new stuff in some detail.
>> Also, the default value of focus-follows-mouse should be
set
>> according to the window manager's focus policy. This might entail
>> some special case code for particular window managers (each of which
>> has their own protocol for obtaining this property), with a default
>> value of nil under Unix and true under Windows.
Hrvoje>
Hrvoje> Why not the opposite -- nil under Windows, and true under Unix?
OK, but I have no clue how to do these last two....
No problem, that code can be added later.
--
Hrvoje Niksic <hniksic(a)srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
- Now what did we learn from this?
- I learned what my liver looks like!