emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ding - too often (OS X and in general)


From: YAMAMOTO Mitsuharu
Subject: Re: ding - too often (OS X and in general)
Date: Fri, 27 May 2005 18:06:11 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/22.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Thu, 26 May 2005 18:51:16 +0200, Christian Schlauer <address@hidden> 
>>>>> said:

> I have a friend that runs Emacs on Mac OS X with visible-bell set to
> t. On Windows, it flashes the title bar of the frame. Okay. On
> GNU/Linux, it flashes the minibuffer and the first line in the
> buffer.  Okay. On OS X, it is really irritating: the _whole_ screen
> flashes (not only the Emacs frame), like the screen is going to
> explode. When one works in a little darker environment, it really
> blinds the user.

That is caused by `FlashMenuBar' calls in XTflash, and it used to
flash only the menu bar part as its name stands for on Mac OS 9.  I
also think the current behavior on Mac OS X is too much.

The following patch replaces such calls with inversions of the
minibuffer and the first line as in X11.  Do we need to leave the
current behavior?

                                     YAMAMOTO Mitsuharu
                                address@hidden

Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.115
diff -c -r1.115 macterm.c
*** src/macterm.c       13 May 2005 08:42:38 -0000      1.115
--- src/macterm.c       27 May 2005 08:44:24 -0000
***************
*** 736,741 ****
--- 736,758 ----
  
  
  static void
+ mac_invert_rectangle (display, w, x, y, width, height)
+      Display *display;
+      WindowPtr w;
+      int x, y;
+      unsigned int width, height;
+ {
+   Rect r;
+ 
+   SetPortWindowPort (w);
+ 
+   SetRect (&r, x, y, x + width, y + height);
+ 
+   InvertRect (&r);
+ }
+ 
+ 
+ static void
  mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
                        bytes_per_char)
       Display *display;
***************
*** 3326,3334 ****
  XTflash (f)
       struct frame *f;
  {
    BLOCK_INPUT;
  
!   FlashMenuBar (0);
  
    {
      struct timeval wakeup;
--- 3343,3399 ----
  XTflash (f)
       struct frame *f;
  {
+   /* Get the height not including a menu bar widget.  */
+   int height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, FRAME_LINES (f));
+   /* Height of each line to flash.  */
+   int flash_height = FRAME_LINE_HEIGHT (f);
+   /* These will be the left and right margins of the rectangles.  */
+   int flash_left = FRAME_INTERNAL_BORDER_WIDTH (f);
+   int flash_right = FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f);
+ 
+   int width;
+ 
+   /* Don't flash the area between a scroll bar and the frame
+      edge it is next to.  */
+   switch (FRAME_VERTICAL_SCROLL_BAR_TYPE (f))
+     {
+     case vertical_scroll_bar_left:
+       flash_left += VERTICAL_SCROLL_BAR_WIDTH_TRIM;
+       break;
+ 
+     case vertical_scroll_bar_right:
+       flash_right -= VERTICAL_SCROLL_BAR_WIDTH_TRIM;
+       break;
+ 
+     default:
+       break;
+     }
+ 
+   width = flash_right - flash_left;
+ 
    BLOCK_INPUT;
  
!   /* If window is tall, flash top and bottom line.  */
!   if (height > 3 * FRAME_LINE_HEIGHT (f))
!     {
!       mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
!                           flash_left,
!                           (FRAME_INTERNAL_BORDER_WIDTH (f)
!                            + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT 
(f)),
!                           width, flash_height);
!       mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
!                           flash_left,
!                           (height - flash_height
!                            - FRAME_INTERNAL_BORDER_WIDTH (f)),
!                           width, flash_height);
!     }
!   else
!     /* If it is short, flash it all.  */
!     mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
!                         flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
!                         width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
! 
!   x_flush (f);
  
    {
      struct timeval wakeup;
***************
*** 3340,3363 ****
      wakeup.tv_sec += (wakeup.tv_usec / 1000000);
      wakeup.tv_usec %= 1000000;
  
!     /* Keep waiting until past the time wakeup.  */
!     while (1)
        {
!         struct timeval timeout;
  
!         EMACS_GET_TIME (timeout);
  
!         /* In effect, timeout = wakeup - timeout.
!            Break if result would be negative.  */
!         if (timeval_subtract (&timeout, wakeup, timeout))
!           break;
  
!         /* Try to wait that long--but we might wake up sooner.  */
!         select (0, NULL, NULL, NULL, &timeout);
        }
    }
  
!   FlashMenuBar (0);
  
    UNBLOCK_INPUT;
  }
--- 3405,3453 ----
      wakeup.tv_sec += (wakeup.tv_usec / 1000000);
      wakeup.tv_usec %= 1000000;
  
!     /* Keep waiting until past the time wakeup or any input gets
!        available.  */
!     while (! detect_input_pending ())
        {
!       struct timeval current;
!       struct timeval timeout;
  
!       EMACS_GET_TIME (current);
  
!       /* Break if result would be negative.  */
!       if (timeval_subtract (&current, wakeup, current))
!         break;
  
!       /* How long `select' should wait.  */
!       timeout.tv_sec = 0;
!       timeout.tv_usec = 10000;
! 
!       /* Try to wait that long--but we might wake up sooner.  */
!       select (0, NULL, NULL, NULL, &timeout);
        }
    }
  
!   /* If window is tall, flash top and bottom line.  */
!   if (height > 3 * FRAME_LINE_HEIGHT (f))
!     {
!       mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
!                           flash_left,
!                           (FRAME_INTERNAL_BORDER_WIDTH (f)
!                            + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT 
(f)),
!                           width, flash_height);
!       mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
!                           flash_left,
!                           (height - flash_height
!                            - FRAME_INTERNAL_BORDER_WIDTH (f)),
!                           width, flash_height);
!     }
!   else
!     /* If it is short, flash it all.  */
!     mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
!                         flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
!                         width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
! 
!   x_flush (f);
  
    UNBLOCK_INPUT;
  }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]