-(define-minor-mode t-mouse-mode
- "Toggle t-mouse mode to use the mouse in Linux consoles.
-With prefix arg, turn t-mouse mode on iff arg is positive.
-
-This allows the use of the mouse when operating on a Linux console, in the
-same way as you can use the mouse under X11.
-It requires the `mev' program, part of the `gpm' utilities."
- :global t :group 'mouse
- (if window-system
- (error "t-mouse only works in the console on GNU/Linux")
- (if t-mouse-mode
- (progn
- (unless (fboundp 'term-open-connection)
- (progn
- (setq t-mouse-mode nil)
- (error "Emacs must be built with Gpm to use this mode")))
- (unless (term-open-connection)
- (progn
- (setq t-mouse-mode nil)
- (error "Can't open mouse connection"))))
- ;; Turn it off
- (term-close-connection))))
+(define-obsolete-function-alias 't-mouse-mode 'gpm-mouse-mode "23.1")
+;;;###autoload
+(define-minor-mode gpm-mouse-mode
+ "Toggle gpm-mouse mode to use the mouse in GNU/Linux consoles.
+With prefix arg, turn gpm-mouse mode on if arg is positive,
+otherwise turn it off.
+
+This allows the use of the mouse when operating on a GNU/Linux console,
+in the same way as you can use the mouse under X11.
+It relies on the `gpm' daemon being activated."
+ :global t :group 'mouse :init-value t
+ (dolist (terminal (terminal-list))
+ (when (and (eq t (terminal-live-p terminal))
+ (not (eq gpm-mouse-mode
+ (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))))))