summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/frame.el7
-rw-r--r--lisp/term/xterm.el21
2 files changed, 25 insertions, 3 deletions
diff --git a/lisp/frame.el b/lisp/frame.el
index 359c5036557..c3daff44406 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -129,7 +129,7 @@ appended when the minibuffer frame is created."
;; Gildea@x.org says it is ok to ask questions before terminating.
(save-buffers-kill-emacs))))
-(defun handle-focus-in (_event)
+(defun handle-focus-in (&optional _event)
"Handle a focus-in event.
Focus-in events are usually bound to this function.
Focus-in events occur when a frame has focus, but a switch-frame event
@@ -138,7 +138,7 @@ This function runs the hook `focus-in-hook'."
(interactive "e")
(run-hooks 'focus-in-hook))
-(defun handle-focus-out (_event)
+(defun handle-focus-out (&optional _event)
"Handle a focus-out event.
Focus-out events are usually bound to this function.
Focus-out events occur when no frame has focus.
@@ -2339,7 +2339,8 @@ frame receives focus."
This is done when a frame gets focus. Blink timers may be stopped by
`blink-cursor-suspend'."
(when (and blink-cursor-mode
- (not blink-cursor-idle-timer))
+ (not blink-cursor-idle-timer)
+ (display-graphic-p))
(remove-hook 'post-command-hook 'blink-cursor-check)
(blink-cursor--start-idle-timer)))
diff --git a/lisp/term/xterm.el b/lisp/term/xterm.el
index fea9851d720..6410a4b83c9 100644
--- a/lisp/term/xterm.el
+++ b/lisp/term/xterm.el
@@ -104,6 +104,16 @@ Return the pasted text as a string."
(define-key global-map [xterm-paste] #'xterm-paste)
+(defun xterm-handle-focus-in ()
+ (interactive)
+ (handle-focus-in))
+(define-key global-map [xterm-focus-in] #'xterm-handle-focus-in)
+
+(defun xterm-handle-focus-out ()
+ (interactive)
+ (handle-focus-out))
+(define-key global-map [xterm-focus-out] #'xterm-handle-focus-out)
+
(defvar xterm-rxvt-function-map
(let ((map (make-sparse-keymap)))
(define-key map "\e[2~" [insert])
@@ -136,6 +146,9 @@ Return the pasted text as a string."
;; internally recognizes the end.
(define-key map "\e[200~" [xterm-paste])
+ (define-key map "\e[I" [xterm-focus-in])
+ (define-key map "\e[O" [xterm-focus-out])
+
map)
"Keymap of escape sequences, shared between xterm and rxvt support.")
@@ -817,6 +830,8 @@ We run the first FUNCTION whose STRING matches the input events."
;; Unconditionally enable bracketed paste mode: terminals that don't
;; support it just ignore the sequence.
(xterm--init-bracketed-paste-mode)
+ ;; We likewise unconditionally enable support for focus tracking.
+ (xterm--init-focus-tracking)
(run-hooks 'terminal-init-xterm-hook))
@@ -832,6 +847,12 @@ We run the first FUNCTION whose STRING matches the input events."
(push "\e[?2004l" (terminal-parameter nil 'tty-mode-reset-strings))
(push "\e[?2004h" (terminal-parameter nil 'tty-mode-set-strings)))
+(defun xterm--init-focus-tracking ()
+ "Terminal initialization for focus tracking mode."
+ (send-string-to-terminal "\e[?1004h")
+ (push "\e[?1004l" (terminal-parameter nil 'tty-mode-reset-strings))
+ (push "\e[?1004h" (terminal-parameter nil 'tty-mode-set-strings)))
+
(defun xterm--init-activate-get-selection ()
"Terminal initialization for `gui-get-selection'."
(set-terminal-parameter nil 'xterm--get-selection t))