comparison src/events.c @ 20:859a2309aef8 r19-15b93

Import from CVS: tag r19-15b93
author cvs
date Mon, 13 Aug 2007 08:50:05 +0200
parents ac2d302a0011
children 131b0175ea99
comparison
equal deleted inserted replaced
19:ac1f612d5250 20:859a2309aef8
386 event-properties) to allow creation of any type of event. 386 event-properties) to allow creation of any type of event.
387 This is useful, for example, in Lisp code that might want 387 This is useful, for example, in Lisp code that might want
388 to determine if, for a given button-down event, what the 388 to determine if, for a given button-down event, what the
389 binding for the corresponding button-up event is. */ 389 binding for the corresponding button-up event is. */
390 390
391 DEFUN ("make-event", Fmake_event, Smake_event, 0, 0, 0 /* 391 DEFUN ("make-event", Fmake_event, 0, 0, 0, /*
392 Create a new empty event. 392 Create a new empty event.
393 WARNING, the event object returned may be a reused one; see the function 393 WARNING, the event object returned may be a reused one; see the function
394 `deallocate-event'. 394 `deallocate-event'.
395 */ ) 395 */
396 () 396 ())
397 { 397 {
398 Lisp_Object event; 398 Lisp_Object event;
399 399
400 if (!NILP (Vevent_resource)) 400 if (!NILP (Vevent_resource))
401 { 401 {
408 } 408 }
409 zero_event (XEVENT (event)); 409 zero_event (XEVENT (event));
410 return event; 410 return event;
411 } 411 }
412 412
413 DEFUN ("deallocate-event", Fdeallocate_event, Sdeallocate_event, 1, 1, 0 /* 413 DEFUN ("deallocate-event", Fdeallocate_event, 1, 1, 0, /*
414 Allow the given event structure to be reused. 414 Allow the given event structure to be reused.
415 You MUST NOT use this event object after calling this function with it. 415 You MUST NOT use this event object after calling this function with it.
416 You will lose. It is not necessary to call this function, as event 416 You will lose. It is not necessary to call this function, as event
417 objects are garbage-collected like all other objects; however, it may 417 objects are garbage-collected like all other objects; however, it may
418 be more efficient to explicitly deallocate events when you are sure 418 be more efficient to explicitly deallocate events when you are sure
419 that it is safe to do so. 419 that it is safe to do so.
420 */ ) 420 */
421 (event) 421 (event))
422 Lisp_Object event;
423 { 422 {
424 CHECK_EVENT (event); 423 CHECK_EVENT (event);
425 424
426 if (XEVENT_TYPE (event) == dead_event) 425 if (XEVENT_TYPE (event) == dead_event)
427 error ("this event is already deallocated!"); 426 error ("this event is already deallocated!");
457 Vevent_resource = event; 456 Vevent_resource = event;
458 #endif 457 #endif
459 return Qnil; 458 return Qnil;
460 } 459 }
461 460
462 DEFUN ("copy-event", Fcopy_event, Scopy_event, 1, 2, 0 /* 461 DEFUN ("copy-event", Fcopy_event, 1, 2, 0, /*
463 Make a copy of the given event object. 462 Make a copy of the given event object.
464 If a second argument is given, the first event is copied into the second 463 If a second argument is given, the first event is copied into the second
465 and the second is returned. If the second argument is not supplied (or 464 and the second is returned. If the second argument is not supplied (or
466 is nil) then a new event will be made as with `allocate-event.' See also 465 is nil) then a new event will be made as with `allocate-event.' See also
467 the function `deallocate-event'. 466 the function `deallocate-event'.
468 */ ) 467 */
469 (event1, event2) 468 (event1, event2))
470 Lisp_Object event1, event2;
471 { 469 {
472 CHECK_LIVE_EVENT (event1); 470 CHECK_LIVE_EVENT (event1);
473 if (NILP (event2)) 471 if (NILP (event2))
474 event2 = Fmake_event (); 472 event2 = Fmake_event ();
475 else CHECK_LIVE_EVENT (event2); 473 else CHECK_LIVE_EVENT (event2);
671 unsigned int m = 0; 669 unsigned int m = 0;
672 if (event->event_type == dead_event) 670 if (event->event_type == dead_event)
673 error ("character-to-event called with a deallocated event!"); 671 error ("character-to-event called with a deallocated event!");
674 672
675 c &= 255; 673 c &= 255;
676
677 if (c > 127 && c <= 255) 674 if (c > 127 && c <= 255)
678 { 675 {
679 int meta_flag = 1; 676 int meta_flag = 1;
680 if (use_console_meta_flag && CONSOLE_TTY_P (con)) 677 if (use_console_meta_flag && CONSOLE_TTY_P (con))
681 meta_flag = TTY_FLAGS (con).meta_key; 678 meta_flag = TTY_FLAGS (con).meta_key;
788 c |= 0200; 785 c |= 0200;
789 } 786 }
790 return c; 787 return c;
791 } 788 }
792 789
793 790 DEFUN ("event-to-character", Fevent_to_character, 1, 4, 0, /*
794 DEFUN ("event-to-character", Fevent_to_character, Sevent_to_character,
795 1, 4, 0 /*
796 Return the closest ASCII approximation to the given event object. 791 Return the closest ASCII approximation to the given event object.
797 If the event isn't a keypress, this returns nil. 792 If the event isn't a keypress, this returns nil.
798 If the ALLOW-EXTRA-MODIFIERS argument is non-nil, then this is lenient in 793 If the ALLOW-EXTRA-MODIFIERS argument is non-nil, then this is lenient in
799 its translation; it will ignore modifier keys other than control and meta, 794 its translation; it will ignore modifier keys other than control and meta,
800 and will ignore the shift modifier on those characters which have no 795 and will ignore the shift modifier on those characters which have no
807 present in the prevailing character set (see the `character-set-property' 802 present in the prevailing character set (see the `character-set-property'
808 variable) will be returned as their code in that character set, instead of 803 variable) will be returned as their code in that character set, instead of
809 the return value being restricted to ASCII. 804 the return value being restricted to ASCII.
810 Note that specifying both ALLOW-META and ALLOW-NON-ASCII is ambiguous, as 805 Note that specifying both ALLOW-META and ALLOW-NON-ASCII is ambiguous, as
811 both use the high bit; `M-x' and `oslash' will be indistinguishable. 806 both use the high bit; `M-x' and `oslash' will be indistinguishable.
812 */ ) 807 */
813 (event, allow_extra_modifiers, allow_meta, allow_non_ascii) 808 (event, allow_extra_modifiers, allow_meta, allow_non_ascii))
814 Lisp_Object event, allow_extra_modifiers, allow_meta, allow_non_ascii;
815 { 809 {
816 Emchar c; 810 Emchar c;
817 CHECK_LIVE_EVENT (event); 811 CHECK_LIVE_EVENT (event);
818 c = event_to_character (XEVENT (event), 812 c = event_to_character (XEVENT (event),
819 !NILP (allow_extra_modifiers), 813 !NILP (allow_extra_modifiers),
820 !NILP (allow_meta), 814 !NILP (allow_meta),
821 !NILP (allow_non_ascii)); 815 !NILP (allow_non_ascii));
822 return (c < 0 ? Qnil : make_char (c)); 816 return (c < 0 ? Qnil : make_char (c));
823 } 817 }
824 818
825 DEFUN ("character-to-event", Fcharacter_to_event, Scharacter_to_event, 819 DEFUN ("character-to-event", Fcharacter_to_event, 1, 4, 0, /*
826 1, 4, 0 /*
827 Converts a keystroke specifier into an event structure, replete with 820 Converts a keystroke specifier into an event structure, replete with
828 bucky bits. The keystroke is the first argument, and the event to fill 821 bucky bits. The keystroke is the first argument, and the event to fill
829 in is the second. This function contains knowledge about what the codes 822 in is the second. This function contains knowledge about what the codes
830 ``mean'' -- for example, the number 9 is converted to the character ``Tab'', 823 ``mean'' -- for example, the number 9 is converted to the character ``Tab'',
831 not the distinct character ``Control-I''. 824 not the distinct character ``Control-I''.
848 in a list containing the character. 841 in a list containing the character.
849 842
850 Beware that character-to-event and event-to-character are not strictly 843 Beware that character-to-event and event-to-character are not strictly
851 inverse functions, since events contain much more information than the 844 inverse functions, since events contain much more information than the
852 ASCII character set can encode. 845 ASCII character set can encode.
853 */ ) 846 */
854 (ch, event, console, use_console_meta_flag) 847 (ch, event, console, use_console_meta_flag))
855 Lisp_Object ch, event, console, use_console_meta_flag;
856 { 848 {
857 struct console *con = decode_console (console); 849 struct console *con = decode_console (console);
858 if (NILP (event)) 850 if (NILP (event))
859 event = Fmake_event (); 851 event = Fmake_event ();
860 else 852 else
1023 abort (); 1015 abort ();
1024 if (mouse_p) 1016 if (mouse_p)
1025 strncpy (buf, "up", 4); 1017 strncpy (buf, "up", 4);
1026 } 1018 }
1027 1019
1028 DEFUN ("eventp", Feventp, Seventp, 1, 1, 0 /* 1020 DEFUN ("eventp", Feventp, 1, 1, 0, /*
1029 True if OBJECT is an event object. 1021 True if OBJECT is an event object.
1030 */ ) 1022 */
1031 (object) 1023 (object))
1032 Lisp_Object object;
1033 { 1024 {
1034 return ((EVENTP (object)) ? Qt : Qnil); 1025 return ((EVENTP (object)) ? Qt : Qnil);
1035 } 1026 }
1036 1027
1037 DEFUN ("event-live-p", Fevent_live_p, Sevent_live_p, 1, 1, 0 /* 1028 DEFUN ("event-live-p", Fevent_live_p, 1, 1, 0, /*
1038 True if OBJECT is an event object that has not been deallocated. 1029 True if OBJECT is an event object that has not been deallocated.
1039 */ ) 1030 */
1040 (object) 1031 (object))
1041 Lisp_Object object;
1042 { 1032 {
1043 return ((EVENTP (object) && XEVENT (object)->event_type != dead_event) 1033 return ((EVENTP (object) && XEVENT (object)->event_type != dead_event)
1044 ? Qt : Qnil); 1034 ? Qt : Qnil);
1045 } 1035 }
1046 1036
1090 return (next_event); 1080 return (next_event);
1091 } 1081 }
1092 1082
1093 #endif /* 0 */ 1083 #endif /* 0 */
1094 1084
1095 DEFUN ("event-type", Fevent_type, Sevent_type, 1, 1, 0 /* 1085 DEFUN ("event-type", Fevent_type, 1, 1, 0, /*
1096 Return the type of EVENT. 1086 Return the type of EVENT.
1097 This will be a symbol; one of 1087 This will be a symbol; one of
1098 1088
1099 key-press A key was pressed. 1089 key-press A key was pressed.
1100 button-press A mouse button was pressed. 1090 button-press A mouse button was pressed.
1104 motion The mouse moved. 1094 motion The mouse moved.
1105 process Input is available from a subprocess. 1095 process Input is available from a subprocess.
1106 timeout A timeout has expired. 1096 timeout A timeout has expired.
1107 eval This causes a specified action to occur when dispatched. 1097 eval This causes a specified action to occur when dispatched.
1108 magic Some window-system-specific event has occurred. 1098 magic Some window-system-specific event has occurred.
1109 */ ) 1099 */
1110 (event) 1100 (event))
1111 Lisp_Object event;
1112 { 1101 {
1113 CHECK_LIVE_EVENT (event); 1102 CHECK_LIVE_EVENT (event);
1114 switch (XEVENT (event)->event_type) 1103 switch (XEVENT (event)->event_type)
1115 { 1104 {
1116 case key_press_event: 1105 case key_press_event:
1145 abort (); 1134 abort ();
1146 return Qnil; 1135 return Qnil;
1147 } 1136 }
1148 } 1137 }
1149 1138
1150 DEFUN ("event-timestamp", Fevent_timestamp, Sevent_timestamp, 1, 1, 0 /* 1139 DEFUN ("event-timestamp", Fevent_timestamp, 1, 1, 0, /*
1151 Return the timestamp of the given event object. 1140 Return the timestamp of the given event object.
1152 */ ) 1141 */
1153 (event) 1142 (event))
1154 Lisp_Object event;
1155 { 1143 {
1156 CHECK_LIVE_EVENT (event); 1144 CHECK_LIVE_EVENT (event);
1157 /* This junk is so that timestamps don't get to be negative, but contain 1145 /* This junk is so that timestamps don't get to be negative, but contain
1158 as many bits as this particular emacs will allow. 1146 as many bits as this particular emacs will allow.
1159 */ 1147 */
1171 { CHECK_LIVE_EVENT (e); \ 1159 { CHECK_LIVE_EVENT (e); \
1172 if (XEVENT(e)->event_type != (t1) && XEVENT(e)->event_type != (t2)) \ 1160 if (XEVENT(e)->event_type != (t1) && XEVENT(e)->event_type != (t2)) \
1173 e = wrong_type_argument ((sym),(e)); \ 1161 e = wrong_type_argument ((sym),(e)); \
1174 } 1162 }
1175 1163
1176 DEFUN ("event-key", Fevent_key, Sevent_key, 1, 1, 0 /* 1164 DEFUN ("event-key", Fevent_key, 1, 1, 0, /*
1177 Return the Keysym of the given key-press event. 1165 Return the Keysym of the given key-press event.
1178 This will be the ASCII code of a printing character, or a symbol. 1166 This will be the ASCII code of a printing character, or a symbol.
1179 */ ) 1167 */
1180 (event) 1168 (event))
1181 Lisp_Object event;
1182 { 1169 {
1183 CHECK_EVENT_TYPE (event, key_press_event, Qkey_press_event_p); 1170 CHECK_EVENT_TYPE (event, key_press_event, Qkey_press_event_p);
1184 return (XEVENT (event)->event.key.keysym); 1171 return (XEVENT (event)->event.key.keysym);
1185 } 1172 }
1186 1173
1187 DEFUN ("event-button", Fevent_button, Sevent_button, 1, 1, 0 /* 1174 DEFUN ("event-button", Fevent_button, 1, 1, 0, /*
1188 Return the button-number of the given mouse-button-press event. 1175 Return the button-number of the given mouse-button-press event.
1189 */ ) 1176 */
1190 (event) 1177 (event))
1191 Lisp_Object event;
1192 { 1178 {
1193 CHECK_EVENT_TYPE2 (event, button_press_event, button_release_event, 1179 CHECK_EVENT_TYPE2 (event, button_press_event, button_release_event,
1194 Qbutton_event_p); 1180 Qbutton_event_p);
1195 #ifdef HAVE_WINDOW_SYSTEM 1181 #ifdef HAVE_WINDOW_SYSTEM
1196 return make_int (XEVENT (event)->event.button.button); 1182 return make_int (XEVENT (event)->event.button.button);
1197 #else /* !HAVE_WINDOW_SYSTEM */ 1183 #else /* !HAVE_WINDOW_SYSTEM */
1198 return Qzero; 1184 return Qzero;
1199 #endif /* !HAVE_WINDOW_SYSTEM */ 1185 #endif /* !HAVE_WINDOW_SYSTEM */
1200 } 1186 }
1201 1187
1202 DEFUN ("event-modifier-bits", Fevent_modifier_bits, Sevent_modifier_bits, 1188 DEFUN ("event-modifier-bits", Fevent_modifier_bits, 1, 1, 0, /*
1203 1, 1, 0 /*
1204 Return a number representing the modifier keys which were down 1189 Return a number representing the modifier keys which were down
1205 when the given mouse or keyboard event was produced. See also the function 1190 when the given mouse or keyboard event was produced. See also the function
1206 event-modifiers. 1191 event-modifiers.
1207 */ ) 1192 */
1208 (event) 1193 (event))
1209 Lisp_Object event;
1210 { 1194 {
1211 again: 1195 again:
1212 CHECK_LIVE_EVENT (event); 1196 CHECK_LIVE_EVENT (event);
1213 if (XEVENT (event)->event_type == key_press_event) 1197 if (XEVENT (event)->event_type == key_press_event)
1214 return make_int (XEVENT (event)->event.key.modifiers); 1198 return make_int (XEVENT (event)->event.key.modifiers);
1222 event = wrong_type_argument (intern ("key-or-mouse-event-p"), event); 1206 event = wrong_type_argument (intern ("key-or-mouse-event-p"), event);
1223 goto again; 1207 goto again;
1224 } 1208 }
1225 } 1209 }
1226 1210
1227 DEFUN ("event-modifiers", Fevent_modifiers, Sevent_modifiers, 1, 1, 0 /* 1211 DEFUN ("event-modifiers", Fevent_modifiers, 1, 1, 0, /*
1228 Return a list of symbols, the names of the modifier keys 1212 Return a list of symbols, the names of the modifier keys
1229 which were down when the given mouse or keyboard event was produced. 1213 which were down when the given mouse or keyboard event was produced.
1230 See also the function event-modifier-bits. 1214 See also the function event-modifier-bits.
1231 */ ) 1215 */
1232 (event) 1216 (event))
1233 Lisp_Object event;
1234 { 1217 {
1235 int mod = XINT (Fevent_modifier_bits (event)); 1218 int mod = XINT (Fevent_modifier_bits (event));
1236 Lisp_Object result = Qnil; 1219 Lisp_Object result = Qnil;
1237 if (mod & MOD_SHIFT) result = Fcons (Qshift, result); 1220 if (mod & MOD_SHIFT) result = Fcons (Qshift, result);
1238 if (mod & MOD_ALT) result = Fcons (Qalt, result); 1221 if (mod & MOD_ALT) result = Fcons (Qalt, result);
1282 } 1265 }
1283 1266
1284 return 1; 1267 return 1;
1285 } 1268 }
1286 1269
1287 DEFUN ("event-window-x-pixel", Fevent_window_x_pixel, Sevent_window_x_pixel, 1270 DEFUN ("event-window-x-pixel", Fevent_window_x_pixel, 1, 1, 0, /*
1288 1, 1, 0 /*
1289 Return the X position in pixels of the given mouse event. 1271 Return the X position in pixels of the given mouse event.
1290 The value returned is relative to the window the event occurred in. 1272 The value returned is relative to the window the event occurred in.
1291 This will signal an error if the event is not a mouse-motion, button-press, 1273 This will signal an error if the event is not a mouse-motion, button-press,
1292 or button-release event. See also `event-x-pixel'. 1274 or button-release event. See also `event-x-pixel'.
1293 */ ) 1275 */
1294 (event) 1276 (event))
1295 Lisp_Object event;
1296 { 1277 {
1297 int x, y; 1278 int x, y;
1298 1279
1299 CHECK_LIVE_EVENT (event); 1280 CHECK_LIVE_EVENT (event);
1300 1281
1302 return wrong_type_argument (Qmouse_event_p, event); 1283 return wrong_type_argument (Qmouse_event_p, event);
1303 else 1284 else
1304 return make_int (x); 1285 return make_int (x);
1305 } 1286 }
1306 1287
1307 DEFUN ("event-window-y-pixel", Fevent_window_y_pixel, Sevent_window_y_pixel, 1288 DEFUN ("event-window-y-pixel", Fevent_window_y_pixel, 1, 1, 0, /*
1308 1, 1, 0 /*
1309 Return the Y position in pixels of the given mouse event. 1289 Return the Y position in pixels of the given mouse event.
1310 The value returned is relative to the window the event occurred in. 1290 The value returned is relative to the window the event occurred in.
1311 This will signal an error if the event is not a mouse-motion, button-press, 1291 This will signal an error if the event is not a mouse-motion, button-press,
1312 or button-release event. See also `event-y-pixel'. 1292 or button-release event. See also `event-y-pixel'.
1313 */ ) 1293 */
1314 (event) 1294 (event))
1315 Lisp_Object event;
1316 { 1295 {
1317 int x, y; 1296 int x, y;
1318 1297
1319 CHECK_LIVE_EVENT (event); 1298 CHECK_LIVE_EVENT (event);
1320 1299
1322 return wrong_type_argument (Qmouse_event_p, event); 1301 return wrong_type_argument (Qmouse_event_p, event);
1323 else 1302 else
1324 return make_int (y); 1303 return make_int (y);
1325 } 1304 }
1326 1305
1327 DEFUN ("event-x-pixel", Fevent_x_pixel, Sevent_x_pixel, 1306 DEFUN ("event-x-pixel", Fevent_x_pixel, 1, 1, 0, /*
1328 1, 1, 0 /*
1329 Return the X position in pixels of the given mouse event. 1307 Return the X position in pixels of the given mouse event.
1330 The value returned is relative to the frame the event occurred in. 1308 The value returned is relative to the frame the event occurred in.
1331 This will signal an error if the event is not a mouse-motion, button-press, 1309 This will signal an error if the event is not a mouse-motion, button-press,
1332 or button-release event. See also `event-window-x-pixel'. 1310 or button-release event. See also `event-window-x-pixel'.
1333 */ ) 1311 */
1334 (event) 1312 (event))
1335 Lisp_Object event;
1336 { 1313 {
1337 int x, y; 1314 int x, y;
1338 1315
1339 CHECK_LIVE_EVENT (event); 1316 CHECK_LIVE_EVENT (event);
1340 1317
1342 return wrong_type_argument (Qmouse_event_p, event); 1319 return wrong_type_argument (Qmouse_event_p, event);
1343 else 1320 else
1344 return make_int (x); 1321 return make_int (x);
1345 } 1322 }
1346 1323
1347 DEFUN ("event-y-pixel", Fevent_y_pixel, Sevent_y_pixel, 1324 DEFUN ("event-y-pixel", Fevent_y_pixel, 1, 1, 0, /*
1348 1, 1, 0 /*
1349 Return the Y position in pixels of the given mouse event. 1325 Return the Y position in pixels of the given mouse event.
1350 The value returned is relative to the frame the event occurred in. 1326 The value returned is relative to the frame the event occurred in.
1351 This will signal an error if the event is not a mouse-motion, button-press, 1327 This will signal an error if the event is not a mouse-motion, button-press,
1352 or button-release event. See also `event-window-y-pixel'. 1328 or button-release event. See also `event-window-y-pixel'.
1353 */ ) 1329 */
1354 (event) 1330 (event))
1355 Lisp_Object event;
1356 { 1331 {
1357 int x, y; 1332 int x, y;
1358 1333
1359 CHECK_LIVE_EVENT (event); 1334 CHECK_LIVE_EVENT (event);
1360 1335
1470 *obj2 = ret_obj2; 1445 *obj2 = ret_obj2;
1471 1446
1472 return result; 1447 return result;
1473 } 1448 }
1474 1449
1475 DEFUN ("event-over-text-area-p", Fevent_over_text_area_p, 1450 DEFUN ("event-over-text-area-p", Fevent_over_text_area_p, 1, 1, 0, /*
1476 Sevent_over_text_area_p, 1, 1, 0 /*
1477 Return whether the given mouse event occurred over the text area of a window. 1451 Return whether the given mouse event occurred over the text area of a window.
1478 The modeline is not considered to be part of the text area. 1452 The modeline is not considered to be part of the text area.
1479 */ ) 1453 */
1480 (event) 1454 (event))
1481 Lisp_Object event;
1482 { 1455 {
1483 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 1456 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1484 1457
1485 if (result == OVER_TEXT || result == OVER_NOTHING) 1458 if (result == OVER_TEXT || result == OVER_NOTHING)
1486 return Qt; 1459 return Qt;
1487 else 1460 else
1488 return Qnil; 1461 return Qnil;
1489 } 1462 }
1490 1463
1491 DEFUN ("event-over-modeline-p", Fevent_over_modeline_p, Sevent_over_modeline_p, 1464 DEFUN ("event-over-modeline-p", Fevent_over_modeline_p, 1, 1, 0, /*
1492 1, 1, 0 /*
1493 Return whether the given mouse event occurred over the modeline of a window. 1465 Return whether the given mouse event occurred over the modeline of a window.
1494 */ ) 1466 */
1495 (event) 1467 (event))
1496 Lisp_Object event;
1497 { 1468 {
1498 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 1469 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1499 1470
1500 if (result == OVER_MODELINE) 1471 if (result == OVER_MODELINE)
1501 return Qt; 1472 return Qt;
1502 else 1473 else
1503 return Qnil; 1474 return Qnil;
1504 } 1475 }
1505 1476
1506 DEFUN ("event-over-border-p", Fevent_over_border_p, Sevent_over_border_p, 1477 DEFUN ("event-over-border-p", Fevent_over_border_p, 1, 1, 0, /*
1507 1, 1, 0 /*
1508 Return whether the given mouse event occurred over an internal border. 1478 Return whether the given mouse event occurred over an internal border.
1509 */ ) 1479 */
1510 (event) 1480 (event))
1511 Lisp_Object event;
1512 { 1481 {
1513 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 1482 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1514 1483
1515 if (result == OVER_BORDER) 1484 if (result == OVER_BORDER)
1516 return Qt; 1485 return Qt;
1517 else 1486 else
1518 return Qnil; 1487 return Qnil;
1519 } 1488 }
1520 1489
1521 DEFUN ("event-over-toolbar-p", Fevent_over_toolbar_p, Sevent_over_toolbar_p, 1490 DEFUN ("event-over-toolbar-p", Fevent_over_toolbar_p, 1, 1, 0, /*
1522 1, 1, 0 /*
1523 Return whether the given mouse event occurred over a toolbar. 1491 Return whether the given mouse event occurred over a toolbar.
1524 */ ) 1492 */
1525 (event) 1493 (event))
1526 Lisp_Object event;
1527 { 1494 {
1528 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 1495 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1529 1496
1530 if (result == OVER_TOOLBAR) 1497 if (result == OVER_TOOLBAR)
1531 return Qt; 1498 return Qt;
1543 console = Vselected_console; 1510 console = Vselected_console;
1544 1511
1545 return XCONSOLE (console); 1512 return XCONSOLE (console);
1546 } 1513 }
1547 1514
1548 DEFUN ("event-channel", Fevent_channel, Sevent_channel, 1, 1, 0 /* 1515 DEFUN ("event-channel", Fevent_channel, 1, 1, 0, /*
1549 Return the channel that the given event occurred on. 1516 Return the channel that the given event occurred on.
1550 This will be a frame, device, console, or nil for some types 1517 This will be a frame, device, console, or nil for some types
1551 of events (e.g. eval events). 1518 of events (e.g. eval events).
1552 */ ) 1519 */
1553 (event) 1520 (event))
1554 Lisp_Object event;
1555 { 1521 {
1556 CHECK_LIVE_EVENT (event); 1522 CHECK_LIVE_EVENT (event);
1557 return EVENT_CHANNEL (XEVENT (event)); 1523 return EVENT_CHANNEL (XEVENT (event));
1558 } 1524 }
1559 1525
1560 DEFUN ("event-window", Fevent_window, Sevent_window, 1, 1, 0 /* 1526 DEFUN ("event-window", Fevent_window, 1, 1, 0, /*
1561 Return the window of the given mouse event. 1527 Return the window of the given mouse event.
1562 This may be nil if the event occurred in the border or over a toolbar. 1528 This may be nil if the event occurred in the border or over a toolbar.
1563 The modeline is considered to be in the window it represents. 1529 The modeline is considered to be in the window it represents.
1564 */ ) 1530 */
1565 (event) 1531 (event))
1566 Lisp_Object event;
1567 { 1532 {
1568 struct window *w; 1533 struct window *w;
1569 Lisp_Object window; 1534 Lisp_Object window;
1570 1535
1571 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, 0); 1536 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, 0);
1577 XSETWINDOW (window, w); 1542 XSETWINDOW (window, w);
1578 return window; 1543 return window;
1579 } 1544 }
1580 } 1545 }
1581 1546
1582 DEFUN ("event-point", Fevent_point, Sevent_point, 1, 1, 0 /* 1547 DEFUN ("event-point", Fevent_point, 1, 1, 0, /*
1583 Return the character position of the given mouse event. 1548 Return the character position of the given mouse event.
1584 If the event did not occur over a window, or did not occur over text, 1549 If the event did not occur over a window, or did not occur over text,
1585 then this returns nil. Otherwise, it returns an index into the buffer 1550 then this returns nil. Otherwise, it returns an index into the buffer
1586 visible in the event's window. 1551 visible in the event's window.
1587 */ ) 1552 */
1588 (event) 1553 (event))
1589 Lisp_Object event;
1590 { 1554 {
1591 Bufpos bufp; 1555 Bufpos bufp;
1592 struct window *w; 1556 struct window *w;
1593 1557
1594 event_pixel_translation (event, 0, 0, 0, 0, &w, &bufp, 0, 0, 0, 0); 1558 event_pixel_translation (event, 0, 0, 0, 0, &w, &bufp, 0, 0, 0, 0);
1599 return Qnil; 1563 return Qnil;
1600 else 1564 else
1601 return make_int (bufp); 1565 return make_int (bufp);
1602 } 1566 }
1603 1567
1604 DEFUN ("event-closest-point", Fevent_closest_point, Sevent_closest_point, 1568 DEFUN ("event-closest-point", Fevent_closest_point, 1, 1, 0, /*
1605 1, 1, 0 /*
1606 Return the character position of the given mouse event. 1569 Return the character position of the given mouse event.
1607 If the event did not occur over a window or over text, return the 1570 If the event did not occur over a window or over text, return the
1608 closest point to the location of the event. If the Y pixel position 1571 closest point to the location of the event. If the Y pixel position
1609 overlaps a window and the X pixel position is to the left of that 1572 overlaps a window and the X pixel position is to the left of that
1610 window, the closest point is the beginning of the line containing the 1573 window, the closest point is the beginning of the line containing the
1611 Y position. If the Y pixel position overlaps a window and the X pixel 1574 Y position. If the Y pixel position overlaps a window and the X pixel
1612 position is to the right of that window, the closest point is the end 1575 position is to the right of that window, the closest point is the end
1613 of the line containing the Y position. If the Y pixel position is 1576 of the line containing the Y position. If the Y pixel position is
1614 above a window, return 0. If it is below a window, return the value 1577 above a window, return 0. If it is below a window, return the value
1615 of (window-end). 1578 of (window-end).
1616 */ ) 1579 */
1617 (event) 1580 (event))
1618 Lisp_Object event;
1619 { 1581 {
1620 Bufpos bufp; 1582 Bufpos bufp;
1621 1583
1622 event_pixel_translation (event, 0, 0, 0, 0, 0, 0, &bufp, 0, 0, 0); 1584 event_pixel_translation (event, 0, 0, 0, 0, 0, 0, &bufp, 0, 0, 0);
1623 1585
1625 return Qnil; 1587 return Qnil;
1626 else 1588 else
1627 return make_int (bufp); 1589 return make_int (bufp);
1628 } 1590 }
1629 1591
1630 DEFUN ("event-x", Fevent_x, Sevent_x, 1, 1, 0 /* 1592 DEFUN ("event-x", Fevent_x, 1, 1, 0, /*
1631 Return the X position of the given mouse event in characters. 1593 Return the X position of the given mouse event in characters.
1632 This is relative to the window the event occurred over. 1594 This is relative to the window the event occurred over.
1633 */ ) 1595 */
1634 (event) 1596 (event))
1635 Lisp_Object event;
1636 { 1597 {
1637 int char_x; 1598 int char_x;
1638 1599
1639 event_pixel_translation (event, &char_x, 0, 0, 0, 0, 0, 0, 0, 0, 0); 1600 event_pixel_translation (event, &char_x, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1640 1601
1641 return make_int (char_x); 1602 return make_int (char_x);
1642 } 1603 }
1643 1604
1644 DEFUN ("event-y", Fevent_y, Sevent_y, 1, 1, 0 /* 1605 DEFUN ("event-y", Fevent_y, 1, 1, 0, /*
1645 Return the Y position of the given mouse event in characters. 1606 Return the Y position of the given mouse event in characters.
1646 This is relative to the window the event occurred over. 1607 This is relative to the window the event occurred over.
1647 */ ) 1608 */
1648 (event) 1609 (event))
1649 Lisp_Object event;
1650 { 1610 {
1651 int char_y; 1611 int char_y;
1652 1612
1653 event_pixel_translation (event, 0, &char_y, 0, 0, 0, 0, 0, 0, 0, 0); 1613 event_pixel_translation (event, 0, &char_y, 0, 0, 0, 0, 0, 0, 0, 0);
1654 1614
1655 return make_int (char_y); 1615 return make_int (char_y);
1656 } 1616 }
1657 1617
1658 DEFUN ("event-modeline-position", Fevent_modeline_position, 1618 DEFUN ("event-modeline-position", Fevent_modeline_position, 1, 1, 0, /*
1659 Sevent_modeline_position, 1, 1, 0 /*
1660 Return the character position in the modeline that EVENT occurred over. 1619 Return the character position in the modeline that EVENT occurred over.
1661 EVENT should be a mouse event. If EVENT did not occur over a modeline, 1620 EVENT should be a mouse event. If EVENT did not occur over a modeline,
1662 nil is returned. You can determine the actual character that the 1621 nil is returned. You can determine the actual character that the
1663 event occurred over by looking in `generated-modeline-string' at the 1622 event occurred over by looking in `generated-modeline-string' at the
1664 returned character position. Note that `generated-modeline-string' 1623 returned character position. Note that `generated-modeline-string'
1665 is buffer-local, and you must use EVENT's buffer when retrieving 1624 is buffer-local, and you must use EVENT's buffer when retrieving
1666 `generated-modeline-string' in order to get accurate results. 1625 `generated-modeline-string' in order to get accurate results.
1667 */ ) 1626 */
1668 (event) 1627 (event))
1669 Lisp_Object event;
1670 { 1628 {
1671 Charcount mbufp; 1629 Charcount mbufp;
1672 1630
1673 event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, &mbufp, 0, 0); 1631 event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, &mbufp, 0, 0);
1674 1632
1676 return Qnil; 1634 return Qnil;
1677 else 1635 else
1678 return make_int (mbufp); 1636 return make_int (mbufp);
1679 } 1637 }
1680 1638
1681 DEFUN ("event-glyph", Fevent_glyph, Sevent_glyph, 1639 DEFUN ("event-glyph", Fevent_glyph, 1, 1, 0, /*
1682 1, 1, 0 /*
1683 Return the glyph that the given mouse event occurred over, or nil. 1640 Return the glyph that the given mouse event occurred over, or nil.
1684 */ ) 1641 */
1685 (event) 1642 (event))
1686 Lisp_Object event;
1687 { 1643 {
1688 Lisp_Object glyph; 1644 Lisp_Object glyph;
1689 struct window *w; 1645 struct window *w;
1690 1646
1691 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, &glyph, 0); 1647 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, &glyph, 0);
1696 return glyph; 1652 return glyph;
1697 else 1653 else
1698 return Qnil; 1654 return Qnil;
1699 } 1655 }
1700 1656
1701 DEFUN ("event-glyph-extent", Fevent_glyph_extent, Sevent_glyph_extent, 1657 DEFUN ("event-glyph-extent", Fevent_glyph_extent, 1, 1, 0, /*
1702 1, 1, 0 /*
1703 Return the extent of the glyph that the given mouse event occurred over. 1658 Return the extent of the glyph that the given mouse event occurred over.
1704 If the event did not occur over a glyph, nil is returned. 1659 If the event did not occur over a glyph, nil is returned.
1705 */ ) 1660 */
1706 (event) 1661 (event))
1707 Lisp_Object event;
1708 { 1662 {
1709 Lisp_Object extent; 1663 Lisp_Object extent;
1710 struct window *w; 1664 struct window *w;
1711 1665
1712 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, &extent); 1666 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, &extent);
1717 return extent; 1671 return extent;
1718 else 1672 else
1719 return Qnil; 1673 return Qnil;
1720 } 1674 }
1721 1675
1722 DEFUN ("event-glyph-x-pixel", Fevent_glyph_x_pixel, Sevent_glyph_x_pixel, 1676 DEFUN ("event-glyph-x-pixel", Fevent_glyph_x_pixel, 1, 1, 0, /*
1723 1, 1, 0 /*
1724 Return the X pixel position of EVENT relative to the glyph it occurred over. 1677 Return the X pixel position of EVENT relative to the glyph it occurred over.
1725 EVENT should be a mouse event. If the event did not occur over a glyph, 1678 EVENT should be a mouse event. If the event did not occur over a glyph,
1726 nil is returned. 1679 nil is returned.
1727 */ ) 1680 */
1728 (event) 1681 (event))
1729 Lisp_Object event;
1730 { 1682 {
1731 Lisp_Object extent; 1683 Lisp_Object extent;
1732 struct window *w; 1684 struct window *w;
1733 int obj_x; 1685 int obj_x;
1734 1686
1738 return make_int (obj_x); 1690 return make_int (obj_x);
1739 else 1691 else
1740 return Qnil; 1692 return Qnil;
1741 } 1693 }
1742 1694
1743 DEFUN ("event-glyph-y-pixel", Fevent_glyph_y_pixel, Sevent_glyph_y_pixel, 1695 DEFUN ("event-glyph-y-pixel", Fevent_glyph_y_pixel, 1, 1, 0, /*
1744 1, 1, 0 /*
1745 Return the Y pixel position of EVENT relative to the glyph it occurred over. 1696 Return the Y pixel position of EVENT relative to the glyph it occurred over.
1746 EVENT should be a mouse event. If the event did not occur over a glyph, 1697 EVENT should be a mouse event. If the event did not occur over a glyph,
1747 nil is returned. 1698 nil is returned.
1748 */ ) 1699 */
1749 (event) 1700 (event))
1750 Lisp_Object event;
1751 { 1701 {
1752 Lisp_Object extent; 1702 Lisp_Object extent;
1753 struct window *w; 1703 struct window *w;
1754 int obj_y; 1704 int obj_y;
1755 1705
1759 return make_int (obj_y); 1709 return make_int (obj_y);
1760 else 1710 else
1761 return Qnil; 1711 return Qnil;
1762 } 1712 }
1763 1713
1764 DEFUN ("event-toolbar-button", Fevent_toolbar_button, Sevent_toolbar_button, 1714 DEFUN ("event-toolbar-button", Fevent_toolbar_button, 1, 1, 0, /*
1765 1, 1, 0 /*
1766 Return the toolbar button that the given mouse event occurred over. 1715 Return the toolbar button that the given mouse event occurred over.
1767 If the event did not occur over a toolbar, nil is returned. 1716 If the event did not occur over a toolbar, nil is returned.
1768 */ ) 1717 */
1769 (event) 1718 (event))
1770 Lisp_Object event;
1771 { 1719 {
1772 #ifdef HAVE_TOOLBARS 1720 #ifdef HAVE_TOOLBARS
1773 Lisp_Object button; 1721 Lisp_Object button;
1774 int result; 1722 int result;
1775 1723
1785 else 1733 else
1786 #endif 1734 #endif
1787 return Qnil; 1735 return Qnil;
1788 } 1736 }
1789 1737
1790 DEFUN ("event-process", Fevent_process, Sevent_process, 1, 1, 0 /* 1738 DEFUN ("event-process", Fevent_process, 1, 1, 0, /*
1791 Return the process of the given process-output event. 1739 Return the process of the given process-output event.
1792 */ ) 1740 */
1793 (event) 1741 (event))
1794 Lisp_Object event;
1795 { 1742 {
1796 CHECK_EVENT_TYPE (event, process_event, Qprocess_event_p); 1743 CHECK_EVENT_TYPE (event, process_event, Qprocess_event_p);
1797 return (XEVENT (event)->event.process.process); 1744 return (XEVENT (event)->event.process.process);
1798 } 1745 }
1799 1746
1800 DEFUN ("event-function", Fevent_function, Sevent_function, 1, 1, 0 /* 1747 DEFUN ("event-function", Fevent_function, 1, 1, 0, /*
1801 Return the callback function of EVENT. 1748 Return the callback function of EVENT.
1802 EVENT should be a timeout, misc-user, or eval event. 1749 EVENT should be a timeout, misc-user, or eval event.
1803 */ ) 1750 */
1804 (event) 1751 (event))
1805 Lisp_Object event;
1806 { 1752 {
1807 CHECK_LIVE_EVENT (event); 1753 CHECK_LIVE_EVENT (event);
1808 switch (XEVENT (event)->event_type) 1754 switch (XEVENT (event)->event_type)
1809 { 1755 {
1810 case timeout_event: 1756 case timeout_event:
1815 default: 1761 default:
1816 return wrong_type_argument (intern ("timeout-or-eval-event-p"), event); 1762 return wrong_type_argument (intern ("timeout-or-eval-event-p"), event);
1817 } 1763 }
1818 } 1764 }
1819 1765
1820 DEFUN ("event-object", Fevent_object, Sevent_object, 1, 1, 0 /* 1766 DEFUN ("event-object", Fevent_object, 1, 1, 0, /*
1821 Return the callback function argument of EVENT. 1767 Return the callback function argument of EVENT.
1822 EVENT should be a timeout, misc-user, or eval event. 1768 EVENT should be a timeout, misc-user, or eval event.
1823 */ ) 1769 */
1824 (event) 1770 (event))
1825 Lisp_Object event;
1826 { 1771 {
1827 again: 1772 again:
1828 CHECK_LIVE_EVENT (event); 1773 CHECK_LIVE_EVENT (event);
1829 switch (XEVENT (event)->event_type) 1774 switch (XEVENT (event)->event_type)
1830 { 1775 {
1837 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event); 1782 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event);
1838 goto again; 1783 goto again;
1839 } 1784 }
1840 } 1785 }
1841 1786
1842 DEFUN ("event-properties", Fevent_properties, Sevent_properties, 1, 1, 0 /* 1787 DEFUN ("event-properties", Fevent_properties, 1, 1, 0, /*
1843 Return a list of all of the properties of EVENT. 1788 Return a list of all of the properties of EVENT.
1844 This is in the form of a property list (alternating keyword/value pairs). 1789 This is in the form of a property list (alternating keyword/value pairs).
1845 */ ) 1790 */
1846 (event) 1791 (event))
1847 Lisp_Object event;
1848 { 1792 {
1849 Lisp_Object props = Qnil; 1793 Lisp_Object props = Qnil;
1850 struct Lisp_Event *e; 1794 struct Lisp_Event *e;
1851 struct gcpro gcpro1; 1795 struct gcpro gcpro1;
1852 1796
1915 /************************************************************************/ 1859 /************************************************************************/
1916 1860
1917 void 1861 void
1918 syms_of_events (void) 1862 syms_of_events (void)
1919 { 1863 {
1920 defsubr (&Scharacter_to_event); 1864 DEFSUBR (Fcharacter_to_event);
1921 defsubr (&Sevent_to_character); 1865 DEFSUBR (Fevent_to_character);
1922 1866
1923 defsubr (&Smake_event); 1867 DEFSUBR (Fmake_event);
1924 defsubr (&Sdeallocate_event); 1868 DEFSUBR (Fdeallocate_event);
1925 defsubr (&Scopy_event); 1869 DEFSUBR (Fcopy_event);
1926 defsubr (&Seventp); 1870 DEFSUBR (Feventp);
1927 defsubr (&Sevent_live_p); 1871 DEFSUBR (Fevent_live_p);
1928 defsubr (&Sevent_type); 1872 DEFSUBR (Fevent_type);
1929 defsubr (&Sevent_properties); 1873 DEFSUBR (Fevent_properties);
1930 1874
1931 defsubr (&Sevent_timestamp); 1875 DEFSUBR (Fevent_timestamp);
1932 defsubr (&Sevent_key); 1876 DEFSUBR (Fevent_key);
1933 defsubr (&Sevent_button); 1877 DEFSUBR (Fevent_button);
1934 defsubr (&Sevent_modifier_bits); 1878 DEFSUBR (Fevent_modifier_bits);
1935 defsubr (&Sevent_modifiers); 1879 DEFSUBR (Fevent_modifiers);
1936 defsubr (&Sevent_x_pixel); 1880 DEFSUBR (Fevent_x_pixel);
1937 defsubr (&Sevent_y_pixel); 1881 DEFSUBR (Fevent_y_pixel);
1938 defsubr (&Sevent_window_x_pixel); 1882 DEFSUBR (Fevent_window_x_pixel);
1939 defsubr (&Sevent_window_y_pixel); 1883 DEFSUBR (Fevent_window_y_pixel);
1940 defsubr (&Sevent_over_text_area_p); 1884 DEFSUBR (Fevent_over_text_area_p);
1941 defsubr (&Sevent_over_modeline_p); 1885 DEFSUBR (Fevent_over_modeline_p);
1942 defsubr (&Sevent_over_border_p); 1886 DEFSUBR (Fevent_over_border_p);
1943 defsubr (&Sevent_over_toolbar_p); 1887 DEFSUBR (Fevent_over_toolbar_p);
1944 defsubr (&Sevent_channel); 1888 DEFSUBR (Fevent_channel);
1945 defsubr (&Sevent_window); 1889 DEFSUBR (Fevent_window);
1946 defsubr (&Sevent_point); 1890 DEFSUBR (Fevent_point);
1947 defsubr (&Sevent_closest_point); 1891 DEFSUBR (Fevent_closest_point);
1948 defsubr (&Sevent_x); 1892 DEFSUBR (Fevent_x);
1949 defsubr (&Sevent_y); 1893 DEFSUBR (Fevent_y);
1950 defsubr (&Sevent_modeline_position); 1894 DEFSUBR (Fevent_modeline_position);
1951 defsubr (&Sevent_glyph); 1895 DEFSUBR (Fevent_glyph);
1952 defsubr (&Sevent_glyph_extent); 1896 DEFSUBR (Fevent_glyph_extent);
1953 defsubr (&Sevent_glyph_x_pixel); 1897 DEFSUBR (Fevent_glyph_x_pixel);
1954 defsubr (&Sevent_glyph_y_pixel); 1898 DEFSUBR (Fevent_glyph_y_pixel);
1955 defsubr (&Sevent_toolbar_button); 1899 DEFSUBR (Fevent_toolbar_button);
1956 defsubr (&Sevent_process); 1900 DEFSUBR (Fevent_process);
1957 defsubr (&Sevent_function); 1901 DEFSUBR (Fevent_function);
1958 defsubr (&Sevent_object); 1902 DEFSUBR (Fevent_object);
1959 1903
1960 defsymbol (&Qeventp, "eventp"); 1904 defsymbol (&Qeventp, "eventp");
1961 defsymbol (&Qevent_live_p, "event-live-p"); 1905 defsymbol (&Qevent_live_p, "event-live-p");
1962 defsymbol (&Qkey_press_event_p, "key-press-event-p"); 1906 defsymbol (&Qkey_press_event_p, "key-press-event-p");
1963 defsymbol (&Qbutton_event_p, "button-event-p"); 1907 defsymbol (&Qbutton_event_p, "button-event-p");