]> code.delx.au - gnu-emacs/blobdiff - src/w32menu.c
Don't install keyboard hook when debugged on MS-Windows
[gnu-emacs] / src / w32menu.c
index 2a1dafbd6d7d740183280bd8938442956be4caf6..13296d9d855a77fd7c8aee28018e0218bb41fdc9 100644 (file)
@@ -1,13 +1,13 @@
 /* Menu support for GNU Emacs on the Microsoft Windows API.
-   Copyright (C) 1986, 1988, 1993-1994, 1996, 1998-1999, 2001-2015 Free
+   Copyright (C) 1986, 1988, 1993-1994, 1996, 1998-1999, 2001-2016 Free
    Software Foundation, Inc.
 
 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 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,15 +25,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "lisp.h"
 #include "keyboard.h"
-#include "keymap.h"
 #include "frame.h"
-#include "termhooks.h"
-#include "window.h"
 #include "blockinput.h"
-#include "character.h"
 #include "buffer.h"
-#include "charset.h"
-#include "coding.h"
+#include "coding.h"    /* for ENCODE_SYSTEM */
 #include "menu.h"
 
 /* This may include sys/types.h, and that somehow loses
@@ -54,8 +49,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <sys/types.h>
 #endif
 
-#include "dispextern.h"
-
 #include "w32common.h" /* for osinfo_cache */
 
 #undef HAVE_DIALOGS /* TODO: Implement native dialogs.  */
@@ -67,9 +60,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 HMENU current_popup_menu;
 
-void syms_of_w32menu (void);
-void globals_of_w32menu (void);
-
 typedef BOOL (WINAPI * GetMenuItemInfoA_Proc) (
     IN HMENU,
     IN UINT,
@@ -87,10 +77,10 @@ typedef int (WINAPI * MessageBoxW_Proc) (
     IN UINT type);
 
 #ifdef NTGUI_UNICODE
-#define get_menu_item_info GetMenuItemInfoA
-#define set_menu_item_info SetMenuItemInfoA
-#define unicode_append_menu AppendMenuW
-#define unicode_message_box MessageBoxW
+GetMenuItemInfoA_Proc get_menu_item_info = GetMenuItemInfoA;
+SetMenuItemInfoA_Proc set_menu_item_info = SetMenuItemInfoA;
+AppendMenuW_Proc unicode_append_menu = AppendMenuW;
+MessageBoxW_Proc unicode_message_box = MessageBoxW;
 #else /* !NTGUI_UNICODE */
 GetMenuItemInfoA_Proc get_menu_item_info = NULL;
 SetMenuItemInfoA_Proc set_menu_item_info = NULL;
@@ -98,12 +88,10 @@ AppendMenuW_Proc unicode_append_menu = NULL;
 MessageBoxW_Proc unicode_message_box = NULL;
 #endif /* NTGUI_UNICODE */
 
-void set_frame_menubar (struct frame *, bool, bool);
-
 #ifdef HAVE_DIALOGS
 static Lisp_Object w32_dialog_show (struct frame *, Lisp_Object, Lisp_Object, char **);
 #else
-static int is_simple_dialog (Lisp_Object);
+static bool is_simple_dialog (Lisp_Object);
 static Lisp_Object simple_dialog_show (struct frame *, Lisp_Object, Lisp_Object);
 #endif
 
@@ -166,7 +154,7 @@ w32_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
 void
 x_activate_menubar (struct frame *f)
 {
-  set_frame_menubar (f, 0, 1);
+  set_frame_menubar (f, false, true);
 
   /* Lock out further menubar changes while active.  */
   f->output_data.w32->menubar_active = 1;
@@ -179,6 +167,7 @@ x_activate_menubar (struct frame *f)
    when the user makes a selection.
    Figure out what the user chose
    and put the appropriate events into the keyboard buffer.  */
+void menubar_selection_callback (struct frame *, void *);
 
 void
 menubar_selection_callback (struct frame *f, void * client_data)
@@ -289,7 +278,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
   XSETFRAME (Vmenu_updating_frame, f);
 
   if (! menubar_widget)
-    deep_p = 1;
+    deep_p = true;
 
   if (deep_p)
     {
@@ -388,7 +377,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
          else
            first_wv->contents = wv;
          /* Don't set wv->name here; GC during the loop might relocate it.  */
-         wv->enabled = 1;
+         wv->enabled = true;
          wv->button_type = BUTTON_TYPE_NONE;
          prev_wv = wv;
        }
@@ -501,7 +490,10 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
     /* Force the window size to be recomputed so that the frame's text
        area remains the same, if menubar has just been created.  */
     if (old_widget == NULL)
-      adjust_frame_size (f, -1, -1, 2, 0, Qmenu_bar_lines);
+      {
+       windows_or_buffers_changed = 23;
+       adjust_frame_size (f, -1, -1, 2, false, Qmenu_bar_lines);
+      }
   }
 
   unblock_input ();
@@ -518,7 +510,7 @@ initialize_frame_menubar (struct frame *f)
   /* This function is called before the first chance to redisplay
      the frame.  It has to be, so the frame will have the right size.  */
   fset_menu_bar_items (f, menu_bar_items (FRAME_MENU_BAR_ITEMS (f)));
-  set_frame_menubar (f, 1, 1);
+  set_frame_menubar (f, true, true);
 }
 
 /* Get rid of the menu bar of frame F, and free its storage.
@@ -570,7 +562,7 @@ w32_menu_show (struct frame *f, int x, int y, int menuflags,
   Lisp_Object *subprefix_stack
     = (Lisp_Object *) alloca (menu_items_used * word_size);
   int submenu_depth = 0;
-  int first_pane;
+  bool first_pane;
 
   *error = NULL;
 
@@ -590,7 +582,7 @@ w32_menu_show (struct frame *f, int x, int y, int menuflags,
   wv = make_widget_value ("menu", NULL, true, Qnil);
   wv->button_type = BUTTON_TYPE_NONE;
   first_wv = wv;
-  first_pane = 1;
+  first_pane = true;
 
   /* Loop over all panes and items, filling in the tree.  */
   i = 0;
@@ -601,14 +593,14 @@ w32_menu_show (struct frame *f, int x, int y, int menuflags,
          submenu_stack[submenu_depth++] = save_wv;
          save_wv = prev_wv;
          prev_wv = 0;
-         first_pane = 1;
+         first_pane = false;
          i++;
        }
       else if (EQ (AREF (menu_items, i), Qlambda))
        {
          prev_wv = save_wv;
          save_wv = submenu_stack[--submenu_depth];
-         first_pane = 0;
+         first_pane = false;
          i++;
        }
       else if (EQ (AREF (menu_items, i), Qt)
@@ -664,7 +656,7 @@ w32_menu_show (struct frame *f, int x, int y, int menuflags,
              save_wv = wv;
              prev_wv = 0;
            }
-         first_pane = 0;
+         first_pane = false;
          i += MENU_ITEMS_PANE_LENGTH;
        }
       else
@@ -883,8 +875,9 @@ w32_dialog_show (struct frame *f, Lisp_Object title,
 
   /* Number of elements seen so far, before boundary.  */
   int left_count = 0;
-  /* 1 means we've seen the boundary between left-hand elts and right-hand.  */
-  int boundary_seen = 0;
+  /* true means we've seen the boundary between left-hand elts and
+     right-hand.  */
+  bool boundary_seen = false;
 
   *error = NULL;
 
@@ -928,7 +921,7 @@ w32_dialog_show (struct frame *f, Lisp_Object title,
          {
            /* This is the boundary between left-side elts
               and right-side elts.  Stop incrementing right_count.  */
-           boundary_seen = 1;
+           boundary_seen = true;
            i++;
            continue;
          }
@@ -986,7 +979,7 @@ w32_dialog_show (struct frame *f, Lisp_Object title,
   /* Actually create the dialog.  */
   dialog_id = widget_id_tick++;
   menu = lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv,
-                          f->output_data.w32->widget, 1, 0,
+                          f->output_data.w32->widget, true, 0,
                           dialog_selection_callback, 0);
   lw_modify_all_widgets (dialog_id, first_wv->contents, TRUE);
 
@@ -1037,25 +1030,25 @@ w32_dialog_show (struct frame *f, Lisp_Object title,
    anywhere in Emacs that uses the other specific dialog choices that
    MessageBox provides.  */
 
-static int
+static bool
 is_simple_dialog (Lisp_Object contents)
 {
   Lisp_Object options;
   Lisp_Object name, yes, no, other;
 
   if (!CONSP (contents))
-    return 0;
+    return false;
   options = XCDR (contents);
 
   yes = build_string ("Yes");
   no = build_string ("No");
 
   if (!CONSP (options))
-    return 0;
+    return false;
 
   name = XCAR (options);
   if (!CONSP (name))
-    return 0;
+    return false;
   name = XCAR (name);
 
   if (!NILP (Fstring_equal (name, yes)))
@@ -1063,18 +1056,18 @@ is_simple_dialog (Lisp_Object contents)
   else if (!NILP (Fstring_equal (name, no)))
     other = yes;
   else
-    return 0;
+    return false;
 
   options = XCDR (options);
   if (!CONSP (options))
-    return 0;
+    return false;
 
   name = XCAR (options);
   if (!CONSP (name))
-    return 0;
+    return false;
   name = XCAR (name);
   if (NILP (Fstring_equal (name, other)))
-    return 0;
+    return false;
 
   /* Check there are no more options.  */
   options = XCDR (options);
@@ -1103,18 +1096,18 @@ simple_dialog_show (struct frame *f, Lisp_Object contents, Lisp_Object header)
 
       if (STRINGP (temp))
        {
-         char *utf8_text = SDATA (ENCODE_UTF_8 (temp));
+         char *utf8_text = SSDATA (ENCODE_UTF_8 (temp));
          /* Be pessimistic about the number of characters needed.
             Remember characters outside the BMP will take more than
             one utf16 word, so we cannot simply use the character
             length of temp.  */
          int utf8_len = strlen (utf8_text);
          text = SAFE_ALLOCA ((utf8_len + 1) * sizeof (WCHAR));
-         utf8to16 (utf8_text, utf8_len, text);
+         utf8to16 ((unsigned char *)utf8_text, utf8_len, text);
        }
       else
        {
-         text = L"";
+         text = (WCHAR *)L"";
        }
 
       if (NILP (header))
@@ -1139,7 +1132,7 @@ simple_dialog_show (struct frame *f, Lisp_Object contents, Lisp_Object header)
         encoding so questions representable by the system codepage
         are encoded properly.  */
       if (STRINGP (temp))
-       text = SDATA (ENCODE_SYSTEM (temp));
+       text = SSDATA (ENCODE_SYSTEM (temp));
       else
        text = "";
 
@@ -1352,7 +1345,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
       else
        utf16_string = SAFE_ALLOCA ((utf8_len + 1) * sizeof (WCHAR));
 
-      utf8to16 (out_string, utf8_len, utf16_string);
+      utf8to16 ((unsigned char *)out_string, utf8_len, utf16_string);
       return_value = unicode_append_menu (menu, fuFlags,
                                          item != NULL ? (UINT_PTR) item
                                            : (UINT_PTR) wv->call_data,
@@ -1468,6 +1461,8 @@ fill_in_menu (HMENU menu, widget_value *wv)
 /* Display help string for currently pointed to menu item. Not
    supported on NT 3.51 and earlier, as GetMenuItemInfo is not
    available. */
+void w32_menu_display_help (HWND, HMENU, UINT, UINT);
+
 void
 w32_menu_display_help (HWND owner, HMENU menu, UINT item, UINT flags)
 {