comparison lisp/dframe.el @ 94274:b9513e9a71ae

(dframe-have-timer-flag): Drop support for Emacs without timers. Doc fix. (dframe-update-speed): Drop support for XEmacs < 20. (dframe-frame-mode): Drop support for Emacs < 20. (dframe-set-timer-internal): Drop support for Emacs without timers. (dframe-popup-kludge): Use mouse-menu-major-mode-map if defined.
author Glenn Morris <rgm@gnu.org>
date Wed, 23 Apr 2008 02:57:11 +0000
parents 107ccd98fa12
children ee5932bf781d
comparison
equal deleted inserted replaced
94273:4fad9433957b 94274:b9513e9a71ae
41 ;; * Switching between frames. 41 ;; * Switching between frames.
42 ;; * Timed activities using idle-timers 42 ;; * Timed activities using idle-timers
43 ;; * Frame/buffer killing hooks 43 ;; * Frame/buffer killing hooks
44 ;; * Mouse-3 position relative menu 44 ;; * Mouse-3 position relative menu
45 ;; * Mouse motion, help-echo hacks 45 ;; * Mouse motion, help-echo hacks
46 ;; * Mouse clicking, double clicking, & Xemacs image clicking hack 46 ;; * Mouse clicking, double clicking, & XEmacs image clicking hack
47 ;; * Mode line hacking 47 ;; * Mode line hacking
48 ;; * Utilities for use in a program covering: 48 ;; * Utilities for use in a program covering:
49 ;; o keymap massage for some actions 49 ;; o keymap massage for some actions
50 ;; o working with an associated buffer 50 ;; o working with an associated buffer
51 ;; o shift-click 51 ;; o shift-click
106 ;; then `shift' was held down during the click. 106 ;; then `shift' was held down during the click.
107 107
108 ;;; Bugs 108 ;;; Bugs
109 ;; 109 ;;
110 ;; * The timer managers doesn't handle multiple different timeouts. 110 ;; * The timer managers doesn't handle multiple different timeouts.
111 ;; * You can't specify continuous timouts (as opposed to just lidle timers.) 111 ;; * You can't specify continuous timeouts (as opposed to just idle timers.)
112 112
113 (defvar x-pointer-hand2) 113 (defvar x-pointer-hand2)
114 (defvar x-pointer-top-left-arrow) 114 (defvar x-pointer-top-left-arrow)
115 115
116 ;;; Code: 116 ;;; Code:
129 (defgroup dframe nil 129 (defgroup dframe nil
130 "Faces used in dframe." 130 "Faces used in dframe."
131 :prefix "dframe-" 131 :prefix "dframe-"
132 :group 'dframe) 132 :group 'dframe)
133 133
134 (defvar dframe-have-timer-flag 134 (defvar dframe-have-timer-flag (if (fboundp 'display-graphic-p)
135 (and (or (fboundp 'run-with-idle-timer) 135 (display-graphic-p)
136 (fboundp 'start-itimer) 136 window-system)
137 (boundp 'post-command-idle-hook)) 137 "Non-nil means that timers are available for this Emacs.
138 (if (fboundp 'display-graphic-p) 138 This is nil for terminals, since updating a frame in a terminal
139 (display-graphic-p) 139 is not useful to the user.")
140 window-system))
141 "Non-nil means that timers are available for this Emacs.")
142 140
143 (defcustom dframe-update-speed 141 (defcustom dframe-update-speed
144 (if (featurep 'xemacs) 142 (if (featurep 'xemacs) 2 ; 1 is too obrusive in XEmacs
145 (if (>= emacs-major-version 20)
146 2 ; 1 is too obrusive in XEmacs
147 5) ; when no idleness, need long delay
148 1) 143 1)
149 "Idle time in seconds needed before dframe will update itself. 144 "Idle time in seconds needed before dframe will update itself.
150 Updates occur to allow dframe to display directory information 145 Updates occur to allow dframe to display directory information
151 relevant to the buffer you are currently editing." 146 relevant to the buffer you are currently editing."
152 :group 'dframe 147 :group 'dframe
389 paramsa 384 paramsa
390 (append 385 (append
391 paramsa 386 paramsa
392 (list (cons 'width (frame-width)))))) 387 (list (cons 'width (frame-width))))))
393 (frame 388 (frame
394 (if (or (< emacs-major-version 20) 389 (if (not (eq window-system 'x))
395 (not (eq window-system 'x)))
396 (make-frame params) 390 (make-frame params)
397 (let ((x-pointer-shape x-pointer-top-left-arrow) 391 (let ((x-pointer-shape x-pointer-top-left-arrow)
398 (x-sensitive-text-pointer-shape 392 (x-sensitive-text-pointer-shape
399 x-pointer-hand2)) 393 x-pointer-hand2))
400 (make-frame params))))) 394 (make-frame params)))))
742 (and dframe-timer (not timeout) dframe-client-functions)) 736 (and dframe-timer (not timeout) dframe-client-functions))
743 ;; Only call the low level function if we are changing the state. 737 ;; Only call the low level function if we are changing the state.
744 (dframe-set-timer-internal timeout null-on-error))) 738 (dframe-set-timer-internal timeout null-on-error)))
745 739
746 (defun dframe-set-timer-internal (timeout &optional null-on-error) 740 (defun dframe-set-timer-internal (timeout &optional null-on-error)
747 "Apply a timer with TIMEOUT to call the dframe timer manager. 741 "Apply a timer with TIMEOUT to call the dframe timer manager."
748 If NULL-ON-ERROR is a symbol, set it to nil if we cannot create a timer." 742 (when dframe-timer
749 (cond 743 (if (featurep 'xemacs)
750 ;; XEmacs 744 (delete-itimer dframe-timer)
751 ((featurep 'xemacs) 745 (cancel-timer dframe-timer))
752 (if dframe-timer 746 (setq dframe-timer nil))
753 (progn (delete-itimer dframe-timer) 747 (when timeout
754 (setq dframe-timer nil))) 748 (setq dframe-timer
755 (if timeout 749 (if (featurep 'xemacs)
756 (if (or (>= emacs-major-version 21) 750 (start-itimer "dframe" 'dframe-timer-fn
757 (and (= emacs-major-version 20) 751 timeout timeout t)
758 (> emacs-minor-version 0)) 752 (run-with-idle-timer timeout t 'dframe-timer-fn)))))
759 (and (= emacs-major-version 19)
760 (>= emacs-minor-version 15)))
761 (setq dframe-timer (start-itimer "dframe"
762 'dframe-timer-fn
763 timeout
764 timeout
765 t))
766 (setq dframe-timer (start-itimer "dframe"
767 'dframe-timer-fn
768 timeout
769 nil)))))
770 ;; Post 19.31 Emacs
771 ((fboundp 'run-with-idle-timer)
772 (if dframe-timer
773 (progn (cancel-timer dframe-timer)
774 (setq dframe-timer nil)))
775 (if timeout
776 (setq dframe-timer
777 (run-with-idle-timer timeout t 'dframe-timer-fn))))
778 ;; Emacs 19.30 (Thanks twice: ptype@dra.hmg.gb)
779 ((boundp 'post-command-idle-hook)
780 (if timeout
781 (add-hook 'post-command-idle-hook 'dframe-timer-fn)
782 (remove-hook 'post-command-idle-hook 'dframe-timer-fn)))
783 ;; Older or other Emacsen with no timers. Set up so that its
784 ;; obvious this emacs can't handle the updates
785 ((symbolp null-on-error)
786 (set null-on-error nil)))
787 )
788 753
789 (defun dframe-timer-fn () 754 (defun dframe-timer-fn ()
790 "Called due to the dframe timer. 755 "Called due to the dframe timer.
791 Evaluates all cached timer functions in sequence." 756 Evaluates all cached timer functions in sequence."
792 (let ((l dframe-client-functions)) 757 (let ((l dframe-client-functions))
838 (save-excursion 803 (save-excursion
839 (mouse-set-point e) 804 (mouse-set-point e)
840 ;; This gets the cursor where the user can see it. 805 ;; This gets the cursor where the user can see it.
841 (if (not (bolp)) (forward-char -1)) 806 (if (not (bolp)) (forward-char -1))
842 (sit-for 0) 807 (sit-for 0)
843 (if (< emacs-major-version 20) 808 (if (fboundp 'mouse-menu-major-mode-map)
844 (mouse-major-mode-menu e) 809 (popup-menu (mouse-menu-major-mode-map) e)
845 (mouse-major-mode-menu e nil)))))) 810 (with-no-warnings ; don't warn about obsolete fallback
811 (mouse-major-mode-menu e nil)))))))
846 812
847 ;;; Interactive user functions for the mouse 813 ;;; Interactive user functions for the mouse
848 ;; 814 ;;
849 (defalias 'dframe-mouse-event-p 815 (defalias 'dframe-mouse-event-p
850 (if (featurep 'xemacs) 816 (if (featurep 'xemacs)