Mercurial > hg > xemacs-beta
comparison src/events.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 | de805c49cfc1 |
comparison
equal
deleted
inserted
replaced
403:9f011ab08d48 | 404:2f8bb876ab1d |
---|---|
35 #include "frame.h" | 35 #include "frame.h" |
36 #include "glyphs.h" | 36 #include "glyphs.h" |
37 #include "keymap.h" /* for key_desc_list_to_event() */ | 37 #include "keymap.h" /* for key_desc_list_to_event() */ |
38 #include "redisplay.h" | 38 #include "redisplay.h" |
39 #include "window.h" | 39 #include "window.h" |
40 | |
41 #ifdef WINDOWSNT | |
42 /* Hmm, under unix we want X modifiers, under NT we want X modifiers if | |
43 we are running X and Windows modifiers otherwise. | |
44 gak. This is a kludge until we support multiple native GUIs! | |
45 */ | |
46 #undef MOD_ALT | |
47 #undef MOD_CONTROL | |
48 #undef MOD_SHIFT | |
49 #endif | |
50 | |
51 #include "events-mod.h" | 40 #include "events-mod.h" |
52 | 41 |
53 /* Where old events go when they are explicitly deallocated. | 42 /* Where old events go when they are explicitly deallocated. |
54 The event chain here is cut loose before GC, so these will be freed | 43 The event chain here is cut loose before GC, so these will be freed |
55 eventually. | 44 eventually. |
85 | 74 |
86 for (i = 0; i < (int) (sizeof (Lisp_Event) / sizeof (int)); i++) | 75 for (i = 0; i < (int) (sizeof (Lisp_Event) / sizeof (int)); i++) |
87 ((int *) event) [i] = 0xdeadbeef; | 76 ((int *) event) [i] = 0xdeadbeef; |
88 event->event_type = dead_event; | 77 event->event_type = dead_event; |
89 event->channel = Qnil; | 78 event->channel = Qnil; |
90 set_lheader_implementation (&(event->lheader), &lrecord_event); | 79 set_lheader_implementation (&event->lheader, &lrecord_event); |
91 XSET_EVENT_NEXT (ev, Qnil); | 80 XSET_EVENT_NEXT (ev, Qnil); |
92 } | 81 } |
93 | 82 |
94 /* Set everything to zero or nil so that it's predictable. */ | 83 /* Set everything to zero or nil so that it's predictable. */ |
95 void | 84 void |
96 zero_event (Lisp_Event *e) | 85 zero_event (Lisp_Event *e) |
97 { | 86 { |
98 xzero (*e); | 87 xzero (*e); |
99 set_lheader_implementation (&(e->lheader), &lrecord_event); | 88 set_lheader_implementation (&e->lheader, &lrecord_event); |
100 e->event_type = empty_event; | 89 e->event_type = empty_event; |
101 e->next = Qnil; | 90 e->next = Qnil; |
102 e->channel = Qnil; | 91 e->channel = Qnil; |
103 } | 92 } |
104 | 93 |
549 int modifiers = 0; | 538 int modifiers = 0; |
550 Lisp_Object sym; | 539 Lisp_Object sym; |
551 | 540 |
552 EXTERNAL_LIST_LOOP_2 (sym, value) | 541 EXTERNAL_LIST_LOOP_2 (sym, value) |
553 { | 542 { |
554 if (EQ (sym, Qcontrol)) modifiers |= MOD_CONTROL; | 543 if (EQ (sym, Qcontrol)) modifiers |= XEMACS_MOD_CONTROL; |
555 else if (EQ (sym, Qmeta)) modifiers |= MOD_META; | 544 else if (EQ (sym, Qmeta)) modifiers |= XEMACS_MOD_META; |
556 else if (EQ (sym, Qsuper)) modifiers |= MOD_SUPER; | 545 else if (EQ (sym, Qsuper)) modifiers |= XEMACS_MOD_SUPER; |
557 else if (EQ (sym, Qhyper)) modifiers |= MOD_HYPER; | 546 else if (EQ (sym, Qhyper)) modifiers |= XEMACS_MOD_HYPER; |
558 else if (EQ (sym, Qalt)) modifiers |= MOD_ALT; | 547 else if (EQ (sym, Qalt)) modifiers |= XEMACS_MOD_ALT; |
559 else if (EQ (sym, Qsymbol)) modifiers |= MOD_ALT; | 548 else if (EQ (sym, Qsymbol)) modifiers |= XEMACS_MOD_ALT; |
560 else if (EQ (sym, Qshift)) modifiers |= MOD_SHIFT; | 549 else if (EQ (sym, Qshift)) modifiers |= XEMACS_MOD_SHIFT; |
561 else | 550 else |
562 signal_simple_error ("Invalid key modifier", sym); | 551 signal_simple_error ("Invalid key modifier", sym); |
563 } | 552 } |
564 | 553 |
565 switch (e->event_type) | 554 switch (e->event_type) |
975 void | 964 void |
976 character_to_event (Emchar c, Lisp_Event *event, struct console *con, | 965 character_to_event (Emchar c, Lisp_Event *event, struct console *con, |
977 int use_console_meta_flag, int do_backspace_mapping) | 966 int use_console_meta_flag, int do_backspace_mapping) |
978 { | 967 { |
979 Lisp_Object k = Qnil; | 968 Lisp_Object k = Qnil; |
980 unsigned int m = 0; | 969 int m = 0; |
981 if (event->event_type == dead_event) | 970 if (event->event_type == dead_event) |
982 error ("character-to-event called with a deallocated event!"); | 971 error ("character-to-event called with a deallocated event!"); |
983 | 972 |
984 #ifndef MULE | 973 #ifndef MULE |
985 c &= 255; | 974 c &= 255; |
994 case 0: /* ignore top bit; it's parity */ | 983 case 0: /* ignore top bit; it's parity */ |
995 c -= 128; | 984 c -= 128; |
996 break; | 985 break; |
997 case 1: /* top bit is meta */ | 986 case 1: /* top bit is meta */ |
998 c -= 128; | 987 c -= 128; |
999 m = MOD_META; | 988 m = XEMACS_MOD_META; |
1000 break; | 989 break; |
1001 default: /* this is a real character */ | 990 default: /* this is a real character */ |
1002 break; | 991 break; |
1003 } | 992 } |
1004 } | 993 } |
1005 if (c < ' ') c += '@', m |= MOD_CONTROL; | 994 if (c < ' ') c += '@', m |= XEMACS_MOD_CONTROL; |
1006 if (m & MOD_CONTROL) | 995 if (m & XEMACS_MOD_CONTROL) |
1007 { | 996 { |
1008 switch (c) | 997 switch (c) |
1009 { | 998 { |
1010 case 'I': k = QKtab; m &= ~MOD_CONTROL; break; | 999 case 'I': k = QKtab; m &= ~XEMACS_MOD_CONTROL; break; |
1011 case 'J': k = QKlinefeed; m &= ~MOD_CONTROL; break; | 1000 case 'J': k = QKlinefeed; m &= ~XEMACS_MOD_CONTROL; break; |
1012 case 'M': k = QKreturn; m &= ~MOD_CONTROL; break; | 1001 case 'M': k = QKreturn; m &= ~XEMACS_MOD_CONTROL; break; |
1013 case '[': k = QKescape; m &= ~MOD_CONTROL; break; | 1002 case '[': k = QKescape; m &= ~XEMACS_MOD_CONTROL; break; |
1014 default: | 1003 default: |
1015 #if defined(HAVE_TTY) | 1004 #if defined(HAVE_TTY) |
1016 if (do_backspace_mapping && | 1005 if (do_backspace_mapping && |
1017 CHARP (con->tty_erase_char) && | 1006 CHARP (con->tty_erase_char) && |
1018 c - '@' == XCHAR (con->tty_erase_char)) | 1007 c - '@' == XCHAR (con->tty_erase_char)) |
1019 { | 1008 { |
1020 k = QKbackspace; | 1009 k = QKbackspace; |
1021 m &= ~MOD_CONTROL; | 1010 m &= ~XEMACS_MOD_CONTROL; |
1022 } | 1011 } |
1023 #endif /* defined(HAVE_TTY) && !defined(__CYGWIN32__) */ | 1012 #endif /* defined(HAVE_TTY) && !defined(__CYGWIN32__) */ |
1024 break; | 1013 break; |
1025 } | 1014 } |
1026 if (c >= 'A' && c <= 'Z') c -= 'A'-'a'; | 1015 if (c >= 'A' && c <= 'Z') c -= 'A'-'a'; |
1065 { | 1054 { |
1066 assert (event->event_type != dead_event); | 1055 assert (event->event_type != dead_event); |
1067 return -1; | 1056 return -1; |
1068 } | 1057 } |
1069 if (!allow_extra_modifiers && | 1058 if (!allow_extra_modifiers && |
1070 event->event.key.modifiers & (MOD_SUPER|MOD_HYPER|MOD_ALT)) | 1059 event->event.key.modifiers & (XEMACS_MOD_SUPER|XEMACS_MOD_HYPER|XEMACS_MOD_ALT)) |
1071 return -1; | 1060 return -1; |
1072 if (CHAR_OR_CHAR_INTP (event->event.key.keysym)) | 1061 if (CHAR_OR_CHAR_INTP (event->event.key.keysym)) |
1073 c = XCHAR_OR_CHAR_INT (event->event.key.keysym); | 1062 c = XCHAR_OR_CHAR_INT (event->event.key.keysym); |
1074 else if (!SYMBOLP (event->event.key.keysym)) | 1063 else if (!SYMBOLP (event->event.key.keysym)) |
1075 abort (); | 1064 abort (); |
1084 Qascii_character, Qnil))) | 1073 Qascii_character, Qnil))) |
1085 c = XCHAR_OR_CHAR_INT (code); | 1074 c = XCHAR_OR_CHAR_INT (code); |
1086 else | 1075 else |
1087 return -1; | 1076 return -1; |
1088 | 1077 |
1089 if (event->event.key.modifiers & MOD_CONTROL) | 1078 if (event->event.key.modifiers & XEMACS_MOD_CONTROL) |
1090 { | 1079 { |
1091 if (c >= 'a' && c <= 'z') | 1080 if (c >= 'a' && c <= 'z') |
1092 c -= ('a' - 'A'); | 1081 c -= ('a' - 'A'); |
1093 else | 1082 else |
1094 /* reject Control-Shift- keys */ | 1083 /* reject Control-Shift- keys */ |
1102 else | 1091 else |
1103 /* reject keys that can't take Control- modifiers */ | 1092 /* reject keys that can't take Control- modifiers */ |
1104 if (! allow_extra_modifiers) return -1; | 1093 if (! allow_extra_modifiers) return -1; |
1105 } | 1094 } |
1106 | 1095 |
1107 if (event->event.key.modifiers & MOD_META) | 1096 if (event->event.key.modifiers & XEMACS_MOD_META) |
1108 { | 1097 { |
1109 if (! allow_meta) return -1; | 1098 if (! allow_meta) return -1; |
1110 if (c & 0200) return -1; /* don't allow M-oslash (overlap) */ | 1099 if (c & 0200) return -1; /* don't allow M-oslash (overlap) */ |
1111 #ifdef MULE | 1100 #ifdef MULE |
1112 if (c >= 256) return -1; | 1101 if (c >= 256) return -1; |
1242 { | 1231 { |
1243 mod = event->event.key.modifiers; | 1232 mod = event->event.key.modifiers; |
1244 key = event->event.key.keysym; | 1233 key = event->event.key.keysym; |
1245 /* Hack. */ | 1234 /* Hack. */ |
1246 if (! brief && CHARP (key) && | 1235 if (! brief && CHARP (key) && |
1247 mod & (MOD_CONTROL | MOD_META | MOD_SUPER | MOD_HYPER)) | 1236 mod & (XEMACS_MOD_CONTROL | XEMACS_MOD_META | XEMACS_MOD_SUPER | XEMACS_MOD_HYPER)) |
1248 { | 1237 { |
1249 int k = XCHAR (key); | 1238 int k = XCHAR (key); |
1250 if (k >= 'a' && k <= 'z') | 1239 if (k >= 'a' && k <= 'z') |
1251 key = make_char (k - ('a' - 'A')); | 1240 key = make_char (k - ('a' - 'A')); |
1252 else if (k >= 'A' && k <= 'Z') | 1241 else if (k >= 'A' && k <= 'Z') |
1253 mod |= MOD_SHIFT; | 1242 mod |= XEMACS_MOD_SHIFT; |
1254 } | 1243 } |
1255 break; | 1244 break; |
1256 } | 1245 } |
1257 case button_release_event: | 1246 case button_release_event: |
1258 mouse_p++; | 1247 mouse_p++; |
1290 default: | 1279 default: |
1291 abort (); | 1280 abort (); |
1292 } | 1281 } |
1293 #define modprint1(x) do { strcpy (buf, (x)); buf += sizeof (x)-1; } while (0) | 1282 #define modprint1(x) do { strcpy (buf, (x)); buf += sizeof (x)-1; } while (0) |
1294 #define modprint(x,y) do { if (brief) modprint1 (y); else modprint1 (x); } while (0) | 1283 #define modprint(x,y) do { if (brief) modprint1 (y); else modprint1 (x); } while (0) |
1295 if (mod & MOD_CONTROL) modprint ("control-", "C-"); | 1284 if (mod & XEMACS_MOD_CONTROL) modprint ("control-", "C-"); |
1296 if (mod & MOD_META) modprint ("meta-", "M-"); | 1285 if (mod & XEMACS_MOD_META) modprint ("meta-", "M-"); |
1297 if (mod & MOD_SUPER) modprint ("super-", "S-"); | 1286 if (mod & XEMACS_MOD_SUPER) modprint ("super-", "S-"); |
1298 if (mod & MOD_HYPER) modprint ("hyper-", "H-"); | 1287 if (mod & XEMACS_MOD_HYPER) modprint ("hyper-", "H-"); |
1299 if (mod & MOD_ALT) modprint ("alt-", "A-"); | 1288 if (mod & XEMACS_MOD_ALT) modprint ("alt-", "A-"); |
1300 if (mod & MOD_SHIFT) modprint ("shift-", "Sh-"); | 1289 if (mod & XEMACS_MOD_SHIFT) modprint ("shift-", "Sh-"); |
1301 if (mouse_p) | 1290 if (mouse_p) |
1302 { | 1291 { |
1303 modprint1 ("button"); | 1292 modprint1 ("button"); |
1304 --mouse_p; | 1293 --mouse_p; |
1305 } | 1294 } |
1552 */ | 1541 */ |
1553 (event)) | 1542 (event)) |
1554 { | 1543 { |
1555 int mod = XINT (Fevent_modifier_bits (event)); | 1544 int mod = XINT (Fevent_modifier_bits (event)); |
1556 Lisp_Object result = Qnil; | 1545 Lisp_Object result = Qnil; |
1557 if (mod & MOD_SHIFT) result = Fcons (Qshift, result); | 1546 if (mod & XEMACS_MOD_SHIFT) result = Fcons (Qshift, result); |
1558 if (mod & MOD_ALT) result = Fcons (Qalt, result); | 1547 if (mod & XEMACS_MOD_ALT) result = Fcons (Qalt, result); |
1559 if (mod & MOD_HYPER) result = Fcons (Qhyper, result); | 1548 if (mod & XEMACS_MOD_HYPER) result = Fcons (Qhyper, result); |
1560 if (mod & MOD_SUPER) result = Fcons (Qsuper, result); | 1549 if (mod & XEMACS_MOD_SUPER) result = Fcons (Qsuper, result); |
1561 if (mod & MOD_META) result = Fcons (Qmeta, result); | 1550 if (mod & XEMACS_MOD_META) result = Fcons (Qmeta, result); |
1562 if (mod & MOD_CONTROL) result = Fcons (Qcontrol, result); | 1551 if (mod & XEMACS_MOD_CONTROL) result = Fcons (Qcontrol, result); |
1563 return result; | 1552 return result; |
1564 } | 1553 } |
1565 | 1554 |
1566 static int | 1555 static int |
1567 event_x_y_pixel_internal (Lisp_Object event, int *x, int *y, int relative) | 1556 event_x_y_pixel_internal (Lisp_Object event, int *x, int *y, int relative) |