Mercurial > emacs
comparison src/xfns.c @ 96664:b306a69b9d7f
applying patch to consolidate non-GUI portion of hourglass implementation as posted at http://thread.gmane.org/gmane.emacs.devel/98341
author | Adrian Robert <Adrian.B.Robert@gmail.com> |
---|---|
date | Tue, 15 Jul 2008 13:04:01 +0000 |
parents | 8fc8962839b7 |
children | 840bd675fd85 |
comparison
equal
deleted
inserted
replaced
96663:4d8d83c2373a | 96664:b306a69b9d7f |
---|---|
146 config.h defines `static' as an empty replacement string. */ | 146 config.h defines `static' as an empty replacement string. */ |
147 | 147 |
148 int gray_bitmap_width = gray_width; | 148 int gray_bitmap_width = gray_width; |
149 int gray_bitmap_height = gray_height; | 149 int gray_bitmap_height = gray_height; |
150 char *gray_bitmap_bits = gray_bits; | 150 char *gray_bitmap_bits = gray_bits; |
151 | |
152 /* Non-zero means we're allowed to display an hourglass cursor. */ | |
153 | |
154 int display_hourglass_p; | |
155 | 151 |
156 /* Non-zero means prompt with the old GTK file selection dialog. */ | 152 /* Non-zero means prompt with the old GTK file selection dialog. */ |
157 | 153 |
158 int x_gtk_use_old_file_dialog; | 154 int x_gtk_use_old_file_dialog; |
159 | 155 |
4470 | 4466 |
4471 /*********************************************************************** | 4467 /*********************************************************************** |
4472 Busy cursor | 4468 Busy cursor |
4473 ***********************************************************************/ | 4469 ***********************************************************************/ |
4474 | 4470 |
4475 /* If non-null, an asynchronous timer that, when it expires, displays | |
4476 an hourglass cursor on all frames. */ | |
4477 | |
4478 static struct atimer *hourglass_atimer; | |
4479 | |
4480 /* Non-zero means an hourglass cursor is currently shown. */ | |
4481 | |
4482 static int hourglass_shown_p; | |
4483 | |
4484 /* Number of seconds to wait before displaying an hourglass cursor. */ | |
4485 | |
4486 static Lisp_Object Vhourglass_delay; | |
4487 | |
4488 /* Default number of seconds to wait before displaying an hourglass | |
4489 cursor. */ | |
4490 | |
4491 #define DEFAULT_HOURGLASS_DELAY 1 | |
4492 | |
4493 /* Function prototypes. */ | |
4494 | |
4495 static void show_hourglass P_ ((struct atimer *)); | |
4496 static void hide_hourglass P_ ((void)); | |
4497 | |
4498 /* Return non-zero if houglass timer has been started or hourglass is shown. */ | |
4499 | |
4500 int | |
4501 hourglass_started () | |
4502 { | |
4503 return hourglass_shown_p || hourglass_atimer != NULL; | |
4504 } | |
4505 | |
4506 | |
4507 /* Cancel a currently active hourglass timer, and start a new one. */ | |
4508 | |
4509 void | |
4510 start_hourglass () | |
4511 { | |
4512 EMACS_TIME delay; | |
4513 int secs, usecs = 0; | |
4514 | |
4515 cancel_hourglass (); | |
4516 | |
4517 if (INTEGERP (Vhourglass_delay) | |
4518 && XINT (Vhourglass_delay) > 0) | |
4519 secs = XFASTINT (Vhourglass_delay); | |
4520 else if (FLOATP (Vhourglass_delay) | |
4521 && XFLOAT_DATA (Vhourglass_delay) > 0) | |
4522 { | |
4523 Lisp_Object tem; | |
4524 tem = Ftruncate (Vhourglass_delay, Qnil); | |
4525 secs = XFASTINT (tem); | |
4526 usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000; | |
4527 } | |
4528 else | |
4529 secs = DEFAULT_HOURGLASS_DELAY; | |
4530 | |
4531 EMACS_SET_SECS_USECS (delay, secs, usecs); | |
4532 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay, | |
4533 show_hourglass, NULL); | |
4534 } | |
4535 | |
4536 | |
4537 /* Cancel the hourglass cursor timer if active, hide a busy cursor if | |
4538 shown. */ | |
4539 | |
4540 void | |
4541 cancel_hourglass () | |
4542 { | |
4543 if (hourglass_atimer) | |
4544 { | |
4545 cancel_atimer (hourglass_atimer); | |
4546 hourglass_atimer = NULL; | |
4547 } | |
4548 | |
4549 if (hourglass_shown_p) | |
4550 hide_hourglass (); | |
4551 } | |
4552 | |
4553 | |
4554 /* Timer function of hourglass_atimer. TIMER is equal to | 4471 /* Timer function of hourglass_atimer. TIMER is equal to |
4555 hourglass_atimer. | 4472 hourglass_atimer. |
4556 | 4473 |
4557 Display an hourglass pointer on all frames by mapping the frames' | 4474 Display an hourglass pointer on all frames by mapping the frames' |
4558 hourglass_window. Set the hourglass_p flag in the frames' | 4475 hourglass_window. Set the hourglass_p flag in the frames' |
4559 output_data.x structure to indicate that an hourglass cursor is | 4476 output_data.x structure to indicate that an hourglass cursor is |
4560 shown on the frames. */ | 4477 shown on the frames. */ |
4561 | 4478 |
4562 static void | 4479 void |
4563 show_hourglass (timer) | 4480 show_hourglass (timer) |
4564 struct atimer *timer; | 4481 struct atimer *timer; |
4565 { | 4482 { |
4566 /* The timer implementation will cancel this timer automatically | 4483 /* The timer implementation will cancel this timer automatically |
4567 after this function has run. Set hourglass_atimer to null | 4484 after this function has run. Set hourglass_atimer to null |
4622 | 4539 |
4623 | 4540 |
4624 /* Hide the hourglass pointer on all frames, if it is currently | 4541 /* Hide the hourglass pointer on all frames, if it is currently |
4625 shown. */ | 4542 shown. */ |
4626 | 4543 |
4627 static void | 4544 void |
4628 hide_hourglass () | 4545 hide_hourglass () |
4629 { | 4546 { |
4630 if (hourglass_shown_p) | 4547 if (hourglass_shown_p) |
4631 { | 4548 { |
4632 Lisp_Object rest, frame; | 4549 Lisp_Object rest, frame; |
5903 doc: /* The shape of the pointer when Emacs is busy. | 5820 doc: /* The shape of the pointer when Emacs is busy. |
5904 This variable takes effect when you create a new frame | 5821 This variable takes effect when you create a new frame |
5905 or when you set the mouse color. */); | 5822 or when you set the mouse color. */); |
5906 Vx_hourglass_pointer_shape = Qnil; | 5823 Vx_hourglass_pointer_shape = Qnil; |
5907 | 5824 |
5908 DEFVAR_BOOL ("display-hourglass", &display_hourglass_p, | |
5909 doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */); | |
5910 display_hourglass_p = 1; | |
5911 | |
5912 DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay, | |
5913 doc: /* *Seconds to wait before displaying an hourglass pointer. | |
5914 Value must be an integer or float. */); | |
5915 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY); | |
5916 | |
5917 #if 0 /* This doesn't really do anything. */ | 5825 #if 0 /* This doesn't really do anything. */ |
5918 DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape, | 5826 DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape, |
5919 doc: /* The shape of the pointer when over the mode line. | 5827 doc: /* The shape of the pointer when over the mode line. |
5920 This variable takes effect when you create a new frame | 5828 This variable takes effect when you create a new frame |
5921 or when you set the mouse color. */); | 5829 or when you set the mouse color. */); |
6051 defsubr (&Sx_backspace_delete_keys_p); | 5959 defsubr (&Sx_backspace_delete_keys_p); |
6052 | 5960 |
6053 /* Setting callback functions for fontset handler. */ | 5961 /* Setting callback functions for fontset handler. */ |
6054 check_window_system_func = check_x; | 5962 check_window_system_func = check_x; |
6055 | 5963 |
6056 hourglass_atimer = NULL; | |
6057 hourglass_shown_p = 0; | |
6058 | |
6059 defsubr (&Sx_show_tip); | 5964 defsubr (&Sx_show_tip); |
6060 defsubr (&Sx_hide_tip); | 5965 defsubr (&Sx_hide_tip); |
6061 tip_timer = Qnil; | 5966 tip_timer = Qnil; |
6062 staticpro (&tip_timer); | 5967 staticpro (&tip_timer); |
6063 tip_frame = Qnil; | 5968 tip_frame = Qnil; |