*** empty log message ***
[bpt/emacs.git] / src / macmenu.c
index 6fe064d..aa0be0b 100644 (file)
@@ -6,7 +6,7 @@ This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -26,10 +26,10 @@ Boston, MA 02110-1301, USA.  */
 #include <stdio.h>
 
 #include "lisp.h"
+#include "frame.h"
 #include "termhooks.h"
 #include "keyboard.h"
 #include "keymap.h"
-#include "frame.h"
 #include "window.h"
 #include "blockinput.h"
 #include "buffer.h"
@@ -347,15 +347,8 @@ save_menu_items ()
 static void
 grow_menu_items ()
 {
-  Lisp_Object old;
-  int old_size = menu_items_allocated;
-  old = menu_items;
-
   menu_items_allocated *= 2;
-
-  menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
-  bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents,
-        old_size * sizeof (Lisp_Object));
+  menu_items = larger_vector (menu_items, menu_items_allocated, Qnil);
 }
 
 /* Begin a submenu.  */
@@ -720,8 +713,8 @@ no quit occurs and `x-popup-menu' returns nil.  */)
          enum scroll_bar_part part;
          unsigned long time;
 
-         if (mouse_position_hook)
-           (*mouse_position_hook) (&new_f, 1, &bar_window,
+         if (FRAME_TERMINAL (new_f)->mouse_position_hook)
+           (*FRAME_TERMINAL (new_f)->mouse_position_hook) (&new_f, 1, &bar_window,
                                    &part, &x, &y, &time);
          if (new_f != 0)
            XSETFRAME (window, new_f);
@@ -2331,6 +2324,7 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error)
   ((value) + DIALOG_BUTTON_COMMAND_ID_OFFSET)
 
 extern EMACS_TIME timer_check P_ ((int));
+static int quit_dialog_event_loop;
 
 static pascal OSStatus
 mac_handle_dialog_event (next_handler, event, data)
@@ -2340,7 +2334,6 @@ mac_handle_dialog_event (next_handler, event, data)
 {
   OSStatus err, result = eventNotHandledErr;
   WindowRef window = (WindowRef) data;
-  int quit_event_loop_p = 0;
 
   switch (GetEventClass (event))
     {
@@ -2355,7 +2348,7 @@ mac_handle_dialog_event (next_handler, event, data)
          if (DIALOG_BUTTON_COMMAND_ID_P (command.commandID))
            {
              SetWRefCon (window, command.commandID);
-             quit_event_loop_p = 1;
+             quit_dialog_event_loop = 1;
              break;
            }
 
@@ -2379,7 +2372,7 @@ mac_handle_dialog_event (next_handler, event, data)
          switch (char_code)
            {
            case kEscapeCharCode:
-             quit_event_loop_p = 1;
+             quit_dialog_event_loop = 1;
              break;
 
            default:
@@ -2395,7 +2388,7 @@ mac_handle_dialog_event (next_handler, event, data)
                                           NULL, &key_code);
                if (err == noErr)
                  if (mac_quit_char_key_p (modifiers, key_code))
-                   quit_event_loop_p = 1;
+                   quit_dialog_event_loop = 1;
              }
              break;
            }
@@ -2406,7 +2399,7 @@ mac_handle_dialog_event (next_handler, event, data)
       abort ();
     }
 
-  if (quit_event_loop_p)
+  if (quit_dialog_event_loop)
     {
       err = QuitEventLoop (GetCurrentEventLoop ());
       if (err == noErr)
@@ -2733,6 +2726,7 @@ create_and_show_dialog (f, first_wv)
     {
       EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget ();
 
+      quit_dialog_event_loop = 0;
       while (1)
        {
          EMACS_TIME next_time = timer_check (1);
@@ -2758,12 +2752,22 @@ create_and_show_dialog (f, first_wv)
              SendEventToEventTarget (event, toolbox_dispatcher);
              ReleaseEvent (event);
            }
+#ifdef MAC_OSX
          else if (err != eventLoopTimedOutErr)
            {
              if (err == eventLoopQuitErr)
                err = noErr;
              break;
            }
+#else
+         /* The return value of ReceiveNextEvent seems to be
+            unreliable.  Use our own global variable instead.  */
+         if (quit_dialog_event_loop)
+           {
+             err = noErr;
+             break;
+           }
+#endif
        }
     }
   if (err == noErr)