#include <config.h>
-#if 0 /* Why was this included? And without syssignal.h? */
-/* On 4.3 this loses if it comes after xterm.h. */
-#include <signal.h>
-#endif
-
#include <stdio.h>
-#include <setjmp.h>
#include "lisp.h"
#include "keyboard.h"
static Lisp_Object Qdebug_on_next_call;
#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
-static Lisp_Object xdialog_show (FRAME_PTR, int, Lisp_Object, Lisp_Object,
+static Lisp_Object xdialog_show (FRAME_PTR, bool, Lisp_Object, Lisp_Object,
const char **);
#endif
\f
int dummy;
if (! FRAME_X_P (f))
- abort ();
+ emacs_abort ();
- BLOCK_INPUT;
+ block_input ();
XQueryPointer (FRAME_X_DISPLAY (f),
DefaultRootWindow (FRAME_X_DISPLAY (f)),
we don't care. */
(unsigned int *) &dummy);
- UNBLOCK_INPUT;
+ unblock_input ();
/* xmenu_show expects window coordinates, not root window
coordinates. Translate. */
}
else if (CONSP (position))
{
- Lisp_Object tem;
- tem = Fcar (position);
+ Lisp_Object tem = XCAR (position);
if (CONSP (tem))
- window = Fcar (Fcdr (position));
+ window = Fcar (XCDR (position));
else
{
- tem = Fcar (Fcdr (position)); /* EVENT_START (position) */
+ tem = Fcar (XCDR (position)); /* EVENT_START (position) */
window = Fcar (tem); /* POSN_WINDOW (tem) */
}
}
list_of_panes (Fcons (contents, Qnil));
/* Display them in a dialog box. */
- BLOCK_INPUT;
+ block_input ();
selection = xdialog_show (f, 0, title, header, &error_name);
- UNBLOCK_INPUT;
+ unblock_input ();
unbind_to (specpdl_count, Qnil);
discard_menu_items ();
ntp = &next_time;
#ifdef HAVE_GTK3
- /* Gtk3 have arrows on menus when they don't fit. When the pointer is
- over an arrow, a timeout scrolls it a bit. Use xg_select so that
- timeout gets triggered. */
-
- xg_select (n + 1, &read_fds, NULL, NULL, ntp);
+ /* Gtk3 have arrows on menus when they don't fit. When the
+ pointer is over an arrow, a timeout scrolls it a bit. Use
+ xg_select so that timeout gets triggered. */
+ xg_select (n + 1, &read_fds, NULL, NULL, ntp, NULL);
#else
pselect (n + 1, &read_fds, NULL, NULL, ntp, NULL);
#endif
XEvent ev;
FRAME_PTR f = check_x_frame (frame);
Widget menubar;
- BLOCK_INPUT;
+ block_input ();
if (FRAME_EXTERNAL_MENU_BAR (f))
set_frame_menubar (f, 0, 1);
}
}
- UNBLOCK_INPUT;
+ unblock_input ();
return Qnil;
}
FRAME_PTR f;
/* gcc 2.95 doesn't accept the FRAME_PTR declaration after
- BLOCK_INPUT. */
+ block_input (). */
- BLOCK_INPUT;
+ block_input ();
f = check_x_frame (frame);
if (FRAME_EXTERNAL_MENU_BAR (f))
g_list_free (children);
}
}
- UNBLOCK_INPUT;
+ unblock_input ();
return Qnil;
}
x_activate_menubar (FRAME_PTR f)
{
if (! FRAME_X_P (f))
- abort ();
+ emacs_abort ();
if (!f->output_data.x->saved_menu_event->type)
return;
#endif
set_frame_menubar (f, 0, 1);
- BLOCK_INPUT;
+ block_input ();
popup_activated_flag = 1;
#ifdef USE_GTK
XPutBackEvent (f->output_data.x->display_info->display,
#else
XtDispatchEvent (f->output_data.x->saved_menu_event);
#endif
- UNBLOCK_INPUT;
+ unblock_input ();
/* Ignore this if we get it a second time. */
f->output_data.x->saved_menu_event->type = 0;
/* This callback is invoked when a dialog or menu is finished being
used and has been unposted. */
-#ifdef USE_GTK
static void
-popup_deactivate_callback (GtkWidget *widget, gpointer client_data)
-{
- popup_activated_flag = 0;
-}
+popup_deactivate_callback (
+#ifdef USE_GTK
+ GtkWidget *widget, gpointer client_data
#else
-static void
-popup_deactivate_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
+ Widget widget, LWLIB_ID id, XtPointer client_data
+#endif
+ )
{
popup_activated_flag = 0;
}
-#endif
/* Function that finds the frame for WIDGET and shows the HELP text
sit-for will exit at once if the focus event follows the menu selection
event. */
- BLOCK_INPUT;
+ block_input ();
while (gtk_events_pending ())
gtk_main_iteration ();
- UNBLOCK_INPUT;
+ unblock_input ();
find_and_call_menu_selection (cb_data->cl_data->f,
cb_data->cl_data->menu_bar_items_used,
#endif /* not USE_GTK */
\f
/* Recompute all the widgets of frame F, when the menu bar has been
- changed. Value is non-zero if widgets were updated. */
+ changed. */
-static int
+static void
update_frame_menubar (FRAME_PTR f)
{
#ifdef USE_GTK
- return xg_update_frame_menubar (f);
+ xg_update_frame_menubar (f);
#else
struct x_output *x;
int columns, rows;
if (! FRAME_X_P (f))
- abort ();
+ emacs_abort ();
x = f->output_data.x;
if (!x->menubar_widget || XtIsManaged (x->menubar_widget))
- return 0;
+ return;
- BLOCK_INPUT;
+ block_input ();
/* Save the size of the frame because the pane widget doesn't accept
to resize itself. So force it. */
columns = FRAME_COLS (f);
/* Force the pane widget to resize itself with the right values. */
EmacsFrameSetCharSize (x->edit_widget, columns, rows);
- UNBLOCK_INPUT;
+ unblock_input ();
#endif
- return 1;
}
#ifdef USE_LUCID
it is set the first time this is called, from initialize_frame_menubar. */
void
-set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
+set_frame_menubar (FRAME_PTR f, bool first_time, bool deep_p)
{
xt_or_gtk_widget menubar_widget;
#ifdef USE_X_TOOLKIT
widget_value *wv, *first_wv, *prev_wv = 0;
int i;
int *submenu_start, *submenu_end;
- int *submenu_top_level_items, *submenu_n_panes;
+ bool *submenu_top_level_items;
+ int *submenu_n_panes;
if (! FRAME_X_P (f))
- abort ();
+ emacs_abort ();
menubar_widget = f->output_data.x->menubar_widget;
else if (!f->output_data.x->saved_menu_event && !deep_p)
{
deep_p = 1;
- f->output_data.x->saved_menu_event = (XEvent*)xmalloc (sizeof (XEvent));
+ f->output_data.x->saved_menu_event = xmalloc (sizeof (XEvent));
f->output_data.x->saved_menu_event->type = 0;
}
ptrdiff_t specpdl_count = SPECPDL_INDEX ();
int previous_menu_items_used = f->menu_bar_items_used;
Lisp_Object *previous_items
- = (Lisp_Object *) alloca (previous_menu_items_used
- * sizeof (Lisp_Object));
+ = alloca (previous_menu_items_used * sizeof *previous_items);
int subitems;
/* If we are making a new widget, its contents are empty,
if (! NILP (Vlucid_menu_bar_dirty_flag))
call0 (Qrecompute_lucid_menubar);
safe_run_hooks (Qmenu_bar_update_hook);
- FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
+ fset_menu_bar_items (f, menu_bar_items (FRAME_MENU_BAR_ITEMS (f)));
items = FRAME_MENU_BAR_ITEMS (f);
/* Save the frame's previous menu bar contents data. */
if (previous_menu_items_used)
memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents,
- previous_menu_items_used * sizeof (Lisp_Object));
+ previous_menu_items_used * word_size);
/* Fill in menu_items with the current menu bar contents.
This can evaluate Lisp code. */
menu_items = f->menu_bar_vector;
menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
subitems = ASIZE (items) / 4;
- submenu_start = (int *) alloca ((subitems + 1) * sizeof (int));
- submenu_end = (int *) alloca (subitems * sizeof (int));
- submenu_n_panes = (int *) alloca (subitems * sizeof (int));
- submenu_top_level_items = (int *) alloca (subitems * sizeof (int));
+ submenu_start = alloca ((subitems + 1) * sizeof *submenu_start);
+ submenu_end = alloca (subitems * sizeof *submenu_end);
+ submenu_n_panes = alloca (subitems * sizeof *submenu_n_panes);
+ submenu_top_level_items = alloca (subitems
+ * sizeof *submenu_top_level_items);
init_menu_items ();
for (i = 0; i < subitems; i++)
{
}
/* The menu items are different, so store them in the frame. */
- f->menu_bar_vector = menu_items;
+ fset_menu_bar_vector (f, menu_items);
f->menu_bar_items_used = menu_items_used;
/* This undoes save_menu_items. */
/* Create or update the menu bar widget. */
- BLOCK_INPUT;
+ block_input ();
#ifdef USE_GTK
xg_crazy_callback_abort = 1;
xg_crazy_callback_abort = 0;
#endif
- UNBLOCK_INPUT;
+ unblock_input ();
}
/* Called from Fx_create_frame to create the initial menubar of a frame
{
/* This function is called before the first chance to redisplay
the frame. It has to be, so the frame will have the right size. */
- FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
+ fset_menu_bar_items (f, menu_bar_items (FRAME_MENU_BAR_ITEMS (f)));
set_frame_menubar (f, 1, 1);
}
Widget menubar_widget;
if (! FRAME_X_P (f))
- abort ();
+ emacs_abort ();
menubar_widget = f->output_data.x->menubar_widget;
Position x0, y0, x1, y1;
#endif
- BLOCK_INPUT;
+ block_input ();
#ifdef USE_MOTIF
if (f->output_data.x->widget)
#endif
x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
}
- UNBLOCK_INPUT;
+ unblock_input ();
}
}
#endif /* not USE_GTK */
/* F is the frame the menu is for.
X and Y are the frame-relative specified position,
relative to the inside upper left corner of the frame F.
- FOR_CLICK is nonzero if this menu was invoked for a mouse click.
- KEYMAPS is 1 if this menu was specified with keymaps;
+ FOR_CLICK is true if this menu was invoked for a mouse click.
+ KEYMAPS is true if this menu was specified with keymaps;
in that case, we return a list containing the chosen item's value
and perhaps also the pane's prefix.
TITLE is the specified menu title.
struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
popup_activated_flag = 0;
- BLOCK_INPUT;
+ block_input ();
gtk_widget_destroy (GTK_WIDGET (p->pointer));
- UNBLOCK_INPUT;
+ unblock_input ();
return Qnil;
}
menu_item_selection will be set to the selection. */
static void
create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, int x, int y,
- int for_click, Time timestamp)
+ bool for_click, Time timestamp)
{
int i;
GtkWidget *menu;
GtkMenuPositionFunc pos_func = 0; /* Pop up at pointer. */
struct next_popup_x_y popup_x_y;
ptrdiff_t specpdl_count = SPECPDL_INDEX ();
- int use_pos_func = ! for_click;
+ bool use_pos_func = ! for_click;
#ifdef HAVE_GTK3
/* Always use position function for Gtk3. Otherwise menus may become
#endif
if (! FRAME_X_P (f))
- abort ();
+ emacs_abort ();
xg_crazy_callback_abort = 1;
menu = xg_create_widget ("popup", first_wv->name, f, first_wv,
LWLIB_ID id = (XINT (XCAR (arg)) << 4 * sizeof (LWLIB_ID)
| XINT (XCDR (arg)));
- BLOCK_INPUT;
+ block_input ();
lw_destroy_all_widgets (id);
- UNBLOCK_INPUT;
+ unblock_input ();
popup_activated_flag = 0;
return Qnil;
menu_item_selection will be set to the selection. */
static void
create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv,
- int x, int y, int for_click, Time timestamp)
+ int x, int y, bool for_click, Time timestamp)
{
int i;
Arg av[2];
Widget menu;
if (! FRAME_X_P (f))
- abort ();
+ emacs_abort ();
#ifdef USE_LUCID
apply_systemfont_to_menu (f, f->output_data.x->widget);
}
Lisp_Object
-xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
+xmenu_show (FRAME_PTR f, int x, int y, bool for_click, bool keymaps,
Lisp_Object title, const char **error_name, Time timestamp)
{
int i;
widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0;
widget_value **submenu_stack
- = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
+ = alloca (menu_items_used * sizeof *submenu_stack);
Lisp_Object *subprefix_stack
- = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object));
+ = alloca (menu_items_used * sizeof *subprefix_stack);
int submenu_depth = 0;
int first_pane;
ptrdiff_t specpdl_count = SPECPDL_INDEX ();
if (! FRAME_X_P (f))
- abort ();
+ emacs_abort ();
*error_name = NULL;
save_wv->next = wv;
else
first_wv->contents = wv;
- wv->name = pane_string;
+ wv->name = (char *) pane_string;
if (keymaps && !NILP (prefix))
wv->name++;
wv->value = 0;
/* If this item has a null value,
make the call_data null so that it won't display a box
when the mouse is on it. */
- wv->call_data
- = (!NILP (def) ? (void *) &AREF (menu_items, i) : 0);
+ wv->call_data = !NILP (def) ? aref_addr (menu_items, i) : 0;
wv->enabled = !NILP (enable);
if (NILP (type))
else if (EQ (type, QCradio))
wv->button_type = BUTTON_TYPE_RADIO;
else
- abort ();
+ emacs_abort ();
wv->selected = !NILP (selected);
{
entry
= AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
- if (menu_item_selection == &AREF (menu_items, i))
+ if (menu_item_selection == aref_addr (menu_items, i))
{
- if (keymaps != 0)
+ if (keymaps)
{
int j;
GtkWidget *menu;
if (! FRAME_X_P (f))
- abort ();
+ emacs_abort ();
menu = xg_create_widget ("dialog", first_wv->name, f, first_wv,
G_CALLBACK (dialog_selection_callback),
if ((intptr_t) client_data != -1)
menu_item_selection = (Lisp_Object *) client_data;
- BLOCK_INPUT;
+ block_input ();
lw_destroy_all_widgets (id);
- UNBLOCK_INPUT;
+ unblock_input ();
popup_activated_flag = 0;
}
LWLIB_ID dialog_id;
if (!FRAME_X_P (f))
- abort ();
+ emacs_abort ();
dialog_id = widget_id_tick++;
#ifdef USE_LUCID
static Lisp_Object
xdialog_show (FRAME_PTR f,
- int keymaps,
+ bool keymaps,
Lisp_Object title,
Lisp_Object header,
const char **error_name)
ptrdiff_t specpdl_count = SPECPDL_INDEX ();
if (! FRAME_X_P (f))
- abort ();
+ emacs_abort ();
*error_name = NULL;
pane_string = (NILP (pane_name)
? "" : SSDATA (pane_name));
prev_wv = xmalloc_widget_value ();
- prev_wv->value = pane_string;
+ prev_wv->value = (char *) pane_string;
if (keymaps && !NILP (prefix))
prev_wv->name++;
prev_wv->enabled = 1;
if (!NILP (descrip))
wv->key = SSDATA (descrip);
wv->value = SSDATA (item_name);
- wv->call_data = (void *) &AREF (menu_items, i);
+ wv->call_data = aref_addr (menu_items, i);
wv->enabled = !NILP (enable);
wv->help = Qnil;
prev_wv = wv;
{
entry
= AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
- if (menu_item_selection == &AREF (menu_items, i))
+ if (menu_item_selection == aref_addr (menu_items, i))
{
if (keymaps != 0)
{
FRAME_PTR f = p1->pointer;
XMenu *menu = p2->pointer;
- BLOCK_INPUT;
+ block_input ();
#ifndef MSDOS
XUngrabPointer (FRAME_X_DISPLAY (f), CurrentTime);
XUngrabKeyboard (FRAME_X_DISPLAY (f), CurrentTime);
#endif /* HAVE_X_WINDOWS */
- UNBLOCK_INPUT;
+ unblock_input ();
return Qnil;
}
Lisp_Object
-xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
+xmenu_show (FRAME_PTR f, int x, int y, bool for_click, bool keymaps,
Lisp_Object title, const char **error_name, Time timestamp)
{
Window root;
ptrdiff_t specpdl_count = SPECPDL_INDEX ();
if (! FRAME_X_P (f) && ! FRAME_MSDOS_P (f))
- abort ();
+ emacs_abort ();
*error_name = 0;
if (menu_items_n_panes == 0)
{
/* if alloca is fast, use that to make the space,
to reduce gc needs. */
- item_data = (char *) alloca (maxwidth + SBYTES (descrip) + 1);
+ item_data = alloca (maxwidth + SBYTES (descrip) + 1);
memcpy (item_data, SSDATA (item_name), SBYTES (item_name));
for (j = SCHARS (item_name); j < maxwidth; j++)
item_data[j] = ' ';
{
entry
= AREF (menu_items, i + MENU_ITEMS_ITEM_VALUE);
- if (keymaps != 0)
+ if (keymaps)
{
entry = Fcons (entry, Qnil);
if (!NILP (pane_prefix))
/* Detect if a dialog or menu has been posted. MSDOS has its own
implementation on msdos.c. */
-int
+int ATTRIBUTE_CONST
popup_activated (void)
{
return popup_activated_flag;