Mercurial > hg > xemacs-beta
comparison src/menubar-x.c @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 56c54cf7c5b6 |
children | 6a378aca36af |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
306 unbind_to (count, Qnil); | 306 unbind_to (count, Qnil); |
307 return wv; | 307 return wv; |
308 } | 308 } |
309 | 309 |
310 | 310 |
311 #ifdef LWLIB_MENUBARS_LUCID | |
312 int in_menu_callback; | |
313 | |
314 Lisp_Object | |
315 restore_in_menu_callback(Lisp_Object val) | |
316 { | |
317 in_menu_callback = XINT(val); | |
318 return Qnil; | |
319 } | |
320 #endif /* LWLIB_MENUBARS_LUCID */ | |
321 | |
322 | |
323 /* The order in which callbacks are run is funny to say the least. | 311 /* The order in which callbacks are run is funny to say the least. |
324 It's sometimes tricky to avoid running a callback twice, and to | 312 It's sometimes tricky to avoid running a callback twice, and to |
325 avoid returning prematurely. So, this function returns true | 313 avoid returning prematurely. So, this function returns true |
326 if the menu's callbacks are no longer gc protected. So long | 314 if the menu's callbacks are no longer gc protected. So long |
327 as we unprotect them before allowing other callbacks to run, | 315 as we unprotect them before allowing other callbacks to run, |
346 /* This function can GC */ | 334 /* This function can GC */ |
347 struct gcpro gcpro1; | 335 struct gcpro gcpro1; |
348 struct device *d = get_device_from_display (XtDisplay (widget)); | 336 struct device *d = get_device_from_display (XtDisplay (widget)); |
349 struct frame *f = x_any_window_to_frame (d, XtWindow (widget)); | 337 struct frame *f = x_any_window_to_frame (d, XtWindow (widget)); |
350 Lisp_Object rest = Qnil; | 338 Lisp_Object rest = Qnil; |
351 Lisp_Object frame; | |
352 int any_changes = 0; | 339 int any_changes = 0; |
353 int count; | |
354 | 340 |
355 if (!f) | 341 if (!f) |
356 f = x_any_window_to_frame (d, XtWindow (XtParent (widget))); | 342 f = x_any_window_to_frame (d, XtWindow (XtParent (widget))); |
357 if (!f) | 343 if (!f) |
358 return; | 344 return; |
359 | 345 |
360 /* make sure f is the selected frame */ | |
361 XSETFRAME (frame, f); | |
362 Fselect_frame (frame); | |
363 | |
364 if (client_data) | 346 if (client_data) |
365 { | 347 { |
366 /* this is an incremental menu construction callback */ | 348 /* this is an incremental menu construction callback */ |
367 widget_value *hack_wv = (widget_value *) client_data; | 349 widget_value *hack_wv = (widget_value *) client_data; |
368 Lisp_Object submenu_desc; | 350 Lisp_Object submenu_desc; |
369 widget_value *wv; | 351 widget_value *wv; |
370 | 352 |
371 assert (hack_wv->type == INCREMENTAL_TYPE); | 353 assert (hack_wv->type == INCREMENTAL_TYPE); |
372 VOID_TO_LISP (submenu_desc, hack_wv->call_data); | 354 VOID_TO_LISP (submenu_desc, hack_wv->call_data); |
373 | |
374 /* | |
375 * #### Fix the menu code so this isn't necessary. | |
376 * | |
377 * Protect against reentering the menu code otherwise we will | |
378 * crash later when the code gets confused at the state | |
379 * changes. | |
380 */ | |
381 count = specpdl_depth (); | |
382 record_unwind_protect (restore_in_menu_callback, | |
383 make_int (in_menu_callback)); | |
384 in_menu_callback = 1; | |
385 wv = menu_item_descriptor_to_widget_value (submenu_desc, SUBMENU_TYPE, | 355 wv = menu_item_descriptor_to_widget_value (submenu_desc, SUBMENU_TYPE, |
386 1, 0); | 356 1, 1); |
387 unbind_to (count, Qnil); | |
388 | |
389 if (!wv) | 357 if (!wv) |
390 { | 358 { |
391 wv = xmalloc_widget_value (); | 359 wv = xmalloc_widget_value (); |
392 wv->type = CASCADE_TYPE; | 360 wv->type = CASCADE_TYPE; |
393 wv->next = NULL; | 361 wv->next = NULL; |
463 | 431 |
464 if (NILP (menubar)) | 432 if (NILP (menubar)) |
465 data = 0; | 433 data = 0; |
466 else | 434 else |
467 { | 435 { |
468 Lisp_Object old_buffer; | |
469 int count = specpdl_depth (); | |
470 | |
471 old_buffer = Fcurrent_buffer (); | |
472 record_unwind_protect (Fset_buffer, old_buffer); | |
473 Fset_buffer ( XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer); | |
474 data = menu_item_descriptor_to_widget_value (menubar, MENUBAR_TYPE, | 436 data = menu_item_descriptor_to_widget_value (menubar, MENUBAR_TYPE, |
475 deep_p, 0); | 437 deep_p, 0); |
476 #ifdef ENERGIZE | 438 #ifdef ENERGIZE |
477 if (data) | 439 if (data) |
478 set_panel_button_sensitivity (f, data); | 440 set_panel_button_sensitivity (f, data); |
479 #endif | 441 #endif |
480 Fset_buffer (old_buffer); | |
481 unbind_to (count, Qnil); | |
482 } | 442 } |
483 return data; | 443 return data; |
484 } | 444 } |
485 | 445 |
486 static int | 446 static int |
671 (f->menubar_changed | 631 (f->menubar_changed |
672 || NILP (FRAME_MENUBAR_DATA (f)) | 632 || NILP (FRAME_MENUBAR_DATA (f)) |
673 || (!EQ (XFRAME_MENUBAR_DATA (f)->last_menubar_buffer, | 633 || (!EQ (XFRAME_MENUBAR_DATA (f)->last_menubar_buffer, |
674 XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer))); | 634 XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer))); |
675 | 635 |
676 Boolean menubar_was_visible = XtIsManaged (FRAME_X_MENUBAR_WIDGET (f)); | 636 int menubar_was_visible = XtIsManaged (FRAME_X_MENUBAR_WIDGET (f)); |
677 Boolean menubar_will_be_visible = menubar_was_visible; | 637 int menubar_will_be_visible = menubar_was_visible; |
678 Boolean menubar_visibility_changed; | 638 int menubar_visibility_changed; |
679 Cardinal new_num_top_widgets = 1; /* for the menubar */ | 639 Cardinal new_num_top_widgets = 1; /* for the menubar */ |
680 Widget container = FRAME_X_CONTAINER_WIDGET (f); | 640 Widget container = FRAME_X_CONTAINER_WIDGET (f); |
681 | 641 |
682 #ifdef ENERGIZE | 642 #ifdef ENERGIZE |
683 int *old_sheets = FRAME_X_CURRENT_PSHEETS (f); | 643 int *old_sheets = FRAME_X_CURRENT_PSHEETS (f); |