Mercurial > emacs
comparison src/macterm.c @ 65822:00a8cdae2968
(mac_invert_rectangle): New function.
(XTflash): Use it.
| author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
|---|---|
| date | Tue, 04 Oct 2005 09:20:38 +0000 |
| parents | 797dc38b416e |
| children | 41fc0bf568be 2a679c81f552 aa89c814f853 |
comparison
equal
deleted
inserted
replaced
| 65821:943945974210 | 65822:00a8cdae2968 |
|---|---|
| 713 return err; | 713 return err; |
| 714 } | 714 } |
| 715 #endif | 715 #endif |
| 716 | 716 |
| 717 static void | 717 static void |
| 718 mac_invert_rectangle (display, w, x, y, width, height) | |
| 719 Display *display; | |
| 720 WindowPtr w; | |
| 721 int x, y; | |
| 722 unsigned int width, height; | |
| 723 { | |
| 724 Rect r; | |
| 725 | |
| 726 SetPortWindowPort (w); | |
| 727 | |
| 728 SetRect (&r, x, y, x + width, y + height); | |
| 729 | |
| 730 InvertRect (&r); | |
| 731 } | |
| 732 | |
| 733 | |
| 734 static void | |
| 718 mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, | 735 mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, |
| 719 bytes_per_char) | 736 bytes_per_char) |
| 720 Display *display; | 737 Display *display; |
| 721 WindowPtr w; | 738 WindowPtr w; |
| 722 GC gc; | 739 GC gc; |
| 3484 | 3501 |
| 3485 void | 3502 void |
| 3486 XTflash (f) | 3503 XTflash (f) |
| 3487 struct frame *f; | 3504 struct frame *f; |
| 3488 { | 3505 { |
| 3506 /* Get the height not including a menu bar widget. */ | |
| 3507 int height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, FRAME_LINES (f)); | |
| 3508 /* Height of each line to flash. */ | |
| 3509 int flash_height = FRAME_LINE_HEIGHT (f); | |
| 3510 /* These will be the left and right margins of the rectangles. */ | |
| 3511 int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f); | |
| 3512 int flash_right = FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f); | |
| 3513 | |
| 3514 int width; | |
| 3515 | |
| 3516 /* Don't flash the area between a scroll bar and the frame | |
| 3517 edge it is next to. */ | |
| 3518 switch (FRAME_VERTICAL_SCROLL_BAR_TYPE (f)) | |
| 3519 { | |
| 3520 case vertical_scroll_bar_left: | |
| 3521 flash_left += VERTICAL_SCROLL_BAR_WIDTH_TRIM; | |
| 3522 break; | |
| 3523 | |
| 3524 case vertical_scroll_bar_right: | |
| 3525 flash_right -= VERTICAL_SCROLL_BAR_WIDTH_TRIM; | |
| 3526 break; | |
| 3527 | |
| 3528 default: | |
| 3529 break; | |
| 3530 } | |
| 3531 | |
| 3532 width = flash_right - flash_left; | |
| 3533 | |
| 3489 BLOCK_INPUT; | 3534 BLOCK_INPUT; |
| 3490 | 3535 |
| 3491 FlashMenuBar (0); | 3536 /* If window is tall, flash top and bottom line. */ |
| 3537 if (height > 3 * FRAME_LINE_HEIGHT (f)) | |
| 3538 { | |
| 3539 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), | |
| 3540 flash_left, | |
| 3541 (FRAME_INTERNAL_BORDER_WIDTH (f) | |
| 3542 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)), | |
| 3543 width, flash_height); | |
| 3544 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), | |
| 3545 flash_left, | |
| 3546 (height - flash_height | |
| 3547 - FRAME_INTERNAL_BORDER_WIDTH (f)), | |
| 3548 width, flash_height); | |
| 3549 } | |
| 3550 else | |
| 3551 /* If it is short, flash it all. */ | |
| 3552 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), | |
| 3553 flash_left, FRAME_INTERNAL_BORDER_WIDTH (f), | |
| 3554 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); | |
| 3555 | |
| 3556 x_flush (f); | |
| 3492 | 3557 |
| 3493 { | 3558 { |
| 3494 struct timeval wakeup; | 3559 struct timeval wakeup; |
| 3495 | 3560 |
| 3496 EMACS_GET_TIME (wakeup); | 3561 EMACS_GET_TIME (wakeup); |
| 3498 /* Compute time to wait until, propagating carry from usecs. */ | 3563 /* Compute time to wait until, propagating carry from usecs. */ |
| 3499 wakeup.tv_usec += 150000; | 3564 wakeup.tv_usec += 150000; |
| 3500 wakeup.tv_sec += (wakeup.tv_usec / 1000000); | 3565 wakeup.tv_sec += (wakeup.tv_usec / 1000000); |
| 3501 wakeup.tv_usec %= 1000000; | 3566 wakeup.tv_usec %= 1000000; |
| 3502 | 3567 |
| 3503 /* Keep waiting until past the time wakeup. */ | 3568 /* Keep waiting until past the time wakeup or any input gets |
| 3504 while (1) | 3569 available. */ |
| 3570 while (! detect_input_pending ()) | |
| 3505 { | 3571 { |
| 3506 struct timeval timeout; | 3572 struct timeval current; |
| 3507 | 3573 struct timeval timeout; |
| 3508 EMACS_GET_TIME (timeout); | 3574 |
| 3509 | 3575 EMACS_GET_TIME (current); |
| 3510 /* In effect, timeout = wakeup - timeout. | 3576 |
| 3511 Break if result would be negative. */ | 3577 /* Break if result would be negative. */ |
| 3512 if (timeval_subtract (&timeout, wakeup, timeout)) | 3578 if (timeval_subtract (¤t, wakeup, current)) |
| 3513 break; | 3579 break; |
| 3514 | 3580 |
| 3515 /* Try to wait that long--but we might wake up sooner. */ | 3581 /* How long `select' should wait. */ |
| 3516 select (0, NULL, NULL, NULL, &timeout); | 3582 timeout.tv_sec = 0; |
| 3583 timeout.tv_usec = 10000; | |
| 3584 | |
| 3585 /* Try to wait that long--but we might wake up sooner. */ | |
| 3586 select (0, NULL, NULL, NULL, &timeout); | |
| 3517 } | 3587 } |
| 3518 } | 3588 } |
| 3519 | 3589 |
| 3520 FlashMenuBar (0); | 3590 /* If window is tall, flash top and bottom line. */ |
| 3591 if (height > 3 * FRAME_LINE_HEIGHT (f)) | |
| 3592 { | |
| 3593 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), | |
| 3594 flash_left, | |
| 3595 (FRAME_INTERNAL_BORDER_WIDTH (f) | |
| 3596 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)), | |
| 3597 width, flash_height); | |
| 3598 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), | |
| 3599 flash_left, | |
| 3600 (height - flash_height | |
| 3601 - FRAME_INTERNAL_BORDER_WIDTH (f)), | |
| 3602 width, flash_height); | |
| 3603 } | |
| 3604 else | |
| 3605 /* If it is short, flash it all. */ | |
| 3606 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), | |
| 3607 flash_left, FRAME_INTERNAL_BORDER_WIDTH (f), | |
| 3608 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); | |
| 3609 | |
| 3610 x_flush (f); | |
| 3521 | 3611 |
| 3522 UNBLOCK_INPUT; | 3612 UNBLOCK_INPUT; |
| 3523 } | 3613 } |
| 3524 | 3614 |
| 3525 #endif /* defined (HAVE_TIMEVAL) && defined (HAVE_SELECT) */ | 3615 #endif /* defined (HAVE_TIMEVAL) && defined (HAVE_SELECT) */ |
