+ (unless activated (gpm-mouse-disable)))))
+
+(defun gpm-mouse-disable ()
+ "Try to disable gpm mouse support on the current terminal."
+ (when (fboundp 'gpm-mouse-stop)
+ (gpm-mouse-stop))
+ (set-terminal-parameter nil 'gpm-mouse-active nil))
+
+;;;###autoload
+(define-obsolete-function-alias 't-mouse-mode 'gpm-mouse-mode "23.1")
+;;;###autoload
+(define-minor-mode gpm-mouse-mode
+ "Toggle mouse support in GNU/Linux consoles (GPM Mouse mode).
+With a prefix argument ARG, enable GPM Mouse mode if ARG is
+positive, and disable it otherwise. If called from Lisp, enable
+the mode if ARG is omitted or nil.
+
+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))))))