comparison src/macfns.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 e1cdfeed8fea
children 3760da9fe15e
comparison
equal deleted inserted replaced
96663:4d8d83c2373a 96664:b306a69b9d7f
54 /* Carbon version info */ 54 /* Carbon version info */
55 55
56 static Lisp_Object Vmac_carbon_version_string; 56 static Lisp_Object Vmac_carbon_version_string;
57 57
58 #endif /* TARGET_API_MAC_CARBON */ 58 #endif /* TARGET_API_MAC_CARBON */
59
60 /* Non-zero means we're allowed to display an hourglass cursor. */
61
62 int display_hourglass_p;
63 59
64 /* The background and shape of the mouse pointer, and shape when not 60 /* The background and shape of the mouse pointer, and shape when not
65 over text or in the modeline. */ 61 over text or in the modeline. */
66 62
67 Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape; 63 Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape;
3418 3414
3419 /*********************************************************************** 3415 /***********************************************************************
3420 Busy cursor 3416 Busy cursor
3421 ***********************************************************************/ 3417 ***********************************************************************/
3422 3418
3423 /* If non-null, an asynchronous timer that, when it expires, displays
3424 an hourglass cursor on all frames. */
3425
3426 static struct atimer *hourglass_atimer;
3427
3428 /* Non-zero means an hourglass cursor is currently shown. */
3429
3430 static int hourglass_shown_p;
3431
3432 /* Number of seconds to wait before displaying an hourglass cursor. */
3433
3434 static Lisp_Object Vhourglass_delay;
3435
3436 /* Default number of seconds to wait before displaying an hourglass
3437 cursor. */
3438
3439 #define DEFAULT_HOURGLASS_DELAY 1
3440
3441 /* Function prototypes. */
3442
3443 static void show_hourglass P_ ((struct atimer *));
3444 static void hide_hourglass P_ ((void));
3445
3446 /* Return non-zero if houglass timer has been started or hourglass is shown. */
3447
3448 int
3449 hourglass_started ()
3450 {
3451 return hourglass_shown_p || hourglass_atimer != NULL;
3452 }
3453
3454
3455 /* Cancel a currently active hourglass timer, and start a new one. */
3456
3457 void
3458 start_hourglass ()
3459 {
3460 #ifdef MAC_OSX
3461 EMACS_TIME delay;
3462 int secs, usecs = 0;
3463
3464 cancel_hourglass ();
3465
3466 if (INTEGERP (Vhourglass_delay)
3467 && XINT (Vhourglass_delay) > 0)
3468 secs = XFASTINT (Vhourglass_delay);
3469 else if (FLOATP (Vhourglass_delay)
3470 && XFLOAT_DATA (Vhourglass_delay) > 0)
3471 {
3472 Lisp_Object tem;
3473 tem = Ftruncate (Vhourglass_delay, Qnil);
3474 secs = XFASTINT (tem);
3475 usecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000000;
3476 }
3477 else
3478 secs = DEFAULT_HOURGLASS_DELAY;
3479
3480 EMACS_SET_SECS_USECS (delay, secs, usecs);
3481 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
3482 show_hourglass, NULL);
3483 #endif /* MAC_OSX */
3484 }
3485
3486
3487 /* Cancel the hourglass cursor timer if active, hide a busy cursor if
3488 shown. */
3489
3490 void
3491 cancel_hourglass ()
3492 {
3493 #ifdef MAC_OSX
3494 if (hourglass_atimer)
3495 {
3496 cancel_atimer (hourglass_atimer);
3497 hourglass_atimer = NULL;
3498 }
3499
3500 if (hourglass_shown_p)
3501 hide_hourglass ();
3502 #endif /* MAC_OSX */
3503 }
3504
3505
3506 /* Timer function of hourglass_atimer. TIMER is equal to 3419 /* Timer function of hourglass_atimer. TIMER is equal to
3507 hourglass_atimer. 3420 hourglass_atimer.
3508 3421
3509 On Mac, busy status is shown by the progress indicator (chasing 3422 On Mac, busy status is shown by the progress indicator (chasing
3510 arrows) at the upper-right corner of each frame instead of the 3423 arrows) at the upper-right corner of each frame instead of the
3511 hourglass pointer. */ 3424 hourglass pointer. */
3512 3425
3513 static void 3426 void
3514 show_hourglass (timer) 3427 show_hourglass (timer)
3515 struct atimer *timer; 3428 struct atimer *timer;
3516 { 3429 {
3517 #if TARGET_API_MAC_CARBON 3430 #if TARGET_API_MAC_CARBON
3518 /* The timer implementation will cancel this timer automatically 3431 /* The timer implementation will cancel this timer automatically
3543 3456
3544 3457
3545 /* Hide the progress indicators on all frames, if it is currently 3458 /* Hide the progress indicators on all frames, if it is currently
3546 shown. */ 3459 shown. */
3547 3460
3548 static void 3461 void
3549 hide_hourglass () 3462 hide_hourglass ()
3550 { 3463 {
3551 #if TARGET_API_MAC_CARBON 3464 #if TARGET_API_MAC_CARBON
3552 if (hourglass_shown_p) 3465 if (hourglass_shown_p)
3553 { 3466 {
4377 doc: /* The shape of the pointer when Emacs is busy. 4290 doc: /* The shape of the pointer when Emacs is busy.
4378 This variable takes effect when you create a new frame 4291 This variable takes effect when you create a new frame
4379 or when you set the mouse color. */); 4292 or when you set the mouse color. */);
4380 Vx_hourglass_pointer_shape = Qnil; 4293 Vx_hourglass_pointer_shape = Qnil;
4381 4294
4382 DEFVAR_BOOL ("display-hourglass", &display_hourglass_p,
4383 doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */);
4384 display_hourglass_p = 1;
4385
4386 DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay,
4387 doc: /* *Seconds to wait before displaying an hourglass pointer.
4388 Value must be an integer or float. */);
4389 Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY);
4390
4391 #if 0 /* This doesn't really do anything. */ 4295 #if 0 /* This doesn't really do anything. */
4392 DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape, 4296 DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape,
4393 doc: /* The shape of the pointer when over the mode line. 4297 doc: /* The shape of the pointer when over the mode line.
4394 This variable takes effect when you create a new frame 4298 This variable takes effect when you create a new frame
4395 or when you set the mouse color. */); 4299 or when you set the mouse color. */);