Replace bcopy, bzero, bcmp by memcpy, memmove, memset, memcmp
[bpt/emacs.git] / src / nsterm.m
index 8f3233f..62f1c0b 100644 (file)
@@ -27,7 +27,7 @@ GNUstep port and post-20 update by Adrian Robert (arobert@cogsci.ucsd.edu)
 
 /* This should be the first include, as it may set up #defines affecting
    interpretation of even the system includes. */
-#include "config.h"
+#include <config.h>
 
 #include <math.h>
 #include <sys/types.h>
@@ -808,58 +808,23 @@ ns_ring_bell ()
       view = FRAME_NS_VIEW (frame);
       if (view != nil)
         {
-          /* Get the bounds of our NSView */
-          NSRect viewBounds = [view bounds];
-
-          /* Height of each line to flash.  */
-          int flash_height = FRAME_LINE_HEIGHT (frame);
-          int width = FRAME_PIXEL_WIDTH (frame)
-                    - NS_SCROLL_BAR_WIDTH (frame);
-
-          /* Get the GraphicsContext */
-          CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicsPort];
-          CGRect lowerLine, upperLine;
-          lowerLine =
-          CGRectMake(viewBounds.origin.x, viewBounds.origin.y,
-                     width + NS_SCROLL_BAR_WIDTH(frame),
-                     flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame));
-          upperLine =
-          CGRectMake(viewBounds.origin.x,
-                     viewBounds.origin.y + viewBounds.size.height
-                     - (flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame)),
-                     width,
-                     flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame));
-
-          /* Invert the colors using a difference blend.  */
-          CGContextSetBlendMode(ctxt, kCGBlendModeDifference);
-          CGContextSetGrayFillColor(ctxt, 1, 1);
-
-          /* If window is tall, flash top and bottom line.  */
-          if (viewBounds.size.height > 3 * FRAME_LINE_HEIGHT (frame))
-            {
-              CGContextFillRect(ctxt, upperLine);
-              CGContextFillRect(ctxt, lowerLine);
-            }
-          else
-            /* If it is short, flash it all.  */
-            CGContextFillRect(ctxt, NSRectToCGRect([view bounds]));
-
-          /* Bounce Dock icon. Maybe we can allow some configuration here.  */
-          [NSApp requestUserAttention: NSInformationalRequest];
-
+          NSRect r, surr;
+          NSPoint dim = NSMakePoint (128, 128);
+
+          r = [view bounds];
+          r.origin.x += (r.size.width - dim.x) / 2;
+          r.origin.y += (r.size.height - dim.y) / 2;
+          r.size.width = dim.x;
+          r.size.height = dim.y;
+          surr = NSInsetRect (r, -2, -2);
+          ns_focus (frame, &surr, 1);
+          [[view window] cacheImageInRect: [view convertRect: surr toView:nil]];
+          [ns_lookup_indexed_color (NS_FACE_FOREGROUND
+                                      (FRAME_DEFAULT_FACE (frame)), frame) set];
+          NSRectFill (r);
           [[view window] flushWindow];
           ns_timeout (150000);
-
-          /* If window is tall, flash top and bottom line.  */
-          if (viewBounds.size.height > 3 * FRAME_LINE_HEIGHT (frame))
-            {
-              CGContextFillRect(ctxt, upperLine);
-              CGContextFillRect(ctxt, lowerLine);
-            }
-          else
-            /* If it is short, flash it all.  */
-            CGContextFillRect(ctxt, NSRectToCGRect([view bounds]));
-
+          [[view window] restoreCachedImage];
           [[view window] flushWindow];
           ns_unfocus (frame);
         }
@@ -1173,15 +1138,15 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
     /* NOTE: previously this would generate wrong result if toolbar not
              yet displayed and fixing toolbar_height=32 helped, but
              now (200903) seems no longer needed */
-    FRAME_NS_TOOLBAR_HEIGHT (f) =
+    FRAME_TOOLBAR_HEIGHT (f) =
       NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)])
         - FRAME_NS_TITLEBAR_HEIGHT (f);
   else
-    FRAME_NS_TOOLBAR_HEIGHT (f) = 0;
+    FRAME_TOOLBAR_HEIGHT (f) = 0;
 
   wr.size.width = pixelwidth + f->border_width;
   wr.size.height = pixelheight + FRAME_NS_TITLEBAR_HEIGHT (f) 
-                  + FRAME_NS_TOOLBAR_HEIGHT (f);
+                  + FRAME_TOOLBAR_HEIGHT (f);
 
   /* constrain to screen if we can */
   if (screen)
@@ -2198,11 +2163,11 @@ ns_draw_fringe_bitmap (struct window *w, struct glyph_row *row,
     {
       EmacsImage **newBimgs
        = xmalloc (max_used_fringe_bitmap * sizeof (EmacsImage *));
-      bzero (newBimgs, max_used_fringe_bitmap * sizeof (EmacsImage *));
+      memset (newBimgs, 0, max_used_fringe_bitmap * sizeof (EmacsImage *));
 
       if (nBimgs)
         {
-          bcopy (bimgs, newBimgs, nBimgs * sizeof (EmacsImage *));
+          memcpy (newBimgs, bimgs, nBimgs * sizeof (EmacsImage *));
           xfree (bimgs);
         }
 
@@ -3742,7 +3707,7 @@ ns_term_init (Lisp_Object display_name)
                                              name: nil object: nil]; */
 
   dpyinfo = (struct ns_display_info *)xmalloc (sizeof (struct ns_display_info));
-  bzero (dpyinfo, sizeof (struct ns_display_info));
+  memset (dpyinfo, 0, sizeof (struct ns_display_info));
 
   ns_initialize_display_info (dpyinfo);
   terminal = ns_create_terminal (dpyinfo);
@@ -4208,8 +4173,6 @@ ns_term_shutdown (int sig)
   ns_send_appdefined (-2);
 }
 
-extern void update_window_cursor (struct window *w, int on);
-
 - (void)fd_handler: (NSTimer *) fdEntry
 /* --------------------------------------------------------------------------
      Check data waiting on file descriptors and terminate if so
@@ -4931,16 +4894,16 @@ extern void update_window_cursor (struct window *w, int on);
   rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (emacsframe, frameSize.height
 #ifdef NS_IMPL_GNUSTEP
       - FRAME_NS_TITLEBAR_HEIGHT (emacsframe) + 3
-        - FRAME_NS_TOOLBAR_HEIGHT (emacsframe));
+        - FRAME_TOOLBAR_HEIGHT (emacsframe));
 #else
       - FRAME_NS_TITLEBAR_HEIGHT (emacsframe)
-        - FRAME_NS_TOOLBAR_HEIGHT (emacsframe));
+        - FRAME_TOOLBAR_HEIGHT (emacsframe));
 #endif
   if (rows < MINHEIGHT)
     rows = MINHEIGHT;
   frameSize.height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (emacsframe, rows)
                        + FRAME_NS_TITLEBAR_HEIGHT (emacsframe)
-                       + FRAME_NS_TOOLBAR_HEIGHT (emacsframe);
+                       + FRAME_TOOLBAR_HEIGHT (emacsframe);
 #ifdef NS_IMPL_COCOA
   {
     /* this sets window title to have size in it; the wm does this under GS */
@@ -5151,7 +5114,7 @@ extern void update_window_cursor (struct window *w, int on);
   [toggleButton setTarget: self];
   [toggleButton setAction: @selector (toggleToolbar: )];
 #endif
-  FRAME_NS_TOOLBAR_HEIGHT (f) = 0;
+  FRAME_TOOLBAR_HEIGHT (f) = 0;
 
   tem = f->icon_name;
   if (!NILP (tem))