comparison src/menubar-x.c @ 373:6240c7796c7a r21-2b2

Import from CVS: tag r21-2b2
author cvs
date Mon, 13 Aug 2007 11:04:06 +0200
parents cc15677e0335
children d883f39b8495
comparison
equal deleted inserted replaced
372:49e1ed2d7ed8 373:6240c7796c7a
331 in_menu_callback = XINT(val); 331 in_menu_callback = XINT(val);
332 return Qnil; 332 return Qnil;
333 } 333 }
334 #endif /* LWLIB_MENUBARS_LUCID || LWLIB_MENUBARS_MOTIF */ 334 #endif /* LWLIB_MENUBARS_LUCID || LWLIB_MENUBARS_MOTIF */
335 335
336 #if 0
337 /* #### Sort of a hack needed to process Vactivate_menubar_hook
338 correctly wrt buffer-local values. A correct solution would
339 involve adding a callback mechanism to run_hook(). This function
340 is currently unused. */
341 static int
342 my_run_hook (Lisp_Object hooksym, int allow_global_p)
343 {
344 /* This function can GC */
345 Lisp_Object tail;
346 Lisp_Object value = Fsymbol_value (hooksym);
347 int changes = 0;
348
349 if (!NILP (value) && (!CONSP (value) || EQ (XCAR (value), Qlambda)))
350 return !EQ (call0 (value), Qt);
351
352 EXTERNAL_LIST_LOOP (tail, value)
353 {
354 if (allow_global_p && EQ (XCAR (tail), Qt))
355 changes |= my_run_hook (Fdefault_value (hooksym), 0);
356 if (!EQ (call0 (XCAR (tail)), Qt))
357 changes = 1;
358 }
359 return changes;
360 }
361 #endif
362
336 363
337 /* The order in which callbacks are run is funny to say the least. 364 /* The order in which callbacks are run is funny to say the least.
338 It's sometimes tricky to avoid running a callback twice, and to 365 It's sometimes tricky to avoid running a callback twice, and to
339 avoid returning prematurely. So, this function returns true 366 avoid returning prematurely. So, this function returns true
340 if the menu's callbacks are no longer gc protected. So long 367 if the menu's callbacks are no longer gc protected. So long
356 383
357 static void 384 static void
358 pre_activate_callback (Widget widget, LWLIB_ID id, XtPointer client_data) 385 pre_activate_callback (Widget widget, LWLIB_ID id, XtPointer client_data)
359 { 386 {
360 /* This function can GC */ 387 /* This function can GC */
361 struct gcpro gcpro1;
362 struct device *d = get_device_from_display (XtDisplay (widget)); 388 struct device *d = get_device_from_display (XtDisplay (widget));
363 struct frame *f = x_any_window_to_frame (d, XtWindow (widget)); 389 struct frame *f = x_any_window_to_frame (d, XtWindow (widget));
364 Lisp_Object rest = Qnil;
365 Lisp_Object frame; 390 Lisp_Object frame;
366 int any_changes = 0;
367 int count; 391 int count;
368 392
369 /* set in lwlib to the time stamp associated with the most recent menu 393 /* set in lwlib to the time stamp associated with the most recent menu
370 operation */ 394 operation */
371 extern Time x_focus_timestamp_really_sucks_fix_me_better; 395 extern Time x_focus_timestamp_really_sucks_fix_me_better;
416 } 440 }
417 assert (wv && wv->type == CASCADE_TYPE && wv->contents); 441 assert (wv && wv->type == CASCADE_TYPE && wv->contents);
418 replace_widget_value_tree (hack_wv, wv->contents); 442 replace_widget_value_tree (hack_wv, wv->contents);
419 free_popup_widget_value_tree (wv); 443 free_popup_widget_value_tree (wv);
420 } 444 }
445 else if (!POPUP_DATAP (FRAME_MENUBAR_DATA (f)))
446 return;
421 else 447 else
422 { 448 {
423 if (!POPUP_DATAP (FRAME_MENUBAR_DATA (f))) 449 #if 0 /* Unused, see comment below. */
424 return; 450 int any_changes;
451
425 /* #### - this menubar update mechanism is expensively anti-social and 452 /* #### - this menubar update mechanism is expensively anti-social and
426 the activate-menubar-hook is now mostly obsolete. */ 453 the activate-menubar-hook is now mostly obsolete. */
427 /* make the activate-menubar-hook be a list of functions, not a single 454 any_changes = my_run_hook (Qactivate_menubar_hook, 1);
428 function, just to simplify things. */ 455
429 if (!NILP (Vactivate_menubar_hook) &&
430 (!CONSP (Vactivate_menubar_hook) ||
431 EQ (XCAR (Vactivate_menubar_hook), Qlambda)))
432 Vactivate_menubar_hook = Fcons (Vactivate_menubar_hook, Qnil);
433
434 GCPRO1 (rest);
435 for (rest = Vactivate_menubar_hook; !NILP (rest); rest = Fcdr (rest))
436 if (!EQ (call0 (XCAR (rest)), Qt))
437 any_changes = 1;
438 #if 0
439 /* #### - It is necessary to *ALWAYS* call set_frame_menubar() now that 456 /* #### - It is necessary to *ALWAYS* call set_frame_menubar() now that
440 incremental menus are implemented. If a subtree of a menu has been 457 incremental menus are implemented. If a subtree of a menu has been
441 updated incrementally (a destructive operation), then that subtree 458 updated incrementally (a destructive operation), then that subtree
442 must somehow be wiped. 459 must somehow be wiped.
443 460
444 It is difficult to undo the destructive operation in lwlib because 461 It is difficult to undo the destructive operation in lwlib because
445 a pointer back to lisp data needs to be hidden away somewhere. So 462 a pointer back to lisp data needs to be hidden away somewhere. So
446 that an INCREMENTAL_TYPE widget_value can be recreated... Hmmmmm. */ 463 that an INCREMENTAL_TYPE widget_value can be recreated... Hmmmmm. */
447 if (any_changes || 464 if (any_changes ||
448 !XFRAME_MENUBAR_DATA (f)->menubar_contents_up_to_date) 465 !XFRAME_MENUBAR_DATA (f)->menubar_contents_up_to_date)
466 set_frame_menubar (f, 1, 0);
467 #else
468 run_hook (Qactivate_menubar_hook);
469 set_frame_menubar (f, 1, 0);
449 #endif 470 #endif
450 set_frame_menubar (f, 1, 0);
451 DEVICE_X_MOUSE_TIMESTAMP (XDEVICE (FRAME_DEVICE (f))) = 471 DEVICE_X_MOUSE_TIMESTAMP (XDEVICE (FRAME_DEVICE (f))) =
452 DEVICE_X_GLOBAL_MOUSE_TIMESTAMP (XDEVICE (FRAME_DEVICE (f))) = 472 DEVICE_X_GLOBAL_MOUSE_TIMESTAMP (XDEVICE (FRAME_DEVICE (f))) =
453 x_focus_timestamp_really_sucks_fix_me_better; 473 x_focus_timestamp_really_sucks_fix_me_better;
454 UNGCPRO;
455 } 474 }
456 } 475 }
457 476
458 static widget_value * 477 static widget_value *
459 compute_menubar_data (struct frame *f, Lisp_Object menubar, int deep_p) 478 compute_menubar_data (struct frame *f, Lisp_Object menubar, int deep_p)