Dock menu customization, based on a patch by Ken Raeburn, plus some other fixes.
authorAdrian Robert <Adrian.B.Robert@gmail.com>
Tue, 5 Aug 2008 03:05:14 +0000 (03:05 +0000)
committerAdrian Robert <Adrian.B.Robert@gmail.com>
Tue, 5 Aug 2008 03:05:14 +0000 (03:05 +0000)
lisp/ChangeLog
lisp/term/ns-win.el
src/ChangeLog
src/lisp.h
src/nsmenu.m
src/nsterm.h
src/nsterm.m

index eb44fb0..c860387 100644 (file)
@@ -1,3 +1,7 @@
+2008-07-27  Adrian Robert  <Adrian.B.Robert@gmail.com>
+
+       * term/ns-win.el ([ns-new-frame]): New global key.
+
 2008-08-04  Juanma Barranquero  <lekktu@gmail.com>
 
        * international/mule-cmds.el (read-char-by-name):
index bdea472..b3f52c4 100644 (file)
@@ -279,6 +279,7 @@ The properties returned may include `top', `left', `height', and `width'."
 (define-key global-map [ns-insert-working-text] 'ns-insert-working-text)
 (define-key global-map [ns-delete-working-text] 'ns-delete-working-text)
 (define-key global-map [ns-spi-service-call] 'ns-spi-service-call)
+(define-key global-map [ns-new-frame] 'make-frame)
 
 
 
@@ -384,6 +385,7 @@ this defaults to \"printenv\"."
              (cons (logior (lsh 0 16)   9) 'ns-insert-working-text)
              (cons (logior (lsh 0 16)  10) 'ns-delete-working-text)
              (cons (logior (lsh 0 16)  11) 'ns-spi-service-call)
+             (cons (logior (lsh 0 16)  12) 'ns-new-frame)
              (cons (logior (lsh 1 16)  32) 'f1)
              (cons (logior (lsh 1 16)  33) 'f2)
              (cons (logior (lsh 1 16)  34) 'f3)
index 4b15796..ed88f0c 100644 (file)
@@ -1,3 +1,20 @@
+2008-08-04  Adrian Robert  <Adrian.B.Robert@gmail.com>
+
+       Dock menu customization, based on a patch by Ken Raeburn, plus some
+       other fixes.
+       * nsmenu.m (dockMenu): New variable.
+       (EmacsDialog -clicked:): Fix mistake in change of 2008-07-17.
+
+       * nsterm.h (dockMenu): Declare.
+
+       * nsterm.m (KEY_NS_NEW_FRAME): New definition.
+       (ns_term_init): Initialize dockMenu.
+       (EmacsApp -newFrame:, -applicationDockMenu:): New methods.
+       (EmacsView -windowShouldClose:): Don't behave specially if <= 1 frame
+       left.
+
+       * lisp.h (LSB_TAG): Use on DARWIN_OS, not NS_IMPL_COCOA.
+
 2008-08-04  Chong Yidong  <cyd@stupidchicken.com>
 
        * nsterm.h: Test directly for NS_HAVE_INTEGER before defining it.
@@ -30,7 +47,7 @@
        when popup done.
        (ns_popup_dialog): Set popup_activated_flag.
 
-       * nsterm.m (EmacsView -converstationIdentifier): Use NSInteger
+       * nsterm.m (EmacsView -conversationIdentifier): Use NSInteger
        version for GNUstep (handled by conditional typedef in nsterm.m).
        (ns_get_color): Remove special-casing for "darkblue", "dark blue" (now
        in rgb.txt).
index 0e9c8b7..d013a04 100644 (file)
@@ -157,7 +157,7 @@ extern void die P_((const char *, const char *, int)) NO_RETURN;
 #endif
 
 /* Let's USE_LSB_TAG on systems where we know malloc returns mult-of-8.  */
-#if defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ || defined(NS_IMPL_COCOA)
+#if defined GNU_MALLOC || defined DOUG_LEA_MALLOC || defined __GLIBC__ || defined DARWIN_OS
 /* We also need to be able to specify mult-of-8 alignment on static vars.  */
 # if defined DECL_ALIGN
 /* We currently do not support USE_LSB_TAG with a union Lisp_Object.  */
index b4e8dbc..825568f 100644 (file)
@@ -63,7 +63,7 @@ extern Lisp_Object Voverriding_local_map, Voverriding_local_map_menu_flag,
                   Qoverriding_local_map, Qoverriding_terminal_local_map;
 
 extern long context_menu_value;
-EmacsMenu *mainMenu, *svcsMenu;
+EmacsMenu *mainMenu, *svcsMenu, *dockMenu;
 
 /* Nonzero means a menu is currently active.  */
 static int popup_activated_flag;
@@ -1747,7 +1747,7 @@ void process_dialog (id window, Lisp_Object list)
     return self;
 
   seltag = [[sellist objectAtIndex: 0] tag];
-  if (seltag == XHASH (Qundefined)) // FIXME: BIG UGLY HACK!!
+  if (seltag != XHASH (Qundefined)) // FIXME: BIG UGLY HACK!!
     [NSApp stopModalWithCode: seltag];
   return self;
 }
index f0b15b7..c479b33 100644 (file)
@@ -355,7 +355,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 @end
 
 extern NSArray *ns_send_types, *ns_return_types;
-extern EmacsMenu *mainMenu, *svcsMenu;
+extern EmacsMenu *mainMenu, *svcsMenu, *dockMenu;
 
 /* Apple removed the declaration, but kept the implementation */
 #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4
index fd3757b..3fb9905 100644 (file)
@@ -78,6 +78,7 @@ int term_trace_num = 0;
 #define KEY_NS_INSERT_WORKING_TEXT     ((1<<28)|(0<<16)|9)
 #define KEY_NS_DELETE_WORKING_TEXT     ((1<<28)|(0<<16)|10)
 #define KEY_NS_SPI_SERVICE_CALL        ((1<<28)|(0<<16)|11)
+#define KEY_NS_NEW_FRAME               ((1<<28)|(0<<16)|12)
 
 /* Convert a symbol indexed with an NSxxx value to a value as defined
    in keyboard.c (lispy_function_key). I hope this is a correct way
@@ -3880,6 +3881,7 @@ ns_term_init (Lisp_Object display_name)
     appMenu = [[EmacsMenu alloc] initWithTitle: @"Emacs"];
     [appMenu setAutoenablesItems: NO];
     mainMenu = [[EmacsMenu alloc] initWithTitle: @""];
+    dockMenu = [[EmacsMenu alloc] initWithTitle: @""];
 
     [appMenu insertItemWithTitle: @"About Emacs"
                           action: @selector (orderFrontStandardAboutPanel:)
@@ -3918,6 +3920,10 @@ ns_term_init (Lisp_Object display_name)
                            keyEquivalent: @""
                                  atIndex: 0];
     [mainMenu setSubmenu: appMenu forItem: item];
+    [dockMenu insertItemWithTitle: @"New Frame"
+                          action: @selector (newFrame:)
+                   keyEquivalent: @""
+                         atIndex: 0];
 
     [NSApp setMainMenu: mainMenu];
     [NSApp setAppleMenu: appMenu];
@@ -4026,6 +4032,20 @@ ns_term_shutdown (int sig)
 }
 
 
+- (void)newFrame: (id)sender
+{
+  struct frame *emacsframe = SELECTED_FRAME ();
+  NSEvent *theEvent = [NSApp currentEvent];
+
+  if (!emacs_event)
+    return;
+  emacs_event->kind = NON_ASCII_KEYSTROKE_EVENT;
+  emacs_event->code = KEY_NS_NEW_FRAME;
+  emacs_event->modifiers = 0;
+  EV_TRAILER (theEvent);
+}
+
+
 /* Open a file (used by below, after going into queue read by ns_read_socket) */
 - (BOOL) openFile: (NSString *)fileName
 {
@@ -4137,6 +4157,14 @@ fprintf (stderr, "res = %d\n", EQ (res, Qt)); /* FIXME */
 
 }
 
+
+/* Handle dock menu requests.  */
+- (NSMenu *)applicationDockMenu: (NSApplication *) sender
+{
+  return dockMenu;
+}
+
+
 /* TODO: these may help w/IO switching btwn terminal and NSApp */
 - (void)applicationDidBecomeActive: (NSNotification *)notification
 {
@@ -4834,8 +4862,6 @@ if (NS_KEYLOG) NSLog (@"attributedSubstringFromRange request");
 
   NSTRACE (windowShouldClose);
   windowClosing = YES;
-  if (ns_window_num <= 1)
-    return NO;
   if (!emacs_event)
     return NO;
   emacs_event->kind = DELETE_WINDOW_EVENT;
@@ -4943,7 +4969,7 @@ if (NS_KEYLOG) NSLog (@"attributedSubstringFromRange request");
 
   ns_send_appdefined (-1);
 
-  /* The following line causes a crash on GNUstep.  Adrian Roberts
+  /* The following line causes a crash on GNUstep.  Adrian Robert
      says he doesn't remember why he added this line, but removing it
      doesn't seem to cause problems on OSX, either.  */
 #if 0