]> code.delx.au - gnu-emacs/blobdiff - src/nsterm.m
Bump version to 24.1.
[gnu-emacs] / src / nsterm.m
index 3d3723fc28c76801b344f523ab2c463796ba2159..7cbaf9913111c40d77da7ec43b771ea14414e36f 100644 (file)
@@ -1,6 +1,7 @@
 /* NeXT/Open/GNUstep / MacOSX communication module.
-   Copyright (C) 1989, 1993-1994, 2005-2006, 2008-2011
-     Free Software Foundation, Inc.
+
+Copyright (C) 1989, 1993-1994, 2005-2006, 2008-2012
+  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -64,6 +65,7 @@ int term_trace_num = 0;
 #define NSTRACE(x)
 #endif
 
+extern NSString *NSMenuDidBeginTrackingNotification;
 
 /* ==========================================================================
 
@@ -559,7 +561,7 @@ ns_constrain_all_frames (void)
         {
           NSView *view = FRAME_NS_VIEW (f);
           /* This no-op will trigger the default window placing
-           * constriant system. */
+           * constraint system. */
           f->output_data.ns->dont_constrain = 0;
           [[view window] setFrameOrigin:[[view window] frame].origin];
         }
@@ -1158,6 +1160,9 @@ x_free_frame_resources (struct frame *f)
 
   xfree (f->output_data.ns);
 
+  if (f->output_data.ns->miniimage != nil)
+    [f->output_data.ns->miniimage release];
+
   [[view window] close];
   [view release];
 
@@ -1351,7 +1356,7 @@ ns_index_color (NSColor *color, struct frame *f)
 {
   struct ns_color_table *color_table = FRAME_NS_DISPLAY_INFO (f)->color_table;
   ptrdiff_t idx;
-  NSNumber *index;
+  ptrdiff_t i;
 
   if (!color_table->colors)
     {
@@ -1364,21 +1369,13 @@ ns_index_color (NSColor *color, struct frame *f)
     }
 
   /* do we already have this color ? */
-  {
-    ptrdiff_t i;
-    for (i = 1; i < color_table->avail; i++)
-      {
-        if (color_table->colors[i] && [color_table->colors[i] isEqual: color])
-          {
-            [color_table->colors[i] retain];
-            return i;
-          }
-      }
-  }
+  for (i = 1; i < color_table->avail; i++)
+    if (color_table->colors[i] && [color_table->colors[i] isEqual: color])
+      return i;
 
   if ([color_table->empty_indices count] > 0)
     {
-      index = [color_table->empty_indices anyObject];
+      NSNumber *index = [color_table->empty_indices anyObject];
       [color_table->empty_indices removeObject: index];
       idx = [index unsignedLongValue];
     }
@@ -1411,20 +1408,20 @@ ns_free_indexed_color (unsigned long idx, struct frame *f)
   color_table = FRAME_NS_DISPLAY_INFO (f)->color_table;
 
   if (idx <= 0 || idx >= color_table->size) {
-    message1("ns_free_indexed_color: Color index out of range.\n");
+    message1 ("ns_free_indexed_color: Color index out of range.\n");
     return;
   }
 
   index = [NSNumber numberWithUnsignedInt: idx];
   if ([color_table->empty_indices containsObject: index]) {
-    message1("ns_free_indexed_color: attempt to free already freed color.\n");
+    message1 ("ns_free_indexed_color: attempt to free already freed color.\n");
     return;
   }
 
   color = color_table->colors[idx];
   [color release];
   color_table->colors[idx] = nil;
-  [color_table->empty_indices addObject: [NSNumber numberWithUnsignedInt: idx]];
+  [color_table->empty_indices addObject: index];
 /*fprintf(stderr, "color_table: FREED %d\n",idx);*/
 }
 
@@ -2108,7 +2105,7 @@ ns_scroll_run (struct window *w, struct run *run)
     }
   else
     {
-      /* Scolling down.  Make sure we don't copy over the mode line.
+      /* Scrolling down.  Make sure we don't copy over the mode line.
         at the bottom.  */
       if (to_y + run->height > bottom_y)
        height = bottom_y - to_y;
@@ -3035,7 +3032,7 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
       /* Currently on NS img->mask is always 0. Since
          get_window_cursor_type specifies a hollow box cursor when on
          a non-masked image we never reach this clause. But we put it
-         in in antipication of better support for image masks on
+         in in anticipation of better support for image masks on
          NS. */
       tdCol = ns_lookup_indexed_color (NS_FACE_FOREGROUND (face), s->f);
     }
@@ -3075,7 +3072,7 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
 
   /* If there is no mask, the background won't be seen,
      so draw a rectangle on the image for the cursor.
-     Do this for all images, getting trancparency right is not reliable.  */
+     Do this for all images, getting transparency right is not reliable.  */
   if (s->hl == DRAW_CURSOR)
     {
       int thickness = abs (s->img->relief);
@@ -3824,11 +3821,9 @@ ns_default (const char *parameter, Lisp_Object *result,
       Check a parameter value in user's preferences
    -------------------------------------------------------------------------- */
 {
-  const char *value;
+  const char *value = ns_get_defaults_value (parameter);
 
-  if ( (value =[[[NSUserDefaults standardUserDefaults]
-                   stringForKey: [NSString stringWithUTF8String: parameter]]
-                UTF8String]) )
+  if (value)
     {
       double f;
       char *pos;
@@ -4205,6 +4200,15 @@ ns_term_init (Lisp_Object display_name)
     [NSApp setServicesMenu: svcsMenu];
     /* Needed at least on Cocoa, to get dock menu to show windows */
     [NSApp setWindowsMenu: [[NSMenu alloc] init]];
+
+    [[NSNotificationCenter defaultCenter]
+      addObserver: mainMenu
+         selector: @selector (trackingNotification:)
+             name: NSMenuDidBeginTrackingNotification object: mainMenu];
+    [[NSNotificationCenter defaultCenter]
+      addObserver: mainMenu
+         selector: @selector (trackingNotification:)
+             name: NSMenuDidEndTrackingNotification object: mainMenu];
   }
 #endif /* MAC OS X menu setup */
 
@@ -4503,7 +4507,7 @@ ns_term_shutdown (int sig)
   //ns_app_active=YES;
 
   ns_update_auto_hide_menu_bar ();
-  // No constrining takes place when the application is not active.
+  // No constraining takes place when the application is not active.
   ns_constrain_all_frames ();
 }
 - (void)applicationDidResignActive: (NSNotification *)notification
@@ -6034,11 +6038,15 @@ ns_term_shutdown (int sig)
    restrict the height to just one monitor.  So we override this.  */
 - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
 {
-  /* When making the frame visible for the first time, we want to
-     constrain.  Other times not.  */
+  /* When making the frame visible for the first time or if there is just
+     one screen, we want to constrain.  Other times not.  */
+  NSUInteger nr_screens = [[NSScreen screens] count];
   struct frame *f = ((EmacsView *)[self delegate])->emacsframe;
   NSTRACE (constrainFrameRect);
 
+  if (nr_screens == 1)
+    return [super constrainFrameRect:frameRect toScreen:screen];
+  
   if (f->output_data.ns->dont_constrain
       || ns_menu_bar_should_be_hidden ())
     return frameRect;
@@ -6733,12 +6741,12 @@ Only works on OSX 10.6 or later.  */);
 
   /* TODO: move to common code */
   DEFVAR_LISP ("x-toolkit-scroll-bars", Vx_toolkit_scroll_bars,
-              doc: /* If not nil, Emacs uses toolkit scroll bars.  */);
-#ifdef USE_TOOLKIT_SCROLL_BARS
+              doc: /* Which toolkit scroll bars Emacs uses, if any.
+A value of nil means Emacs doesn't use toolkit scroll bars.
+With the X Window system, the value is a symbol describing the
+X toolkit.  Possible values are: gtk, motif, xaw, or xaw3d.
+With MS Windows or Nextstep, the value is t.  */);
   Vx_toolkit_scroll_bars = Qt;
-#else
-  Vx_toolkit_scroll_bars = Qnil;
-#endif
 
   DEFVAR_BOOL ("x-use-underline-position-properties",
               x_use_underline_position_properties,