diff options
| author | Gerd Moellmann | 2000-02-25 13:32:18 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-02-25 13:32:18 +0000 |
| commit | 4ae9a85e9783e65d87061bf74dcc58e6e7a9209d (patch) | |
| tree | b3bb01b104d06025e0d16f3cd52091c422e27f93 /src | |
| parent | e5baa1a7d2ad22112b78a64ee774316a56bf43f9 (diff) | |
| download | emacs-4ae9a85e9783e65d87061bf74dcc58e6e7a9209d.tar.gz emacs-4ae9a85e9783e65d87061bf74dcc58e6e7a9209d.zip | |
(inhibit_busy_cursor, busy_count): Removed.
(Fx_show_busy_cursor, Fx_hide_busy_cursor): Removed.
(busy_cursor_atimer, busy_cursor_shown_p, Vbusy_cursor_delay): New
variables.
(DEFAULT_BUSY_CURSOR_DELAY): New define.
(start_busy_cursor, cancel_busy_cursor, show_busy_cursor)
(hide_busy_cursor): New functions.
(syms_of_xfns): DEFVAR_LISP Vbusy_cursor_delay.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfns.c | 183 |
1 files changed, 114 insertions, 69 deletions
diff --git a/src/xfns.c b/src/xfns.c index 147a6d1b59c..7fd8119a5f3 100644 --- a/src/xfns.c +++ b/src/xfns.c | |||
| @@ -42,6 +42,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 42 | #include "fontset.h" | 42 | #include "fontset.h" |
| 43 | #include "systime.h" | 43 | #include "systime.h" |
| 44 | #include "termhooks.h" | 44 | #include "termhooks.h" |
| 45 | #include "atimer.h" | ||
| 45 | 46 | ||
| 46 | #ifdef HAVE_X_WINDOWS | 47 | #ifdef HAVE_X_WINDOWS |
| 47 | 48 | ||
| @@ -10057,48 +10058,102 @@ value.") | |||
| 10057 | Busy cursor | 10058 | Busy cursor |
| 10058 | ***********************************************************************/ | 10059 | ***********************************************************************/ |
| 10059 | 10060 | ||
| 10060 | /* The implementation partly follows a patch from | 10061 | /* If non-null, an asynchronous timer that, when it expires, displays |
| 10061 | F.Pierresteguy@frcl.bull.fr dated 1994. */ | 10062 | a busy cursor on all frames. */ |
| 10062 | 10063 | ||
| 10063 | /* Setting inhibit_busy_cursor to 2 inhibits busy-cursor display until | 10064 | static struct atimer *busy_cursor_atimer; |
| 10064 | the next X event is read and we enter XTread_socket again. Setting | ||
| 10065 | it to 1 inhibits busy-cursor display for direct commands. */ | ||
| 10066 | 10065 | ||
| 10067 | int inhibit_busy_cursor; | 10066 | /* Non-zero means a busy cursor is currently shown. */ |
| 10068 | 10067 | ||
| 10069 | /* Incremented with each call to x-display-busy-cursor. | 10068 | static int busy_cursor_shown_p; |
| 10070 | Decremented in x-undisplay-busy-cursor. */ | ||
| 10071 | 10069 | ||
| 10072 | static int busy_count; | 10070 | /* Number of seconds to wait before displaying a busy cursor. */ |
| 10073 | 10071 | ||
| 10072 | static Lisp_Object Vbusy_cursor_delay; | ||
| 10074 | 10073 | ||
| 10075 | DEFUN ("x-show-busy-cursor", Fx_show_busy_cursor, | 10074 | /* Default number of seconds to wait before displaying a busy |
| 10076 | Sx_show_busy_cursor, 0, 0, 0, | 10075 | cursor. */ |
| 10077 | "Show a busy cursor, if not already shown.\n\ | 10076 | |
| 10078 | Each call to this function must be matched by a call to\n\ | 10077 | #define DEFAULT_BUSY_CURSOR_DELAY 1 |
| 10079 | `x-hide-busy-cursor' to make the busy pointer disappear again.") | 10078 | |
| 10080 | () | 10079 | /* Function prototypes. */ |
| 10080 | |||
| 10081 | static void show_busy_cursor P_ ((struct atimer *)); | ||
| 10082 | static void hide_busy_cursor P_ ((void)); | ||
| 10083 | |||
| 10084 | |||
| 10085 | /* Cancel a currently active busy-cursor timer, and start a new one. */ | ||
| 10086 | |||
| 10087 | void | ||
| 10088 | start_busy_cursor () | ||
| 10081 | { | 10089 | { |
| 10082 | ++busy_count; | 10090 | EMACS_TIME delay; |
| 10083 | if (busy_count == 1) | 10091 | int secs; |
| 10092 | |||
| 10093 | cancel_busy_cursor (); | ||
| 10094 | |||
| 10095 | if (INTEGERP (Vbusy_cursor_delay) | ||
| 10096 | && XINT (Vbusy_cursor_delay) > 0) | ||
| 10097 | secs = XFASTINT (Vbusy_cursor_delay); | ||
| 10098 | else | ||
| 10099 | secs = DEFAULT_BUSY_CURSOR_DELAY; | ||
| 10100 | |||
| 10101 | EMACS_SET_SECS_USECS (delay, secs, 0); | ||
| 10102 | busy_cursor_atimer = start_atimer (ATIMER_RELATIVE, delay, | ||
| 10103 | show_busy_cursor, NULL); | ||
| 10104 | } | ||
| 10105 | |||
| 10106 | |||
| 10107 | /* Cancel the busy cursor timer if active, hide a busy cursor if | ||
| 10108 | shown. */ | ||
| 10109 | |||
| 10110 | void | ||
| 10111 | cancel_busy_cursor () | ||
| 10112 | { | ||
| 10113 | if (busy_cursor_atimer) | ||
| 10114 | cancel_atimer (busy_cursor_atimer); | ||
| 10115 | if (busy_cursor_shown_p) | ||
| 10116 | hide_busy_cursor (); | ||
| 10117 | } | ||
| 10118 | |||
| 10119 | |||
| 10120 | /* Timer function of busy_cursor_atimer. TIMER is equal to | ||
| 10121 | busy_cursor_atimer. | ||
| 10122 | |||
| 10123 | Display a busy cursor on all frames by mapping the frames' | ||
| 10124 | busy_window. Set the busy_p flag in the frames' output_data.x | ||
| 10125 | structure to indicate that a busy cursor is shown on the | ||
| 10126 | frames. */ | ||
| 10127 | |||
| 10128 | static void | ||
| 10129 | show_busy_cursor (timer) | ||
| 10130 | struct atimer *timer; | ||
| 10131 | { | ||
| 10132 | /* The timer implementation will cancel this timer automatically | ||
| 10133 | after this function has run. Set busy_cursor_atimer to null | ||
| 10134 | so that we know the timer doesn't have to be canceled. */ | ||
| 10135 | busy_cursor_atimer = NULL; | ||
| 10136 | |||
| 10137 | if (!busy_cursor_shown_p) | ||
| 10084 | { | 10138 | { |
| 10085 | Lisp_Object rest, frame; | 10139 | Lisp_Object rest, frame; |
| 10086 | 10140 | ||
| 10141 | BLOCK_INPUT; | ||
| 10142 | |||
| 10087 | FOR_EACH_FRAME (rest, frame) | 10143 | FOR_EACH_FRAME (rest, frame) |
| 10088 | if (FRAME_X_P (XFRAME (frame))) | 10144 | if (FRAME_X_P (XFRAME (frame))) |
| 10089 | { | 10145 | { |
| 10090 | struct frame *f = XFRAME (frame); | 10146 | struct frame *f = XFRAME (frame); |
| 10091 | 10147 | ||
| 10092 | BLOCK_INPUT; | ||
| 10093 | f->output_data.x->busy_p = 1; | 10148 | f->output_data.x->busy_p = 1; |
| 10094 | 10149 | ||
| 10095 | if (!f->output_data.x->busy_window) | 10150 | if (!f->output_data.x->busy_window) |
| 10096 | { | 10151 | { |
| 10097 | unsigned long mask = CWCursor; | 10152 | unsigned long mask = CWCursor; |
| 10098 | XSetWindowAttributes attrs; | 10153 | XSetWindowAttributes attrs; |
| 10099 | 10154 | ||
| 10100 | attrs.cursor = f->output_data.x->busy_cursor; | 10155 | attrs.cursor = f->output_data.x->busy_cursor; |
| 10101 | 10156 | ||
| 10102 | f->output_data.x->busy_window | 10157 | f->output_data.x->busy_window |
| 10103 | = XCreateWindow (FRAME_X_DISPLAY (f), | 10158 | = XCreateWindow (FRAME_X_DISPLAY (f), |
| 10104 | FRAME_OUTER_WINDOW (f), | 10159 | FRAME_OUTER_WINDOW (f), |
| @@ -10107,58 +10162,46 @@ Each call to this function must be matched by a call to\n\ | |||
| 10107 | CopyFromParent, | 10162 | CopyFromParent, |
| 10108 | mask, &attrs); | 10163 | mask, &attrs); |
| 10109 | } | 10164 | } |
| 10110 | 10165 | ||
| 10111 | XMapRaised (FRAME_X_DISPLAY (f), f->output_data.x->busy_window); | 10166 | XMapRaised (FRAME_X_DISPLAY (f), f->output_data.x->busy_window); |
| 10112 | UNBLOCK_INPUT; | 10167 | XFlush (FRAME_X_DISPLAY (f)); |
| 10113 | } | 10168 | } |
| 10114 | } | ||
| 10115 | 10169 | ||
| 10116 | return Qnil; | 10170 | busy_cursor_shown_p = 1; |
| 10171 | UNBLOCK_INPUT; | ||
| 10172 | } | ||
| 10117 | } | 10173 | } |
| 10118 | 10174 | ||
| 10119 | 10175 | ||
| 10120 | DEFUN ("x-hide-busy-cursor", Fx_hide_busy_cursor, | 10176 | /* Hide the busy cursor on all frames, if it is currently shown. */ |
| 10121 | Sx_hide_busy_cursor, 0, 1, 0, | ||
| 10122 | "Hide a busy-cursor.\n\ | ||
| 10123 | A busy-cursor will actually be undisplayed when a matching\n\ | ||
| 10124 | `x-hide-busy-cursor' is called for each `x-show-busy-cursor'\n\ | ||
| 10125 | issued. FORCE non-nil means hide the busy-cursor forcibly,\n\ | ||
| 10126 | not counting calls.") | ||
| 10127 | (force) | ||
| 10128 | Lisp_Object force; | ||
| 10129 | { | ||
| 10130 | Lisp_Object rest, frame; | ||
| 10131 | |||
| 10132 | if (busy_count == 0) | ||
| 10133 | return Qnil; | ||
| 10134 | |||
| 10135 | if (!NILP (force) && busy_count != 0) | ||
| 10136 | busy_count = 1; | ||
| 10137 | 10177 | ||
| 10138 | --busy_count; | 10178 | static void |
| 10139 | if (busy_count != 0) | 10179 | hide_busy_cursor () |
| 10140 | return Qnil; | 10180 | { |
| 10141 | 10181 | if (busy_cursor_shown_p) | |
| 10142 | FOR_EACH_FRAME (rest, frame) | ||
| 10143 | { | 10182 | { |
| 10144 | struct frame *f = XFRAME (frame); | 10183 | Lisp_Object rest, frame; |
| 10145 | 10184 | ||
| 10146 | if (FRAME_X_P (f) | 10185 | BLOCK_INPUT; |
| 10147 | /* Watch out for newly created frames. */ | 10186 | FOR_EACH_FRAME (rest, frame) |
| 10148 | && f->output_data.x->busy_window) | ||
| 10149 | { | 10187 | { |
| 10150 | 10188 | struct frame *f = XFRAME (frame); | |
| 10151 | BLOCK_INPUT; | 10189 | |
| 10152 | XUnmapWindow (FRAME_X_DISPLAY (f), f->output_data.x->busy_window); | 10190 | if (FRAME_X_P (f) |
| 10153 | /* Sync here because XTread_socket looks at the busy_p flag | 10191 | /* Watch out for newly created frames. */ |
| 10154 | that is reset to zero below. */ | 10192 | && f->output_data.x->busy_window) |
| 10155 | XSync (FRAME_X_DISPLAY (f), False); | 10193 | { |
| 10156 | UNBLOCK_INPUT; | 10194 | XUnmapWindow (FRAME_X_DISPLAY (f), f->output_data.x->busy_window); |
| 10157 | f->output_data.x->busy_p = 0; | 10195 | /* Sync here because XTread_socket looks at the busy_p flag |
| 10196 | that is reset to zero below. */ | ||
| 10197 | XSync (FRAME_X_DISPLAY (f), False); | ||
| 10198 | f->output_data.x->busy_p = 0; | ||
| 10199 | } | ||
| 10158 | } | 10200 | } |
| 10159 | } | ||
| 10160 | 10201 | ||
| 10161 | return Qnil; | 10202 | busy_cursor_shown_p = 0; |
| 10203 | UNBLOCK_INPUT; | ||
| 10204 | } | ||
| 10162 | } | 10205 | } |
| 10163 | 10206 | ||
| 10164 | 10207 | ||
| @@ -10945,6 +10988,11 @@ or when you set the mouse color."); | |||
| 10945 | "Non-zero means Emacs displays a busy cursor on window systems."); | 10988 | "Non-zero means Emacs displays a busy cursor on window systems."); |
| 10946 | display_busy_cursor_p = 1; | 10989 | display_busy_cursor_p = 1; |
| 10947 | 10990 | ||
| 10991 | DEFVAR_LISP ("busy-cursor-delay", &Vbusy_cursor_delay, | ||
| 10992 | "*Seconds to wait before displaying a busy-cursor.\n\ | ||
| 10993 | Value must be an integer."); | ||
| 10994 | Vbusy_cursor_delay = make_number (DEFAULT_BUSY_CURSOR_DELAY); | ||
| 10995 | |||
| 10948 | #if 0 /* This doesn't really do anything. */ | 10996 | #if 0 /* This doesn't really do anything. */ |
| 10949 | DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape, | 10997 | DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape, |
| 10950 | "The shape of the pointer when over the mode line.\n\ | 10998 | "The shape of the pointer when over the mode line.\n\ |
| @@ -11128,11 +11176,8 @@ Each element of the list is a symbol for a supported image type."); | |||
| 11128 | defsubr (&Slookup_image); | 11176 | defsubr (&Slookup_image); |
| 11129 | #endif | 11177 | #endif |
| 11130 | 11178 | ||
| 11131 | /* Busy-cursor. */ | 11179 | busy_cursor_atimer = NULL; |
| 11132 | defsubr (&Sx_show_busy_cursor); | 11180 | busy_cursor_shown_p = 0; |
| 11133 | defsubr (&Sx_hide_busy_cursor); | ||
| 11134 | busy_count = 0; | ||
| 11135 | inhibit_busy_cursor = 0; | ||
| 11136 | 11181 | ||
| 11137 | defsubr (&Sx_show_tip); | 11182 | defsubr (&Sx_show_tip); |
| 11138 | defsubr (&Sx_hide_tip); | 11183 | defsubr (&Sx_hide_tip); |