From a28ede3a61a70cf83dfcba6c9d314fbb051a3a94 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 30 Aug 2022 17:55:03 -0400 Subject: [PATCH] t-mouse.el: Make sure we apply the setting to new terminals * lisp/t-mouse.el (gpm-mouse-tty-setup): New function. (gpm-mouse-mode): Use it as well as `tty-setup-hook`. * lisp/term/linux.el (terminal-init-linux): Remove gpm-specific code, not neded any more. --- lisp/t-mouse.el | 7 ++++++- lisp/term/linux.el | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lisp/t-mouse.el b/lisp/t-mouse.el index cdfc30c8793..7a4e7f330ea 100644 --- a/lisp/t-mouse.el +++ b/lisp/t-mouse.el @@ -62,6 +62,9 @@ (gpm-mouse-stop)) (set-terminal-parameter nil 'gpm-mouse-active nil)) +(defun gpm-mouse-tty-setup () + (if gpm-mouse-mode (gpm-mouse-enable) (gpm-mouse-disable))) + ;;;###autoload (define-minor-mode gpm-mouse-mode "Toggle mouse support in GNU/Linux consoles (GPM Mouse mode). @@ -80,7 +83,9 @@ GPM. This is due to limitations in GPM and the Linux kernel." (terminal-parameter terminal 'gpm-mouse-active)))) ;; Simulate selecting a terminal by selecting one of its frames ;-( (with-selected-frame (car (frames-on-display-list terminal)) - (if gpm-mouse-mode (gpm-mouse-enable) (gpm-mouse-disable)))))) + (gpm-mouse-tty-setup)))) + (when gpm-mouse-mode + (add-hook 'tty-setup-hook #'gpm-mouse-tty-setup))) (provide 't-mouse) diff --git a/lisp/term/linux.el b/lisp/term/linux.el index ab5a6d8698f..60bf91fcf52 100644 --- a/lisp/term/linux.el +++ b/lisp/term/linux.el @@ -15,8 +15,6 @@ ;; Compositions confuse cursor movement. (setq-default auto-composition-mode "linux") - (ignore-errors (when gpm-mouse-mode (require 't-mouse) (gpm-mouse-enable))) - ;; Don't translate ESC TAB to backtab as directed ;; by ncurses-6.3. (define-key input-decode-map "\e\t" nil) -- 2.39.2