X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/996ad1b846a0865245df008bdb551093278b3c30..cab3f0a222412b1fd592b1c2f1e305fa245f9279:/src/menu.c diff --git a/src/menu.c b/src/menu.c index 61163ae021..cbddef3575 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1,6 +1,6 @@ /* Platform-independent code for terminal communications. -Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2014 Free Software +Copyright (C) 1986, 1988, 1993-1994, 1996, 1999-2016 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -23,13 +23,14 @@ along with GNU Emacs. If not, see . */ #include /* for INT_MAX */ #include "lisp.h" +#include "character.h" +#include "coding.h" #include "keyboard.h" #include "keymap.h" #include "frame.h" #include "window.h" #include "termhooks.h" #include "blockinput.h" -#include "dispextern.h" #include "buffer.h" #ifdef USE_X_TOOLKIT @@ -276,7 +277,6 @@ single_keymap_panes (Lisp_Object keymap, Lisp_Object pane_name, Lisp_Object prefix, int maxdepth) { struct skp skp; - struct gcpro gcpro1; skp.pending_maps = Qnil; skp.maxdepth = maxdepth; @@ -296,9 +296,7 @@ single_keymap_panes (Lisp_Object keymap, Lisp_Object pane_name, skp.notbuttons = menu_items_used; } - GCPRO1 (skp.pending_maps); map_keymap_canonical (keymap, single_menu_item, Qnil, &skp); - UNGCPRO; /* Process now any submenus which want to be panes at this level. */ while (CONSP (skp.pending_maps)) @@ -325,14 +323,11 @@ static void single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *skp_v) { Lisp_Object map, item_string, enabled; - struct gcpro gcpro1, gcpro2; bool res; struct skp *skp = skp_v; /* Parse the menu item and leave the result in item_properties. */ - GCPRO2 (key, item); res = parse_menu_item (item, 0); - UNGCPRO; if (!res) return; /* Not a menu item. */ @@ -1135,7 +1130,7 @@ If POSITION is t, it means to use the current mouse position. MENU is a specifier for a menu. For the simplest case, MENU is a keymap. The menu items come from key bindings that have a menu string as well as a definition; actually, the "definition" in such a key binding looks like -\(STRING . REAL-DEFINITION). To give the menu a title, put a string into +(STRING . REAL-DEFINITION). To give the menu a title, put a string into the keymap as a top-level element. If REAL-DEFINITION is nil, that puts a nonselectable string in the menu. @@ -1177,7 +1172,6 @@ no quit occurs and `x-popup-menu' returns nil. */) Lisp_Object x, y, window; int menuflags = 0; ptrdiff_t specpdl_count = SPECPDL_INDEX (); - struct gcpro gcpro1; if (NILP (position)) /* This is an obsolete call, which wants us to precompute the @@ -1242,36 +1236,43 @@ no quit occurs and `x-popup-menu' returns nil. */) { /* Use the mouse's current position. */ struct frame *new_f = SELECTED_FRAME (); + + XSETFASTINT (x, 0); + XSETFASTINT (y, 0); #ifdef HAVE_X_WINDOWS - /* Can't use mouse_position_hook for X since it returns - coordinates relative to the window the mouse is in, - we need coordinates relative to the edit widget always. */ - if (new_f != 0) + if (FRAME_X_P (new_f)) { - int cur_x, cur_y; - - x_relative_mouse_position (new_f, &cur_x, &cur_y); - /* cur_x/y may be negative, so use make_number. */ - x = make_number (cur_x); - y = make_number (cur_y); + /* Can't use mouse_position_hook for X since it returns + coordinates relative to the window the mouse is in, + we need coordinates relative to the edit widget always. */ + if (new_f != 0) + { + int cur_x, cur_y; + + x_relative_mouse_position (new_f, &cur_x, &cur_y); + /* cur_x/y may be negative, so use make_number. */ + x = make_number (cur_x); + y = make_number (cur_y); + } + } + else +#endif /* HAVE_X_WINDOWS */ + { + Lisp_Object bar_window; + enum scroll_bar_part part; + Time time; + void (*mouse_position_hook) (struct frame **, int, + Lisp_Object *, + enum scroll_bar_part *, + Lisp_Object *, + Lisp_Object *, + Time *) = + FRAME_TERMINAL (new_f)->mouse_position_hook; + + if (mouse_position_hook) + (*mouse_position_hook) (&new_f, 1, &bar_window, + &part, &x, &y, &time); } - -#else /* not HAVE_X_WINDOWS */ - Lisp_Object bar_window; - enum scroll_bar_part part; - Time time; - void (*mouse_position_hook) (struct frame **, int, - Lisp_Object *, - enum scroll_bar_part *, - Lisp_Object *, - Lisp_Object *, - Time *) = - FRAME_TERMINAL (new_f)->mouse_position_hook; - - if (mouse_position_hook) - (*mouse_position_hook) (&new_f, 1, &bar_window, - &part, &x, &y, &time); -#endif /* not HAVE_X_WINDOWS */ if (new_f != 0) XSETFRAME (window, new_f); @@ -1325,7 +1326,6 @@ no quit occurs and `x-popup-menu' returns nil. */) record_unwind_protect_void (unuse_menu_items); title = Qnil; - GCPRO1 (title); /* Decode the menu items from what was specified. */ @@ -1418,7 +1418,6 @@ no quit occurs and `x-popup-menu' returns nil. */) { discard_menu_items (); FRAME_DISPLAY_INFO (f)->grabbed = 0; - UNGCPRO; return Qnil; } #endif @@ -1445,8 +1444,6 @@ no quit occurs and `x-popup-menu' returns nil. */) FRAME_DISPLAY_INFO (f)->grabbed = 0; #endif - UNGCPRO; - if (error_name) error ("%s", error_name); return selection; } @@ -1498,7 +1495,7 @@ The return value is VALUE from the chosen item. An ITEM may also be just a string--that makes a nonselectable item. An ITEM may also be nil--that means to put all preceding items on the left of the dialog box and all following items on the right. -\(By default, approximately half appear on each side.) +(By default, approximately half appear on each side.) If HEADER is non-nil, the frame title for the box is "Information", otherwise it is "Question".