comparison src/gui.c @ 1318:b531bf8658e9

[xemacs-hg @ 2003-02-21 06:56:46 by ben] redisplay fixes et al. PROBLEMS: Add comment about Cygwin, unexec and sysmalloc. Move some non-general stuff out of general. Make a section for x86. configure.in: Add check for broken alloca in funcalls. mule/mule-cmds.el: Alias file-name to native not vice-versa. Do set EOL of native but not of process output to fix various problems and be consistent with code-init.el. code-cmds.el: Return a name not a coding system. code-init.el: Reindent. Remove `file-name' since it should always be the same as native. unicode.el: Rename to load-unicode-mapping-table as suggested by the anonymous (but rather Turnbullian) comment in unicode.c. xemacs.dsp: Add /k to default build. alloc.c: Make gc_currently_forbidden static. config.h.in, lisp.h: Move some stuff to lisp.h. console-gtk.h, console-impl.h, console-msw.h, console-x.h, event-Xt.c, event-msw.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-x.c, gtk-xemacs.c: Remove duplicated code to redraw exposed area. Add deadbox method needed by the generalized redraw code. Defer redrawing if already in redisplay. frame-msw.c, event-stream.c, frame.c: Add comments about calling Lisp. debug.c, general-slots.h: Move generalish symbols to general-slots.h. doprnt.c: reindent. lisp.h, dynarr.c: Add debug code for locking a dynarr to catch invalid mods. Use in redisplay.c. eval.c: file-coding.c: Define file-name as alias for native not vice-versa. frame-gtk.c, frame-x.c: Move Qwindow_id to general-slots. dialog-msw.c, glyphs-gtk.c, glyphs-msw.c, glyphs-widget.c, glyphs-x.c, gui.c, gui.h, menubar-msw.c, menubar.c: Ensure that various glyph functions that eval within redisplay protect the evals. Same for calls to internal_equal(). Modify various functions, e.g. gui_item_*(), to protect evals within redisplay, taking an in_redisplay parameter if it's possible for them to be called both inside and outside of redisplay. gutter.c: Defer specifier-changed updating till after redisplay, if necessary, since we need to enter redisplay to do it. gutter.c: Do nothing if in redisplay. lisp.h: Add version of alloca() for use in function calls. lisp.h: Add XCAD[D+]R up to 6 D's, and aliases X1ST, X2ND, etc. frame.c, frame.h, redisplay.c, redisplay.h, signal.c, toolbar.c: Redo critical-section code and move from frame.c to redisplay.c. Require that every place inside of redisplay catch errors itself, not at the edge of the critical section (thereby bypassing the rest of redisplay and leaving things in an inconsistent state). Introduce separate means of holding frame-size changes without entering a complete critical section. Introduce "post-redisplay" methods for deferring things till after redisplay. Abort if we enter redisplay reentrantly. Disable all quit checking in redisplay since it's too dangerous. Ensure that all calls to QUIT trigger an abort if unprotected. redisplay.c, scrollbar-gtk.c, scrollbar-x.c, scrollbar.c: Create enter/exit_redisplay_critical_section_maybe() for code that needs to ensure it's in a critical section but doesn't interfere with an existing critical section. sysdep.c: Use _wexecve() when under Windows NT for Unicode correctness. text.c, text.h: Add new_dfc() functions, which return an alloca()ed value rather than requiring an lvalue. (Not really used yet; used in another workspace, to come.) Add some macros for SIZED_EXTERNAL. Update the encoding aliases after involved scrutinization of the X manual. unicode.c: Answer the anonymous but suspiciously Turnbullian questions. Rename parse-unicode-translation-table to load-unicode-mapping-table, as suggested.
author ben
date Fri, 21 Feb 2003 06:57:21 +0000
parents e22b0213b713
children 7473844a83d3
comparison
equal deleted inserted replaced
1317:d9d08dc5e617 1318:b531bf8658e9
1 /* Generic GUI code. (menubars, scrollbars, toolbars, dialogs) 1 /* Generic GUI code. (menubars, scrollbars, toolbars, dialogs)
2 Copyright (C) 1995 Board of Trustees, University of Illinois. 2 Copyright (C) 1995 Board of Trustees, University of Illinois.
3 Copyright (C) 1995, 1996, 2000, 2001, 2002 Ben Wing. 3 Copyright (C) 1995, 1996, 2000, 2001, 2002, 2003 Ben Wing.
4 Copyright (C) 1995 Sun Microsystems, Inc. 4 Copyright (C) 1995 Sun Microsystems, Inc.
5 Copyright (C) 1998 Free Software Foundation, Inc. 5 Copyright (C) 1998 Free Software Foundation, Inc.
6 6
7 This file is part of XEmacs. 7 This file is part of XEmacs.
8 8
31 #include "buffer.h" 31 #include "buffer.h"
32 #include "bytecode.h" 32 #include "bytecode.h"
33 #include "elhash.h" 33 #include "elhash.h"
34 #include "gui.h" 34 #include "gui.h"
35 #include "menubar.h" 35 #include "menubar.h"
36 #include "redisplay.h"
36 37
37 Lisp_Object Qmenu_no_selection_hook; 38 Lisp_Object Qmenu_no_selection_hook;
38 Lisp_Object Vmenu_no_selection_hook; 39 Lisp_Object Vmenu_no_selection_hook;
39 40
40 static Lisp_Object parse_gui_item_tree_list (Lisp_Object list); 41 static Lisp_Object parse_gui_item_tree_list (Lisp_Object list);
379 Fplist_put (plist, Q_accelerator, pgui_item->accelerator); 380 Fplist_put (plist, Q_accelerator, pgui_item->accelerator);
380 if (!NILP (pgui_item->value)) 381 if (!NILP (pgui_item->value))
381 Fplist_put (plist, Q_value, pgui_item->value); 382 Fplist_put (plist, Q_value, pgui_item->value);
382 } 383 }
383 384
385 static int
386 gui_item_value (Lisp_Object form, int in_redisplay)
387 {
388 /* This function can call Lisp. */
389
390 #ifndef ERROR_CHECK_DISPLAY
391 /* Shortcut to avoid evaluating Qt/Qnil each time; but don't do it when
392 error-checking so we catch unprotected eval within redisplay quicker */
393 if (NILP (form))
394 return 0;
395 if (EQ (form, Qt))
396 return 1;
397 #endif
398 if (in_redisplay)
399 return !NILP (eval_within_redisplay (form));
400 else
401 return !NILP (Feval (form));
402 }
403
384 /* 404 /*
385 * Decide whether a GUI item is active by evaluating its :active form 405 * Decide whether a GUI item is active by evaluating its :active form
386 * if any 406 * if any
387 */ 407 */
388 int 408 int
389 gui_item_active_p (Lisp_Object gui_item) 409 gui_item_active_p (Lisp_Object gui_item, int in_redisplay)
390 { 410 {
391 /* This function can call lisp */ 411 return gui_item_value (XGUI_ITEM (gui_item)->active, in_redisplay);
392
393 /* Shortcut to avoid evaluating Qt each time */
394 return (EQ (XGUI_ITEM (gui_item)->active, Qt)
395 || !NILP (Feval (XGUI_ITEM (gui_item)->active)));
396 } 412 }
397 413
398 /* set menu accelerator key to first underlined character in menu name */ 414 /* set menu accelerator key to first underlined character in menu name */
399 Lisp_Object 415 Lisp_Object
400 gui_item_accelerator (Lisp_Object gui_item) 416 gui_item_accelerator (Lisp_Object gui_item)
434 /* 450 /*
435 * Decide whether a GUI item is selected by evaluating its :selected form 451 * Decide whether a GUI item is selected by evaluating its :selected form
436 * if any 452 * if any
437 */ 453 */
438 int 454 int
439 gui_item_selected_p (Lisp_Object gui_item) 455 gui_item_selected_p (Lisp_Object gui_item, int in_redisplay)
440 { 456 {
441 /* This function can call lisp */ 457 return gui_item_value (XGUI_ITEM (gui_item)->selected, in_redisplay);
442
443 /* Shortcut to avoid evaluating Qt each time */
444 return (EQ (XGUI_ITEM (gui_item)->selected, Qt)
445 || !NILP (Feval (XGUI_ITEM (gui_item)->selected)));
446 } 458 }
447 459
448 Lisp_Object 460 Lisp_Object
449 gui_item_list_find_selected (Lisp_Object gui_item_list) 461 gui_item_list_find_selected (Lisp_Object gui_item_list)
450 { 462 {
451 /* This function can GC. */ 463 /* This function can call Lisp but cannot GC because it is called within
464 redisplay, and redisplay disables GC. */
452 Lisp_Object rest; 465 Lisp_Object rest;
453 LIST_LOOP (rest, gui_item_list) 466 LIST_LOOP (rest, gui_item_list)
454 { 467 {
455 if (gui_item_selected_p (XCAR (rest))) 468 if (gui_item_selected_p (XCAR (rest), 1))
456 return XCAR (rest); 469 return XCAR (rest);
457 } 470 }
458 return XCAR (gui_item_list); 471 return XCAR (gui_item_list);
459 } 472 }
460 473
468 { 481 {
469 /* This function can call lisp */ 482 /* This function can call lisp */
470 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item); 483 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
471 484
472 /* Evaluate :included first. Shortcut to avoid evaluating Qt each time */ 485 /* Evaluate :included first. Shortcut to avoid evaluating Qt each time */
473 if (!EQ (pgui_item->included, Qt) 486 if (!gui_item_value (pgui_item->included, 0))
474 && NILP (Feval (pgui_item->included)))
475 return 0; 487 return 0;
476 488
477 /* Do :config if conflist is given */ 489 /* Do :config if conflist is given */
478 if (!NILP (conflist) && !NILP (pgui_item->config) 490 if (!NILP (conflist) && !NILP (pgui_item->config)
479 && NILP (Fmemq (pgui_item->config, conflist))) 491 && NILP (Fmemq (pgui_item->config, conflist)))
617 id = GUI_ITEM_ID_BITS (id + 1, slot); 629 id = GUI_ITEM_ID_BITS (id + 1, slot);
618 } 630 }
619 return id; 631 return id;
620 } 632 }
621 633
634 static int
635 gui_value_equal (Lisp_Object a, Lisp_Object b, int depth, int in_redisplay)
636 {
637 if (in_redisplay)
638 return internal_equal_trapping_problems
639 (Qredisplay, "Error calling function within redisplay", 0, 0,
640 /* say they're not equal in case of error; code calling
641 gui_item_equal_sans_selected() in redisplay does extra stuff
642 only when equal */
643 0, a, b, depth);
644 else
645 return internal_equal (a, b, depth);
646 }
647
622 int 648 int
623 gui_item_equal_sans_selected (Lisp_Object obj1, Lisp_Object obj2, int depth) 649 gui_item_equal_sans_selected (Lisp_Object obj1, Lisp_Object obj2, int depth,
650 int in_redisplay)
624 { 651 {
625 Lisp_Gui_Item *p1 = XGUI_ITEM (obj1); 652 Lisp_Gui_Item *p1 = XGUI_ITEM (obj1);
626 Lisp_Gui_Item *p2 = XGUI_ITEM (obj2); 653 Lisp_Gui_Item *p2 = XGUI_ITEM (obj2);
627 654
628 if (!(internal_equal (p1->name, p2->name, depth + 1) 655 if (!(gui_value_equal (p1->name, p2->name, depth + 1, in_redisplay)
629 && 656 &&
630 internal_equal (p1->callback, p2->callback, depth + 1) 657 gui_value_equal (p1->callback, p2->callback, depth + 1, in_redisplay)
631 && 658 &&
632 internal_equal (p1->callback_ex, p2->callback_ex, depth + 1) 659 gui_value_equal (p1->callback_ex, p2->callback_ex, depth + 1,
660 in_redisplay)
633 && 661 &&
634 EQ (p1->suffix, p2->suffix) 662 EQ (p1->suffix, p2->suffix)
635 && 663 &&
636 EQ (p1->active, p2->active) 664 EQ (p1->active, p2->active)
637 && 665 &&
656 gui_item_equal (Lisp_Object obj1, Lisp_Object obj2, int depth) 684 gui_item_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
657 { 685 {
658 Lisp_Gui_Item *p1 = XGUI_ITEM (obj1); 686 Lisp_Gui_Item *p1 = XGUI_ITEM (obj1);
659 Lisp_Gui_Item *p2 = XGUI_ITEM (obj2); 687 Lisp_Gui_Item *p2 = XGUI_ITEM (obj2);
660 688
661 if (!(gui_item_equal_sans_selected (obj1, obj2, depth) 689 if (!(gui_item_equal_sans_selected (obj1, obj2, depth, 0) &&
662 &&
663 EQ (p1->selected, p2->selected))) 690 EQ (p1->selected, p2->selected)))
664 return 0; 691 return 0;
665 return 1; 692 return 1;
666 } 693 }
667 694