Mercurial > hg > xemacs-beta
comparison src/menubar-x.c @ 398:74fd4e045ea6 r21-2-29
Import from CVS: tag r21-2-29
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:13:30 +0200 |
parents | bbff43aa5eb7 |
children | 2f8bb876ab1d |
comparison
equal
deleted
inserted
replaced
397:f4aeb21a5bad | 398:74fd4e045ea6 |
---|---|
92 /* This function cannot GC. | 92 /* This function cannot GC. |
93 It is only called from menu_item_descriptor_to_widget_value, which | 93 It is only called from menu_item_descriptor_to_widget_value, which |
94 prohibits GC. */ | 94 prohibits GC. */ |
95 /* !!#### This function has not been Mule-ized */ | 95 /* !!#### This function has not been Mule-ized */ |
96 int menubar_root_p = (menu_type == MENUBAR_TYPE && depth == 0); | 96 int menubar_root_p = (menu_type == MENUBAR_TYPE && depth == 0); |
97 widget_value *wv; | |
98 Lisp_Object wv_closure; | |
99 int count = specpdl_depth (); | 97 int count = specpdl_depth (); |
100 int partition_seen = 0; | 98 int partition_seen = 0; |
101 | 99 widget_value *wv = xmalloc_widget_value (); |
102 wv = xmalloc_widget_value (); | 100 Lisp_Object wv_closure = make_opaque_ptr (wv); |
103 | 101 |
104 wv_closure = make_opaque_ptr (wv); | |
105 record_unwind_protect (widget_value_unwind, wv_closure); | 102 record_unwind_protect (widget_value_unwind, wv_closure); |
106 | 103 |
107 if (STRINGP (desc)) | 104 if (STRINGP (desc)) |
108 { | 105 { |
109 char *string_chars = (char *) XSTRING_DATA (desc); | 106 char *string_chars = (char *) XSTRING_DATA (desc); |
118 { | 115 { |
119 wv->value = menu_separator_style (string_chars); | 116 wv->value = menu_separator_style (string_chars); |
120 } | 117 } |
121 else | 118 else |
122 { | 119 { |
123 wv->name = string_chars; | 120 wv->name = xstrdup (string_chars); |
124 wv->enabled = 1; | 121 wv->enabled = 1; |
125 /* dverna Dec. 98: command_builder_operate_menu_accelerator will | 122 /* dverna Dec. 98: command_builder_operate_menu_accelerator will |
126 manipulate the accel as a Lisp_Object if the widget has a name. | 123 manipulate the accel as a Lisp_Object if the widget has a name. |
127 Since simple labels have a name, but no accel, we *must* set it | 124 Since simple labels have a name, but no accel, we *must* set it |
128 to nil */ | 125 to nil */ |
129 wv->accel = LISP_TO_VOID (Qnil); | 126 wv->accel = LISP_TO_VOID (Qnil); |
130 } | 127 } |
131 } | 128 } |
132 else if (VECTORP (desc)) | 129 else if (VECTORP (desc)) |
133 { | 130 { |
134 if (!button_item_to_widget_value (desc, wv, 1, | 131 Lisp_Object gui_item = gui_parse_item_keywords (desc); |
132 if (!button_item_to_widget_value (gui_item, wv, 1, | |
135 (menu_type == MENUBAR_TYPE | 133 (menu_type == MENUBAR_TYPE |
136 && depth <= 1))) | 134 && depth <= 1))) |
137 { | 135 { |
138 /* :included form was nil */ | 136 /* :included form was nil */ |
139 wv = NULL; | 137 wv = NULL; |
154 int included_spec = 0; | 152 int included_spec = 0; |
155 int active_spec = 0; | 153 int active_spec = 0; |
156 wv->type = CASCADE_TYPE; | 154 wv->type = CASCADE_TYPE; |
157 wv->enabled = 1; | 155 wv->enabled = 1; |
158 wv->name = (char *) XSTRING_DATA (LISP_GETTEXT (XCAR (desc))); | 156 wv->name = (char *) XSTRING_DATA (LISP_GETTEXT (XCAR (desc))); |
159 | 157 wv->name = xstrdup (wv->name); |
160 accel = menu_name_to_accelerator (wv->name); | 158 |
159 accel = gui_name_accelerator (LISP_GETTEXT (XCAR (desc))); | |
161 wv->accel = LISP_TO_VOID (accel); | 160 wv->accel = LISP_TO_VOID (accel); |
162 | 161 |
163 desc = Fcdr (desc); | 162 desc = Fcdr (desc); |
164 | 163 |
165 while (key = Fcar (desc), KEYWORDP (key)) | 164 while (key = Fcar (desc), KEYWORDP (key)) |
223 widget_value *incr_wv = xmalloc_widget_value (); | 222 widget_value *incr_wv = xmalloc_widget_value (); |
224 wv->contents = incr_wv; | 223 wv->contents = incr_wv; |
225 incr_wv->type = INCREMENTAL_TYPE; | 224 incr_wv->type = INCREMENTAL_TYPE; |
226 incr_wv->enabled = 1; | 225 incr_wv->enabled = 1; |
227 incr_wv->name = wv->name; | 226 incr_wv->name = wv->name; |
227 incr_wv->name = xstrdup (wv->name); | |
228 /* This is automatically GC protected through | 228 /* This is automatically GC protected through |
229 the call to lw_map_widget_values(); no need | 229 the call to lw_map_widget_values(); no need |
230 to worry. */ | 230 to worry. */ |
231 incr_wv->call_data = LISP_TO_VOID (incremental_data); | 231 incr_wv->call_data = LISP_TO_VOID (incremental_data); |
232 goto menu_item_done; | 232 goto menu_item_done; |
239 the menu: a label, and two separators (to get a double | 239 the menu: a label, and two separators (to get a double |
240 line). */ | 240 line). */ |
241 widget_value *title_wv = xmalloc_widget_value (); | 241 widget_value *title_wv = xmalloc_widget_value (); |
242 widget_value *sep_wv = xmalloc_widget_value (); | 242 widget_value *sep_wv = xmalloc_widget_value (); |
243 title_wv->type = TEXT_TYPE; | 243 title_wv->type = TEXT_TYPE; |
244 title_wv->name = wv->name; | 244 title_wv->name = xstrdup (wv->name); |
245 title_wv->enabled = 1; | 245 title_wv->enabled = 1; |
246 title_wv->next = sep_wv; | 246 title_wv->next = sep_wv; |
247 sep_wv->type = SEPARATOR_TYPE; | 247 sep_wv->type = SEPARATOR_TYPE; |
248 sep_wv->value = menu_separator_style ("=="); | 248 sep_wv->value = menu_separator_style ("=="); |
249 sep_wv->next = 0; | 249 sep_wv->next = 0; |
255 if (deep_p && !wv->enabled && !NILP (desc)) | 255 if (deep_p && !wv->enabled && !NILP (desc)) |
256 { | 256 { |
257 widget_value *dummy; | 257 widget_value *dummy; |
258 /* Add a fake entry so the menus show up */ | 258 /* Add a fake entry so the menus show up */ |
259 wv->contents = dummy = xmalloc_widget_value (); | 259 wv->contents = dummy = xmalloc_widget_value (); |
260 dummy->name = "(inactive)"; | 260 dummy->name = xstrdup ("(inactive)"); |
261 dummy->accel = LISP_TO_VOID (Qnil); | 261 dummy->accel = LISP_TO_VOID (Qnil); |
262 dummy->enabled = 0; | 262 dummy->enabled = 0; |
263 dummy->selected = 0; | 263 dummy->selected = 0; |
264 dummy->value = NULL; | 264 dummy->value = NULL; |
265 dummy->type = BUTTON_TYPE; | 265 dummy->type = BUTTON_TYPE; |
270 } | 270 } |
271 | 271 |
272 } | 272 } |
273 else if (menubar_root_p) | 273 else if (menubar_root_p) |
274 { | 274 { |
275 wv->name = (char *) "menubar"; | 275 wv->name = xstrdup ("menubar"); |
276 wv->type = CASCADE_TYPE; /* Well, nothing else seems to fit and | 276 wv->type = CASCADE_TYPE; /* Well, nothing else seems to fit and |
277 this is ignored anyway... */ | 277 this is ignored anyway... */ |
278 } | 278 } |
279 else | 279 else |
280 { | 280 { |
358 int in_menu_callback; | 358 int in_menu_callback; |
359 | 359 |
360 static Lisp_Object | 360 static Lisp_Object |
361 restore_in_menu_callback (Lisp_Object val) | 361 restore_in_menu_callback (Lisp_Object val) |
362 { | 362 { |
363 in_menu_callback = XINT(val); | 363 in_menu_callback = XINT (val); |
364 return Qnil; | 364 return Qnil; |
365 } | 365 } |
366 #endif /* LWLIB_MENUBARS_LUCID || LWLIB_MENUBARS_MOTIF */ | 366 #endif /* LWLIB_MENUBARS_LUCID || LWLIB_MENUBARS_MOTIF */ |
367 | 367 |
368 #if 0 | 368 #if 0 |
463 if (!wv) | 463 if (!wv) |
464 { | 464 { |
465 wv = xmalloc_widget_value (); | 465 wv = xmalloc_widget_value (); |
466 wv->type = CASCADE_TYPE; | 466 wv->type = CASCADE_TYPE; |
467 wv->next = NULL; | 467 wv->next = NULL; |
468 wv->accel = LISP_TO_VOID (Qnil); | |
468 wv->contents = xmalloc_widget_value (); | 469 wv->contents = xmalloc_widget_value (); |
469 wv->contents->type = TEXT_TYPE; | 470 wv->contents->type = TEXT_TYPE; |
470 wv->contents->name = (char *) "No menu"; | 471 wv->contents->name = xstrdup ("No menu"); |
471 wv->contents->next = NULL; | 472 wv->contents->next = NULL; |
473 wv->contents->accel = LISP_TO_VOID (Qnil); | |
472 } | 474 } |
473 assert (wv && wv->type == CASCADE_TYPE && wv->contents); | 475 assert (wv && wv->type == CASCADE_TYPE && wv->contents); |
474 replace_widget_value_tree (hack_wv, wv->contents); | 476 replace_widget_value_tree (hack_wv, wv->contents); |
475 free_popup_widget_value_tree (wv); | 477 free_popup_widget_value_tree (wv); |
476 } | 478 } |
507 } | 509 } |
508 | 510 |
509 static widget_value * | 511 static widget_value * |
510 compute_menubar_data (struct frame *f, Lisp_Object menubar, int deep_p) | 512 compute_menubar_data (struct frame *f, Lisp_Object menubar, int deep_p) |
511 { | 513 { |
512 widget_value *data; | |
513 | |
514 if (NILP (menubar)) | 514 if (NILP (menubar)) |
515 data = 0; | 515 return 0; |
516 else | 516 else |
517 { | 517 { |
518 Lisp_Object old_buffer; | 518 widget_value *data; |
519 int count = specpdl_depth (); | 519 int count = specpdl_depth (); |
520 | 520 |
521 old_buffer = Fcurrent_buffer (); | 521 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
522 record_unwind_protect (Fset_buffer, old_buffer); | 522 Fset_buffer (XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer); |
523 Fset_buffer ( XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer); | |
524 data = menu_item_descriptor_to_widget_value (menubar, MENUBAR_TYPE, | 523 data = menu_item_descriptor_to_widget_value (menubar, MENUBAR_TYPE, |
525 deep_p, 0); | 524 deep_p, 0); |
526 Fset_buffer (old_buffer); | |
527 unbind_to (count, Qnil); | 525 unbind_to (count, Qnil); |
528 } | 526 |
529 return data; | 527 return data; |
528 } | |
530 } | 529 } |
531 | 530 |
532 static int | 531 static int |
533 set_frame_menubar (struct frame *f, int deep_p, int first_time_p) | 532 set_frame_menubar (struct frame *f, int deep_p, int first_time_p) |
534 { | 533 { |
535 widget_value *data; | 534 widget_value *data; |
536 Lisp_Object menubar; | 535 Lisp_Object menubar; |
537 int menubar_visible; | 536 int menubar_visible; |
538 long id; | 537 long id; |
539 /* As for the toolbar, the minibuffer does not have its own menubar. */ | 538 /* As with the toolbar, the minibuffer does not have its own menubar. */ |
540 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f)); | 539 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f)); |
541 | 540 |
542 if (! FRAME_X_P (f)) | 541 if (! FRAME_X_P (f)) |
543 return 0; | 542 return 0; |
544 | 543 |
570 abort (); | 569 abort (); |
571 | 570 |
572 if (NILP (FRAME_MENUBAR_DATA (f))) | 571 if (NILP (FRAME_MENUBAR_DATA (f))) |
573 { | 572 { |
574 struct popup_data *mdata = | 573 struct popup_data *mdata = |
575 alloc_lcrecord_type (struct popup_data, lrecord_popup_data); | 574 alloc_lcrecord_type (struct popup_data, &lrecord_popup_data); |
576 | 575 |
577 mdata->id = new_lwlib_id (); | 576 mdata->id = new_lwlib_id (); |
578 mdata->last_menubar_buffer = Qnil; | 577 mdata->last_menubar_buffer = Qnil; |
579 mdata->menubar_contents_up_to_date = 0; | 578 mdata->menubar_contents_up_to_date = 0; |
580 XSETPOPUP_DATA (FRAME_MENUBAR_DATA (f), mdata); | 579 XSETPOPUP_DATA (FRAME_MENUBAR_DATA (f), mdata); |
655 lw_destroy_all_widgets (id); | 654 lw_destroy_all_widgets (id); |
656 } | 655 } |
657 | 656 |
658 | 657 |
659 static void | 658 static void |
660 make_dummy_xbutton_event (XEvent *dummy, | 659 make_dummy_xbutton_event (XEvent *dummy, Widget daddy, Lisp_Event *eev) |
661 Widget daddy, | |
662 struct Lisp_Event *eev) | |
663 /* NULL for eev means query pointer */ | 660 /* NULL for eev means query pointer */ |
664 { | 661 { |
665 XButtonPressedEvent *btn = (XButtonPressedEvent *) dummy; | 662 XButtonPressedEvent *btn = (XButtonPressedEvent *) dummy; |
666 | 663 |
667 btn->type = ButtonPress; | 664 btn->type = ButtonPress; |
670 btn->display = XtDisplay (daddy); | 667 btn->display = XtDisplay (daddy); |
671 btn->window = XtWindow (daddy); | 668 btn->window = XtWindow (daddy); |
672 if (eev) | 669 if (eev) |
673 { | 670 { |
674 Position shellx, shelly, framex, framey; | 671 Position shellx, shelly, framex, framey; |
675 Widget shell = XtParent (daddy); | |
676 Arg al [2]; | 672 Arg al [2]; |
677 btn->time = eev->timestamp; | 673 btn->time = eev->timestamp; |
678 btn->button = eev->event.button.button; | 674 btn->button = eev->event.button.button; |
679 btn->root = RootWindowOfScreen (XtScreen (daddy)); | 675 btn->root = RootWindowOfScreen (XtScreen (daddy)); |
680 btn->subwindow = (Window) NULL; | 676 btn->subwindow = (Window) NULL; |
681 btn->x = eev->event.button.x; | 677 btn->x = eev->event.button.x; |
682 btn->y = eev->event.button.y; | 678 btn->y = eev->event.button.y; |
683 XtSetArg (al [0], XtNx, &shellx); | 679 shellx = shelly = 0; |
684 XtSetArg (al [1], XtNy, &shelly); | 680 #ifndef HAVE_WMCOMMAND |
685 XtGetValues (shell, al, 2); | 681 { |
682 Widget shell = XtParent (daddy); | |
683 | |
684 XtSetArg (al [0], XtNx, &shellx); | |
685 XtSetArg (al [1], XtNy, &shelly); | |
686 XtGetValues (shell, al, 2); | |
687 } | |
688 #endif | |
686 XtSetArg (al [0], XtNx, &framex); | 689 XtSetArg (al [0], XtNx, &framex); |
687 XtSetArg (al [1], XtNy, &framey); | 690 XtSetArg (al [1], XtNy, &framey); |
688 XtGetValues (daddy, al, 2); | 691 XtGetValues (daddy, al, 2); |
689 btn->x_root = shellx + framex + btn->x; | 692 btn->x_root = shellx + framex + btn->x; |
690 btn->y_root = shelly + framey + btn->y; | 693 btn->y_root = shelly + framey + btn->y; |
770 int menu_id; | 773 int menu_id; |
771 struct frame *f = selected_frame (); | 774 struct frame *f = selected_frame (); |
772 widget_value *data; | 775 widget_value *data; |
773 Widget parent; | 776 Widget parent; |
774 Widget menu; | 777 Widget menu; |
775 struct Lisp_Event *eev = NULL; | 778 Lisp_Event *eev = NULL; |
776 XEvent xev; | 779 XEvent xev; |
777 Lisp_Object frame; | 780 Lisp_Object frame; |
778 | 781 |
779 XSETFRAME (frame, f); | 782 XSETFRAME (frame, f); |
780 CHECK_X_FRAME (frame); | 783 CHECK_X_FRAME (frame); |
850 CONSOLE_HAS_METHOD (x, free_frame_menubars); | 853 CONSOLE_HAS_METHOD (x, free_frame_menubars); |
851 CONSOLE_HAS_METHOD (x, popup_menu); | 854 CONSOLE_HAS_METHOD (x, popup_menu); |
852 } | 855 } |
853 | 856 |
854 void | 857 void |
858 reinit_vars_of_menubar_x (void) | |
859 { | |
860 last_popup_menu_selection_callback_id = (LWLIB_ID) -1; | |
861 } | |
862 | |
863 void | |
855 vars_of_menubar_x (void) | 864 vars_of_menubar_x (void) |
856 { | 865 { |
857 last_popup_menu_selection_callback_id = (LWLIB_ID) -1; | 866 reinit_vars_of_menubar_x (); |
858 | 867 |
859 #if defined (LWLIB_MENUBARS_LUCID) | 868 #if defined (LWLIB_MENUBARS_LUCID) |
860 Fprovide (intern ("lucid-menubars")); | 869 Fprovide (intern ("lucid-menubars")); |
861 #elif defined (LWLIB_MENUBARS_MOTIF) | 870 #elif defined (LWLIB_MENUBARS_MOTIF) |
862 Fprovide (intern ("motif-menubars")); | 871 Fprovide (intern ("motif-menubars")); |