]> code.delx.au - gnu-emacs/blobdiff - src/w32menu.c
(redisplay_window): Fix access to w->last_point{,_[xy]}.
[gnu-emacs] / src / w32menu.c
index eb6b18fa21d023686ddfb0eb968a7a9e5610371e..f77ce136fe2434a4e8be6e11487eb7120db53732 100644 (file)
@@ -1,4 +1,4 @@
-/* X Communication module for terminals which understand the X protocol.
+/* Menu support for GNU Emacs on the Microsoft W32 API.
    Copyright (C) 1986, 1988, 1993, 1994 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -66,8 +66,8 @@ extern Lisp_Object Qoverriding_local_map, Qoverriding_terminal_local_map;
 
 extern Lisp_Object Qmenu_bar_update_hook;
 
-static Lisp_Object win32_dialog_show ();
-static Lisp_Object win32menu_show ();
+static Lisp_Object w32_dialog_show ();
+static Lisp_Object w32menu_show ();
 
 static HMENU keymap_panes ();
 static HMENU single_keymap_panes ();
@@ -576,7 +576,7 @@ single_keymap_panes (lpmm, keymap, pane_name, prefix, notreal)
       eltcdr = XCONS (elt)->cdr;
       string = XCONS (eltcdr)->car;
       /* We no longer discard the @ from the beginning of the string here.
-        Instead, we do this in win32menu_show.  */
+        Instead, we do this in w32menu_show.  */
       {
        HMENU new_hmenu = single_keymap_panes (lpmm,
                                               Fcar (elt),
@@ -946,7 +946,7 @@ get_single_keymap_event (keymap, lpnum)
       eltcdr = XCONS (elt)->cdr;
       string = XCONS (eltcdr)->car;
       /* We no longer discard the @ from the beginning of the string here.
-        Instead, we do this in win32menu_show.  */
+        Instead, we do this in w32menu_show.  */
       {
        Lisp_Object event = get_single_keymap_event (Fcar (elt), lpnum);
 
@@ -1152,16 +1152,18 @@ cached information about equivalent key sequences.")
   if (! NILP (position))
     {
       /* Decode the first argument: find the window and the coordinates.  */
-      if (EQ (position, Qt))
+      if (EQ (position, Qt)
+         || (CONSP (position) && EQ (XCONS (position)->car, Qmenu_bar)))
        {
          /* Use the mouse's current position.  */
-         FRAME_PTR new_f = 0;
+         FRAME_PTR new_f = selected_frame;
          Lisp_Object bar_window;
          int part;
          unsigned long time;
          
          if (mouse_position_hook)
-           (*mouse_position_hook) (&new_f, &bar_window, &part, &x, &y, &time);
+           (*mouse_position_hook) (&new_f, 1, &bar_window, 
+                                   &part, &x, &y, &time);
          if (new_f != 0)
            XSETFRAME (window, new_f);
          else
@@ -1212,8 +1214,8 @@ cached information about equivalent key sequences.")
          CHECK_LIVE_WINDOW (window, 0);
          f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
          
-         xpos = (FONT_WIDTH (f->output_data.win32->font) * XWINDOW (window)->left);
-         ypos = (f->output_data.win32->line_height * XWINDOW (window)->top);
+         xpos = (FONT_WIDTH (f->output_data.w32->font) * XWINDOW (window)->left);
+         ypos = (f->output_data.w32->line_height * XWINDOW (window)->top);
        }
       else
        /* ??? Not really clean; should be CHECK_WINDOW_OR_FRAME,
@@ -1240,7 +1242,7 @@ cached information about equivalent key sequences.")
   /* Display them in a menu.  */
   BLOCK_INPUT;
   
-  selection = win32menu_show (f, xpos, ypos, menu, &hmenu, &error_name);
+  selection = w32menu_show (f, xpos, ypos, menu, &hmenu, &error_name);
   
   UNBLOCK_INPUT;
   
@@ -1337,7 +1339,7 @@ on the left of the dialog box and all following items on the right.\n\
 
     /* Display them in a dialog box.  */
     BLOCK_INPUT;
-    selection = win32_dialog_show (f, 0, 0, title, &error_name);
+    selection = w32_dialog_show (f, 0, 0, title, &error_name);
     UNBLOCK_INPUT;
 
     discard_menu_items ();
@@ -1405,7 +1407,7 @@ set_frame_menubar (f, first_time)
      because it is not reentrant.  */
   specbind (Qdebug_on_next_call, Qnil);
 
-  record_unwind_protect (Fstore_match_data, Fmatch_data ());
+  record_unwind_protect (Fstore_match_data, Fmatch_data (Qnil, Qnil));
   if (NILP (Voverriding_local_map_menu_flag))
     {
       specbind (Qoverriding_terminal_local_map, Qnil);
@@ -1465,8 +1467,8 @@ set_frame_menubar (f, first_time)
   
   BLOCK_INPUT;
   {
-    HMENU old = GetMenu (FRAME_WIN32_WINDOW (f));
-    SetMenu (FRAME_WIN32_WINDOW (f), hmenu);
+    HMENU old = GetMenu (FRAME_W32_WINDOW (f));
+    SetMenu (FRAME_W32_WINDOW (f), hmenu);
     DestroyMenu (old);
   }
   
@@ -1484,14 +1486,14 @@ free_frame_menubar (f)
   BLOCK_INPUT;
 
   {
-    HMENU old = GetMenu (FRAME_WIN32_WINDOW (f));
-    SetMenu (FRAME_WIN32_WINDOW (f), NULL);
+    HMENU old = GetMenu (FRAME_W32_WINDOW (f));
+    SetMenu (FRAME_W32_WINDOW (f), NULL);
     DestroyMenu (old);
   }
     
   UNBLOCK_INPUT;
 }
-/* Called from Fwin32_create_frame to create the initial menubar of a frame
+/* Called from Fw32_create_frame to create the initial menubar of a frame
    before it is mapped, so that the window is mapped with the menubar already
    there instead of us tacking it on later and thrashing the window after it
    is visible.  */
@@ -1517,7 +1519,7 @@ check_mouse_other_menu_bar (f)
   Lisp_Object x, y;
   unsigned long time;
 
-  (*mouse_position_hook) (&new_f, &bar_window, &part, &x, &y, &time);
+  (*mouse_position_hook) (&new_f, 1, &bar_window, &part, &x, &y, &time);
 
   if (f == new_f && other_menu_bar_item_p (f, x, y))
     {
@@ -1647,9 +1649,9 @@ else
 
 #endif
 
-/* win32menu_show actually displays a menu using the panes and items in 
+/* w32menu_show actually displays a menu using the panes and items in 
    menu_items and returns the value selected from it.
-   There are two versions of win32menu_show, one for Xt and one for Xlib.
+   There are two versions of w32menu_show, one for Xt and one for Xlib.
    Both assume input is blocked by the caller.  */
 
 /* F is the frame the menu is for.
@@ -1665,7 +1667,7 @@ else
 
 
 static Lisp_Object 
-win32menu_show (f, x, y, menu, hmenu, error)
+w32menu_show (f, x, y, menu, hmenu, error)
      FRAME_PTR f;
      int x;
      int y;
@@ -1688,7 +1690,7 @@ win32menu_show (f, x, y, menu, hmenu, error)
   pos.y = y;
     
   /* Offset the coordinates to root-relative.  */
-  ClientToScreen (FRAME_WIN32_WINDOW (f), &pos);
+  ClientToScreen (FRAME_W32_WINDOW (f), &pos);
   
 #if 0
   /* If the mouse moves out of the menu before we show the menu,
@@ -1705,7 +1707,7 @@ win32menu_show (f, x, y, menu, hmenu, error)
                                   0x10,
                                   pos.x, pos.y,
                                   0,
-                                  FRAME_WIN32_WINDOW (f),
+                                  FRAME_W32_WINDOW (f),
                                   NULL);
   if (menu_selection == -1)
     {
@@ -1739,7 +1741,7 @@ static char * button_names [] =
 };
 
 static Lisp_Object
-win32_dialog_show (f, menubarp, keymaps, title, error)
+w32_dialog_show (f, menubarp, keymaps, title, error)
      FRAME_PTR f;
      int menubarp;
      int keymaps;
@@ -1856,7 +1858,7 @@ win32_dialog_show (f, menubarp, keymaps, title, error)
   /* Actually create the dialog.  */
   dialog_id = ++popup_id_tick;
   menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv,
-                          f->output_data.win32->widget, 1, 0,
+                          f->output_data.w32->widget, 1, 0,
                           dialog_selection_callback, 0);
 #if 0 /* This causes crashes, and seems to be redundant -- rms.  */
   lw_modify_all_widgets (dialog_id, first_wv, True);
@@ -1903,7 +1905,7 @@ win32_dialog_show (f, menubarp, keymaps, title, error)
      That is not necessarily true, but the fiction leads to reasonable
      results, and it is a pain to ask which are actually held now
      or track this in the loop above.  */
-  win32_mouse_grabbed = 0;
+  w32_mouse_grabbed = 0;
   
   /* Unread any events that we got but did not handle.  */
   while (queue != NULL) 
@@ -1957,7 +1959,7 @@ win32_dialog_show (f, menubarp, keymaps, title, error)
 }
 #endif
 
-syms_of_win32menu ()
+syms_of_w32menu ()
 {
   Qdebug_on_next_call = intern ("debug-on-next-call");
   staticpro (&Qdebug_on_next_call);