comparison src/gui-x.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents a86b2b5e0111
children b8cc9ab3f761
comparison
equal deleted inserted replaced
403:9f011ab08d48 404:2f8bb876ab1d
211 XtPointer client_data) 211 XtPointer client_data)
212 { 212 {
213 Lisp_Object fn, arg; 213 Lisp_Object fn, arg;
214 Lisp_Object data; 214 Lisp_Object data;
215 Lisp_Object frame; 215 Lisp_Object frame;
216 int update_subwindows_p = 0;
216 struct device *d = get_device_from_display (XtDisplay (widget)); 217 struct device *d = get_device_from_display (XtDisplay (widget));
217 struct frame *f = x_any_widget_or_parent_to_frame (d, widget); 218 struct frame *f = x_any_widget_or_parent_to_frame (d, widget);
218 219
219 /* set in lwlib to the time stamp associated with the most recent menu 220 /* set in lwlib to the time stamp associated with the most recent menu
220 operation */ 221 operation */
243 fn = Qrun_hooks; 244 fn = Qrun_hooks;
244 arg = Qmenu_no_selection_hook; 245 arg = Qmenu_no_selection_hook;
245 } 246 }
246 else 247 else
247 { 248 {
248 MARK_SUBWINDOWS_STATE_CHANGED; 249 update_subwindows_p = 1;
249 get_gui_callback (data, &fn, &arg); 250 get_gui_callback (data, &fn, &arg);
250 } 251 }
251 252
252 /* This is the timestamp used for asserting focus so we need to get an 253 /* This is the timestamp used for asserting focus so we need to get an
253 up-to-date value event if no events has been dispatched to emacs 254 up-to-date value event if no events has been dispatched to emacs
256 DEVICE_X_MOUSE_TIMESTAMP (d) = x_focus_timestamp_really_sucks_fix_me_better; 257 DEVICE_X_MOUSE_TIMESTAMP (d) = x_focus_timestamp_really_sucks_fix_me_better;
257 #else 258 #else
258 DEVICE_X_MOUSE_TIMESTAMP (d) = DEVICE_X_GLOBAL_MOUSE_TIMESTAMP (d); 259 DEVICE_X_MOUSE_TIMESTAMP (d) = DEVICE_X_GLOBAL_MOUSE_TIMESTAMP (d);
259 #endif 260 #endif
260 signal_special_Xt_user_event (frame, fn, arg); 261 signal_special_Xt_user_event (frame, fn, arg);
262 /* The result of this evaluation could cause other instances to change so
263 enqueue an update callback to check this. */
264 if (update_subwindows_p)
265 signal_special_Xt_user_event (frame, Qeval,
266 list2 (Qupdate_widget_instances, frame));
261 } 267 }
262 268
263 #if 1 269 #if 1
264 /* Eval the activep slot of the menu item */ 270 /* Eval the activep slot of the menu item */
265 # define wv_set_evalable_slot(slot,form) do { \ 271 # define wv_set_evalable_slot(slot,form) do { \
301 return xstrdup (p+1); 307 return xstrdup (p+1);
302 308
303 return NULL; 309 return NULL;
304 } 310 }
305 311
312 char *
313 strdup_and_add_accel (char *name)
314 {
315 int i;
316 int found_accel = 0;
317
318 for (i=0; name[i]; ++i)
319 if (name[i] == '%' && name[i+1] == '_')
320 {
321 found_accel = 1;
322 break;
323 }
324
325 if (found_accel)
326 return xstrdup (name);
327 else
328 {
329 char *chars = (char *) alloca (strlen (name) + 3);
330 chars[0] = '%';
331 chars[1] = '_';
332 memcpy (chars+2, name, strlen (name) + 1);
333 return xstrdup (chars);
334 }
335 }
306 336
307 /* This does the dirty work. gc_currently_forbidden is 1 when this is called. 337 /* This does the dirty work. gc_currently_forbidden is 1 when this is called.
308 */ 338 */
309 int 339 int
310 button_item_to_widget_value (Lisp_Object gui_item, widget_value *wv, 340 button_item_to_widget_value (Lisp_Object gui_item, widget_value *wv,
318 /* degenerate case */ 348 /* degenerate case */
319 if (STRINGP (gui_item)) 349 if (STRINGP (gui_item))
320 { 350 {
321 wv->type = TEXT_TYPE; 351 wv->type = TEXT_TYPE;
322 wv->name = (char *) XSTRING_DATA (gui_item); 352 wv->name = (char *) XSTRING_DATA (gui_item);
323 wv->name = xstrdup (wv->name); 353 wv->name = strdup_and_add_accel (wv->name);
324 return 1; 354 return 1;
325 } 355 }
326 else if (!GUI_ITEMP (gui_item)) 356 else if (!GUI_ITEMP (gui_item))
327 signal_simple_error("need a string or a gui_item here", gui_item); 357 signal_simple_error("need a string or a gui_item here", gui_item);
328 358
336 { 366 {
337 /* the include specification says to ignore this item. */ 367 /* the include specification says to ignore this item. */
338 return 0; 368 return 0;
339 } 369 }
340 #endif /* HAVE_MENUBARS */ 370 #endif /* HAVE_MENUBARS */
371
372 if (!STRINGP (pgui->name))
373 pgui->name = Feval (pgui->name);
341 374
342 CHECK_STRING (pgui->name); 375 CHECK_STRING (pgui->name);
343 wv->name = (char *) XSTRING_DATA (pgui->name); 376 wv->name = (char *) XSTRING_DATA (pgui->name);
344 wv->name = xstrdup (wv->name); 377 wv->name = xstrdup (wv->name);
345 wv->accel = LISP_TO_VOID (gui_item_accelerator (gui_item)); 378 wv->accel = LISP_TO_VOID (gui_item_accelerator (gui_item));
386 else 419 else
387 wv->key = 0; 420 wv->key = 0;
388 } 421 }
389 else if (SYMBOLP (pgui->callback)) /* Show the binding of this command. */ 422 else if (SYMBOLP (pgui->callback)) /* Show the binding of this command. */
390 { 423 {
391 char buf [1024]; 424 char buf[1024]; /* #### */
392 /* #### Warning, dependency here on current_buffer and point */ 425 /* #### Warning, dependency here on current_buffer and point */
393 where_is_to_char (pgui->callback, buf); 426 where_is_to_char (pgui->callback, buf);
394 if (buf [0]) 427 if (buf [0])
395 wv->key = xstrdup (buf); 428 wv->key = xstrdup (buf);
396 else 429 else