diff src/xmenu.c @ 83370:5272862a4865

Fix crashes in xdialog_show (and other places) with xterm-mouse-mode. * src/dispextern.h (get_tty_device): Declare. * src/dispnew.c (Fsend_string_to_terminal): Add optional TERMINAL parameter. * src/fns.c (Fy_or_n_p, Fyes_or_no_p): Don't try to open an X dialog on tty terminals. * src/term.c (get_tty_device): Remove static qualifier. * src/xmenu.c (create_and_show_dialog, create_and_show_popup_menu) (free_frame_menubar, mouse_position_for_popup, set_frame_menubar) (update_frame_menubar, x_activate_menubar, xdialog_show, xmenu_show): Abort when given a non-X frame. * src/xmenu.c (Fx_popup_menu, Fx_popup_dialog): Throw an error when run on a non-X frame. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-410
author Karoly Lorentey <lorentey@elte.hu>
date Sun, 11 Sep 2005 03:15:42 +0000
parents 532e0a9335a9
children 14a4eb789b45
line wrap: on
line diff
--- a/src/xmenu.c	Sun Sep 11 03:06:33 2005 +0000
+++ b/src/xmenu.c	Sun Sep 11 03:15:42 2005 +0000
@@ -705,6 +705,9 @@
   Window root, dummy_window;
   int dummy;
 
+  if (! FRAME_X_P (f))
+    abort ();
+
   BLOCK_INPUT;
 
   XQueryPointer (FRAME_X_DISPLAY (f),
@@ -899,6 +902,9 @@
 
       xpos += XINT (x);
       ypos += XINT (y);
+
+      if (! FRAME_X_P (f))
+        error ("Can not put X menu on non-X terminal");
     }
   Vmenu_updating_frame = Qnil;
 #endif /* HAVE_MENUS */
@@ -1085,6 +1091,9 @@
        but I don't want to make one now.  */
     CHECK_WINDOW (window);
 
+  if (! FRAME_X_P (f))
+    error ("Can not put X dialog on non-X terminal");
+
 #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
   /* Display a menu with these alternatives
      in the middle of frame F.  */
@@ -1302,6 +1311,9 @@
 x_activate_menubar (f)
      FRAME_PTR f;
 {
+  if (! FRAME_X_P (f))
+    abort ();
+
   if (!f->output_data.x->saved_menu_event->type)
     return;
 
@@ -1922,9 +1934,14 @@
 #ifdef USE_GTK
   return xg_update_frame_menubar (f);
 #else
-  struct x_output *x = f->output_data.x;
+  struct x_output *x;
   int columns, rows;
 
+  if (! FRAME_X_P (f))
+    abort ();
+
+  x = f->output_data.x;
+
   if (!x->menubar_widget || XtIsManaged (x->menubar_widget))
     return 0;
 
@@ -1970,7 +1987,7 @@
      int first_time;
      int deep_p;
 {
-  xt_or_gtk_widget menubar_widget = f->output_data.x->menubar_widget;
+  xt_or_gtk_widget menubar_widget;
 #ifdef USE_X_TOOLKIT
   LWLIB_ID id;
 #endif
@@ -1980,6 +1997,10 @@
   int *submenu_start, *submenu_end;
   int *submenu_top_level_items, *submenu_n_panes;
 
+  if (! FRAME_X_P (f))
+    abort ();
+
+  menubar_widget = f->output_data.x->menubar_widget;
 
   XSETFRAME (Vmenu_updating_frame, f);
 
@@ -2324,6 +2345,9 @@
 {
   Widget menubar_widget;
 
+  if (! FRAME_X_P (f))
+    abort ();
+
   menubar_widget = f->output_data.x->menubar_widget;
 
   f->output_data.x->menubar_height = 0;
@@ -2476,6 +2500,9 @@
   struct next_popup_x_y popup_x_y;
   int specpdl_count = SPECPDL_INDEX ();
 
+  if (! FRAME_X_P (f))
+    abort ();
+
   xg_crazy_callback_abort = 1;
   menu = xg_create_widget ("popup", first_wv->name, f, first_wv,
                            G_CALLBACK (popup_selection_callback),
@@ -2584,6 +2611,9 @@
   LWLIB_ID menu_id;
   Widget menu;
 
+  if (! FRAME_X_P (f))
+    abort ();
+
   menu_id = widget_id_tick++;
   menu = lw_create_widget ("popup", first_wv->name, menu_id, first_wv,
                            f->output_data.x->widget, 1, 0,
@@ -2659,6 +2689,9 @@
 
   int first_pane;
 
+  if (! FRAME_X_P (f))
+    abort ();
+
   *error = NULL;
 
   if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
@@ -2941,6 +2974,9 @@
 {
   GtkWidget *menu;
 
+  if (! FRAME_X_P (f))
+    abort ();
+
   menu = xg_create_widget ("dialog", first_wv->name, f, first_wv,
                            G_CALLBACK (dialog_selection_callback),
                            G_CALLBACK (popup_deactivate_callback),
@@ -2990,6 +3026,9 @@
 {
   LWLIB_ID dialog_id;
 
+  if (!FRAME_X_P (f))
+    abort();
+
   dialog_id = widget_id_tick++;
   lw_create_widget (first_wv->name, "dialog", dialog_id, first_wv,
                     f->output_data.x->widget, 1, 0,
@@ -3041,6 +3080,9 @@
   /* 1 means we've seen the boundary between left-hand elts and right-hand.  */
   int boundary_seen = 0;
 
+  if (! FRAME_X_P (f))
+    abort ();
+
   *error_name = NULL;
 
   if (menu_items_n_panes > 1)
@@ -3308,6 +3350,9 @@
   unsigned int dummy_uint;
   int specpdl_count = SPECPDL_INDEX ();
 
+  if (! FRAME_X_P (f))
+    abort ();
+
   *error = 0;
   if (menu_items_n_panes == 0)
     return Qnil;