comparison src/events.c @ 267:966663fcf606 r20-5b32

Import from CVS: tag r20-5b32
author cvs
date Mon, 13 Aug 2007 10:26:29 +0200
parents 727739f917cb
children b2472a1930f2
comparison
equal deleted inserted replaced
266:18d185df8c54 267:966663fcf606
480 e->event_type = button_press_event; 480 e->event_type = button_press_event;
481 else if (EQ (type, Qbutton_release)) 481 else if (EQ (type, Qbutton_release))
482 e->event_type = button_release_event; 482 e->event_type = button_release_event;
483 else if (EQ (type, Qmotion)) 483 else if (EQ (type, Qmotion))
484 e->event_type = pointer_motion_event; 484 e->event_type = pointer_motion_event;
485 else if (EQ (type, Qmisc_user))
486 {
487 e->event_type = misc_user_event;
488 e->event.eval.function = e->event.eval.object = Qnil;
489 }
485 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS) 490 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
486 else if (EQ (type, Qdnd_drop)) 491 else if (EQ (type, Qdnd_drop))
487 { 492 {
488 e->event_type = dnd_drop_event; 493 e->event_type = dnd_drop_event;
489 e->event.dnd_drop.data = Qnil; 494 e->event.dnd_drop.data = Qnil;
490 } 495 }
491 #endif 496 #endif
492 else 497 else
493 { 498 {
494 /* Not allowed: Qmisc_user, Qprocess, Qtimeout, Qmagic, Qeval, 499 /* Not allowed: Qprocess, Qtimeout, Qmagic, Qeval, Qmagic_eval. */
495 Qmagic_eval. */
496 /* #### Should we allow misc-user events? */
497 signal_simple_error ("Invalid event type", type); 500 signal_simple_error ("Invalid event type", type);
498 } 501 }
502
503 EVENT_CHANNEL (e) = Qnil;
499 504
500 plist = Fcopy_sequence (plist); 505 plist = Fcopy_sequence (plist);
501 Fcanonicalize_plist (plist, Qnil); 506 Fcanonicalize_plist (plist, Qnil);
502 507
503 /* Process the plist. */ 508 #define WRONG_EVENT_TYPE_FOR_PROPERTY(prop) \
509 error_with_frob (type, "Invalid event type for `%s' property", keyword)
510
504 EXTERNAL_PROPERTY_LIST_LOOP (tail, keyword, value, plist) 511 EXTERNAL_PROPERTY_LIST_LOOP (tail, keyword, value, plist)
505 { 512 {
506 if (EQ (keyword, Qchannel)) 513 if (EQ (keyword, Qchannel))
507 { 514 {
508 if (e->event_type == key_press_event) 515 if (e->event_type == key_press_event)
509 { 516 {
510 if (!CONSOLEP (value)) 517 while (!CONSOLEP (value))
511 wrong_type_argument (Qconsolep, value); 518 value = wrong_type_argument (Qconsolep, value);
512 } 519 }
513 else 520 else if (e->event_type != misc_user_event)
514 { 521 {
515 if (!FRAMEP (value)) 522 while (!FRAMEP (value))
516 wrong_type_argument (Qframep, value); 523 value = wrong_type_argument (Qframep, value);
517 } 524 }
518 EVENT_CHANNEL (e) = value; 525 EVENT_CHANNEL (e) = value;
519 } 526 }
520 else if (EQ (keyword, Qkey)) 527 else if (EQ (keyword, Qkey))
521 { 528 {
522 if (e->event_type != key_press_event) 529 if (e->event_type != key_press_event)
523 signal_simple_error ("Invalid event type for `key' property", 530 WRONG_EVENT_TYPE_FOR_PROPERTY (keyword);
524 type);
525 if (!SYMBOLP (value) && !CHARP (value)) 531 if (!SYMBOLP (value) && !CHARP (value))
526 signal_simple_error ("Invalid event key", value); 532 signal_simple_error ("Invalid event key", value);
527 e->event.key.keysym = value; 533 e->event.key.keysym = value;
528 } 534 }
529 else if (EQ (keyword, Qbutton)) 535 else if (EQ (keyword, Qbutton))
530 { 536 {
531 CHECK_NATNUM (value); 537 CHECK_NATNUM (value);
532 check_int_range (XINT(value), 1, 3); 538 check_int_range (XINT (value), 0, 7);
533 if (e->event_type != button_press_event 539 if (e->event_type != button_press_event
534 && e->event_type != button_release_event) 540 && e->event_type != button_release_event)
535 signal_simple_error ("Invalid event type for `button' property", 541 {
536 type); 542 WRONG_EVENT_TYPE_FOR_PROPERTY (keyword);
543 }
537 e->event.button.button = XINT (value); 544 e->event.button.button = XINT (value);
538 } 545 }
539 else if (EQ (keyword, Qmodifiers)) 546 else if (EQ (keyword, Qmodifiers))
540 { 547 {
541 Lisp_Object modtail, sym; 548 Lisp_Object modtail;
542 int modifiers = 0; 549 int modifiers = 0;
543 550
544 if (e->event_type != key_press_event 551 if (e->event_type != key_press_event
545 && e->event_type != button_press_event 552 && e->event_type != button_press_event
546 && e->event_type != button_release_event 553 && e->event_type != button_release_event
547 && e->event_type != pointer_motion_event) 554 && e->event_type != pointer_motion_event)
548 /* Currently unreached. */ 555 WRONG_EVENT_TYPE_FOR_PROPERTY (keyword);
549 signal_simple_error ("Invalid event type for modifiers", type);
550 556
551 EXTERNAL_LIST_LOOP (modtail, value) 557 EXTERNAL_LIST_LOOP (modtail, value)
552 { 558 {
553 sym = XCAR (modtail); 559 Lisp_Object sym = XCAR (modtail);
554 if (EQ (sym, Qcontrol)) modifiers |= MOD_CONTROL; 560 if (EQ (sym, Qcontrol)) modifiers |= MOD_CONTROL;
555 else if (EQ (sym, Qmeta)) modifiers |= MOD_META; 561 else if (EQ (sym, Qmeta)) modifiers |= MOD_META;
556 else if (EQ (sym, Qsuper)) modifiers |= MOD_SUPER; 562 else if (EQ (sym, Qsuper)) modifiers |= MOD_SUPER;
557 else if (EQ (sym, Qhyper)) modifiers |= MOD_HYPER; 563 else if (EQ (sym, Qhyper)) modifiers |= MOD_HYPER;
558 else if (EQ (sym, Qalt)) modifiers |= MOD_ALT; 564 else if (EQ (sym, Qalt)) modifiers |= MOD_ALT;
559 else if (EQ (sym, Qsymbol)) modifiers |= MOD_ALT; 565 else if (EQ (sym, Qsymbol)) modifiers |= MOD_ALT;
560 else if (EQ (sym, Qshift)) modifiers |= MOD_SHIFT; 566 else if (EQ (sym, Qshift)) modifiers |= MOD_SHIFT;
561 else 567 else
562 signal_simple_error ("Invalid key modifier", XCAR (modtail)); 568 signal_simple_error ("Invalid key modifier", sym);
563 } 569 }
564 if (e->event_type == key_press_event) 570 if (e->event_type == key_press_event)
565 e->event.key.modifiers = modifiers; 571 e->event.key.modifiers = modifiers;
566 else if (e->event_type == button_press_event 572 else if (e->event_type == button_press_event
567 || e->event_type == button_release_event) 573 || e->event_type == button_release_event)
576 CHECK_INT (value); 582 CHECK_INT (value);
577 if (e->event_type != pointer_motion_event 583 if (e->event_type != pointer_motion_event
578 && e->event_type != button_press_event 584 && e->event_type != button_press_event
579 && e->event_type != button_release_event) 585 && e->event_type != button_release_event)
580 { 586 {
581 signal_simple_error ("Cannot assign `x' property to event", 587 WRONG_EVENT_TYPE_FOR_PROPERTY (keyword);
582 type);
583 } 588 }
584 coord_x = XINT (value); 589 coord_x = XINT (value);
585 } 590 }
586 else if (EQ (keyword, Qy)) 591 else if (EQ (keyword, Qy))
587 { 592 {
589 CHECK_INT (value); 594 CHECK_INT (value);
590 if (e->event_type != pointer_motion_event 595 if (e->event_type != pointer_motion_event
591 && e->event_type != button_press_event 596 && e->event_type != button_press_event
592 && e->event_type != button_release_event) 597 && e->event_type != button_release_event)
593 { 598 {
594 signal_simple_error ("Cannot assign `y' property to event", 599 WRONG_EVENT_TYPE_FOR_PROPERTY (keyword);
595 type);
596 } 600 }
597 coord_y = XINT (value); 601 coord_y = XINT (value);
598 } 602 }
599 else if (EQ (keyword, Qtimestamp)) 603 else if (EQ (keyword, Qtimestamp))
600 { 604 {
601 CHECK_NATNUM (value); 605 CHECK_NATNUM (value);
602 e->timestamp = XINT (value); 606 e->timestamp = XINT (value);
607 }
608 else if (EQ (keyword, Qfunction))
609 {
610 if (e->event_type != misc_user_event)
611 WRONG_EVENT_TYPE_FOR_PROPERTY (keyword);
612 e->event.eval.function = value;
613 }
614 else if (EQ (keyword, Qobject))
615 {
616 if (e->event_type != misc_user_event)
617 WRONG_EVENT_TYPE_FOR_PROPERTY (keyword);
618 e->event.eval.object = value;
603 } 619 }
604 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS) 620 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
605 else if (EQ (keyword, Qdnd_data)) 621 else if (EQ (keyword, Qdnd_data))
606 { 622 {
607 Lisp_Object dnd_tail; 623 Lisp_Object dnd_tail;
625 e->event.dnd_drop.data = Fcopy_tree (value, Qnil); 641 e->event.dnd_drop.data = Fcopy_tree (value, Qnil);
626 } 642 }
627 } 643 }
628 #endif /* HAVE_OFFIX_DND || HAVE_MS_WINDOWS */ 644 #endif /* HAVE_OFFIX_DND || HAVE_MS_WINDOWS */
629 else 645 else
630 signal_simple_error ("Invalid property", keyword); 646 signal_simple_error_2 ("Invalid property", keyword, value);
631 } /* while */ 647 }
632 648
633 /* Insert the channel, if missing. */ 649 /* Insert the channel, if missing. */
634 if (NILP (EVENT_CHANNEL (e))) 650 if (NILP (EVENT_CHANNEL (e)))
635 { 651 {
636 if (e->event_type == key_press_event) 652 if (e->event_type == key_press_event)
637 EVENT_CHANNEL (e) = Vselected_console; 653 EVENT_CHANNEL (e) = Vselected_console;
638 else 654 else if (e->event_type != misc_user_event)
639 EVENT_CHANNEL (e) = Fselected_frame (Qnil); 655 EVENT_CHANNEL (e) = Fselected_frame (Qnil);
640 } 656 }
641 657
642 /* Fevent_properties, Fevent_x_pixel, etc. work with pixels relative 658 /* Fevent_properties, Fevent_x_pixel, etc. work with pixels relative
643 to the frame, so we must adjust accordingly. */ 659 to the frame, so we must adjust accordingly. */
999 case 'I': k = QKtab; m &= ~MOD_CONTROL; break; 1015 case 'I': k = QKtab; m &= ~MOD_CONTROL; break;
1000 case 'J': k = QKlinefeed; m &= ~MOD_CONTROL; break; 1016 case 'J': k = QKlinefeed; m &= ~MOD_CONTROL; break;
1001 case 'M': k = QKreturn; m &= ~MOD_CONTROL; break; 1017 case 'M': k = QKreturn; m &= ~MOD_CONTROL; break;
1002 case '[': k = QKescape; m &= ~MOD_CONTROL; break; 1018 case '[': k = QKescape; m &= ~MOD_CONTROL; break;
1003 default: 1019 default:
1004 #if defined(HAVE_TTY) && !defined(__CYGWIN32__) 1020 #if defined(HAVE_TTY)
1005 if (do_backspace_mapping && 1021 if (do_backspace_mapping &&
1006 CHARP (con->tty_erase_char) && 1022 CHARP (con->tty_erase_char) &&
1007 c - '@' == XCHAR (con->tty_erase_char)) 1023 c - '@' == XCHAR (con->tty_erase_char))
1008 { 1024 {
1009 k = QKbackspace; 1025 k = QKbackspace;
1012 #endif /* defined(HAVE_TTY) && !defined(__CYGWIN32__) */ 1028 #endif /* defined(HAVE_TTY) && !defined(__CYGWIN32__) */
1013 break; 1029 break;
1014 } 1030 }
1015 if (c >= 'A' && c <= 'Z') c -= 'A'-'a'; 1031 if (c >= 'A' && c <= 'Z') c -= 'A'-'a';
1016 } 1032 }
1017 #if defined(HAVE_TTY) && !defined(__CYGWIN32__) 1033 #if defined(HAVE_TTY)
1018 else if (do_backspace_mapping && 1034 else if (do_backspace_mapping &&
1019 CHARP (con->tty_erase_char) && c == XCHAR (con->tty_erase_char)) 1035 CHARP (con->tty_erase_char) && c == XCHAR (con->tty_erase_char))
1020 k = QKbackspace; 1036 k = QKbackspace;
1021 #endif /* defined(HAVE_TTY) && !defined(__CYGWIN32__) */ 1037 #endif /* defined(HAVE_TTY) && !defined(__CYGWIN32__) */
1022 else if (c == 127) 1038 else if (c == 127)