/* X Communication module for terminals which understand the X protocol.
- Copyright (C) 1986, 88, 93, 94, 96, 1999 Free Software Foundation, Inc.
+ Copyright (C) 1986, 88, 93, 94, 96, 99, 2000 Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <stdio.h>
#include "lisp.h"
#include "termhooks.h"
+#include "keyboard.h"
#include "frame.h"
#include "window.h"
-#include "keyboard.h"
#include "blockinput.h"
#include "buffer.h"
But don't make a pane that is empty--ignore that map instead.
P is the number of panes we have made so far. */
for (mapno = 0; mapno < nmaps; mapno++)
- single_keymap_panes (keymaps[mapno], Qnil, Qnil, notreal, 10);
+ single_keymap_panes (keymaps[mapno],
+ map_prompt (keymaps[mapno]), Qnil, notreal, 10);
finish_menu_items ();
}
Lisp_Object position, menu;
{
Lisp_Object keymap, tem;
- int xpos, ypos;
+ int xpos = 0, ypos = 0;
Lisp_Object title;
char *error_name;
Lisp_Object selection;
- FRAME_PTR f;
+ struct frame *f = NULL;
Lisp_Object x, y, window;
int keymaps = 0;
int for_click = 0;
/* Decode the first argument: find the window and the coordinates. */
if (EQ (position, Qt)
- || (CONSP (position) && EQ (XCAR (position), Qmenu_bar)))
+ || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
+ || EQ (XCAR (position), Qtool_bar))))
{
/* Use the mouse's current position. */
FRAME_PTR new_f = SELECTED_FRAME ();
/* Decode the menu items from what was specified. */
- keymap = Fkeymapp (menu);
- tem = Qnil;
- if (CONSP (menu))
- tem = Fkeymapp (Fcar (menu));
- if (!NILP (keymap))
+ keymap = get_keymap (menu, 0, 0);
+ if (CONSP (keymap))
{
/* We were given a keymap. Extract menu info from the keymap. */
Lisp_Object prompt;
- keymap = get_keymap (menu);
/* Extract the detailed info to make one pane. */
keymap_panes (&menu, 1, NILP (position));
keymaps = 1;
}
- else if (!NILP (tem))
+ else if (CONSP (menu) && KEYMAPP (XCAR (menu)))
{
/* We were given a list of keymaps. */
int nmaps = XFASTINT (Flength (menu));
{
Lisp_Object prompt;
- maps[i++] = keymap = get_keymap (Fcar (tem));
+ maps[i++] = keymap = get_keymap (Fcar (tem), 1, 0);
prompt = map_prompt (keymap);
if (NILP (title) && !NILP (prompt))
(position, contents)
Lisp_Object position, contents;
{
- FRAME_PTR f;
+ struct frame * f = NULL;
Lisp_Object window;
check_x ();
/* Decode the first argument: find the window or frame to use. */
if (EQ (position, Qt)
- || (CONSP (position) && EQ (XCAR (position), Qmenu_bar)))
+ || (CONSP (position) && (EQ (XCAR (position), Qmenu_bar)
+ || EQ (XCAR (position), Qtool_bar))))
{
#if 0 /* Using the frame the mouse is on may not be right. */
/* Use the mouse's current position. */
&& (event.xany.display != dpyinfo->display
|| x_non_menubar_window_to_frame (dpyinfo, event.xany.window)))
{
- queue_tmp = (struct event_queue *) malloc (sizeof (struct event_queue));
-
- if (queue_tmp != NULL)
- {
- queue_tmp->event = event;
- queue_tmp->next = queue;
- queue = queue_tmp;
- }
+ queue_tmp = (struct event_queue *) xmalloc (sizeof *queue_tmp);
+ queue_tmp->event = event;
+ queue_tmp->next = queue;
+ queue = queue_tmp;
}
else
XtDispatchEvent (&event);
queue_tmp = queue;
XPutBackEvent (queue_tmp->event.xany.display, &queue_tmp->event);
queue = queue_tmp->next;
- free ((char *)queue_tmp);
+ xfree ((char *)queue_tmp);
/* Cause these events to get read as soon as we UNBLOCK_INPUT. */
interrupt_input_pending = 1;
}
widget_value *wv = (widget_value *) call_data;
struct frame *f;
Lisp_Object frame, help;
- struct input_event buf;
+ help = wv && wv->help ? build_string (wv->help) : Qnil;
+
/* Determine the frame for the help event. */
f = menubar_id_to_frame (id);
if (f)
- XSETFRAME (frame, f);
+ {
+ XSETFRAME (frame, f);
+ kbd_buffer_store_help_event (frame, help);
+ }
else
{
/* WIDGET is the popup menu. It's parent is the frame's
FRAME_X_P (f) && f->output_data.x->widget == frame_widget))
break;
}
- }
- /* Store the help event. */
- help = wv && wv->help ? build_string (wv->help) : Qnil;
- buf.kind = HELP_EVENT;
- buf.frame_or_window = Fcons (frame, help);
- kbd_buffer_store_event (&buf);
+ show_help_echo (help, Qnil, Qnil, Qnil, 1);
+ }
}
/* This callback is called from the menu bar pulldown menu
if (!f)
return;
+ entry = Qnil;
subprefix_stack = (Lisp_Object *) alloca (f->menu_bar_items_used * sizeof (Lisp_Object));
vector = f->menu_bar_vector;
prefix = Qnil;
Lisp_Object frame;
XSETFRAME (frame, f);
- buf.kind = menu_bar_event;
- buf.frame_or_window = Fcons (frame, Fcons (Qmenu_bar, Qnil));
+ buf.kind = MENU_BAR_EVENT;
+ buf.frame_or_window = frame;
+ buf.arg = frame;
kbd_buffer_store_event (&buf);
for (j = 0; j < submenu_depth; j++)
if (!NILP (subprefix_stack[j]))
{
- buf.kind = menu_bar_event;
- buf.frame_or_window = Fcons (frame, subprefix_stack[j]);
+ buf.kind = MENU_BAR_EVENT;
+ buf.frame_or_window = frame;
+ buf.arg = subprefix_stack[j];
kbd_buffer_store_event (&buf);
}
if (!NILP (prefix))
{
- buf.kind = menu_bar_event;
- buf.frame_or_window = Fcons (frame, prefix);
+ buf.kind = MENU_BAR_EVENT;
+ buf.frame_or_window = frame;
+ buf.arg = prefix;
kbd_buffer_store_event (&buf);
}
- buf.kind = menu_bar_event;
- buf.frame_or_window = Fcons (frame, entry);
+ buf.kind = MENU_BAR_EVENT;
+ buf.frame_or_window = frame;
+ buf.arg = entry;
kbd_buffer_store_event (&buf);
return;
for (i = 0; i < len; i++)
{
if (SYMBOLP (mapvec[i])
- || (CONSP (mapvec[i])
- && NILP (Fkeymapp (mapvec[i]))))
+ || (CONSP (mapvec[i]) && !KEYMAPP (mapvec[i])))
{
/* Here we have a command at top level in the menu bar
as opposed to a submenu. */
{
XtManageChild (x->menubar_widget);
XtMapWidget (x->menubar_widget);
- XtVaSetValues (x->menubar_widget, XtNmappedWhenManaged, 1, 0);
+ XtVaSetValues (x->menubar_widget, XtNmappedWhenManaged, 1, NULL);
}
/* Re-manage the text-area widget, and then thrash the sizes. */
else
{
/* Create a new item within current pane. */
- Lisp_Object item_name, enable, descrip, def, type, selected;
+ Lisp_Object item_name, enable, descrip, def, type, selected, help;
item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME];
enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
descrip
def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION];
type = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_TYPE];
selected = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_SELECTED];
+ help = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_HELP];
#ifndef HAVE_MULTILINGUAL_MENU
if (STRINGP (item_name) && STRING_MULTIBYTE (item_name))
abort ();
wv->selected = !NILP (selected);
+ if (STRINGP (help))
+ wv->help = XSTRING (help)->data;
prev_wv = wv;
/* Free the widget_value objects we used to specify the contents. */
free_menubar_widget_value_tree (first_wv);
+ /* Override any default settings with ones from the `menu' face. */
+ x_set_menu_resources_from_menu_face (f, menu);
+
/* No selection has been chosen yet. */
menu_item_selection = 0;
/* Display the menu. */
- lw_popup_menu (menu, &dummy);
- x_set_menu_resources_from_menu_face (f, menu);
+ lw_popup_menu (menu, (XEvent *) &dummy);
popup_activated_flag = 1;
/* Process events that apply to the menu. */
{
Lisp_Object prefix, entry;
- prefix = Qnil;
+ prefix = entry = Qnil;
i = 0;
while (i < menu_items_used)
{
= XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
i += MENU_ITEMS_PANE_LENGTH;
}
+ else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
+ {
+ /* This is the boundary between left-side elts and
+ right-side elts. */
+ ++i;
+ }
else
{
entry
return Qnil;
}
+
#else /* not USE_X_TOOLKIT */
/* The frame of the last activated non-toolkit menu bar.
static struct frame *menu_help_frame;
-/* Show help HELP_STRING, or clear help if HELP_STRING is null. This
- cannot be done with generating a HELP_EVENT because XMenuActivate
- contains a loop that doesn't let Emacs process keyboard events. */
+/* Show help HELP_STRING, or clear help if HELP_STRING is null.
+
+ PANE is the pane number, and ITEM is the menu item number in
+ the menu (currently not used).
+
+ This cannot be done with generating a HELP_EVENT because
+ XMenuActivate contains a loop that doesn't let Emacs process
+ keyboard events. */
static void
-menu_help_callback (help_string)
+menu_help_callback (help_string, pane, item)
char *help_string;
+ int pane, item;
{
- Lisp_Object msg;
- extern Lisp_Object Vshow_help_function;
- struct gcpro gcpro1;
-
- msg = help_string ? build_string (help_string) : Qnil;
- GCPRO1 (msg);
-
- if (!NILP (Vshow_help_function))
- call1 (Vshow_help_function, msg);
- else if (!MINI_WINDOW_P (XWINDOW (selected_window)))
- {
- if (STRINGP (msg))
- message3_nolog (msg, XSTRING (msg)->size, STRING_MULTIBYTE (msg));
- else
- message (0);
- }
-
- UNGCPRO;
+ extern Lisp_Object Qmenu_item;
+ Lisp_Object *first_item;
+ Lisp_Object pane_name;
+ Lisp_Object menu_object;
+
+ first_item = XVECTOR (menu_items)->contents;
+ if (EQ (first_item[0], Qt))
+ pane_name = first_item[MENU_ITEMS_PANE_NAME];
+ else if (EQ (first_item[0], Qquote))
+ /* This shouldn't happen, see xmenu_show. */
+ pane_name = build_string ("");
+ else
+ pane_name = first_item[MENU_ITEMS_ITEM_NAME];
+
+ /* (menu-item MENU-NAME PANE-NUMBER) */
+ menu_object = Fcons (Qmenu_item,
+ Fcons (pane_name,
+ Fcons (make_number (pane), Qnil)));
+ show_help_echo (help_string ? build_string (help_string) : Qnil,
+ Qnil, menu_object, make_number (item), 1);
}
-
+
static Lisp_Object
xmenu_show (f, x, y, for_click, keymaps, title, error)