comparison src/gui-x.c @ 175:2d532a89d707 r20-3b14

Import from CVS: tag r20-3b14
author cvs
date Mon, 13 Aug 2007 09:50:14 +0200
parents 8eaf7971accc
children 6075d714658b
comparison
equal deleted inserted replaced
174:bb3568571b84 175:2d532a89d707
84 { 84 {
85 VOID_TO_LISP (markee, val->call_data); 85 VOID_TO_LISP (markee, val->call_data);
86 (cl->markobj) (markee); 86 (cl->markobj) (markee);
87 } 87 }
88 88
89 if (val->accel)
90 {
91 VOID_TO_LISP (markee, val->accel);
92 (cl->markobj) (markee);
93 }
89 return 0; 94 return 0;
90 } 95 }
91 96
92 static Lisp_Object 97 static Lisp_Object
93 mark_popup_data (Lisp_Object obj, void (*markobj) (Lisp_Object)) 98 mark_popup_data (Lisp_Object obj, void (*markobj) (Lisp_Object))
236 Lisp_Object data; 241 Lisp_Object data;
237 Lisp_Object frame = Qnil; 242 Lisp_Object frame = Qnil;
238 struct device *d = get_device_from_display (XtDisplay (widget)); 243 struct device *d = get_device_from_display (XtDisplay (widget));
239 struct frame *f = x_any_widget_or_parent_to_frame (d, widget); 244 struct frame *f = x_any_widget_or_parent_to_frame (d, widget);
240 245
246 /* set in lwlib to the time stamp associated with the most recent menu
247 operation */
248 extern Time x_focus_timestamp_really_sucks_fix_me_better;
249
241 if (!f) 250 if (!f)
242 return; 251 return;
243 if (((EMACS_INT) client_data) == 0) 252 if (((EMACS_INT) client_data) == 0)
244 return; 253 return;
245 VOID_TO_LISP (data, client_data); 254 VOID_TO_LISP (data, client_data);
282 } 291 }
283 292
284 /* This is the timestamp used for asserting focus so we need to get an 293 /* This is the timestamp used for asserting focus so we need to get an
285 up-to-date value event if no events has been dispatched to emacs 294 up-to-date value event if no events has been dispatched to emacs
286 */ 295 */
287 DEVICE_X_MOUSE_TIMESTAMP (d) = DEVICE_X_GLOBAL_MOUSE_TIMESTAMP (d); 296 DEVICE_X_MOUSE_TIMESTAMP (d) = x_focus_timestamp_really_sucks_fix_me_better;
288 signal_special_Xt_user_event (frame, fn, arg); 297 signal_special_Xt_user_event (frame, fn, arg);
289 } 298 }
290 299
291 #if 1 300 #if 1
292 /* Eval the activep slot of the menu item */ 301 /* Eval the activep slot of the menu item */
346 return xstrdup (p+1); 355 return xstrdup (p+1);
347 356
348 return NULL; 357 return NULL;
349 } 358 }
350 359
360 /* set menu accelerator key to first underlined character in menu name */
361
362 Lisp_Object
363 menu_name_to_accelerator (char *name)
364 {
365 while (*name) {
366 if (*name=='%') {
367 ++name;
368 if (!(*name))
369 return Qnil;
370 if (*name=='_'&&*(name+1))
371 return make_char (tolower(*(name+1)));
372 }
373 ++name;
374 }
375 return Qnil;
376 }
377
351 /* This does the dirty work. gc_currently_forbidden is 1 when this is called. 378 /* This does the dirty work. gc_currently_forbidden is 1 when this is called.
352 */ 379 */
353 380
354 int 381 int
355 button_item_to_widget_value (Lisp_Object desc, widget_value *wv, 382 button_item_to_widget_value (Lisp_Object desc, widget_value *wv,
365 Lisp_Object include_p = Qt; 392 Lisp_Object include_p = Qt;
366 Lisp_Object selected_p = Qnil; 393 Lisp_Object selected_p = Qnil;
367 Lisp_Object keys = Qnil; 394 Lisp_Object keys = Qnil;
368 Lisp_Object style = Qnil; 395 Lisp_Object style = Qnil;
369 Lisp_Object config_tag = Qnil; 396 Lisp_Object config_tag = Qnil;
397 Lisp_Object accel = Qnil;
370 int length = XVECTOR_LENGTH (desc); 398 int length = XVECTOR_LENGTH (desc);
371 Lisp_Object *contents = XVECTOR_DATA (desc); 399 Lisp_Object *contents = XVECTOR_DATA (desc);
372 int plist_p; 400 int plist_p;
373 int selected_spec = 0, included_spec = 0; 401 int selected_spec = 0, included_spec = 0;
374 402
414 else if (EQ (key, Q_keys)) keys = val; 442 else if (EQ (key, Q_keys)) keys = val;
415 else if (EQ (key, Q_style)) style = val; 443 else if (EQ (key, Q_style)) style = val;
416 else if (EQ (key, Q_selected)) selected_p = val, selected_spec = 1; 444 else if (EQ (key, Q_selected)) selected_p = val, selected_spec = 1;
417 else if (EQ (key, Q_included)) include_p = val, included_spec = 1; 445 else if (EQ (key, Q_included)) include_p = val, included_spec = 1;
418 else if (EQ (key, Q_config)) config_tag = val; 446 else if (EQ (key, Q_config)) config_tag = val;
447 else if (EQ (key, Q_accelerator))
448 {
449 if ( SYMBOLP (val)
450 || CHARP (val))
451 accel = val;
452 else
453 signal_simple_error ("bad keyboard accelerator", val);
454 }
419 else if (EQ (key, Q_filter)) 455 else if (EQ (key, Q_filter))
420 signal_simple_error(":filter keyword not permitted on leaf nodes", desc); 456 signal_simple_error(":filter keyword not permitted on leaf nodes", desc);
421 else 457 else
422 signal_simple_error_2 ("unknown menu item keyword", key, desc); 458 signal_simple_error_2 ("unknown menu item keyword", key, desc);
423 } 459 }
433 #endif /* HAVE_MENUBARS */ 469 #endif /* HAVE_MENUBARS */
434 470
435 CHECK_STRING (name); 471 CHECK_STRING (name);
436 wv->name = (char *) XSTRING_DATA (name); 472 wv->name = (char *) XSTRING_DATA (name);
437 473
474 if (NILP (accel))
475 accel = menu_name_to_accelerator (wv->name);
476 wv->accel = LISP_TO_VOID (accel);
477
438 if (!NILP (suffix)) 478 if (!NILP (suffix))
439 { 479 {
440 CONST char *const_bogosity; 480 CONST char *const_bogosity;
441 CHECK_STRING (suffix); 481 CHECK_STRING (suffix);
442 GET_C_STRING_FILENAME_DATA_ALLOCA (suffix, const_bogosity); 482 GET_C_STRING_FILENAME_DATA_ALLOCA (suffix, const_bogosity);