diff options
| author | Daniel Colascione | 2018-06-11 14:58:09 -0700 |
|---|---|---|
| committer | Daniel Colascione | 2018-06-11 16:10:34 -0700 |
| commit | 2f6c682061a281dc3e397ff4727a164880e86e7b (patch) | |
| tree | f5990303d483f7d80e1aa1e80a19dc64a6325b66 /src/frame.c | |
| parent | a20fe5a7e3577f9b9ad5e88006962966240d9b0c (diff) | |
| download | emacs-2f6c682061a281dc3e397ff4727a164880e86e7b.tar.gz emacs-2f6c682061a281dc3e397ff4727a164880e86e7b.zip | |
New focus management interface
focus-in-hook and focus-out-hook don't accurately reflect actual
user-visible focus states. Add a new focus interface and mark the old
one obsolete.
* doc/lispref/frames.texi (Input Focus): Document new focus
functions. Remove references to the now-obsolete focus hooks.
* lisp/frame.el (frame-focus-state): New function.
(after-focus-change-function): New variable.
(focus-in-hook, focus-out-hook): Move to lisp from C;
mark obsolete.
* lisp/term/xterm.el (xterm-translate-focus-in)
(xterm-translate-focus-out): Track tty focus in `tty-focus-state'
terminal parameter; call `after-focus-change-function'.
(xterm--suspend-tty-function): New function.
* src/frame.c (Fhandle_switch_frame): Update docstring; don't call
focus hooks.
(focus-in-hook, focus-out-hook): Remove: moved to lisp.
(syms_of_frame): Remove unread_switch_frame; add
Vunread_switch_frame.
* src/keyboard.c:
(Finternal_handle_focus_in): New function.
(make_lispy_event): Always report focus events to lisp; don't
translate them to switch events sometimes. Lisp can take care of
creating synthetic switch-frame events via
`internal-handle-focus-in'.
* src/w32term.c (x_focus_changed): Remove switch-avoidance logic:
just directly report focus changes to lisp.
* src/xterm.c (x_focus_changed): Remove switch-avoidance logic:
just directly report focus changes to lisp.
Diffstat (limited to 'src/frame.c')
| -rw-r--r-- | src/frame.c | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/src/frame.c b/src/frame.c index da82621b8a0..bf0269292d6 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -1455,23 +1455,15 @@ This function returns FRAME, or nil if FRAME has been deleted. */) | |||
| 1455 | DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 1, "^e", | 1455 | DEFUN ("handle-switch-frame", Fhandle_switch_frame, Shandle_switch_frame, 1, 1, "^e", |
| 1456 | doc: /* Handle a switch-frame event EVENT. | 1456 | doc: /* Handle a switch-frame event EVENT. |
| 1457 | Switch-frame events are usually bound to this function. | 1457 | Switch-frame events are usually bound to this function. |
| 1458 | A switch-frame event tells Emacs that the window manager has requested | 1458 | A switch-frame event is an event Emacs sends itself to |
| 1459 | that the user's events be directed to the frame mentioned in the event. | 1459 | indicate that input is arriving in a new frame. It does not |
| 1460 | This function selects the selected window of the frame of EVENT. | 1460 | necessarily represent user-visible input focus. */) |
| 1461 | |||
| 1462 | If EVENT is frame object, handle it as if it were a switch-frame event | ||
| 1463 | to that frame. */) | ||
| 1464 | (Lisp_Object event) | 1461 | (Lisp_Object event) |
| 1465 | { | 1462 | { |
| 1466 | Lisp_Object value; | ||
| 1467 | |||
| 1468 | /* Preserve prefix arg that the command loop just cleared. */ | 1463 | /* Preserve prefix arg that the command loop just cleared. */ |
| 1469 | kset_prefix_arg (current_kboard, Vcurrent_prefix_arg); | 1464 | kset_prefix_arg (current_kboard, Vcurrent_prefix_arg); |
| 1470 | run_hook (Qmouse_leave_buffer_hook); | 1465 | run_hook (Qmouse_leave_buffer_hook); |
| 1471 | /* `switch-frame' implies a focus in. */ | 1466 | return do_switch_frame (event, 0, 0, Qnil); |
| 1472 | value = do_switch_frame (event, 0, 0, Qnil); | ||
| 1473 | call1 (intern ("handle-focus-in"), event); | ||
| 1474 | return value; | ||
| 1475 | } | 1467 | } |
| 1476 | 1468 | ||
| 1477 | DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0, | 1469 | DEFUN ("selected-frame", Fselected_frame, Sselected_frame, 0, 0, 0, |
| @@ -5888,15 +5880,6 @@ when the mouse is over clickable text. */); | |||
| 5888 | The pointer becomes visible again when the mouse is moved. */); | 5880 | The pointer becomes visible again when the mouse is moved. */); |
| 5889 | Vmake_pointer_invisible = Qt; | 5881 | Vmake_pointer_invisible = Qt; |
| 5890 | 5882 | ||
| 5891 | DEFVAR_LISP ("focus-in-hook", Vfocus_in_hook, | ||
| 5892 | doc: /* Normal hook run when a frame gains input focus. | ||
| 5893 | The frame gaining focus is selected at the time this hook is run. */); | ||
| 5894 | Vfocus_in_hook = Qnil; | ||
| 5895 | |||
| 5896 | DEFVAR_LISP ("focus-out-hook", Vfocus_out_hook, | ||
| 5897 | doc: /* Normal hook run when all frames lost input focus. */); | ||
| 5898 | Vfocus_out_hook = Qnil; | ||
| 5899 | |||
| 5900 | DEFVAR_LISP ("move-frame-functions", Vmove_frame_functions, | 5883 | DEFVAR_LISP ("move-frame-functions", Vmove_frame_functions, |
| 5901 | doc: /* Functions run after a frame was moved. | 5884 | doc: /* Functions run after a frame was moved. |
| 5902 | The functions are run with one arg, the frame that moved. */); | 5885 | The functions are run with one arg, the frame that moved. */); |