comparison src/xmenu.c @ 109126:aec1143e8d85

Convert (most) functions in src to standard C. * src/alloc.c: Convert function definitions to standard C. * src/atimer.c: * src/bidi.c: * src/bytecode.c: * src/callint.c: * src/callproc.c: * src/casefiddle.c: * src/casetab.c: * src/category.c: * src/ccl.c: * src/character.c: * src/charset.c: * src/chartab.c: * src/cmds.c: * src/coding.c: * src/composite.c: * src/data.c: * src/dbusbind.c: * src/dired.c: * src/dispnew.c: * src/doc.c: * src/doprnt.c: * src/ecrt0.c: * src/editfns.c: * src/fileio.c: * src/filelock.c: * src/filemode.c: * src/fns.c: * src/font.c: * src/fontset.c: * src/frame.c: * src/fringe.c: * src/ftfont.c: * src/ftxfont.c: * src/gtkutil.c: * src/indent.c: * src/insdel.c: * src/intervals.c: * src/keymap.c: * src/lread.c: * src/macros.c: * src/marker.c: * src/md5.c: * src/menu.c: * src/minibuf.c: * src/prefix-args.c: * src/print.c: * src/ralloc.c: * src/regex.c: * src/region-cache.c: * src/scroll.c: * src/search.c: * src/sound.c: * src/strftime.c: * src/syntax.c: * src/sysdep.c: * src/termcap.c: * src/terminal.c: * src/terminfo.c: * src/textprop.c: * src/tparam.c: * src/undo.c: * src/unexelf.c: * src/window.c: * src/xfaces.c: * src/xfns.c: * src/xfont.c: * src/xftfont.c: * src/xgselect.c: * src/xmenu.c: * src/xrdb.c: * src/xselect.c: * src/xsettings.c: * src/xsmfns.c: * src/xterm.c: Likewise.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sun, 04 Jul 2010 00:50:25 -0700
parents 2bc9a0c04c87
children 750db9f3e6d8
comparison
equal deleted inserted replaced
109125:12b02558bf51 109126:aec1143e8d85
194 be used for X, as it returns window relative coordinates 194 be used for X, as it returns window relative coordinates
195 for the window where the mouse is in. This could be the menu bar, 195 for the window where the mouse is in. This could be the menu bar,
196 the scroll bar or the edit window. Fx_popup_menu needs to be 196 the scroll bar or the edit window. Fx_popup_menu needs to be
197 sure it is the edit window. */ 197 sure it is the edit window. */
198 void 198 void
199 mouse_position_for_popup (f, x, y) 199 mouse_position_for_popup (FRAME_PTR f, int *x, int *y)
200 FRAME_PTR f;
201 int *x;
202 int *y;
203 { 200 {
204 Window root, dummy_window; 201 Window root, dummy_window;
205 int dummy; 202 int dummy;
206 203
207 if (! FRAME_X_P (f)) 204 if (! FRAME_X_P (f))
389 #ifndef MSDOS 386 #ifndef MSDOS
390 387
391 /* Set menu_items_inuse so no other popup menu or dialog is created. */ 388 /* Set menu_items_inuse so no other popup menu or dialog is created. */
392 389
393 void 390 void
394 x_menu_set_in_use (in_use) 391 x_menu_set_in_use (int in_use)
395 int in_use;
396 { 392 {
397 menu_items_inuse = in_use ? Qt : Qnil; 393 menu_items_inuse = in_use ? Qt : Qnil;
398 popup_activated_flag = in_use; 394 popup_activated_flag = in_use;
399 #ifdef USE_X_TOOLKIT 395 #ifdef USE_X_TOOLKIT
400 if (popup_activated_flag) 396 if (popup_activated_flag)
636 632
637 /* Loop util popup_activated_flag is set to zero in a callback. 633 /* Loop util popup_activated_flag is set to zero in a callback.
638 Used for popup menus and dialogs. */ 634 Used for popup menus and dialogs. */
639 635
640 static void 636 static void
641 popup_widget_loop (do_timers, widget) 637 popup_widget_loop (int do_timers, GtkWidget *widget)
642 int do_timers;
643 GtkWidget *widget;
644 { 638 {
645 ++popup_activated_flag; 639 ++popup_activated_flag;
646 640
647 /* Process events in the Gtk event loop until done. */ 641 /* Process events in the Gtk event loop until done. */
648 while (popup_activated_flag) 642 while (popup_activated_flag)
666 The reason for saving the button event until here, instead of 660 The reason for saving the button event until here, instead of
667 passing it to the toolkit right away, is that we can safely 661 passing it to the toolkit right away, is that we can safely
668 execute Lisp code. */ 662 execute Lisp code. */
669 663
670 void 664 void
671 x_activate_menubar (f) 665 x_activate_menubar (FRAME_PTR f)
672 FRAME_PTR f;
673 { 666 {
674 if (! FRAME_X_P (f)) 667 if (! FRAME_X_P (f))
675 abort (); 668 abort ();
676 669
677 if (!f->output_data.x->saved_menu_event->type) 670 if (!f->output_data.x->saved_menu_event->type)
722 /* This callback is invoked when a dialog or menu is finished being 715 /* This callback is invoked when a dialog or menu is finished being
723 used and has been unposted. */ 716 used and has been unposted. */
724 717
725 #ifdef USE_GTK 718 #ifdef USE_GTK
726 static void 719 static void
727 popup_deactivate_callback (widget, client_data) 720 popup_deactivate_callback (GtkWidget *widget, gpointer client_data)
728 GtkWidget *widget;
729 gpointer client_data;
730 { 721 {
731 popup_activated_flag = 0; 722 popup_activated_flag = 0;
732 } 723 }
733 #else 724 #else
734 static void 725 static void
744 735
745 /* Function that finds the frame for WIDGET and shows the HELP text 736 /* Function that finds the frame for WIDGET and shows the HELP text
746 for that widget. 737 for that widget.
747 F is the frame if known, or NULL if not known. */ 738 F is the frame if known, or NULL if not known. */
748 static void 739 static void
749 show_help_event (f, widget, help) 740 show_help_event (FRAME_PTR f, xt_or_gtk_widget widget, Lisp_Object help)
750 FRAME_PTR f;
751 xt_or_gtk_widget widget;
752 Lisp_Object help;
753 { 741 {
754 Lisp_Object frame; 742 Lisp_Object frame;
755 743
756 if (f) 744 if (f)
757 { 745 {
785 the data structure for the menu item, or null in case of 773 the data structure for the menu item, or null in case of
786 unhighlighting. */ 774 unhighlighting. */
787 775
788 #ifdef USE_GTK 776 #ifdef USE_GTK
789 void 777 void
790 menu_highlight_callback (widget, call_data) 778 menu_highlight_callback (GtkWidget *widget, gpointer call_data)
791 GtkWidget *widget;
792 gpointer call_data;
793 { 779 {
794 xg_menu_item_cb_data *cb_data; 780 xg_menu_item_cb_data *cb_data;
795 Lisp_Object help; 781 Lisp_Object help;
796 782
797 cb_data = (xg_menu_item_cb_data*) g_object_get_data (G_OBJECT (widget), 783 cb_data = (xg_menu_item_cb_data*) g_object_get_data (G_OBJECT (widget),
837 /* This callback is called from the menu bar pulldown menu 823 /* This callback is called from the menu bar pulldown menu
838 when the user makes a selection. 824 when the user makes a selection.
839 Figure out what the user chose 825 Figure out what the user chose
840 and put the appropriate events into the keyboard buffer. */ 826 and put the appropriate events into the keyboard buffer. */
841 static void 827 static void
842 menubar_selection_callback (widget, client_data) 828 menubar_selection_callback (GtkWidget *widget, gpointer client_data)
843 GtkWidget *widget;
844 gpointer client_data;
845 { 829 {
846 xg_menu_item_cb_data *cb_data = (xg_menu_item_cb_data*) client_data; 830 xg_menu_item_cb_data *cb_data = (xg_menu_item_cb_data*) client_data;
847 831
848 if (xg_crazy_callback_abort) 832 if (xg_crazy_callback_abort)
849 return; 833 return;
901 885
902 /* Recompute all the widgets of frame F, when the menu bar has been 886 /* Recompute all the widgets of frame F, when the menu bar has been
903 changed. Value is non-zero if widgets were updated. */ 887 changed. Value is non-zero if widgets were updated. */
904 888
905 static int 889 static int
906 update_frame_menubar (f) 890 update_frame_menubar (FRAME_PTR f)
907 FRAME_PTR f;
908 { 891 {
909 #ifdef USE_GTK 892 #ifdef USE_GTK
910 return xg_update_frame_menubar (f); 893 return xg_update_frame_menubar (f);
911 #else 894 #else
912 struct x_output *x; 895 struct x_output *x;
993 /* Set the contents of the menubar widgets of frame F. 976 /* Set the contents of the menubar widgets of frame F.
994 The argument FIRST_TIME is currently ignored; 977 The argument FIRST_TIME is currently ignored;
995 it is set the first time this is called, from initialize_frame_menubar. */ 978 it is set the first time this is called, from initialize_frame_menubar. */
996 979
997 void 980 void
998 set_frame_menubar (f, first_time, deep_p) 981 set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
999 FRAME_PTR f;
1000 int first_time;
1001 int deep_p;
1002 { 982 {
1003 xt_or_gtk_widget menubar_widget; 983 xt_or_gtk_widget menubar_widget;
1004 #ifdef USE_X_TOOLKIT 984 #ifdef USE_X_TOOLKIT
1005 LWLIB_ID id; 985 LWLIB_ID id;
1006 #endif 986 #endif
1345 before it is mapped, so that the window is mapped with the menubar already 1325 before it is mapped, so that the window is mapped with the menubar already
1346 there instead of us tacking it on later and thrashing the window after it 1326 there instead of us tacking it on later and thrashing the window after it
1347 is visible. */ 1327 is visible. */
1348 1328
1349 void 1329 void
1350 initialize_frame_menubar (f) 1330 initialize_frame_menubar (FRAME_PTR f)
1351 FRAME_PTR f;
1352 { 1331 {
1353 /* This function is called before the first chance to redisplay 1332 /* This function is called before the first chance to redisplay
1354 the frame. It has to be, so the frame will have the right size. */ 1333 the frame. It has to be, so the frame will have the right size. */
1355 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); 1334 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
1356 set_frame_menubar (f, 1, 1); 1335 set_frame_menubar (f, 1, 1);
1456 Here it points to a struct next_popup_x_y where the coordinates 1435 Here it points to a struct next_popup_x_y where the coordinates
1457 to store in *X and *Y are as well as the frame for the popup. 1436 to store in *X and *Y are as well as the frame for the popup.
1458 1437
1459 Here only X and Y are used. */ 1438 Here only X and Y are used. */
1460 static void 1439 static void
1461 menu_position_func (menu, x, y, push_in, user_data) 1440 menu_position_func (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
1462 GtkMenu *menu;
1463 gint *x;
1464 gint *y;
1465 gboolean *push_in;
1466 gpointer user_data;
1467 { 1441 {
1468 struct next_popup_x_y* data = (struct next_popup_x_y*)user_data; 1442 struct next_popup_x_y* data = (struct next_popup_x_y*)user_data;
1469 GtkRequisition req; 1443 GtkRequisition req;
1470 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (data->f); 1444 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (data->f);
1471 int disp_width = x_display_pixel_width (dpyinfo); 1445 int disp_width = x_display_pixel_width (dpyinfo);
1482 if (data->y + req.height > disp_height) 1456 if (data->y + req.height > disp_height)
1483 *y -= data->y + req.height - disp_height; 1457 *y -= data->y + req.height - disp_height;
1484 } 1458 }
1485 1459
1486 static void 1460 static void
1487 popup_selection_callback (widget, client_data) 1461 popup_selection_callback (GtkWidget *widget, gpointer client_data)
1488 GtkWidget *widget;
1489 gpointer client_data;
1490 { 1462 {
1491 xg_menu_item_cb_data *cb_data = (xg_menu_item_cb_data*) client_data; 1463 xg_menu_item_cb_data *cb_data = (xg_menu_item_cb_data*) client_data;
1492 1464
1493 if (xg_crazy_callback_abort) return; 1465 if (xg_crazy_callback_abort) return;
1494 if (cb_data) menu_item_selection = (Lisp_Object *) cb_data->call_data; 1466 if (cb_data) menu_item_selection = (Lisp_Object *) cb_data->call_data;
1495 } 1467 }
1496 1468
1497 static Lisp_Object 1469 static Lisp_Object
1498 pop_down_menu (arg) 1470 pop_down_menu (Lisp_Object arg)
1499 Lisp_Object arg;
1500 { 1471 {
1501 struct Lisp_Save_Value *p = XSAVE_VALUE (arg); 1472 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
1502 1473
1503 popup_activated_flag = 0; 1474 popup_activated_flag = 0;
1504 BLOCK_INPUT; 1475 BLOCK_INPUT;
1509 1480
1510 /* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the 1481 /* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop until the
1511 menu pops down. 1482 menu pops down.
1512 menu_item_selection will be set to the selection. */ 1483 menu_item_selection will be set to the selection. */
1513 static void 1484 static void
1514 create_and_show_popup_menu (f, first_wv, x, y, for_click, timestamp) 1485 create_and_show_popup_menu (FRAME_PTR f, widget_value *first_wv, int x, int y, int for_click, EMACS_UINT timestamp)
1515 FRAME_PTR f;
1516 widget_value *first_wv;
1517 int x;
1518 int y;
1519 int for_click;
1520 EMACS_UINT timestamp;
1521 { 1486 {
1522 int i; 1487 int i;
1523 GtkWidget *menu; 1488 GtkWidget *menu;
1524 GtkMenuPositionFunc pos_func = 0; /* Pop up at pointer. */ 1489 GtkMenuPositionFunc pos_func = 0; /* Pop up at pointer. */
1525 struct next_popup_x_y popup_x_y; 1490 struct next_popup_x_y popup_x_y;
1975 return Qnil; 1940 return Qnil;
1976 } 1941 }
1977 1942
1978 #ifdef USE_GTK 1943 #ifdef USE_GTK
1979 static void 1944 static void
1980 dialog_selection_callback (widget, client_data) 1945 dialog_selection_callback (GtkWidget *widget, gpointer client_data)
1981 GtkWidget *widget;
1982 gpointer client_data;
1983 { 1946 {
1984 /* The EMACS_INT cast avoids a warning. There's no problem 1947 /* The EMACS_INT cast avoids a warning. There's no problem
1985 as long as pointers have enough bits to hold small integers. */ 1948 as long as pointers have enough bits to hold small integers. */
1986 if ((int) (EMACS_INT) client_data != -1) 1949 if ((int) (EMACS_INT) client_data != -1)
1987 menu_item_selection = (Lisp_Object *) client_data; 1950 menu_item_selection = (Lisp_Object *) client_data;
1991 1954
1992 /* Pop up the dialog for frame F defined by FIRST_WV and loop until the 1955 /* Pop up the dialog for frame F defined by FIRST_WV and loop until the
1993 dialog pops down. 1956 dialog pops down.
1994 menu_item_selection will be set to the selection. */ 1957 menu_item_selection will be set to the selection. */
1995 static void 1958 static void
1996 create_and_show_dialog (f, first_wv) 1959 create_and_show_dialog (FRAME_PTR f, widget_value *first_wv)
1997 FRAME_PTR f;
1998 widget_value *first_wv;
1999 { 1960 {
2000 GtkWidget *menu; 1961 GtkWidget *menu;
2001 1962
2002 if (! FRAME_X_P (f)) 1963 if (! FRAME_X_P (f))
2003 abort (); 1964 abort ();
2090 static char * button_names [] = { 2051 static char * button_names [] = {
2091 "button1", "button2", "button3", "button4", "button5", 2052 "button1", "button2", "button3", "button4", "button5",
2092 "button6", "button7", "button8", "button9", "button10" }; 2053 "button6", "button7", "button8", "button9", "button10" };
2093 2054
2094 static Lisp_Object 2055 static Lisp_Object
2095 xdialog_show (f, keymaps, title, header, error_name) 2056 xdialog_show (FRAME_PTR f, int keymaps, Lisp_Object title, Lisp_Object header, char **error_name)
2096 FRAME_PTR f;
2097 int keymaps;
2098 Lisp_Object title, header;
2099 char **error_name;
2100 { 2057 {
2101 int i, nb_buttons=0; 2058 int i, nb_buttons=0;
2102 char dialog_name[6]; 2059 char dialog_name[6];
2103 2060
2104 widget_value *wv, *first_wv = 0, *prev_wv = 0; 2061 widget_value *wv, *first_wv = 0, *prev_wv = 0;
2656 #endif /* HAVE_MENUS */ 2613 #endif /* HAVE_MENUS */
2657 2614
2658 /* Detect if a dialog or menu has been posted. */ 2615 /* Detect if a dialog or menu has been posted. */
2659 2616
2660 int 2617 int
2661 popup_activated () 2618 popup_activated (void)
2662 { 2619 {
2663 return popup_activated_flag; 2620 return popup_activated_flag;
2664 } 2621 }
2665 2622
2666 /* The following is used by delayed window autoselection. */ 2623 /* The following is used by delayed window autoselection. */
2675 return Qnil; 2632 return Qnil;
2676 #endif /* HAVE_MENUS */ 2633 #endif /* HAVE_MENUS */
2677 } 2634 }
2678 2635
2679 void 2636 void
2680 syms_of_xmenu () 2637 syms_of_xmenu (void)
2681 { 2638 {
2682 Qdebug_on_next_call = intern_c_string ("debug-on-next-call"); 2639 Qdebug_on_next_call = intern_c_string ("debug-on-next-call");
2683 staticpro (&Qdebug_on_next_call); 2640 staticpro (&Qdebug_on_next_call);
2684 2641
2685 #ifdef USE_X_TOOLKIT 2642 #ifdef USE_X_TOOLKIT