comparison src/events.c @ 249:83b3d10dcba9 r20-5b23

Import from CVS: tag r20-5b23
author cvs
date Mon, 13 Aug 2007 10:19:09 +0200
parents f220cc83d72e
children 11cf20601dec
comparison
equal deleted inserted replaced
248:ad40ac2754d8 249:83b3d10dcba9
64 Lisp_Object Qprocess_event_p; 64 Lisp_Object Qprocess_event_p;
65 65
66 Lisp_Object Qkey_press, Qbutton_press, Qbutton_release, Qmisc_user; 66 Lisp_Object Qkey_press, Qbutton_press, Qbutton_release, Qmisc_user;
67 Lisp_Object Qascii_character; 67 Lisp_Object Qascii_character;
68 68
69 #ifdef HAVE_OFFIX_DND 69 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
70 Lisp_Object Qdnd_drop_event_p; 70 Lisp_Object Qdnd_drop_event_p;
71 Lisp_Object Qdnd_drop; 71 Lisp_Object Qdnd_drop;
72 #endif 72 #endif
73 73
74 /* #### Ad-hoc hack. Should be part of define_lrecord_implementation */ 74 /* #### Ad-hoc hack. Should be part of define_lrecord_implementation */
133 case button_release_event: 133 case button_release_event:
134 case pointer_motion_event: 134 case pointer_motion_event:
135 case magic_event: 135 case magic_event:
136 case empty_event: 136 case empty_event:
137 case dead_event: 137 case dead_event:
138 #ifdef HAVE_OFFIX_DND 138 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
139 case dnd_drop_event: 139 case dnd_drop_event:
140 #endif 140 #endif
141 break; 141 break;
142 default: 142 default:
143 abort (); 143 abort ();
213 write_c_string (")", printcharfun); 213 write_c_string (")", printcharfun);
214 break; 214 break;
215 case dead_event: 215 case dead_event:
216 write_c_string ("#<DEALLOCATED-EVENT", printcharfun); 216 write_c_string ("#<DEALLOCATED-EVENT", printcharfun);
217 break; 217 break;
218 #ifdef HAVE_OFFIX_DND 218 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
219 case dnd_drop_event: 219 case dnd_drop_event:
220 print_event_1 ("#<dnd-drop-event ", obj, printcharfun); 220 print_event_1 ("#<dnd-drop-event ", obj, printcharfun);
221 break; 221 break;
222 #endif 222 #endif
223 default: 223 default:
271 return (e1->event.magic_eval.internal_function == 271 return (e1->event.magic_eval.internal_function ==
272 e2->event.magic_eval.internal_function && 272 e2->event.magic_eval.internal_function &&
273 internal_equal (e1->event.magic_eval.object, 273 internal_equal (e1->event.magic_eval.object,
274 e2->event.magic_eval.object, 0)); 274 e2->event.magic_eval.object, 0));
275 275
276 #ifdef HAVE_OFFIX_DND 276 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
277 case dnd_drop_event: 277 case dnd_drop_event:
278 return (e1->event.dnd_drop.button == e2->event.dnd_drop.button && 278 return (e1->event.dnd_drop.button == e2->event.dnd_drop.button &&
279 e1->event.dnd_drop.modifiers == e2->event.dnd_drop.modifiers && 279 e1->event.dnd_drop.modifiers == e2->event.dnd_drop.modifiers &&
280 EQ (e1->event.dnd_drop.data, e2->event.dnd_drop.data)); 280 EQ (e1->event.dnd_drop.data, e2->event.dnd_drop.data));
281 #endif 281 #endif
348 case magic_eval_event: 348 case magic_eval_event:
349 return HASH3 (hash, 349 return HASH3 (hash,
350 (unsigned long) e->event.magic_eval.internal_function, 350 (unsigned long) e->event.magic_eval.internal_function,
351 internal_hash (e->event.magic_eval.object, depth + 1)); 351 internal_hash (e->event.magic_eval.object, depth + 1));
352 352
353 #ifdef HAVE_OFFIX_DND 353 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
354 case dnd_drop_event: 354 case dnd_drop_event:
355 return HASH4 (hash, e->event.dnd_drop.button, e->event.dnd_drop.modifiers, 355 return HASH4 (hash, e->event.dnd_drop.button, e->event.dnd_drop.modifiers,
356 LISP_HASH(e->event.dnd_drop.data)); 356 LISP_HASH(e->event.dnd_drop.data));
357 #endif 357 #endif
358 358
367 if (CONSOLE_TTY_P (con)) 367 if (CONSOLE_TTY_P (con))
368 return HASH2 (hash, e->event.magic.underlying_tty_event); 368 return HASH2 (hash, e->event.magic.underlying_tty_event);
369 #endif 369 #endif
370 #ifdef HAVE_MS_WINDOWS 370 #ifdef HAVE_MS_WINDOWS
371 if (CONSOLE_MSWINDOWS_P (con)) 371 if (CONSOLE_MSWINDOWS_P (con))
372 return HASH6 (hash, e->event.magic.underlying_mswindows_event.message, 372 return HASH2 (hash, e->event.magic.underlying_mswindows_event);
373 e->event.magic.underlying_mswindows_event.data[0],
374 e->event.magic.underlying_mswindows_event.data[1],
375 e->event.magic.underlying_mswindows_event.data[2],
376 e->event.magic.underlying_mswindows_event.data[3]
377 );
378 #endif 373 #endif
379 } 374 }
380 375
381 case empty_event: 376 case empty_event:
382 case dead_event: 377 case dead_event:
485 e->event_type = button_press_event; 480 e->event_type = button_press_event;
486 else if (EQ (type, Qbutton_release)) 481 else if (EQ (type, Qbutton_release))
487 e->event_type = button_release_event; 482 e->event_type = button_release_event;
488 else if (EQ (type, Qmotion)) 483 else if (EQ (type, Qmotion))
489 e->event_type = pointer_motion_event; 484 e->event_type = pointer_motion_event;
490 #ifdef HAVE_OFFIX_DND 485 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
491 else if (EQ (type, Qdnd_drop)) 486 else if (EQ (type, Qdnd_drop))
492 { 487 {
493 e->event_type = dnd_drop_event; 488 e->event_type = dnd_drop_event;
494 e->event.dnd_drop.data = Qnil; 489 e->event.dnd_drop.data = Qnil;
495 } 490 }
604 else if (EQ (keyword, Qtimestamp)) 599 else if (EQ (keyword, Qtimestamp))
605 { 600 {
606 CHECK_NATNUM (value); 601 CHECK_NATNUM (value);
607 e->timestamp = XINT (value); 602 e->timestamp = XINT (value);
608 } 603 }
609 #ifdef HAVE_OFFIX_DND 604 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
610 else if (EQ (keyword, Qdnd_data)) 605 else if (EQ (keyword, Qdnd_data))
611 { 606 {
612 Lisp_Object dnd_tail; 607 Lisp_Object dnd_tail;
613 /* Value is either nil, or a list of (TYPE DATA). TYPE is 608 /* Value is either nil, or a list of (TYPE DATA). TYPE is
614 an integer. DATA is a list. */ 609 an integer. DATA is a list. */
628 } 623 }
629 /* And now, copy it all. */ 624 /* And now, copy it all. */
630 e->event.dnd_drop.data = Fcopy_tree (value, Qnil); 625 e->event.dnd_drop.data = Fcopy_tree (value, Qnil);
631 } 626 }
632 } 627 }
633 #endif /* HAVE_OFFIX_DND */ 628 #endif /* HAVE_OFFIX_DND || HAVE_MS_WINDOWS */
634 else 629 else
635 signal_simple_error ("Invalid property", keyword); 630 signal_simple_error ("Invalid property", keyword);
636 } /* while */ 631 } /* while */
637 632
638 /* Insert the channel, if missing. */ 633 /* Insert the channel, if missing. */
647 /* Fevent_properties, Fevent_x_pixel, etc. work with pixels relative 642 /* Fevent_properties, Fevent_x_pixel, etc. work with pixels relative
648 to the frame, so we must adjust accordingly. */ 643 to the frame, so we must adjust accordingly. */
649 if (e->event_type == pointer_motion_event 644 if (e->event_type == pointer_motion_event
650 || e->event_type == button_press_event 645 || e->event_type == button_press_event
651 || e->event_type == button_release_event 646 || e->event_type == button_release_event
652 #ifdef HAVE_OFFIX_DND 647 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
653 || e->event_type == dnd_drop_event 648 || e->event_type == dnd_drop_event
654 #endif 649 #endif
655 ) 650 )
656 { 651 {
657 struct frame *f = XFRAME (EVENT_CHANNEL (e)); 652 struct frame *f = XFRAME (EVENT_CHANNEL (e));
664 e->event.motion.x = coord_x; 659 e->event.motion.x = coord_x;
665 e->event.motion.y = coord_y; 660 e->event.motion.y = coord_y;
666 } 661 }
667 else if (e->event_type == button_press_event 662 else if (e->event_type == button_press_event
668 || e->event_type == button_release_event 663 || e->event_type == button_release_event
669 #ifdef HAVE_OFFIX_DND 664 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
670 || e->event_type == dnd_drop_event 665 || e->event_type == dnd_drop_event
671 #endif 666 #endif
672 ) 667 )
673 { 668 {
674 e->event.button.x = coord_x; 669 e->event.button.x = coord_x;
683 if (!(SYMBOLP (e->event.key.keysym) || CHARP (e->event.key.keysym))) 678 if (!(SYMBOLP (e->event.key.keysym) || CHARP (e->event.key.keysym)))
684 error ("Undefined key for keypress event"); 679 error ("Undefined key for keypress event");
685 break; 680 break;
686 case button_press_event: 681 case button_press_event:
687 case button_release_event: 682 case button_release_event:
688 #ifdef HAVE_OFFIX_DND 683 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
689 case dnd_drop_event: 684 case dnd_drop_event:
690 #endif 685 #endif
691 if (!e->event.button.button) 686 if (!e->event.button.button)
692 error ("Undefined button for %s event", 687 error ("Undefined button for %s event",
693 e->event_type == button_press_event 688 e->event_type == button_press_event
694 ? "buton-press" : 689 ? "buton-press" :
695 #ifdef HAVE_OFFIX_DND 690 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
696 e->event_type == button_release_event 691 e->event_type == button_release_event
697 ? "button-release" : "dnd-drop" 692 ? "button-release" : "dnd-drop"
698 #else 693 #else
699 "button-release" 694 "button-release"
700 #endif 695 #endif
954 { 949 {
955 case key_press_event: 950 case key_press_event:
956 case button_press_event: 951 case button_press_event:
957 case button_release_event: 952 case button_release_event:
958 case misc_user_event: 953 case misc_user_event:
959 #ifdef HAVE_OFFIX_DND 954 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
960 case dnd_drop_event: 955 case dnd_drop_event:
961 #endif 956 #endif
962 return 1; 957 return 1;
963 default: 958 default:
964 return 0; 959 return 0;
1214 format_event_object (char *buf, struct Lisp_Event *event, int brief) 1209 format_event_object (char *buf, struct Lisp_Event *event, int brief)
1215 { 1210 {
1216 int mouse_p = 0; 1211 int mouse_p = 0;
1217 int mod = 0; 1212 int mod = 0;
1218 Lisp_Object key; 1213 Lisp_Object key;
1219 #ifdef HAVE_OFFIX_DND 1214 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
1220 int dnd_p = 0; 1215 int dnd_p = 0;
1221 #endif 1216 #endif
1222 1217
1223 switch (event->event_type) 1218 switch (event->event_type)
1224 { 1219 {
1261 #endif /* HAVE_X_WINDOWS */ 1256 #endif /* HAVE_X_WINDOWS */
1262 if (name) strcpy (buf, name); 1257 if (name) strcpy (buf, name);
1263 else strcpy (buf, "???"); 1258 else strcpy (buf, "???");
1264 return; 1259 return;
1265 } 1260 }
1266 #ifdef HAVE_OFFIX_DND 1261 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
1267 case dnd_drop_event: 1262 case dnd_drop_event:
1268 { 1263 {
1269 dnd_p++; 1264 dnd_p++;
1270 mod = event->event.dnd_drop.modifiers; 1265 mod = event->event.dnd_drop.modifiers;
1271 key = make_char (event->event.dnd_drop.button + '0'); 1266 key = make_char (event->event.dnd_drop.button + '0');
1295 { 1290 {
1296 modprint1 ("button"); 1291 modprint1 ("button");
1297 --mouse_p; 1292 --mouse_p;
1298 } 1293 }
1299 1294
1300 #ifdef HAVE_OFFIX_DND 1295 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
1301 switch (dnd_p) 1296 switch (dnd_p)
1302 { 1297 {
1303 case 1: 1298 case 1:
1304 modprint1 ("drop"); 1299 modprint1 ("drop");
1305 } 1300 }
1438 case misc_user_event: return Qmisc_user; 1433 case misc_user_event: return Qmisc_user;
1439 case pointer_motion_event: return Qmotion; 1434 case pointer_motion_event: return Qmotion;
1440 case process_event: return Qprocess; 1435 case process_event: return Qprocess;
1441 case timeout_event: return Qtimeout; 1436 case timeout_event: return Qtimeout;
1442 case eval_event: return Qeval; 1437 case eval_event: return Qeval;
1443 #ifdef HAVE_OFFIX_DND 1438 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
1444 case dnd_drop_event: return Qdnd_drop; 1439 case dnd_drop_event: return Qdnd_drop;
1445 #endif 1440 #endif
1446 case magic_event: 1441 case magic_event:
1447 case magic_eval_event: 1442 case magic_eval_event:
1448 return Qmagic; 1443 return Qmagic;
1495 DEFUN ("event-button", Fevent_button, 1, 1, 0, /* 1490 DEFUN ("event-button", Fevent_button, 1, 1, 0, /*
1496 Return the button-number of the given button-press or button-release event. 1491 Return the button-number of the given button-press or button-release event.
1497 */ 1492 */
1498 (event)) 1493 (event))
1499 { 1494 {
1500 #ifndef HAVE_OFFIX_DND 1495 #if !defined(HAVE_OFFIX_DND) && !defined(HAVE_MS_WINDOWS)
1501 1496
1502 CHECK_EVENT_TYPE2 (event, button_press_event, button_release_event, 1497 CHECK_EVENT_TYPE2 (event, button_press_event, button_release_event,
1503 Qbutton_event_p); 1498 Qbutton_event_p);
1504 #ifdef HAVE_WINDOW_SYSTEM 1499 #ifdef HAVE_WINDOW_SYSTEM
1505 return make_int (XEVENT (event)->event.button.button); 1500 return make_int (XEVENT (event)->event.button.button);
1506 #else /* !HAVE_WINDOW_SYSTEM */ 1501 #else /* !HAVE_WINDOW_SYSTEM */
1507 return Qzero; 1502 return Qzero;
1508 #endif /* !HAVE_WINDOW_SYSTEM */ 1503 #endif /* !HAVE_WINDOW_SYSTEM */
1509 1504
1510 #else /* HAVE_OFFIX_DND */ 1505 #else /* HAVE_OFFIX_DND || HAVE_MS_WINDOWS */
1511 1506
1512 CHECK_LIVE_EVENT (event); 1507 CHECK_LIVE_EVENT (event);
1513 if (XEVENT(event)->event_type == (button_press_event) || 1508 if (XEVENT(event)->event_type == (button_press_event) ||
1514 XEVENT(event)->event_type == (button_release_event)) 1509 XEVENT(event)->event_type == (button_release_event))
1515 /* we always have X if we have OffiX !! */ 1510 /* we always have X if we have OffiX !! */
1539 case button_press_event: 1534 case button_press_event:
1540 case button_release_event: 1535 case button_release_event:
1541 return make_int (XEVENT (event)->event.button.modifiers); 1536 return make_int (XEVENT (event)->event.button.modifiers);
1542 case pointer_motion_event: 1537 case pointer_motion_event:
1543 return make_int (XEVENT (event)->event.motion.modifiers); 1538 return make_int (XEVENT (event)->event.motion.modifiers);
1544 #ifdef HAVE_OFFIX_DND 1539 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
1545 case dnd_drop_event: 1540 case dnd_drop_event:
1546 return make_int (XEVENT (event)->event.dnd_drop.modifiers); 1541 return make_int (XEVENT (event)->event.dnd_drop.modifiers);
1547 #endif 1542 #endif
1548 default: 1543 default:
1549 event = wrong_type_argument (intern ("key-or-mouse-event-p"), event); 1544 event = wrong_type_argument (intern ("key-or-mouse-event-p"), event);
1584 XEVENT (event)->event_type == button_release_event) 1579 XEVENT (event)->event_type == button_release_event)
1585 { 1580 {
1586 *x = XEVENT (event)->event.button.x; 1581 *x = XEVENT (event)->event.button.x;
1587 *y = XEVENT (event)->event.button.y; 1582 *y = XEVENT (event)->event.button.y;
1588 } 1583 }
1589 #ifdef HAVE_OFFIX_DND 1584 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
1590 else if (XEVENT (event)->event_type == dnd_drop_event) 1585 else if (XEVENT (event)->event_type == dnd_drop_event)
1591 { 1586 {
1592 *x = XEVENT (event)->event.dnd_drop.x; 1587 *x = XEVENT (event)->event.dnd_drop.x;
1593 *y = XEVENT (event)->event.dnd_drop.y; 1588 *y = XEVENT (event)->event.dnd_drop.y;
1594 } 1589 }
1741 case button_press_event : 1736 case button_press_event :
1742 case button_release_event : 1737 case button_release_event :
1743 pix_x = XEVENT (event)->event.button.x; 1738 pix_x = XEVENT (event)->event.button.x;
1744 pix_y = XEVENT (event)->event.button.y; 1739 pix_y = XEVENT (event)->event.button.y;
1745 break; 1740 break;
1746 #ifdef HAVE_OFFIX_DND 1741 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
1747 case dnd_drop_event : 1742 case dnd_drop_event :
1748 pix_x = XEVENT (event)->event.dnd_drop.x; 1743 pix_x = XEVENT (event)->event.dnd_drop.x;
1749 pix_y = XEVENT (event)->event.dnd_drop.y; 1744 pix_y = XEVENT (event)->event.dnd_drop.y;
1750 break; 1745 break;
1751 #endif 1746 #endif
2101 Return the Dnd data list of EVENT. 2096 Return the Dnd data list of EVENT.
2102 EVENT should be a dnd_drop event. 2097 EVENT should be a dnd_drop event.
2103 */ 2098 */
2104 (event)) 2099 (event))
2105 { 2100 {
2106 #ifdef HAVE_OFFIX_DND 2101 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
2107 again: 2102 again:
2108 CHECK_LIVE_EVENT (event); 2103 CHECK_LIVE_EVENT (event);
2109 switch (XEVENT (event)->event_type) 2104 switch (XEVENT (event)->event_type)
2110 { 2105 {
2111 case dnd_drop_event: 2106 case dnd_drop_event:
2112 return XEVENT (event)->event.dnd_drop.data; 2107 return XEVENT (event)->event.dnd_drop.data;
2113 default: 2108 default:
2114 event = wrong_type_argument (Qdnd_drop_event_p, event); 2109 event = wrong_type_argument (Qdnd_drop_event_p, event);
2115 goto again; 2110 goto again;
2116 } 2111 }
2117 #else /* !HAVE_OFFIX_DND */ 2112 #else /* !(HAVE_OFFIX_DND || HAVE_MS_WINDOWS) */
2118 return Qnil; 2113 return Qnil;
2119 #endif /* HAVE_OFFIX_DND */ 2114 #endif /* HAVE_OFFIX_DND || HAVE_MS_WINDOWS */
2120 } 2115 }
2121 2116
2122 DEFUN ("event-properties", Fevent_properties, 1, 1, 0, /* 2117 DEFUN ("event-properties", Fevent_properties, 1, 1, 0, /*
2123 Return a list of all of the properties of EVENT. 2118 Return a list of all of the properties of EVENT.
2124 This is in the form of a property list (alternating keyword/value pairs). 2119 This is in the form of a property list (alternating keyword/value pairs).
2171 case eval_event: 2166 case eval_event:
2172 props = Fcons (Qobject, Fcons (Fevent_object (event), props)); 2167 props = Fcons (Qobject, Fcons (Fevent_object (event), props));
2173 props = Fcons (Qfunction, Fcons (Fevent_function (event), props)); 2168 props = Fcons (Qfunction, Fcons (Fevent_function (event), props));
2174 break; 2169 break;
2175 2170
2176 #ifdef HAVE_OFFIX_DND 2171 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
2177 case dnd_drop_event: 2172 case dnd_drop_event:
2178 props = Fcons (Qy, Fcons (Fevent_y_pixel (event), props)); 2173 props = Fcons (Qy, Fcons (Fevent_y_pixel (event), props));
2179 props = Fcons (Qx, Fcons (Fevent_x_pixel (event), props)); 2174 props = Fcons (Qx, Fcons (Fevent_x_pixel (event), props));
2180 props = Fcons (Qmodifiers, Fcons (Fevent_modifiers (event), props)); 2175 props = Fcons (Qmodifiers, Fcons (Fevent_modifiers (event), props));
2181 props = Fcons (Qbutton, Fcons (Fevent_button (event), props)); 2176 props = Fcons (Qbutton, Fcons (Fevent_button (event), props));
2260 defsymbol (&Qkey_press, "key-press"); 2255 defsymbol (&Qkey_press, "key-press");
2261 defsymbol (&Qbutton_press, "button-press"); 2256 defsymbol (&Qbutton_press, "button-press");
2262 defsymbol (&Qbutton_release, "button-release"); 2257 defsymbol (&Qbutton_release, "button-release");
2263 defsymbol (&Qmisc_user, "misc-user"); 2258 defsymbol (&Qmisc_user, "misc-user");
2264 defsymbol (&Qascii_character, "ascii-character"); 2259 defsymbol (&Qascii_character, "ascii-character");
2265 #ifdef HAVE_OFFIX_DND 2260 #if defined(HAVE_OFFIX_DND) || defined(HAVE_MS_WINDOWS)
2266 defsymbol (&Qdnd_drop_event_p, "dnd-drop-event-p"); 2261 defsymbol (&Qdnd_drop_event_p, "dnd-drop-event-p");
2267 defsymbol (&Qdnd_drop, "dnd-drop"); 2262 defsymbol (&Qdnd_drop, "dnd-drop");
2268 #endif 2263 #endif
2269 } 2264 }
2270 2265