Mercurial > hg > xemacs-beta
annotate src/events.c @ 5557:53c066311921
If XLookupKeysym() returned an XFree86 "special key", ignore it. Fixes Sh-F11.
src/ChangeLog addition:
2011-08-27 Aidan Kehoe <kehoea@parhasard.net>
* config.h.in: Make HAVE_X11_XF86KEYSYM_H available here.
* event-Xt.c: #include X11/XF86keysym.h if available.
* event-Xt.c (x_event_to_emacs_event):
If XLookupKeysym () returned one of the XFree86 "special action
keys" for the shifted keysym, treat that as NoSymbol, fixing a
long-standing bug with shifted function keys under X.org.
Details of why in:
http://mid.gmane.org/16960.15685.26911.644835@parhasard.net
ChangeLog addition:
2011-08-27 Aidan Kehoe <kehoea@parhasard.net>
* configure.ac: Check whether X11/XF86keysym.h is available, to
allow us to avoid a bug in the interaction of XKB and XLookupKeysym.
* configure: Regenerate.
| author | Aidan Kehoe <kehoea@parhasard.net> |
|---|---|
| date | Sat, 27 Aug 2011 20:35:23 +0100 |
| parents | 8d29f1c4bb98 |
| children | 56144c8593a8 |
| rev | line source |
|---|---|
| 428 | 1 /* Events: printing them, converting them to and from characters. |
| 2 Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc. | |
| 3 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | |
| 5046 | 4 Copyright (C) 2001, 2002, 2005, 2010 Ben Wing. |
| 428 | 5 |
| 6 This file is part of XEmacs. | |
| 7 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5191
diff
changeset
|
8 XEmacs is free software: you can redistribute it and/or modify it |
| 428 | 9 under the terms of the GNU General Public License as published by the |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5191
diff
changeset
|
10 Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5191
diff
changeset
|
11 option) any later version. |
| 428 | 12 |
| 13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 16 for more details. | |
| 17 | |
| 18 You should have received a copy of the GNU General Public License | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5191
diff
changeset
|
19 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 428 | 20 |
| 21 /* Synched up with: Not in FSF. */ | |
| 22 | |
| 23 /* This file has been Mule-ized. */ | |
| 24 | |
| 25 #include <config.h> | |
| 26 #include "lisp.h" | |
| 27 #include "buffer.h" | |
| 28 #include "console.h" | |
| 29 #include "device.h" | |
| 788 | 30 #include "extents.h" |
| 428 | 31 #include "events.h" |
| 872 | 32 #include "frame-impl.h" |
| 428 | 33 #include "glyphs.h" |
| 34 #include "keymap.h" /* for key_desc_list_to_event() */ | |
| 788 | 35 #include "lstream.h" |
| 428 | 36 #include "redisplay.h" |
| 800 | 37 #include "toolbar.h" |
| 428 | 38 #include "window.h" |
| 39 | |
| 872 | 40 #include "console-tty-impl.h" /* for stuff in character_to_event */ |
| 800 | 41 |
| 428 | 42 /* Where old events go when they are explicitly deallocated. |
| 43 The event chain here is cut loose before GC, so these will be freed | |
| 44 eventually. | |
| 45 */ | |
| 46 static Lisp_Object Vevent_resource; | |
| 47 | |
| 48 Lisp_Object Qeventp; | |
| 49 Lisp_Object Qevent_live_p; | |
| 50 Lisp_Object Qkey_press_event_p; | |
| 51 Lisp_Object Qbutton_event_p; | |
| 52 Lisp_Object Qmouse_event_p; | |
| 53 Lisp_Object Qprocess_event_p; | |
| 54 | |
| 55 Lisp_Object Qkey_press, Qbutton_press, Qbutton_release, Qmisc_user; | |
| 2828 | 56 Lisp_Object Qcharacter_of_keysym, Qascii_character; |
| 428 | 57 |
| 771 | 58 |
| 59 /************************************************************************/ | |
| 60 /* definition of event object */ | |
| 61 /************************************************************************/ | |
| 428 | 62 |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
5146
diff
changeset
|
63 /* #### Ad-hoc hack. Should be an object method. */ |
| 428 | 64 void |
| 65 clear_event_resource (void) | |
| 66 { | |
| 67 Vevent_resource = Qnil; | |
| 68 } | |
| 69 | |
| 934 | 70 /* Make sure we lose quickly if we try to use this event */ |
| 71 static void | |
| 72 deinitialize_event (Lisp_Object ev) | |
| 73 { | |
| 74 Lisp_Event *event = XEVENT (ev); | |
| 75 | |
|
5146
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5143
diff
changeset
|
76 deadbeef_memory ((Rawbyte *) event + sizeof (event->lheader), |
|
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5143
diff
changeset
|
77 sizeof (*event) - sizeof (event->lheader)); |
|
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5143
diff
changeset
|
78 |
| 934 | 79 set_event_type (event, dead_event); |
| 80 SET_EVENT_CHANNEL (event, Qnil); | |
| 428 | 81 XSET_EVENT_NEXT (ev, Qnil); |
| 82 } | |
| 83 | |
| 84 /* Set everything to zero or nil so that it's predictable. */ | |
| 85 void | |
| 440 | 86 zero_event (Lisp_Event *e) |
| 428 | 87 { |
|
5142
f965e31a35f0
reduce lcrecord headers to 2 words, rename printing_unreadable_object
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
88 zero_nonsized_lisp_object (wrap_event (e)); |
| 1204 | 89 set_event_type (e, empty_event); |
| 90 SET_EVENT_CHANNEL (e, Qnil); | |
| 91 SET_EVENT_NEXT (e, Qnil); | |
| 428 | 92 } |
| 93 | |
| 1204 | 94 static const struct memory_description key_data_description_1 [] = { |
| 95 { XD_LISP_OBJECT, offsetof (struct Lisp_Key_Data, keysym) }, | |
| 96 { XD_END } | |
| 97 }; | |
| 98 | |
| 99 static const struct sized_memory_description key_data_description = { | |
| 100 sizeof (Lisp_Key_Data), key_data_description_1 | |
| 101 }; | |
| 102 | |
| 103 static const struct memory_description button_data_description_1 [] = { | |
| 104 { XD_END } | |
| 105 }; | |
| 106 | |
| 107 static const struct sized_memory_description button_data_description = { | |
| 108 sizeof (Lisp_Button_Data), button_data_description_1 | |
| 109 }; | |
| 110 | |
| 111 static const struct memory_description motion_data_description_1 [] = { | |
| 112 { XD_END } | |
| 113 }; | |
| 114 | |
| 115 static const struct sized_memory_description motion_data_description = { | |
| 116 sizeof (Lisp_Motion_Data), motion_data_description_1 | |
| 117 }; | |
| 118 | |
| 119 static const struct memory_description process_data_description_1 [] = { | |
| 120 { XD_LISP_OBJECT, offsetof (struct Lisp_Process_Data, process) }, | |
| 121 { XD_END } | |
| 122 }; | |
| 123 | |
| 124 static const struct sized_memory_description process_data_description = { | |
| 125 sizeof (Lisp_Process_Data), process_data_description_1 | |
| 126 }; | |
| 127 | |
| 128 static const struct memory_description timeout_data_description_1 [] = { | |
| 129 { XD_LISP_OBJECT, offsetof (struct Lisp_Timeout_Data, function) }, | |
| 130 { XD_LISP_OBJECT, offsetof (struct Lisp_Timeout_Data, object) }, | |
| 131 { XD_END } | |
| 132 }; | |
| 133 | |
| 134 static const struct sized_memory_description timeout_data_description = { | |
| 135 sizeof (Lisp_Timeout_Data), timeout_data_description_1 | |
| 136 }; | |
| 137 | |
| 138 static const struct memory_description eval_data_description_1 [] = { | |
| 139 { XD_LISP_OBJECT, offsetof (struct Lisp_Eval_Data, function) }, | |
| 140 { XD_LISP_OBJECT, offsetof (struct Lisp_Eval_Data, object) }, | |
| 141 { XD_END } | |
| 142 }; | |
| 143 | |
| 144 static const struct sized_memory_description eval_data_description = { | |
| 145 sizeof (Lisp_Eval_Data), eval_data_description_1 | |
| 146 }; | |
| 147 | |
| 148 static const struct memory_description misc_user_data_description_1 [] = { | |
| 149 { XD_LISP_OBJECT, offsetof (struct Lisp_Misc_User_Data, function) }, | |
| 150 { XD_LISP_OBJECT, offsetof (struct Lisp_Misc_User_Data, object) }, | |
| 151 { XD_END } | |
| 152 }; | |
| 153 | |
| 154 static const struct sized_memory_description misc_user_data_description = { | |
| 155 sizeof (Lisp_Misc_User_Data), misc_user_data_description_1 | |
| 156 }; | |
| 157 | |
| 158 static const struct memory_description magic_eval_data_description_1 [] = { | |
| 159 { XD_LISP_OBJECT, offsetof (struct Lisp_Magic_Eval_Data, object) }, | |
| 160 { XD_END } | |
| 161 }; | |
| 162 | |
| 163 static const struct sized_memory_description magic_eval_data_description = { | |
| 164 sizeof (Lisp_Magic_Eval_Data), magic_eval_data_description_1 | |
| 165 }; | |
| 166 | |
| 167 static const struct memory_description magic_data_description_1 [] = { | |
| 168 { XD_END } | |
| 169 }; | |
| 170 | |
| 171 static const struct sized_memory_description magic_data_description = { | |
| 172 sizeof (Lisp_Magic_Data), magic_data_description_1 | |
| 173 }; | |
| 174 | |
| 175 static const struct memory_description event_data_description_1 [] = { | |
| 2551 | 176 { XD_BLOCK_ARRAY, key_press_event, 1, { &key_data_description } }, |
| 177 { XD_BLOCK_ARRAY, button_press_event, 1, { &button_data_description } }, | |
| 178 { XD_BLOCK_ARRAY, button_release_event, 1, { &button_data_description } }, | |
| 179 { XD_BLOCK_ARRAY, pointer_motion_event, 1, { &motion_data_description } }, | |
| 180 { XD_BLOCK_ARRAY, process_event, 1, { &process_data_description } }, | |
| 181 { XD_BLOCK_ARRAY, timeout_event, 1, { &timeout_data_description } }, | |
| 182 { XD_BLOCK_ARRAY, magic_event, 1, { &magic_data_description } }, | |
| 183 { XD_BLOCK_ARRAY, magic_eval_event, 1, { &magic_eval_data_description } }, | |
| 184 { XD_BLOCK_ARRAY, eval_event, 1, { &eval_data_description } }, | |
| 185 { XD_BLOCK_ARRAY, misc_user_event, 1, { &misc_user_data_description } }, | |
| 1204 | 186 { XD_END } |
| 187 }; | |
| 188 | |
| 189 static const struct sized_memory_description event_data_description = { | |
| 190 0, event_data_description_1 | |
| 191 }; | |
| 192 | |
| 193 static const struct memory_description event_description [] = { | |
| 194 { XD_INT, offsetof (struct Lisp_Event, event_type) }, | |
| 195 { XD_LISP_OBJECT, offsetof (struct Lisp_Event, next) }, | |
| 196 { XD_LISP_OBJECT, offsetof (struct Lisp_Event, channel) }, | |
| 197 { XD_UNION, offsetof (struct Lisp_Event, event), | |
| 2551 | 198 XD_INDIRECT (0, 0), { &event_data_description } }, |
| 1204 | 199 { XD_END } |
| 200 }; | |
| 201 | |
| 202 #ifdef EVENT_DATA_AS_OBJECTS | |
| 203 | |
|
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
204 DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT ("key-data", key_data, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
205 0, internal_object_printer, 0, 0, 0, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
206 key_data_description, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
207 Lisp_Key_Data); |
| 1204 | 208 |
|
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
209 DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT ("button-data", button_data, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
210 0, internal_object_printer, 0, 0, 0, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
211 button_data_description, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
212 Lisp_Button_Data); |
| 1204 | 213 |
|
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
214 DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT ("motion-data", motion_data, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
215 0, internal_object_printer, 0, 0, 0, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
216 motion_data_description, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
217 Lisp_Motion_Data); |
| 1204 | 218 |
|
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
219 DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT ("process-data", process_data, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
220 0, internal_object_printer, 0, 0, 0, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
221 process_data_description, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
222 Lisp_Process_Data); |
| 1204 | 223 |
|
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
224 DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT ("timeout-data", timeout_data, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
225 0, internal_object_printer, 0, 0, 0, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
226 timeout_data_description, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
227 Lisp_Timeout_Data); |
| 1204 | 228 |
|
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
229 DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT ("eval-data", eval_data, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
230 0, internal_object_printer, 0, 0, 0, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
231 eval_data_description, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
232 Lisp_Eval_Data); |
| 1204 | 233 |
|
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
234 DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT ("misc-user-data", misc_user_data, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
235 0, internal_object_printer, 0, 0, 0, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
236 misc_user_data_description, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
237 Lisp_Misc_User_Data); |
| 1204 | 238 |
|
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
239 DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT ("magic-eval-data", magic_eval_data, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
240 0, internal_object_printer, 0, 0, 0, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
241 magic_eval_data_description, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
242 Lisp_Magic_Eval_Data); |
| 1204 | 243 |
|
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
244 DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT ("magic-data", magic_data, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
245 0, internal_object_printer, 0, 0, 0, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
246 magic_data_description, |
|
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
247 Lisp_Magic_Data); |
| 1204 | 248 |
| 249 #endif /* EVENT_DATA_AS_OBJECTS */ | |
| 250 | |
| 428 | 251 static Lisp_Object |
| 252 mark_event (Lisp_Object obj) | |
| 253 { | |
| 440 | 254 Lisp_Event *event = XEVENT (obj); |
| 428 | 255 |
| 256 switch (event->event_type) | |
| 257 { | |
| 258 case key_press_event: | |
| 1204 | 259 mark_object (EVENT_KEY_KEYSYM (event)); |
| 428 | 260 break; |
| 261 case process_event: | |
| 1204 | 262 mark_object (EVENT_PROCESS_PROCESS (event)); |
| 428 | 263 break; |
| 264 case timeout_event: | |
| 1204 | 265 mark_object (EVENT_TIMEOUT_FUNCTION (event)); |
| 266 mark_object (EVENT_TIMEOUT_OBJECT (event)); | |
| 428 | 267 break; |
| 268 case eval_event: | |
| 269 case misc_user_event: | |
| 1204 | 270 mark_object (EVENT_EVAL_FUNCTION (event)); |
| 271 mark_object (EVENT_EVAL_OBJECT (event)); | |
| 428 | 272 break; |
| 273 case magic_eval_event: | |
| 1204 | 274 mark_object (EVENT_MAGIC_EVAL_OBJECT (event)); |
| 428 | 275 break; |
| 276 case button_press_event: | |
| 277 case button_release_event: | |
| 278 case pointer_motion_event: | |
| 279 case magic_event: | |
| 280 case empty_event: | |
| 281 case dead_event: | |
| 282 break; | |
| 283 default: | |
| 2500 | 284 ABORT (); |
| 428 | 285 } |
| 286 mark_object (event->channel); | |
| 287 return event->next; | |
| 288 } | |
| 289 | |
| 290 static void | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
291 print_event_1 (const Ascbyte *str, Lisp_Object obj, Lisp_Object printcharfun) |
| 428 | 292 { |
| 793 | 293 DECLARE_EISTRING_MALLOC (ei); |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
294 write_ascstring (printcharfun, str); |
| 1204 | 295 format_event_object (ei, obj, 0); |
| 826 | 296 write_eistring (printcharfun, ei); |
| 793 | 297 eifree (ei); |
| 428 | 298 } |
| 299 | |
| 300 static void | |
| 2286 | 301 print_event (Lisp_Object obj, Lisp_Object printcharfun, |
| 302 int UNUSED (escapeflag)) | |
| 428 | 303 { |
| 304 if (print_readably) | |
|
5146
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5143
diff
changeset
|
305 printing_unreadable_object_fmt ("#<event 0x%x>", LISP_OBJECT_UID (obj)); |
| 428 | 306 |
| 307 switch (XEVENT (obj)->event_type) | |
| 308 { | |
| 309 case key_press_event: | |
| 310 print_event_1 ("#<keypress-event ", obj, printcharfun); | |
| 311 break; | |
| 312 case button_press_event: | |
| 313 print_event_1 ("#<buttondown-event ", obj, printcharfun); | |
| 314 break; | |
| 315 case button_release_event: | |
| 316 print_event_1 ("#<buttonup-event ", obj, printcharfun); | |
| 317 break; | |
| 318 case magic_event: | |
| 319 case magic_eval_event: | |
| 320 print_event_1 ("#<magic-event ", obj, printcharfun); | |
| 321 break; | |
| 322 case pointer_motion_event: | |
| 323 { | |
| 324 Lisp_Object Vx, Vy; | |
| 325 Vx = Fevent_x_pixel (obj); | |
| 326 assert (INTP (Vx)); | |
| 327 Vy = Fevent_y_pixel (obj); | |
| 328 assert (INTP (Vy)); | |
| 793 | 329 write_fmt_string (printcharfun, "#<motion-event %ld, %ld", |
| 330 (long) XINT (Vx), (long) XINT (Vy)); | |
| 428 | 331 break; |
| 332 } | |
| 333 case process_event: | |
| 1204 | 334 write_fmt_string_lisp (printcharfun, "#<process-event %S", 1, |
| 335 XEVENT_PROCESS_PROCESS (obj)); | |
| 428 | 336 break; |
| 337 case timeout_event: | |
| 1204 | 338 write_fmt_string_lisp (printcharfun, "#<timeout-event %S", 1, |
| 339 XEVENT_TIMEOUT_OBJECT (obj)); | |
| 428 | 340 break; |
| 341 case empty_event: | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
342 write_ascstring (printcharfun, "#<empty-event"); |
| 428 | 343 break; |
| 344 case misc_user_event: | |
| 1204 | 345 write_fmt_string_lisp (printcharfun, "#<misc-user-event (%S", 1, |
| 346 XEVENT_MISC_USER_FUNCTION (obj)); | |
| 347 write_fmt_string_lisp (printcharfun, " %S)", 1, | |
| 348 XEVENT_MISC_USER_OBJECT (obj)); | |
| 428 | 349 break; |
| 350 case eval_event: | |
| 1204 | 351 write_fmt_string_lisp (printcharfun, "#<eval-event (%S", 1, |
| 352 XEVENT_EVAL_FUNCTION (obj)); | |
| 353 write_fmt_string_lisp (printcharfun, " %S)", 1, | |
| 354 XEVENT_EVAL_OBJECT (obj)); | |
| 428 | 355 break; |
| 356 case dead_event: | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
357 write_ascstring (printcharfun, "#<DEALLOCATED-EVENT"); |
| 428 | 358 break; |
| 359 default: | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
360 write_ascstring (printcharfun, "#<UNKNOWN-EVENT-TYPE"); |
| 428 | 361 break; |
| 362 } | |
|
5146
88bd4f3ef8e4
make lrecord UID's have a separate UID space for each object, resurrect debug SOE code in extents.c
Ben Wing <ben@xemacs.org>
parents:
5143
diff
changeset
|
363 write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj)); |
| 428 | 364 } |
| 365 | |
| 366 static int | |
|
4906
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
367 event_equal (Lisp_Object obj1, Lisp_Object obj2, int UNUSED (depth), |
|
6ef8256a020a
implement equalp in C, fix case-folding, add equal() method for keymaps
Ben Wing <ben@xemacs.org>
parents:
4780
diff
changeset
|
368 int UNUSED (foldcase)) |
| 428 | 369 { |
| 440 | 370 Lisp_Event *e1 = XEVENT (obj1); |
| 371 Lisp_Event *e2 = XEVENT (obj2); | |
| 428 | 372 |
| 373 if (e1->event_type != e2->event_type) return 0; | |
| 374 if (!EQ (e1->channel, e2->channel)) return 0; | |
| 375 /* if (e1->timestamp != e2->timestamp) return 0; */ | |
| 376 switch (e1->event_type) | |
| 377 { | |
| 2500 | 378 default: ABORT (); |
| 428 | 379 |
| 380 case process_event: | |
| 1204 | 381 return EQ (EVENT_PROCESS_PROCESS (e1), EVENT_PROCESS_PROCESS (e2)); |
| 428 | 382 |
| 383 case timeout_event: | |
| 1204 | 384 return (internal_equal (EVENT_TIMEOUT_FUNCTION (e1), |
| 385 EVENT_TIMEOUT_FUNCTION (e2), 0) && | |
| 386 internal_equal (EVENT_TIMEOUT_OBJECT (e1), | |
| 387 EVENT_TIMEOUT_OBJECT (e2), 0)); | |
| 428 | 388 |
| 389 case key_press_event: | |
| 1204 | 390 return (EQ (EVENT_KEY_KEYSYM (e1), EVENT_KEY_KEYSYM (e2)) && |
| 391 (EVENT_KEY_MODIFIERS (e1) == EVENT_KEY_MODIFIERS (e2))); | |
| 428 | 392 |
| 393 case button_press_event: | |
| 394 case button_release_event: | |
| 1204 | 395 return (EVENT_BUTTON_BUTTON (e1) == EVENT_BUTTON_BUTTON (e2) && |
| 396 EVENT_BUTTON_MODIFIERS (e1) == EVENT_BUTTON_MODIFIERS (e2)); | |
| 428 | 397 |
| 398 case pointer_motion_event: | |
| 1204 | 399 return (EVENT_MOTION_X (e1) == EVENT_MOTION_X (e2) && |
| 400 EVENT_MOTION_Y (e1) == EVENT_MOTION_Y (e2)); | |
| 428 | 401 |
| 402 case misc_user_event: | |
| 1204 | 403 return (internal_equal (EVENT_EVAL_FUNCTION (e1), |
| 404 EVENT_EVAL_FUNCTION (e2), 0) && | |
| 405 internal_equal (EVENT_EVAL_OBJECT (e1), | |
| 406 EVENT_EVAL_OBJECT (e2), 0) && | |
| 407 /* #### is this really needed for equality | |
| 428 | 408 or is x and y also important? */ |
| 1204 | 409 EVENT_MISC_USER_BUTTON (e1) == EVENT_MISC_USER_BUTTON (e2) && |
| 410 EVENT_MISC_USER_MODIFIERS (e1) == EVENT_MISC_USER_MODIFIERS (e2)); | |
| 428 | 411 |
| 412 case eval_event: | |
| 1204 | 413 return (internal_equal (EVENT_EVAL_FUNCTION (e1), |
| 414 EVENT_EVAL_FUNCTION (e2), 0) && | |
| 415 internal_equal (EVENT_EVAL_OBJECT (e1), | |
| 416 EVENT_EVAL_OBJECT (e2), 0)); | |
| 428 | 417 |
| 418 case magic_eval_event: | |
| 1204 | 419 return (EVENT_MAGIC_EVAL_INTERNAL_FUNCTION (e1) == |
| 420 EVENT_MAGIC_EVAL_INTERNAL_FUNCTION (e2) && | |
| 421 internal_equal (EVENT_MAGIC_EVAL_OBJECT (e1), | |
| 422 EVENT_MAGIC_EVAL_OBJECT (e2), 0)); | |
| 428 | 423 |
| 424 case magic_event: | |
| 788 | 425 return event_stream_compare_magic_event (e1, e2); |
| 428 | 426 |
| 427 case empty_event: /* Empty and deallocated events are equal. */ | |
| 428 case dead_event: | |
| 429 return 1; | |
| 430 } | |
| 431 } | |
| 432 | |
| 665 | 433 static Hashcode |
|
5191
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5157
diff
changeset
|
434 event_hash (Lisp_Object obj, int depth, Boolint UNUSED (equalp)) |
| 428 | 435 { |
| 440 | 436 Lisp_Event *e = XEVENT (obj); |
| 665 | 437 Hashcode hash; |
| 428 | 438 |
| 439 hash = HASH2 (e->event_type, LISP_HASH (e->channel)); | |
| 440 switch (e->event_type) | |
| 441 { | |
| 442 case process_event: | |
| 1204 | 443 return HASH2 (hash, LISP_HASH (EVENT_PROCESS_PROCESS (e))); |
| 428 | 444 |
| 445 case timeout_event: | |
| 1204 | 446 return HASH3 (hash, |
|
5191
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5157
diff
changeset
|
447 internal_hash (EVENT_TIMEOUT_FUNCTION (e), depth + 1, 0), |
|
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5157
diff
changeset
|
448 internal_hash (EVENT_TIMEOUT_OBJECT (e), depth + 1, 0)); |
| 428 | 449 |
| 450 case key_press_event: | |
| 1204 | 451 return HASH3 (hash, LISP_HASH (EVENT_KEY_KEYSYM (e)), |
| 452 EVENT_KEY_MODIFIERS (e)); | |
| 428 | 453 |
| 454 case button_press_event: | |
| 455 case button_release_event: | |
| 1204 | 456 return HASH3 (hash, EVENT_BUTTON_BUTTON (e), EVENT_BUTTON_MODIFIERS (e)); |
| 428 | 457 |
| 458 case pointer_motion_event: | |
| 1204 | 459 return HASH3 (hash, EVENT_MOTION_X (e), EVENT_MOTION_Y (e)); |
| 428 | 460 |
| 461 case misc_user_event: | |
| 1204 | 462 return HASH5 (hash, |
|
5191
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5157
diff
changeset
|
463 internal_hash (EVENT_MISC_USER_FUNCTION (e), depth + 1, 0), |
|
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5157
diff
changeset
|
464 internal_hash (EVENT_MISC_USER_OBJECT (e), depth + 1, 0), |
| 1204 | 465 EVENT_MISC_USER_BUTTON (e), EVENT_MISC_USER_MODIFIERS (e)); |
| 428 | 466 |
| 467 case eval_event: | |
|
5191
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5157
diff
changeset
|
468 return HASH3 (hash, internal_hash (EVENT_EVAL_FUNCTION (e), depth + 1, 0), |
|
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5157
diff
changeset
|
469 internal_hash (EVENT_EVAL_OBJECT (e), depth + 1, 0)); |
| 428 | 470 |
| 471 case magic_eval_event: | |
| 472 return HASH3 (hash, | |
| 1204 | 473 (Hashcode) EVENT_MAGIC_EVAL_INTERNAL_FUNCTION (e), |
|
5191
71ee43b8a74d
Add #'equalp as a hash test by default; add #'define-hash-table-test, GNU API
Aidan Kehoe <kehoea@parhasard.net>
parents:
5157
diff
changeset
|
474 internal_hash (EVENT_MAGIC_EVAL_OBJECT (e), depth + 1, 0)); |
| 428 | 475 |
| 476 case magic_event: | |
| 788 | 477 return HASH2 (hash, event_stream_hash_magic_event (e)); |
| 428 | 478 |
| 479 case empty_event: | |
| 480 case dead_event: | |
| 481 return hash; | |
| 482 | |
| 483 default: | |
| 2500 | 484 ABORT (); |
| 428 | 485 } |
| 486 | |
| 487 return 0; /* unreached */ | |
| 488 } | |
| 934 | 489 |
|
5118
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
490 DEFINE_NODUMP_FROB_BLOCK_LISP_OBJECT ("event", event, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
491 mark_event, print_event, 0, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
492 event_equal, event_hash, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
493 event_description, |
|
e0db3c197671
merge up to latest default branch, doesn't compile yet
Ben Wing <ben@xemacs.org>
diff
changeset
|
494 Lisp_Event); |
| 428 | 495 |
| 496 DEFUN ("make-event", Fmake_event, 0, 2, 0, /* | |
| 497 Return a new event of type TYPE, with properties described by PLIST. | |
| 498 | |
| 499 TYPE is a symbol, either `empty', `key-press', `button-press', | |
| 500 `button-release', `misc-user' or `motion'. If TYPE is nil, it | |
| 501 defaults to `empty'. | |
| 502 | |
| 503 PLIST is a property list, the properties being compatible to those | |
| 504 returned by `event-properties'. The following properties are | |
| 505 allowed: | |
| 506 | |
| 507 channel -- The event channel, a frame or a console. For | |
| 508 button-press, button-release, misc-user and motion events, | |
| 509 this must be a frame. For key-press events, it must be | |
| 510 a console. If channel is unspecified, it will be set to | |
| 511 the selected frame or selected console, as appropriate. | |
| 512 key -- The event key, a symbol or character. Allowed only for | |
| 513 keypress events. | |
| 514 button -- The event button, integer 1, 2 or 3. Allowed for | |
| 515 button-press, button-release and misc-user events. | |
| 516 modifiers -- The event modifiers, a list of modifier symbols. Allowed | |
| 517 for key-press, button-press, button-release, motion and | |
| 518 misc-user events. | |
| 519 function -- Function. Allowed for misc-user events only. | |
| 520 object -- An object, function's parameter. Allowed for misc-user | |
| 521 events only. | |
| 522 x -- The event X coordinate, an integer. This is relative | |
| 523 to the left of CHANNEL's root window. Allowed for | |
| 524 motion, button-press, button-release and misc-user events. | |
| 525 y -- The event Y coordinate, an integer. This is relative | |
| 526 to the top of CHANNEL's root window. Allowed for | |
| 527 motion, button-press, button-release and misc-user events. | |
| 528 timestamp -- The event timestamp, a non-negative integer. Allowed for | |
| 529 all types of events. If unspecified, it will be set to 0 | |
| 530 by default. | |
| 531 | |
| 532 For event type `empty', PLIST must be nil. | |
| 533 `button-release', or `motion'. If TYPE is left out, it defaults to | |
| 534 `empty'. | |
| 535 PLIST is a list of properties, as returned by `event-properties'. Not | |
| 536 all properties are allowed for all kinds of events, and some are | |
| 537 required. | |
| 538 | |
| 539 WARNING: the event object returned may be a reused one; see the function | |
| 540 `deallocate-event'. | |
| 541 */ | |
| 542 (type, plist)) | |
| 543 { | |
| 544 Lisp_Object event = Qnil; | |
| 440 | 545 Lisp_Event *e; |
| 428 | 546 EMACS_INT coord_x = 0, coord_y = 0; |
| 547 struct gcpro gcpro1; | |
| 548 | |
| 549 GCPRO1 (event); | |
| 550 | |
| 551 if (NILP (type)) | |
| 552 type = Qempty; | |
| 553 | |
| 554 if (!NILP (Vevent_resource)) | |
| 555 { | |
| 556 event = Vevent_resource; | |
| 557 Vevent_resource = XEVENT_NEXT (event); | |
| 558 } | |
| 559 else | |
| 560 { | |
| 561 event = allocate_event (); | |
| 562 } | |
| 563 e = XEVENT (event); | |
| 564 zero_event (e); | |
| 565 | |
| 566 if (EQ (type, Qempty)) | |
| 567 { | |
| 568 /* For empty event, we return immediately, without processing | |
| 569 PLIST. In fact, processing PLIST would be wrong, because the | |
| 570 sanitizing process would fill in the properties | |
| 571 (e.g. CHANNEL), which we don't want in empty events. */ | |
| 934 | 572 set_event_type (e, empty_event); |
| 428 | 573 if (!NILP (plist)) |
| 563 | 574 invalid_operation ("Cannot set properties of empty event", plist); |
| 428 | 575 UNGCPRO; |
| 576 return event; | |
| 577 } | |
| 578 else if (EQ (type, Qkey_press)) | |
| 579 { | |
| 934 | 580 set_event_type (e, key_press_event); |
| 1204 | 581 SET_EVENT_KEY_KEYSYM (e, Qunbound); |
| 428 | 582 } |
| 583 else if (EQ (type, Qbutton_press)) | |
| 934 | 584 set_event_type (e, button_press_event); |
| 428 | 585 else if (EQ (type, Qbutton_release)) |
| 934 | 586 set_event_type (e, button_release_event); |
| 428 | 587 else if (EQ (type, Qmotion)) |
| 934 | 588 set_event_type (e, pointer_motion_event); |
| 428 | 589 else if (EQ (type, Qmisc_user)) |
| 590 { | |
| 934 | 591 set_event_type (e, misc_user_event); |
| 1204 | 592 SET_EVENT_MISC_USER_FUNCTION (e, Qnil); |
| 593 SET_EVENT_MISC_USER_OBJECT (e, Qnil); | |
| 428 | 594 } |
| 595 else | |
| 596 { | |
| 597 /* Not allowed: Qprocess, Qtimeout, Qmagic, Qeval, Qmagic_eval. */ | |
| 563 | 598 invalid_constant ("Invalid event type", type); |
| 428 | 599 } |
| 600 | |
| 601 EVENT_CHANNEL (e) = Qnil; | |
| 602 | |
| 603 plist = Fcopy_sequence (plist); | |
| 604 Fcanonicalize_plist (plist, Qnil); | |
| 605 | |
| 442 | 606 #define WRONG_EVENT_TYPE_FOR_PROPERTY(event_type, prop) \ |
| 563 | 607 invalid_argument_2 ("Invalid property for event type", prop, event_type) |
| 428 | 608 |
| 442 | 609 { |
| 610 EXTERNAL_PROPERTY_LIST_LOOP_3 (keyword, value, plist) | |
| 611 { | |
| 612 if (EQ (keyword, Qchannel)) | |
| 613 { | |
| 1204 | 614 if (EVENT_TYPE (e) == key_press_event) |
| 442 | 615 { |
| 616 if (!CONSOLEP (value)) | |
| 617 value = wrong_type_argument (Qconsolep, value); | |
| 618 } | |
| 619 else | |
| 620 { | |
| 621 if (!FRAMEP (value)) | |
| 622 value = wrong_type_argument (Qframep, value); | |
| 623 } | |
| 624 EVENT_CHANNEL (e) = value; | |
| 625 } | |
| 626 else if (EQ (keyword, Qkey)) | |
| 627 { | |
| 1204 | 628 switch (EVENT_TYPE (e)) |
| 442 | 629 { |
| 630 case key_press_event: | |
| 631 if (!SYMBOLP (value) && !CHARP (value)) | |
| 563 | 632 invalid_argument ("Invalid event key", value); |
| 1204 | 633 SET_EVENT_KEY_KEYSYM (e, value); |
| 442 | 634 break; |
| 635 default: | |
| 636 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
| 637 break; | |
| 638 } | |
| 639 } | |
| 640 else if (EQ (keyword, Qbutton)) | |
| 641 { | |
|
5307
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
642 check_integer_range (value, Qzero, make_int (26)); |
| 428 | 643 |
| 1204 | 644 switch (EVENT_TYPE (e)) |
| 442 | 645 { |
| 646 case button_press_event: | |
| 647 case button_release_event: | |
| 1204 | 648 SET_EVENT_BUTTON_BUTTON (e, XINT (value)); |
| 442 | 649 break; |
| 650 case misc_user_event: | |
| 1204 | 651 SET_EVENT_MISC_USER_BUTTON (e, XINT (value)); |
| 442 | 652 break; |
| 653 default: | |
| 654 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
| 655 break; | |
| 656 } | |
| 657 } | |
| 658 else if (EQ (keyword, Qmodifiers)) | |
| 659 { | |
| 660 int modifiers = 0; | |
| 428 | 661 |
| 442 | 662 EXTERNAL_LIST_LOOP_2 (sym, value) |
| 663 { | |
| 664 if (EQ (sym, Qcontrol)) modifiers |= XEMACS_MOD_CONTROL; | |
| 665 else if (EQ (sym, Qmeta)) modifiers |= XEMACS_MOD_META; | |
| 666 else if (EQ (sym, Qsuper)) modifiers |= XEMACS_MOD_SUPER; | |
| 667 else if (EQ (sym, Qhyper)) modifiers |= XEMACS_MOD_HYPER; | |
| 668 else if (EQ (sym, Qalt)) modifiers |= XEMACS_MOD_ALT; | |
| 669 else if (EQ (sym, Qsymbol)) modifiers |= XEMACS_MOD_ALT; | |
| 670 else if (EQ (sym, Qshift)) modifiers |= XEMACS_MOD_SHIFT; | |
| 671 else if (EQ (sym, Qbutton1)) modifiers |= XEMACS_MOD_BUTTON1; | |
| 672 else if (EQ (sym, Qbutton2)) modifiers |= XEMACS_MOD_BUTTON2; | |
| 673 else if (EQ (sym, Qbutton3)) modifiers |= XEMACS_MOD_BUTTON3; | |
| 674 else if (EQ (sym, Qbutton4)) modifiers |= XEMACS_MOD_BUTTON4; | |
| 675 else if (EQ (sym, Qbutton5)) modifiers |= XEMACS_MOD_BUTTON5; | |
| 676 else | |
| 563 | 677 invalid_constant ("Invalid key modifier", sym); |
| 442 | 678 } |
| 428 | 679 |
| 1204 | 680 switch (EVENT_TYPE (e)) |
| 442 | 681 { |
| 682 case key_press_event: | |
| 1204 | 683 SET_EVENT_KEY_MODIFIERS (e, modifiers); |
| 442 | 684 break; |
| 685 case button_press_event: | |
| 686 case button_release_event: | |
| 1204 | 687 SET_EVENT_BUTTON_MODIFIERS (e, modifiers); |
| 442 | 688 break; |
| 689 case pointer_motion_event: | |
| 1204 | 690 SET_EVENT_MOTION_MODIFIERS (e, modifiers); |
| 442 | 691 break; |
| 692 case misc_user_event: | |
| 1204 | 693 SET_EVENT_MISC_USER_MODIFIERS (e, modifiers); |
| 442 | 694 break; |
| 695 default: | |
| 696 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
| 697 break; | |
| 698 } | |
| 699 } | |
| 700 else if (EQ (keyword, Qx)) | |
| 701 { | |
| 1204 | 702 switch (EVENT_TYPE (e)) |
| 442 | 703 { |
| 704 case pointer_motion_event: | |
| 705 case button_press_event: | |
| 706 case button_release_event: | |
| 707 case misc_user_event: | |
| 708 /* Allow negative values, so we can specify toolbar | |
| 709 positions. */ | |
| 710 CHECK_INT (value); | |
| 711 coord_x = XINT (value); | |
| 712 break; | |
| 713 default: | |
| 714 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
| 715 break; | |
| 716 } | |
| 717 } | |
| 718 else if (EQ (keyword, Qy)) | |
| 719 { | |
| 1204 | 720 switch (EVENT_TYPE (e)) |
| 442 | 721 { |
| 722 case pointer_motion_event: | |
| 723 case button_press_event: | |
| 724 case button_release_event: | |
| 725 case misc_user_event: | |
| 726 /* Allow negative values; see above. */ | |
| 727 CHECK_INT (value); | |
| 728 coord_y = XINT (value); | |
| 729 break; | |
| 730 default: | |
| 731 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
| 732 break; | |
| 733 } | |
| 734 } | |
| 735 else if (EQ (keyword, Qtimestamp)) | |
| 736 { | |
|
5307
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
737 #ifdef HAVE_BIGNUM |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
738 check_integer_range (value, Qzero, make_integer (UINT_MAX)); |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
739 if (BIGNUMP (value)) |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
740 { |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
741 SET_EVENT_TIMESTAMP (e, bignum_to_uint (XBIGNUM_DATA (value))); |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
742 } |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
743 #else |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
744 check_integer_range (value, Qzero, make_integer (EMACS_INT_MAX)); |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
745 #endif |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
746 if (INTP (value)) |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
747 { |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
748 SET_EVENT_TIMESTAMP (e, XINT (value)); |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
749 } |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
750 else |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
751 { |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
752 ABORT (); |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
753 } |
| 442 | 754 } |
| 755 else if (EQ (keyword, Qfunction)) | |
| 756 { | |
| 1204 | 757 switch (EVENT_TYPE (e)) |
| 442 | 758 { |
| 759 case misc_user_event: | |
| 1204 | 760 SET_EVENT_MISC_USER_FUNCTION (e, value); |
| 442 | 761 break; |
| 762 default: | |
| 763 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
| 764 break; | |
| 765 } | |
| 766 } | |
| 767 else if (EQ (keyword, Qobject)) | |
| 768 { | |
| 1204 | 769 switch (EVENT_TYPE (e)) |
| 442 | 770 { |
| 771 case misc_user_event: | |
| 1204 | 772 SET_EVENT_MISC_USER_OBJECT (e, value); |
| 442 | 773 break; |
| 774 default: | |
| 775 WRONG_EVENT_TYPE_FOR_PROPERTY (type, keyword); | |
| 776 break; | |
| 777 } | |
| 778 } | |
| 779 else | |
| 563 | 780 invalid_constant_2 ("Invalid property", keyword, value); |
| 442 | 781 } |
| 782 } | |
| 428 | 783 |
| 784 /* Insert the channel, if missing. */ | |
| 785 if (NILP (EVENT_CHANNEL (e))) | |
| 786 { | |
| 934 | 787 if (EVENT_TYPE (e) == key_press_event) |
| 428 | 788 EVENT_CHANNEL (e) = Vselected_console; |
| 789 else | |
| 790 EVENT_CHANNEL (e) = Fselected_frame (Qnil); | |
| 791 } | |
| 792 | |
| 793 /* Fevent_properties, Fevent_x_pixel, etc. work with pixels relative | |
| 794 to the frame, so we must adjust accordingly. */ | |
| 795 if (FRAMEP (EVENT_CHANNEL (e))) | |
| 796 { | |
| 797 coord_x += FRAME_REAL_LEFT_TOOLBAR_WIDTH (XFRAME (EVENT_CHANNEL (e))); | |
| 798 coord_y += FRAME_REAL_TOP_TOOLBAR_HEIGHT (XFRAME (EVENT_CHANNEL (e))); | |
| 799 | |
| 800 switch (e->event_type) | |
| 801 { | |
| 802 case pointer_motion_event: | |
| 1204 | 803 SET_EVENT_MOTION_X (e, coord_x); |
| 804 SET_EVENT_MOTION_Y (e, coord_y); | |
| 428 | 805 break; |
| 806 case button_press_event: | |
| 807 case button_release_event: | |
| 1204 | 808 SET_EVENT_BUTTON_X (e, coord_x); |
| 809 SET_EVENT_BUTTON_Y (e, coord_y); | |
| 428 | 810 break; |
| 811 case misc_user_event: | |
| 1204 | 812 SET_EVENT_MISC_USER_X (e, coord_x); |
| 813 SET_EVENT_MISC_USER_Y (e, coord_y); | |
| 428 | 814 break; |
| 815 default: | |
| 2500 | 816 ABORT (); |
| 428 | 817 } |
| 818 } | |
| 819 | |
| 820 /* Finally, do some more validation. */ | |
| 1204 | 821 switch (EVENT_TYPE (e)) |
| 428 | 822 { |
| 823 case key_press_event: | |
| 1204 | 824 if (UNBOUNDP (EVENT_KEY_KEYSYM (e))) |
| 563 | 825 sferror ("A key must be specified to make a keypress event", |
| 442 | 826 plist); |
| 428 | 827 break; |
| 828 case button_press_event: | |
| 1204 | 829 if (!EVENT_BUTTON_BUTTON (e)) |
| 563 | 830 sferror |
| 442 | 831 ("A button must be specified to make a button-press event", |
| 832 plist); | |
| 428 | 833 break; |
| 834 case button_release_event: | |
| 1204 | 835 if (!EVENT_BUTTON_BUTTON (e)) |
| 563 | 836 sferror |
| 442 | 837 ("A button must be specified to make a button-release event", |
| 838 plist); | |
| 428 | 839 break; |
| 840 case misc_user_event: | |
| 1204 | 841 if (NILP (EVENT_MISC_USER_FUNCTION (e))) |
| 563 | 842 sferror ("A function must be specified to make a misc-user event", |
| 442 | 843 plist); |
| 428 | 844 break; |
| 845 default: | |
| 846 break; | |
| 847 } | |
| 848 | |
| 849 UNGCPRO; | |
| 850 return event; | |
| 851 } | |
| 852 | |
| 853 DEFUN ("deallocate-event", Fdeallocate_event, 1, 1, 0, /* | |
| 854 Allow the given event structure to be reused. | |
| 855 You MUST NOT use this event object after calling this function with it. | |
| 856 You will lose. It is not necessary to call this function, as event | |
| 857 objects are garbage-collected like all other objects; however, it may | |
| 858 be more efficient to explicitly deallocate events when you are sure | |
| 859 that it is safe to do so. | |
| 860 */ | |
| 861 (event)) | |
| 862 { | |
| 863 CHECK_EVENT (event); | |
| 864 | |
| 865 if (XEVENT_TYPE (event) == dead_event) | |
| 563 | 866 invalid_argument ("this event is already deallocated!", Qunbound); |
| 428 | 867 |
| 868 assert (XEVENT_TYPE (event) <= last_event_type); | |
| 869 | |
| 870 #if 0 | |
| 871 { | |
| 872 int i, len; | |
| 873 | |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
874 assert (!(EQ (event, Vlast_command_event) || |
|
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
875 EQ (event, Vlast_input_event) || |
|
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
876 EQ (event, Vunread_command_event))); |
| 428 | 877 |
| 878 len = XVECTOR_LENGTH (Vthis_command_keys); | |
| 879 for (i = 0; i < len; i++) | |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
880 assert (!EQ (event, XVECTOR_DATA (Vthis_command_keys) [i])); |
| 428 | 881 if (!NILP (Vrecent_keys_ring)) |
| 882 { | |
| 883 int recent_ring_len = XVECTOR_LENGTH (Vrecent_keys_ring); | |
| 884 for (i = 0; i < recent_ring_len; i++) | |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
885 assert (!EQ (event, XVECTOR_DATA (Vrecent_keys_ring) [i])); |
| 428 | 886 } |
| 887 } | |
| 888 #endif /* 0 */ | |
| 889 | |
| 890 assert (!EQ (event, Vevent_resource)); | |
| 891 deinitialize_event (event); | |
| 892 #ifndef ALLOC_NO_POOLS | |
| 893 XSET_EVENT_NEXT (event, Vevent_resource); | |
| 894 Vevent_resource = event; | |
| 895 #endif | |
| 896 return Qnil; | |
| 897 } | |
| 898 | |
| 899 DEFUN ("copy-event", Fcopy_event, 1, 2, 0, /* | |
| 444 | 900 Make a copy of the event object EVENT1. |
| 901 If a second event argument EVENT2 is given, EVENT1 is copied into | |
| 902 EVENT2 and EVENT2 is returned. If EVENT2 is not supplied (or is nil) | |
| 903 then a new event will be made as with `make-event'. See also the | |
| 904 function `deallocate-event'. | |
| 428 | 905 */ |
| 906 (event1, event2)) | |
| 907 { | |
| 908 CHECK_LIVE_EVENT (event1); | |
| 909 if (NILP (event2)) | |
| 910 event2 = Fmake_event (Qnil, Qnil); | |
| 430 | 911 else |
| 912 { | |
| 913 CHECK_LIVE_EVENT (event2); | |
| 914 if (EQ (event1, event2)) | |
| 563 | 915 return signal_continuable_error_2 |
| 916 (Qinvalid_argument, | |
| 917 "copy-event called with `eq' events", event1, event2); | |
| 430 | 918 } |
| 428 | 919 |
| 920 assert (XEVENT_TYPE (event1) <= last_event_type); | |
| 921 assert (XEVENT_TYPE (event2) <= last_event_type); | |
| 922 | |
| 934 | 923 XSET_EVENT_TYPE (event2, XEVENT_TYPE (event1)); |
| 924 XSET_EVENT_CHANNEL (event2, XEVENT_CHANNEL (event1)); | |
| 925 XSET_EVENT_TIMESTAMP (event2, XEVENT_TIMESTAMP (event1)); | |
| 1204 | 926 |
| 927 #ifdef EVENT_DATA_AS_OBJECTS | |
| 928 copy_lisp_object (XEVENT_DATA (event2), XEVENT_DATA (event1)); | |
| 929 #else | |
| 930 XEVENT (event2)->event = XEVENT (event1)->event; | |
| 931 #endif | |
| 934 | 932 return event2; |
| 428 | 933 } |
| 934 | |
| 935 | |
| 771 | 936 /************************************************************************/ |
| 937 /* event chain functions */ | |
| 938 /************************************************************************/ | |
| 428 | 939 |
| 940 /* Given a chain of events (or possibly nil), deallocate them all. */ | |
| 941 | |
| 942 void | |
| 943 deallocate_event_chain (Lisp_Object event_chain) | |
| 944 { | |
| 945 while (!NILP (event_chain)) | |
| 946 { | |
| 947 Lisp_Object next = XEVENT_NEXT (event_chain); | |
| 948 Fdeallocate_event (event_chain); | |
| 949 event_chain = next; | |
| 950 } | |
| 951 } | |
| 952 | |
| 953 /* Return the last event in a chain. | |
| 954 NOTE: You cannot pass nil as a value here! The routine will | |
| 955 abort if you do. */ | |
| 956 | |
| 957 Lisp_Object | |
| 958 event_chain_tail (Lisp_Object event_chain) | |
| 959 { | |
| 960 while (1) | |
| 961 { | |
| 962 Lisp_Object next = XEVENT_NEXT (event_chain); | |
| 963 if (NILP (next)) | |
| 964 return event_chain; | |
| 965 event_chain = next; | |
| 966 } | |
| 967 } | |
| 968 | |
| 969 /* Enqueue a single event onto the end of a chain of events. | |
| 970 HEAD points to the first event in the chain, TAIL to the last event. | |
| 971 If the chain is empty, both values should be nil. */ | |
| 972 | |
| 973 void | |
| 974 enqueue_event (Lisp_Object event, Lisp_Object *head, Lisp_Object *tail) | |
| 975 { | |
| 976 assert (NILP (XEVENT_NEXT (event))); | |
| 977 assert (!EQ (*tail, event)); | |
| 978 | |
| 979 if (!NILP (*tail)) | |
| 980 XSET_EVENT_NEXT (*tail, event); | |
| 981 else | |
| 982 *head = event; | |
| 983 *tail = event; | |
| 984 | |
| 985 assert (!EQ (event, XEVENT_NEXT (event))); | |
| 986 } | |
| 987 | |
| 988 /* Remove an event off the head of a chain of events and return it. | |
| 989 HEAD points to the first event in the chain, TAIL to the last event. */ | |
| 990 | |
| 991 Lisp_Object | |
| 992 dequeue_event (Lisp_Object *head, Lisp_Object *tail) | |
| 993 { | |
| 994 Lisp_Object event; | |
| 995 | |
| 996 event = *head; | |
| 997 *head = XEVENT_NEXT (event); | |
| 998 XSET_EVENT_NEXT (event, Qnil); | |
| 999 if (NILP (*head)) | |
| 1000 *tail = Qnil; | |
| 1001 return event; | |
| 1002 } | |
| 1003 | |
| 1004 /* Enqueue a chain of events (or possibly nil) onto the end of another | |
| 1005 chain of events. HEAD points to the first event in the chain being | |
| 1006 queued onto, TAIL to the last event. If the chain is empty, both values | |
| 1007 should be nil. */ | |
| 1008 | |
| 1009 void | |
| 1010 enqueue_event_chain (Lisp_Object event_chain, Lisp_Object *head, | |
| 1011 Lisp_Object *tail) | |
| 1012 { | |
| 1013 if (NILP (event_chain)) | |
| 1014 return; | |
| 1015 | |
| 1016 if (NILP (*head)) | |
| 1017 { | |
| 1018 *head = event_chain; | |
| 1019 *tail = event_chain; | |
| 1020 } | |
| 1021 else | |
| 1022 { | |
| 1023 XSET_EVENT_NEXT (*tail, event_chain); | |
| 1024 *tail = event_chain_tail (event_chain); | |
| 1025 } | |
| 1026 } | |
| 1027 | |
| 1204 | 1028 /* Map a function over each event in the chain. If the function returns |
| 1029 non-zero, remove the event just processed. Return the total number of | |
| 1030 items removed. | |
| 1031 | |
| 1032 NOTE: | |
| 1033 | |
| 1034 If you want a simple mapping over an event chain, with no intention to | |
| 1035 add or remove items, just use EVENT_CHAIN_LOOP(). | |
| 1036 */ | |
| 1037 | |
| 1038 int | |
| 1039 map_event_chain_remove (int (*fn) (Lisp_Object ev, void *user_data), | |
| 1040 Lisp_Object *head, Lisp_Object *tail, | |
| 1041 void *user_data, int flags) | |
| 1042 { | |
| 1043 Lisp_Object event; | |
| 1044 Lisp_Object previous_event = Qnil; | |
| 1045 int count = 0; | |
| 1046 | |
| 1047 EVENT_CHAIN_LOOP (event, *head) | |
| 1048 { | |
| 1049 if (fn (event, user_data)) | |
| 1050 { | |
| 1051 if (NILP (previous_event)) | |
| 1052 dequeue_event (head, tail); | |
| 1053 else | |
| 1054 { | |
| 1055 XSET_EVENT_NEXT (previous_event, XEVENT_NEXT (event)); | |
| 1056 if (EQ (*tail, event)) | |
| 1057 *tail = previous_event; | |
| 1058 } | |
| 1059 | |
| 1060 if (flags & MECR_DEALLOCATE_EVENT) | |
| 1061 Fdeallocate_event (event); | |
| 1062 count++; | |
| 1063 } | |
| 1064 else | |
| 1065 previous_event = event; | |
| 1066 } | |
| 1067 return count; | |
| 1068 } | |
| 1069 | |
| 428 | 1070 /* Return the number of events (possibly 0) on an event chain. */ |
| 1071 | |
| 1072 int | |
| 1073 event_chain_count (Lisp_Object event_chain) | |
| 1074 { | |
| 1075 Lisp_Object event; | |
| 1076 int n = 0; | |
| 1077 | |
| 1078 EVENT_CHAIN_LOOP (event, event_chain) | |
| 1079 n++; | |
| 1080 | |
| 1081 return n; | |
| 1082 } | |
| 1083 | |
| 1084 /* Find the event before EVENT in an event chain. This aborts | |
| 1085 if the event is not in the chain. */ | |
| 1086 | |
| 1087 Lisp_Object | |
| 1088 event_chain_find_previous (Lisp_Object event_chain, Lisp_Object event) | |
| 1089 { | |
| 1090 Lisp_Object previous = Qnil; | |
| 1091 | |
| 1092 while (!NILP (event_chain)) | |
| 1093 { | |
| 1094 if (EQ (event_chain, event)) | |
| 1095 return previous; | |
| 1096 previous = event_chain; | |
| 1097 event_chain = XEVENT_NEXT (event_chain); | |
| 1098 } | |
| 1099 | |
| 2500 | 1100 ABORT (); |
| 428 | 1101 return Qnil; |
| 1102 } | |
| 1103 | |
| 1104 Lisp_Object | |
| 1105 event_chain_nth (Lisp_Object event_chain, int n) | |
| 1106 { | |
| 1107 Lisp_Object event; | |
| 1108 EVENT_CHAIN_LOOP (event, event_chain) | |
| 1109 { | |
| 1110 if (!n) | |
| 1111 return event; | |
| 1112 n--; | |
| 1113 } | |
| 1114 return Qnil; | |
| 1115 } | |
| 1116 | |
| 771 | 1117 /* Return a freshly allocated copy of all events in the given chain. */ |
| 1118 | |
| 428 | 1119 Lisp_Object |
| 1120 copy_event_chain (Lisp_Object event_chain) | |
| 1121 { | |
| 1122 Lisp_Object new_chain = Qnil; | |
| 1123 Lisp_Object new_chain_tail = Qnil; | |
| 1124 Lisp_Object event; | |
| 1125 | |
| 1126 EVENT_CHAIN_LOOP (event, event_chain) | |
| 1127 { | |
| 1128 Lisp_Object copy = Fcopy_event (event, Qnil); | |
| 1129 enqueue_event (copy, &new_chain, &new_chain_tail); | |
| 1130 } | |
| 1131 | |
| 1132 return new_chain; | |
| 1133 } | |
| 1134 | |
| 771 | 1135 /* Given a pointer (maybe nil) into an old chain (also maybe nil, if |
| 1136 pointer is nil) and a new chain which is a copy of the old, return | |
| 1137 the corresponding new pointer. */ | |
| 1138 Lisp_Object | |
| 1139 transfer_event_chain_pointer (Lisp_Object pointer, Lisp_Object old_chain, | |
| 1140 Lisp_Object new_chain) | |
| 1141 { | |
| 1142 if (NILP (pointer)) | |
| 1143 return Qnil; | |
| 1144 assert (!NILP (old_chain)); | |
| 800 | 1145 #ifdef ERROR_CHECK_STRUCTURES |
| 771 | 1146 /* make sure we're actually in the chain */ |
| 1147 event_chain_find_previous (old_chain, pointer); | |
| 1148 assert (event_chain_count (old_chain) == event_chain_count (new_chain)); | |
| 800 | 1149 #endif /* ERROR_CHECK_STRUCTURES */ |
| 771 | 1150 return event_chain_nth (new_chain, |
| 1151 event_chain_count (old_chain) - | |
| 1152 event_chain_count (pointer)); | |
| 1153 } | |
| 1154 | |
| 428 | 1155 |
| 771 | 1156 /************************************************************************/ |
| 1157 /* higher level functions */ | |
| 1158 /************************************************************************/ | |
| 428 | 1159 |
| 1160 Lisp_Object QKbackspace, QKtab, QKlinefeed, QKreturn, QKescape, | |
| 1161 QKspace, QKdelete; | |
| 1162 | |
| 1163 int | |
| 1164 command_event_p (Lisp_Object event) | |
| 1165 { | |
| 1166 switch (XEVENT_TYPE (event)) | |
| 1167 { | |
| 1168 case key_press_event: | |
| 1169 case button_press_event: | |
| 1170 case button_release_event: | |
| 1171 case misc_user_event: | |
| 1172 return 1; | |
| 1173 default: | |
| 1174 return 0; | |
| 1175 } | |
| 1176 } | |
| 1177 | |
|
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1178 /* META_BEHAVIOR can be one of the following values, defined in events.h: |
|
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1179 |
|
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1180 high_bit_is_meta |
|
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1181 use_console_meta_flag |
|
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1182 latin_1_maps_to_itself |
|
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1183 |
| 1204 | 1184 DO_BACKSPACE_MAPPING means that if CON is a TTY, and C is a the TTY's |
| 1185 backspace character, the event will have keysym `backspace' instead of | |
| 1186 '(control h). It is clearly correct to do this conversion is the | |
| 1187 character was just read from a TTY, clearly incorrect inside of | |
| 1188 define-key, which must be able to handle all consoles. #### What about | |
| 1189 in other circumstances? #### Should the user have access to this flag? | |
| 1190 | |
| 1191 #### We need to go through and review all the flags in | |
| 1192 character_to_event() and event_to_character() and figure out exactly | |
| 1193 under what circumstances they should or should not be set, then go | |
| 1194 through and review all callers of character_to_event(), | |
| 1195 Fcharacter_to_event(), event_to_character(), and Fevent_to_character() | |
| 1196 and check that they are passing the correct flags in for their varied | |
| 1197 circumstances. | |
| 1198 | |
| 1199 #### Some of this garbage, and some of the flags, could go away if we | |
| 1200 implemented the suggestion, originally from event-Xt.c: | |
| 1201 | |
| 2828 | 1202 [[ The way that keysym correspondence to characters should work: |
| 1204 | 1203 - a Lisp_Event should contain a keysym AND a character slot. |
| 1204 - keybindings are tried with the keysym. If no binding can be found, | |
| 2828 | 1205 and there is a corresponding character, call self-insert-command. ]] |
| 1206 | |
| 1207 That's an X-specific way of thinking. All the other platforms--even | |
| 1208 the TTY, make sure you've done (set-input-mode t nil 1) and set your | |
| 1209 console coding system appropriately when checking--just use | |
| 1210 characters as emacs keysyms, and, together with defaulting to | |
| 1211 self-insert-command if an unbound key with a character correspondence | |
| 1212 is typed, that works fine for them. (Yes, this ignores GTK.) | |
| 1213 | |
| 1214 [[ [... snipping other suggestions which I've implemented.] | |
| 1215 Nuke the Qascii_character property. ]] | |
| 1204 | 1216 |
| 2828 | 1217 Well, we've renamed it anyway--it was badly named. |
| 1218 Qcharacter_of_keysym, here we go. It's really only with X11 that how | |
| 1219 to map between adiaeresis and (int-to-char #xE4), or ellipsis and | |
| 1220 whatever, becomes an issue, and IMO the property approach to this is | |
| 1221 fine. Aidan Kehoe, 2005-05-15. | |
| 1204 | 1222 |
| 2828 | 1223 [[ This would apparently solve a lot of different problems. ]] |
| 1224 | |
| 1225 I'd be interested to know what's left. Removing the allow-meta | |
| 1226 argument from event-to-character would be a Good Thing, IMO, but | |
| 1227 beyond that, I'm not sure what else there is to do wrt. key | |
| 1228 mappings. Of course, feedback from users of the Russian C-x facility | |
| 1229 is still needed. */ | |
| 428 | 1230 |
| 1231 void | |
| 867 | 1232 character_to_event (Ichar c, Lisp_Event *event, struct console *con, |
|
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1233 character_to_event_meta_behavior meta_behavior, |
| 2340 | 1234 int USED_IF_TTY (do_backspace_mapping)) |
| 428 | 1235 { |
| 1236 Lisp_Object k = Qnil; | |
| 442 | 1237 int m = 0; |
| 934 | 1238 if (EVENT_TYPE (event) == dead_event) |
| 563 | 1239 invalid_argument ("character-to-event called with a deallocated event!", Qunbound); |
| 428 | 1240 |
| 1241 #ifndef MULE | |
| 1242 c &= 255; | |
| 1243 #endif | |
|
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1244 if (meta_behavior != latin_1_maps_to_itself && c > 127 && c <= 255) |
| 428 | 1245 { |
| 1246 int meta_flag = 1; | |
|
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1247 if (meta_behavior == use_console_meta_flag && CONSOLE_TTY_P (con)) |
| 428 | 1248 meta_flag = TTY_FLAGS (con).meta_key; |
| 1249 switch (meta_flag) | |
| 1250 { | |
| 1251 case 0: /* ignore top bit; it's parity */ | |
| 1252 c -= 128; | |
| 1253 break; | |
| 1254 case 1: /* top bit is meta */ | |
| 1255 c -= 128; | |
| 442 | 1256 m = XEMACS_MOD_META; |
| 428 | 1257 break; |
| 1258 default: /* this is a real character */ | |
| 1259 break; | |
| 1260 } | |
| 1261 } | |
| 442 | 1262 if (c < ' ') c += '@', m |= XEMACS_MOD_CONTROL; |
| 1263 if (m & XEMACS_MOD_CONTROL) | |
| 428 | 1264 { |
| 1265 switch (c) | |
| 1266 { | |
| 442 | 1267 case 'I': k = QKtab; m &= ~XEMACS_MOD_CONTROL; break; |
| 1268 case 'J': k = QKlinefeed; m &= ~XEMACS_MOD_CONTROL; break; | |
| 1269 case 'M': k = QKreturn; m &= ~XEMACS_MOD_CONTROL; break; | |
| 1270 case '[': k = QKescape; m &= ~XEMACS_MOD_CONTROL; break; | |
| 428 | 1271 default: |
| 1204 | 1272 #if defined (HAVE_TTY) |
| 428 | 1273 if (do_backspace_mapping && |
| 1274 CHARP (con->tty_erase_char) && | |
| 1275 c - '@' == XCHAR (con->tty_erase_char)) | |
| 1276 { | |
| 1277 k = QKbackspace; | |
| 442 | 1278 m &= ~XEMACS_MOD_CONTROL; |
| 428 | 1279 } |
| 1204 | 1280 #endif /* defined (HAVE_TTY) */ |
| 428 | 1281 break; |
| 1282 } | |
| 1283 if (c >= 'A' && c <= 'Z') c -= 'A'-'a'; | |
| 1284 } | |
| 1204 | 1285 #if defined (HAVE_TTY) |
| 428 | 1286 else if (do_backspace_mapping && |
| 1287 CHARP (con->tty_erase_char) && c == XCHAR (con->tty_erase_char)) | |
| 1288 k = QKbackspace; | |
| 1204 | 1289 #endif /* defined (HAVE_TTY) */ |
| 428 | 1290 else if (c == 127) |
| 1291 k = QKdelete; | |
| 1292 else if (c == ' ') | |
| 1293 k = QKspace; | |
| 1294 | |
| 934 | 1295 set_event_type (event, key_press_event); |
| 1296 SET_EVENT_TIMESTAMP_ZERO (event); /* #### */ | |
| 1297 SET_EVENT_CHANNEL (event, wrap_console (con)); | |
| 1204 | 1298 SET_EVENT_KEY_KEYSYM (event, (!NILP (k) ? k : make_char (c))); |
| 1299 SET_EVENT_KEY_MODIFIERS (event, m); | |
| 428 | 1300 } |
| 1301 | |
| 867 | 1302 Ichar |
| 1204 | 1303 event_to_character (Lisp_Object event, |
| 428 | 1304 int allow_extra_modifiers, |
| 2828 | 1305 int allow_meta) |
| 428 | 1306 { |
| 867 | 1307 Ichar c = 0; |
| 428 | 1308 Lisp_Object code; |
| 1309 | |
| 1204 | 1310 if (XEVENT_TYPE (event) != key_press_event) |
| 428 | 1311 { |
| 1204 | 1312 assert (XEVENT_TYPE (event) != dead_event); |
| 428 | 1313 return -1; |
| 1314 } | |
| 1315 if (!allow_extra_modifiers && | |
| 2828 | 1316 XEVENT_KEY_MODIFIERS (event) & |
| 1317 (XEMACS_MOD_SUPER|XEMACS_MOD_HYPER|XEMACS_MOD_ALT)) | |
| 428 | 1318 return -1; |
| 1204 | 1319 if (CHAR_OR_CHAR_INTP (XEVENT_KEY_KEYSYM (event))) |
| 1320 c = XCHAR_OR_CHAR_INT (XEVENT_KEY_KEYSYM (event)); | |
| 1321 else if (!SYMBOLP (XEVENT_KEY_KEYSYM (event))) | |
| 2500 | 1322 ABORT (); |
| 1204 | 1323 else if (CHAR_OR_CHAR_INTP (code = Fget (XEVENT_KEY_KEYSYM (event), |
| 2828 | 1324 Qcharacter_of_keysym, Qnil))) |
| 428 | 1325 c = XCHAR_OR_CHAR_INT (code); |
| 1326 else | |
| 2828 | 1327 { |
| 1328 Lisp_Object thekeysym = XEVENT_KEY_KEYSYM (event); | |
| 1329 | |
| 1330 if (CHAR_OR_CHAR_INTP (code = Fget (thekeysym, Qascii_character, Qnil))) | |
| 1331 { | |
| 1332 c = XCHAR_OR_CHAR_INT (code); | |
| 1333 warn_when_safe(Qkey_mapping, Qwarning, | |
| 1334 "Obsolete key binding technique.\n" | |
| 428 | 1335 |
| 2828 | 1336 "Some code you're using bound %s to `self-insert-command' and messed around\n" |
| 1337 "with its `ascii-character' property. Doing this is deprecated, and the code\n" | |
| 1338 "should be updated to use the `set-character-of-keysym' interface.\n" | |
| 1339 "If you're the one updating the code, first check if there's still a need\n" | |
| 1340 "for it; we support many more X11 keysyms out of the box now than we did\n" | |
| 1341 "in the past. ", XSTRING_DATA(XSYMBOL_NAME(thekeysym))); | |
| 1342 /* Only show the warning once for each keysym. */ | |
| 1343 Fput(thekeysym, Qcharacter_of_keysym, code); | |
| 1344 } | |
| 1345 else | |
| 1346 { | |
| 1347 return -1; | |
| 1348 } | |
| 1349 } | |
| 1204 | 1350 if (XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_CONTROL) |
| 428 | 1351 { |
| 1352 if (c >= 'a' && c <= 'z') | |
| 1353 c -= ('a' - 'A'); | |
| 1354 else | |
| 1355 /* reject Control-Shift- keys */ | |
| 1356 if (c >= 'A' && c <= 'Z' && !allow_extra_modifiers) | |
| 1357 return -1; | |
| 1358 | |
| 1359 if (c >= '@' && c <= '_') | |
| 1360 c -= '@'; | |
| 1361 else if (c == ' ') /* C-space and C-@ are the same. */ | |
| 1362 c = 0; | |
| 1363 else | |
| 1364 /* reject keys that can't take Control- modifiers */ | |
| 1365 if (! allow_extra_modifiers) return -1; | |
| 1366 } | |
| 1367 | |
| 1204 | 1368 if (XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_META) |
| 428 | 1369 { |
| 1370 if (! allow_meta) return -1; | |
| 1204 | 1371 if (c >= 128) return -1; /* don't allow M-oslash (overlap) */ |
| 428 | 1372 c |= 0200; |
| 1373 } | |
| 1374 return c; | |
| 1375 } | |
| 1376 | |
| 2862 | 1377 DEFUN ("event-to-character", Fevent_to_character, 1, 4, 0, /* |
| 2828 | 1378 Return the closest character approximation to the given event object. |
| 428 | 1379 If the event isn't a keypress, this returns nil. |
| 1380 If the ALLOW-EXTRA-MODIFIERS argument is non-nil, then this is lenient in | |
| 1381 its translation; it will ignore modifier keys other than control and meta, | |
| 1382 and will ignore the shift modifier on those characters which have no | |
| 1383 shifted ASCII equivalent (Control-Shift-A for example, will be mapped to | |
| 1384 the same ASCII code as Control-A). | |
| 1385 If the ALLOW-META argument is non-nil, then the Meta modifier will be | |
| 1386 represented by turning on the high bit of the byte returned; otherwise, nil | |
| 1387 will be returned for events containing the Meta modifier. | |
| 1204 | 1388 Note that ALLOW-META may cause ambiguity between meta characters and |
| 1389 Latin-1 characters. | |
| 2862 | 1390 ALLOW-NON-ASCII is unused, and retained for compatibility. |
| 428 | 1391 */ |
| 2862 | 1392 (event, allow_extra_modifiers, allow_meta, UNUSED(allow_non_ascii))) |
| 428 | 1393 { |
| 867 | 1394 Ichar c; |
| 428 | 1395 CHECK_LIVE_EVENT (event); |
| 1204 | 1396 c = event_to_character (event, |
| 428 | 1397 !NILP (allow_extra_modifiers), |
| 2828 | 1398 !NILP (allow_meta)); |
| 428 | 1399 return c < 0 ? Qnil : make_char (c); |
| 1400 } | |
| 1401 | |
| 1402 DEFUN ("character-to-event", Fcharacter_to_event, 1, 4, 0, /* | |
| 444 | 1403 Convert KEY-DESCRIPTION into an event structure, replete with bucky bits. |
| 428 | 1404 |
| 444 | 1405 KEY-DESCRIPTION is the first argument, and the event to fill in is the |
| 1406 second. This function contains knowledge about what various kinds of | |
| 1407 arguments ``mean'' -- for example, the number 9 is converted to the | |
| 1408 character ``Tab'', not the distinct character ``Control-I''. | |
| 428 | 1409 |
| 3025 | 1410 KEY-DESCRIPTION can be an integer, a character, a symbol such as `clear', |
| 444 | 1411 or a list such as '(control backspace). |
| 1412 | |
| 1413 If the optional second argument EVENT is an event, it is modified and | |
| 1414 returned; otherwise, a new event object is created and returned. | |
| 428 | 1415 |
| 1416 Optional third arg CONSOLE is the console to store in the event, and | |
| 1417 defaults to the selected console. | |
| 1418 | |
| 444 | 1419 If KEY-DESCRIPTION is an integer or character, the high bit may be |
| 1204 | 1420 interpreted as the meta key. (This is done for backward compatibility in |
| 1421 lots of places -- specifically, because lots of Lisp code uses specs like | |
| 1422 ?\M-d and "\M-d" in key code, expecting this to work; yet these are in | |
| 1423 reality converted directly to 8-bit characters by the Lisp reader.) If | |
| 1424 USE-CONSOLE-META-FLAG is nil or CONSOLE is not a TTY, this will always be | |
| 1425 the case. If USE-CONSOLE-META-FLAG is non-nil and CONSOLE is a TTY, the | |
| 1426 `meta' flag for CONSOLE affects whether the high bit is interpreted as a | |
| 1427 meta key. (See `set-input-mode'.) Don't set this flag to non-nil unless | |
| 1428 you know what you're doing (more specifically, only if the character came | |
| 1429 directly from a TTY, not from the user). If you don't want this silly meta | |
| 1430 interpretation done, you should pass in a list containing the character. | |
| 428 | 1431 |
| 1432 Beware that character-to-event and event-to-character are not strictly | |
| 1433 inverse functions, since events contain much more information than the | |
| 444 | 1434 Lisp character object type can encode. |
| 428 | 1435 */ |
|
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1436 (keystroke, event, console, use_console_meta_flag_)) |
| 428 | 1437 { |
| 1438 struct console *con = decode_console (console); | |
| 1439 if (NILP (event)) | |
| 1440 event = Fmake_event (Qnil, Qnil); | |
| 1441 else | |
| 1442 CHECK_LIVE_EVENT (event); | |
| 444 | 1443 if (CONSP (keystroke) || SYMBOLP (keystroke)) |
| 1444 key_desc_list_to_event (keystroke, event, 1); | |
| 428 | 1445 else |
| 1446 { | |
| 444 | 1447 CHECK_CHAR_COERCE_INT (keystroke); |
| 1448 character_to_event (XCHAR (keystroke), XEVENT (event), con, | |
|
4780
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1449 (NILP (use_console_meta_flag_) ? |
|
2fd201d73a92
Call character_to_event on characters received from XIM, event-Xt.c
Aidan Kehoe <kehoea@parhasard.net>
parents:
3092
diff
changeset
|
1450 high_bit_is_meta : use_console_meta_flag), 1); |
| 428 | 1451 } |
| 1452 return event; | |
| 1453 } | |
| 1454 | |
| 1455 void | |
| 1456 nth_of_key_sequence_as_event (Lisp_Object seq, int n, Lisp_Object event) | |
| 1457 { | |
| 1458 assert (STRINGP (seq) || VECTORP (seq)); | |
| 1459 assert (n < XINT (Flength (seq))); | |
| 1460 | |
| 1461 if (STRINGP (seq)) | |
| 1462 { | |
| 867 | 1463 Ichar ch = string_ichar (seq, n); |
| 428 | 1464 Fcharacter_to_event (make_char (ch), event, Qnil, Qnil); |
| 1465 } | |
| 1466 else | |
| 1467 { | |
| 1468 Lisp_Object keystroke = XVECTOR_DATA (seq)[n]; | |
| 1469 if (EVENTP (keystroke)) | |
| 1470 Fcopy_event (keystroke, event); | |
| 1471 else | |
| 1472 Fcharacter_to_event (keystroke, event, Qnil, Qnil); | |
| 1473 } | |
| 1474 } | |
| 1475 | |
| 1476 Lisp_Object | |
| 1477 key_sequence_to_event_chain (Lisp_Object seq) | |
| 1478 { | |
| 1479 int len = XINT (Flength (seq)); | |
| 1480 int i; | |
| 1481 Lisp_Object head = Qnil, tail = Qnil; | |
| 1482 | |
| 1483 for (i = 0; i < len; i++) | |
| 1484 { | |
| 1485 Lisp_Object event = Fmake_event (Qnil, Qnil); | |
| 1486 nth_of_key_sequence_as_event (seq, i, event); | |
| 1487 enqueue_event (event, &head, &tail); | |
| 1488 } | |
| 1489 | |
| 1490 return head; | |
| 1491 } | |
| 1492 | |
| 934 | 1493 |
| 793 | 1494 /* Concatenate a string description of EVENT onto the end of BUF. If |
| 1495 BRIEF, use short forms for keys, e.g. C- instead of control-. */ | |
| 1496 | |
| 934 | 1497 void |
| 1498 format_event_object (Eistring *buf, Lisp_Object event, int brief) | |
| 428 | 1499 { |
| 1500 int mouse_p = 0; | |
| 1501 int mod = 0; | |
| 1502 Lisp_Object key; | |
| 1503 | |
| 1204 | 1504 switch (XEVENT_TYPE (event)) |
| 428 | 1505 { |
| 1506 case key_press_event: | |
| 1507 { | |
| 1204 | 1508 mod = XEVENT_KEY_MODIFIERS (event); |
| 1509 key = XEVENT_KEY_KEYSYM (event); | |
| 428 | 1510 /* Hack. */ |
| 1511 if (! brief && CHARP (key) && | |
| 793 | 1512 mod & (XEMACS_MOD_CONTROL | XEMACS_MOD_META | XEMACS_MOD_SUPER | |
| 1513 XEMACS_MOD_HYPER)) | |
| 428 | 1514 { |
| 1515 int k = XCHAR (key); | |
| 1516 if (k >= 'a' && k <= 'z') | |
| 1517 key = make_char (k - ('a' - 'A')); | |
| 1518 else if (k >= 'A' && k <= 'Z') | |
| 442 | 1519 mod |= XEMACS_MOD_SHIFT; |
| 428 | 1520 } |
| 1521 break; | |
| 1522 } | |
| 1523 case button_release_event: | |
| 1524 mouse_p++; | |
| 1525 /* Fall through */ | |
| 1526 case button_press_event: | |
| 1527 { | |
| 1528 mouse_p++; | |
| 1204 | 1529 mod = XEVENT_BUTTON_MODIFIERS (event); |
| 1530 key = make_char (XEVENT_BUTTON_BUTTON (event) + '0'); | |
| 428 | 1531 break; |
| 1532 } | |
| 1533 case magic_event: | |
| 1534 { | |
| 788 | 1535 Lisp_Object stream; |
| 1536 struct gcpro gcpro1; | |
| 1537 GCPRO1 (stream); | |
| 428 | 1538 |
| 788 | 1539 stream = make_resizing_buffer_output_stream (); |
| 1204 | 1540 event_stream_format_magic_event (XEVENT (event), stream); |
| 788 | 1541 Lstream_flush (XLSTREAM (stream)); |
| 793 | 1542 eicat_raw (buf, resizing_buffer_stream_ptr (XLSTREAM (stream)), |
| 1543 Lstream_byte_count (XLSTREAM (stream))); | |
| 788 | 1544 Lstream_delete (XLSTREAM (stream)); |
| 1545 UNGCPRO; | |
| 428 | 1546 return; |
| 1547 } | |
| 2421 | 1548 case magic_eval_event: eicat_ascii (buf, "magic-eval"); return; |
| 1549 case pointer_motion_event: eicat_ascii (buf, "motion"); return; | |
| 1550 case misc_user_event: eicat_ascii (buf, "misc-user"); return; | |
| 1551 case eval_event: eicat_ascii (buf, "eval"); return; | |
| 1552 case process_event: eicat_ascii (buf, "process"); return; | |
| 1553 case timeout_event: eicat_ascii (buf, "timeout"); return; | |
| 1554 case empty_event: eicat_ascii (buf, "empty"); return; | |
| 1555 case dead_event: eicat_ascii (buf, "DEAD-EVENT"); return; | |
| 428 | 1556 default: |
| 2500 | 1557 ABORT (); |
| 442 | 1558 return; |
| 428 | 1559 } |
| 793 | 1560 #define modprint(x,y) \ |
| 2421 | 1561 do { if (brief) eicat_ascii (buf, (y)); else eicat_ascii (buf, (x)); } while (0) |
| 442 | 1562 if (mod & XEMACS_MOD_CONTROL) modprint ("control-", "C-"); |
| 1563 if (mod & XEMACS_MOD_META) modprint ("meta-", "M-"); | |
| 1564 if (mod & XEMACS_MOD_SUPER) modprint ("super-", "S-"); | |
| 1565 if (mod & XEMACS_MOD_HYPER) modprint ("hyper-", "H-"); | |
| 1566 if (mod & XEMACS_MOD_ALT) modprint ("alt-", "A-"); | |
| 1567 if (mod & XEMACS_MOD_SHIFT) modprint ("shift-", "Sh-"); | |
| 428 | 1568 if (mouse_p) |
| 1569 { | |
| 2421 | 1570 eicat_ascii (buf, "button"); |
| 428 | 1571 --mouse_p; |
| 1572 } | |
| 1573 | |
| 1574 #undef modprint | |
| 1575 | |
| 1576 if (CHARP (key)) | |
| 793 | 1577 eicat_ch (buf, XCHAR (key)); |
| 428 | 1578 else if (SYMBOLP (key)) |
| 1579 { | |
| 2367 | 1580 const Ascbyte *str = 0; |
| 428 | 1581 if (brief) |
| 1582 { | |
| 1583 if (EQ (key, QKlinefeed)) str = "LFD"; | |
| 1584 else if (EQ (key, QKtab)) str = "TAB"; | |
| 1585 else if (EQ (key, QKreturn)) str = "RET"; | |
| 1586 else if (EQ (key, QKescape)) str = "ESC"; | |
| 1587 else if (EQ (key, QKdelete)) str = "DEL"; | |
| 1588 else if (EQ (key, QKspace)) str = "SPC"; | |
| 1589 else if (EQ (key, QKbackspace)) str = "BS"; | |
| 1590 } | |
| 1591 if (str) | |
| 2421 | 1592 eicat_ascii (buf, str); |
| 428 | 1593 else |
| 793 | 1594 eicat_lstr (buf, XSYMBOL (key)->name); |
| 428 | 1595 } |
| 1596 else | |
| 2500 | 1597 ABORT (); |
| 428 | 1598 if (mouse_p) |
| 2421 | 1599 eicat_ascii (buf, "up"); |
| 428 | 1600 } |
| 1601 | |
| 1204 | 1602 void |
| 1603 upshift_event (Lisp_Object event) | |
| 1604 { | |
| 1605 Lisp_Object keysym = XEVENT_KEY_KEYSYM (event); | |
| 1606 Ichar c = 0; | |
| 1607 | |
| 1608 if (CHAR_OR_CHAR_INTP (keysym) | |
| 1609 && ((c = XCHAR_OR_CHAR_INT (keysym)), | |
| 1610 c >= 'a' && c <= 'z')) | |
| 1611 XSET_EVENT_KEY_KEYSYM (event, make_char (c + 'A' - 'a')); | |
| 1612 else | |
| 1613 if (!(XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_SHIFT)) | |
| 1614 XSET_EVENT_KEY_MODIFIERS | |
| 1615 (event, XEVENT_KEY_MODIFIERS (event) |= XEMACS_MOD_SHIFT); | |
| 1616 } | |
| 1617 | |
| 1618 void | |
| 1619 downshift_event (Lisp_Object event) | |
| 1620 { | |
| 1621 Lisp_Object keysym = XEVENT_KEY_KEYSYM (event); | |
| 1622 Ichar c = 0; | |
| 1623 | |
| 1624 if (XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_SHIFT) | |
| 1625 XSET_EVENT_KEY_MODIFIERS | |
| 1626 (event, XEVENT_KEY_MODIFIERS (event) & ~XEMACS_MOD_SHIFT); | |
| 1627 else if (CHAR_OR_CHAR_INTP (keysym) | |
| 1628 && ((c = XCHAR_OR_CHAR_INT (keysym)), | |
| 1629 c >= 'A' && c <= 'Z')) | |
| 1630 XSET_EVENT_KEY_KEYSYM (event, make_char (c + 'a' - 'A')); | |
| 1631 } | |
| 1632 | |
| 1633 int | |
| 1634 event_upshifted_p (Lisp_Object event) | |
| 1635 { | |
| 1636 Lisp_Object keysym = XEVENT_KEY_KEYSYM (event); | |
| 1637 Ichar c = 0; | |
| 1638 | |
| 1639 if ((XEVENT_KEY_MODIFIERS (event) & XEMACS_MOD_SHIFT) | |
| 1640 || (CHAR_OR_CHAR_INTP (keysym) | |
| 1641 && ((c = XCHAR_OR_CHAR_INT (keysym)), | |
| 1642 c >= 'A' && c <= 'Z'))) | |
| 1643 return 1; | |
| 1644 else | |
| 1645 return 0; | |
| 1646 } | |
| 934 | 1647 |
| 428 | 1648 DEFUN ("eventp", Feventp, 1, 1, 0, /* |
| 1649 True if OBJECT is an event object. | |
| 1650 */ | |
| 1651 (object)) | |
| 1652 { | |
| 1653 return EVENTP (object) ? Qt : Qnil; | |
| 1654 } | |
| 1655 | |
| 1656 DEFUN ("event-live-p", Fevent_live_p, 1, 1, 0, /* | |
| 1657 True if OBJECT is an event object that has not been deallocated. | |
| 1658 */ | |
| 1659 (object)) | |
| 1660 { | |
| 934 | 1661 return EVENTP (object) && XEVENT_TYPE (object) != dead_event ? |
| 1662 Qt : Qnil; | |
| 428 | 1663 } |
| 1664 | |
| 1665 #if 0 /* debugging functions */ | |
| 1666 | |
| 826 | 1667 DEFUN ("event-next", Fevent_next, 1, 1, 0, /* |
| 428 | 1668 Return the event object's `next' event, or nil if it has none. |
| 1669 The `next-event' field is changed by calling `set-next-event'. | |
| 1670 */ | |
| 1671 (event)) | |
| 1672 { | |
| 440 | 1673 Lisp_Event *e; |
| 428 | 1674 CHECK_LIVE_EVENT (event); |
| 1675 | |
| 1676 return XEVENT_NEXT (event); | |
| 1677 } | |
| 1678 | |
| 826 | 1679 DEFUN ("set-event-next", Fset_event_next, 2, 2, 0, /* |
| 428 | 1680 Set the `next event' of EVENT to NEXT-EVENT. |
| 1681 NEXT-EVENT must be an event object or nil. | |
| 1682 */ | |
| 1683 (event, next_event)) | |
| 1684 { | |
| 1685 Lisp_Object ev; | |
| 1686 | |
| 1687 CHECK_LIVE_EVENT (event); | |
| 1688 if (NILP (next_event)) | |
| 1689 { | |
| 1690 XSET_EVENT_NEXT (event, Qnil); | |
| 1691 return Qnil; | |
| 1692 } | |
| 1693 | |
| 1694 CHECK_LIVE_EVENT (next_event); | |
| 1695 | |
| 1696 EVENT_CHAIN_LOOP (ev, XEVENT_NEXT (event)) | |
| 1697 { | |
| 1698 QUIT; | |
| 1699 if (EQ (ev, event)) | |
| 563 | 1700 invalid_operation_2 ("Cyclic event-next", event, next_event); |
| 428 | 1701 } |
| 1702 XSET_EVENT_NEXT (event, next_event); | |
| 1703 return next_event; | |
| 1704 } | |
| 1705 | |
| 1706 #endif /* 0 */ | |
| 1707 | |
| 1708 DEFUN ("event-type", Fevent_type, 1, 1, 0, /* | |
| 1709 Return the type of EVENT. | |
| 1710 This will be a symbol; one of | |
| 1711 | |
| 1712 key-press A key was pressed. | |
| 1713 button-press A mouse button was pressed. | |
| 1714 button-release A mouse button was released. | |
| 1715 misc-user Some other user action happened; typically, this is | |
| 1716 a menu selection or scrollbar action. | |
| 1717 motion The mouse moved. | |
| 1718 process Input is available from a subprocess. | |
| 1719 timeout A timeout has expired. | |
| 1720 eval This causes a specified action to occur when dispatched. | |
| 1721 magic Some window-system-specific event has occurred. | |
| 1722 empty The event has been allocated but not assigned. | |
| 1723 | |
| 1724 */ | |
| 1725 (event)) | |
| 1726 { | |
| 1727 CHECK_LIVE_EVENT (event); | |
| 934 | 1728 switch (XEVENT_TYPE (event)) |
| 428 | 1729 { |
| 1730 case key_press_event: return Qkey_press; | |
| 1731 case button_press_event: return Qbutton_press; | |
| 1732 case button_release_event: return Qbutton_release; | |
| 1733 case misc_user_event: return Qmisc_user; | |
| 1734 case pointer_motion_event: return Qmotion; | |
| 1735 case process_event: return Qprocess; | |
| 1736 case timeout_event: return Qtimeout; | |
| 1737 case eval_event: return Qeval; | |
| 1738 case magic_event: | |
| 1739 case magic_eval_event: | |
| 1740 return Qmagic; | |
| 1741 | |
| 1742 case empty_event: | |
| 1743 return Qempty; | |
| 1744 | |
| 1745 default: | |
| 2500 | 1746 ABORT (); |
| 428 | 1747 return Qnil; |
| 1748 } | |
| 1749 } | |
| 1750 | |
| 1751 DEFUN ("event-timestamp", Fevent_timestamp, 1, 1, 0, /* | |
| 1752 Return the timestamp of the event object EVENT. | |
| 442 | 1753 Timestamps are measured in milliseconds since the start of the window system. |
| 1754 They are NOT related to any current time measurement. | |
| 1755 They should be compared with `event-timestamp<'. | |
| 1756 See also `current-event-timestamp'. | |
| 428 | 1757 */ |
| 1758 (event)) | |
| 1759 { | |
| 1760 CHECK_LIVE_EVENT (event); | |
| 1761 /* This junk is so that timestamps don't get to be negative, but contain | |
|
5307
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1762 as many bits as this particular emacs will allow. We could return |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1763 bignums on builds that support them, but that involves consing and |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1764 doesn't work on builds that don't support bignums. |
| 428 | 1765 */ |
| 2039 | 1766 return make_int (EMACS_INT_MAX & XEVENT_TIMESTAMP (event)); |
| 428 | 1767 } |
| 1768 | |
| 2039 | 1769 #define TIMESTAMP_HALFSPACE (1L << (INT_VALBITS - 2)) |
| 442 | 1770 |
| 1771 DEFUN ("event-timestamp<", Fevent_timestamp_lessp, 2, 2, 0, /* | |
| 1772 Return true if timestamp TIME1 is earlier than timestamp TIME2. | |
| 1773 This correctly handles timestamp wrap. | |
| 1774 See also `event-timestamp' and `current-event-timestamp'. | |
| 1775 */ | |
| 1776 (time1, time2)) | |
| 1777 { | |
| 1778 EMACS_INT t1, t2; | |
| 1779 | |
|
5307
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1780 check_integer_range (time1, Qzero, make_integer (EMACS_INT_MAX)); |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1781 check_integer_range (time2, Qzero, make_integer (EMACS_INT_MAX)); |
|
c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5191
diff
changeset
|
1782 |
| 442 | 1783 t1 = XINT (time1); |
| 1784 t2 = XINT (time2); | |
| 1785 | |
| 1786 if (t1 < t2) | |
| 1787 return t2 - t1 < TIMESTAMP_HALFSPACE ? Qt : Qnil; | |
| 1788 else | |
| 1789 return t1 - t2 < TIMESTAMP_HALFSPACE ? Qnil : Qt; | |
| 1790 } | |
| 1791 | |
| 934 | 1792 #define CHECK_EVENT_TYPE(e,t1,sym) do { \ |
| 1793 CHECK_LIVE_EVENT (e); \ | |
| 1794 if (XEVENT_TYPE (e) != (t1)) \ | |
| 1795 e = wrong_type_argument (sym,e); \ | |
| 1796 } while (0) | |
| 1797 | |
| 1798 #define CHECK_EVENT_TYPE2(e,t1,t2,sym) do { \ | |
| 1799 CHECK_LIVE_EVENT (e); \ | |
| 1800 { \ | |
| 1801 emacs_event_type CET_type = XEVENT_TYPE (e); \ | |
| 1802 if (CET_type != (t1) && \ | |
| 1803 CET_type != (t2)) \ | |
| 1804 e = wrong_type_argument (sym,e); \ | |
| 1805 } \ | |
| 1806 } while (0) | |
| 1807 | |
| 1808 #define CHECK_EVENT_TYPE3(e,t1,t2,t3,sym) do { \ | |
| 1809 CHECK_LIVE_EVENT (e); \ | |
| 1810 { \ | |
| 1811 emacs_event_type CET_type = XEVENT_TYPE (e); \ | |
| 1812 if (CET_type != (t1) && \ | |
| 1813 CET_type != (t2) && \ | |
| 1814 CET_type != (t3)) \ | |
| 1815 e = wrong_type_argument (sym,e); \ | |
| 1816 } \ | |
| 1817 } while (0) | |
| 428 | 1818 |
| 1819 DEFUN ("event-key", Fevent_key, 1, 1, 0, /* | |
| 1820 Return the Keysym of the key-press event EVENT. | |
| 1821 This will be a character if the event is associated with one, else a symbol. | |
| 1822 */ | |
| 1823 (event)) | |
| 1824 { | |
| 1825 CHECK_EVENT_TYPE (event, key_press_event, Qkey_press_event_p); | |
| 1204 | 1826 return XEVENT_KEY_KEYSYM (event); |
| 428 | 1827 } |
| 1828 | |
| 1829 DEFUN ("event-button", Fevent_button, 1, 1, 0, /* | |
| 444 | 1830 Return the button-number of the button-press or button-release event EVENT. |
| 428 | 1831 */ |
| 1832 (event)) | |
| 1833 { | |
| 1834 CHECK_EVENT_TYPE3 (event, button_press_event, button_release_event, | |
| 1835 misc_user_event, Qbutton_event_p); | |
| 1836 #ifdef HAVE_WINDOW_SYSTEM | |
| 1204 | 1837 if (XEVENT_TYPE (event) == misc_user_event) |
| 1838 return make_int (XEVENT_MISC_USER_BUTTON (event)); | |
| 934 | 1839 else |
| 1204 | 1840 return make_int (XEVENT_BUTTON_BUTTON (event)); |
| 428 | 1841 #else /* !HAVE_WINDOW_SYSTEM */ |
| 1842 return Qzero; | |
| 1843 #endif /* !HAVE_WINDOW_SYSTEM */ | |
| 1844 } | |
| 1845 | |
| 1846 DEFUN ("event-modifier-bits", Fevent_modifier_bits, 1, 1, 0, /* | |
| 442 | 1847 Return a number representing the modifier keys and buttons which were down |
| 428 | 1848 when the given mouse or keyboard event was produced. |
| 442 | 1849 See also the function `event-modifiers'. |
| 428 | 1850 */ |
| 1851 (event)) | |
| 1852 { | |
| 1853 again: | |
| 1854 CHECK_LIVE_EVENT (event); | |
| 934 | 1855 switch (XEVENT_TYPE (event)) |
| 1856 { | |
| 1857 case key_press_event: | |
| 1204 | 1858 return make_int (XEVENT_KEY_MODIFIERS (event)); |
| 934 | 1859 case button_press_event: |
| 1860 case button_release_event: | |
| 1204 | 1861 return make_int (XEVENT_BUTTON_MODIFIERS (event)); |
| 934 | 1862 case pointer_motion_event: |
| 1204 | 1863 return make_int (XEVENT_MOTION_MODIFIERS (event)); |
| 934 | 1864 case misc_user_event: |
| 1204 | 1865 return make_int (XEVENT_MISC_USER_MODIFIERS (event)); |
| 934 | 1866 default: |
| 1867 event = wrong_type_argument (intern ("key-or-mouse-event-p"), event); | |
| 1868 goto again; | |
| 1869 } | |
| 428 | 1870 } |
| 1871 | |
| 1872 DEFUN ("event-modifiers", Fevent_modifiers, 1, 1, 0, /* | |
| 442 | 1873 Return a list of symbols, the names of the modifier keys and buttons |
| 428 | 1874 which were down when the given mouse or keyboard event was produced. |
| 442 | 1875 See also the function `event-modifier-bits'. |
| 1876 | |
| 1877 The possible symbols in the list are | |
| 1878 | |
| 1879 `shift': The Shift key. Will not appear, in general, on key events | |
| 1880 where the keysym is an ASCII character, because using Shift | |
| 1881 on such a character converts it into another character rather | |
| 1882 than actually just adding a Shift modifier. | |
| 1883 | |
| 1884 `control': The Control key. | |
| 1885 | |
| 1886 `meta': The Meta key. On PC's and PC-style keyboards, this is generally | |
| 1887 labelled \"Alt\"; Meta is a holdover from early Lisp Machines and | |
| 1888 such, propagated through the X Window System. On Sun keyboards, | |
| 1889 this key is labelled with a diamond. | |
| 1890 | |
| 1891 `alt': The \"Alt\" key. Alt is in quotes because this does not refer | |
| 1892 to what it obviously should refer to, namely the Alt key on PC | |
| 1893 keyboards. Instead, it refers to the key labelled Alt on Sun | |
| 1894 keyboards, and to no key at all on PC keyboards. | |
| 1895 | |
| 1896 `super': The Super key. Most keyboards don't have any such key, but | |
| 1897 under X Windows using `xmodmap' you can assign any key (such as | |
| 1898 an underused right-shift, right-control, or right-alt key) to | |
| 1899 this key modifier. No support currently exists under MS Windows | |
| 1900 for generating these modifiers. | |
| 1901 | |
| 1902 `hyper': The Hyper key. Works just like the Super key. | |
| 1903 | |
| 1904 `button1': The mouse buttons. This means that the specified button was held | |
| 1905 `button2': down at the time the event occurred. NOTE: For button-press | |
| 1906 `button3': events, the button that was just pressed down does NOT appear in | |
| 1907 `button4': the modifiers. | |
| 1908 `button5': | |
| 1909 | |
| 1910 Button modifiers are currently ignored when defining and looking up key and | |
| 1911 mouse strokes in keymaps. This could be changed, which would allow a user to | |
| 1912 create button-chord actions, use a button as a key modifier and do other | |
| 1913 clever things. | |
| 428 | 1914 */ |
| 1915 (event)) | |
| 1916 { | |
| 1917 int mod = XINT (Fevent_modifier_bits (event)); | |
| 1918 Lisp_Object result = Qnil; | |
| 442 | 1919 struct gcpro gcpro1; |
| 1920 | |
| 1921 GCPRO1 (result); | |
| 1922 if (mod & XEMACS_MOD_SHIFT) result = Fcons (Qshift, result); | |
| 1923 if (mod & XEMACS_MOD_ALT) result = Fcons (Qalt, result); | |
| 1924 if (mod & XEMACS_MOD_HYPER) result = Fcons (Qhyper, result); | |
| 1925 if (mod & XEMACS_MOD_SUPER) result = Fcons (Qsuper, result); | |
| 1926 if (mod & XEMACS_MOD_META) result = Fcons (Qmeta, result); | |
| 1927 if (mod & XEMACS_MOD_CONTROL) result = Fcons (Qcontrol, result); | |
| 1928 if (mod & XEMACS_MOD_BUTTON1) result = Fcons (Qbutton1, result); | |
| 1929 if (mod & XEMACS_MOD_BUTTON2) result = Fcons (Qbutton2, result); | |
| 1930 if (mod & XEMACS_MOD_BUTTON3) result = Fcons (Qbutton3, result); | |
| 1931 if (mod & XEMACS_MOD_BUTTON4) result = Fcons (Qbutton4, result); | |
| 1932 if (mod & XEMACS_MOD_BUTTON5) result = Fcons (Qbutton5, result); | |
| 1933 RETURN_UNGCPRO (Fnreverse (result)); | |
| 428 | 1934 } |
| 1935 | |
| 1936 static int | |
| 1937 event_x_y_pixel_internal (Lisp_Object event, int *x, int *y, int relative) | |
| 1938 { | |
| 1939 struct window *w; | |
| 1940 struct frame *f; | |
| 1941 | |
| 934 | 1942 if (XEVENT_TYPE (event) == pointer_motion_event) |
| 1943 { | |
| 1204 | 1944 *x = XEVENT_MOTION_X (event); |
| 1945 *y = XEVENT_MOTION_Y (event); | |
| 934 | 1946 } |
| 1947 else if (XEVENT_TYPE (event) == button_press_event || | |
| 1948 XEVENT_TYPE (event) == button_release_event) | |
| 1949 { | |
| 1204 | 1950 *x = XEVENT_BUTTON_X (event); |
| 1951 *y = XEVENT_BUTTON_Y (event); | |
| 934 | 1952 } |
| 1953 else if (XEVENT_TYPE (event) == misc_user_event) | |
| 1954 { | |
| 1204 | 1955 *x = XEVENT_MISC_USER_X (event); |
| 1956 *y = XEVENT_MISC_USER_Y (event); | |
| 934 | 1957 } |
| 1958 else | |
| 1959 return 0; | |
| 428 | 1960 f = XFRAME (EVENT_CHANNEL (XEVENT (event))); |
| 1961 | |
| 1962 if (relative) | |
| 1963 { | |
| 1964 w = find_window_by_pixel_pos (*x, *y, f->root_window); | |
| 1965 | |
| 1966 if (!w) | |
| 442 | 1967 return 1; /* #### What should really happen here? */ |
| 428 | 1968 |
| 1969 *x -= w->pixel_left; | |
| 1970 *y -= w->pixel_top; | |
| 1971 } | |
| 1972 else | |
| 1973 { | |
| 1974 *y -= FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) - | |
| 1975 FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f); | |
| 1976 *x -= FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) - | |
| 1977 FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f); | |
| 1978 } | |
| 1979 | |
| 1980 return 1; | |
| 1981 } | |
| 1982 | |
| 1983 DEFUN ("event-window-x-pixel", Fevent_window_x_pixel, 1, 1, 0, /* | |
| 1984 Return the X position in pixels of mouse event EVENT. | |
| 1985 The value returned is relative to the window the event occurred in. | |
| 1986 This will signal an error if the event is not a mouse event. | |
| 1987 See also `mouse-event-p' and `event-x-pixel'. | |
| 1988 */ | |
| 1989 (event)) | |
| 1990 { | |
| 1991 int x, y; | |
| 1992 | |
| 1993 CHECK_LIVE_EVENT (event); | |
| 1994 | |
| 1995 if (!event_x_y_pixel_internal (event, &x, &y, 1)) | |
| 1996 return wrong_type_argument (Qmouse_event_p, event); | |
| 1997 else | |
| 1998 return make_int (x); | |
| 1999 } | |
| 2000 | |
| 2001 DEFUN ("event-window-y-pixel", Fevent_window_y_pixel, 1, 1, 0, /* | |
| 2002 Return the Y position in pixels of mouse event EVENT. | |
| 2003 The value returned is relative to the window the event occurred in. | |
| 2004 This will signal an error if the event is not a mouse event. | |
| 2005 See also `mouse-event-p' and `event-y-pixel'. | |
| 2006 */ | |
| 2007 (event)) | |
| 2008 { | |
| 2009 int x, y; | |
| 2010 | |
| 2011 CHECK_LIVE_EVENT (event); | |
| 2012 | |
| 2013 if (!event_x_y_pixel_internal (event, &x, &y, 1)) | |
| 2014 return wrong_type_argument (Qmouse_event_p, event); | |
| 2015 else | |
| 2016 return make_int (y); | |
| 2017 } | |
| 2018 | |
| 2019 DEFUN ("event-x-pixel", Fevent_x_pixel, 1, 1, 0, /* | |
| 2020 Return the X position in pixels of mouse event EVENT. | |
| 2021 The value returned is relative to the frame the event occurred in. | |
| 2022 This will signal an error if the event is not a mouse event. | |
| 2023 See also `mouse-event-p' and `event-window-x-pixel'. | |
| 2024 */ | |
| 2025 (event)) | |
| 2026 { | |
| 2027 int x, y; | |
| 2028 | |
| 2029 CHECK_LIVE_EVENT (event); | |
| 2030 | |
| 2031 if (!event_x_y_pixel_internal (event, &x, &y, 0)) | |
| 2032 return wrong_type_argument (Qmouse_event_p, event); | |
| 2033 else | |
| 2034 return make_int (x); | |
| 2035 } | |
| 2036 | |
| 2037 DEFUN ("event-y-pixel", Fevent_y_pixel, 1, 1, 0, /* | |
| 2038 Return the Y position in pixels of mouse event EVENT. | |
| 2039 The value returned is relative to the frame the event occurred in. | |
| 2040 This will signal an error if the event is not a mouse event. | |
| 2041 See also `mouse-event-p' `event-window-y-pixel'. | |
| 2042 */ | |
| 2043 (event)) | |
| 2044 { | |
| 2045 int x, y; | |
| 2046 | |
| 2047 CHECK_LIVE_EVENT (event); | |
| 2048 | |
| 2049 if (!event_x_y_pixel_internal (event, &x, &y, 0)) | |
| 2050 return wrong_type_argument (Qmouse_event_p, event); | |
| 2051 else | |
| 2052 return make_int (y); | |
| 2053 } | |
| 2054 | |
| 2055 /* Given an event, return a value: | |
| 2056 | |
| 2057 OVER_TOOLBAR: over one of the 4 frame toolbars | |
| 2058 OVER_MODELINE: over a modeline | |
| 2059 OVER_BORDER: over an internal border | |
| 2060 OVER_NOTHING: over the text area, but not over text | |
| 2061 OVER_OUTSIDE: outside of the frame border | |
| 2062 OVER_TEXT: over text in the text area | |
| 2063 OVER_V_DIVIDER: over windows vertical divider | |
| 2064 | |
| 2065 and return: | |
| 2066 | |
| 2067 The X char position in CHAR_X, if not a null pointer. | |
| 2068 The Y char position in CHAR_Y, if not a null pointer. | |
| 2069 (These last two values are relative to the window the event is over.) | |
| 2070 The window it's over in W, if not a null pointer. | |
| 2071 The buffer position it's over in BUFP, if not a null pointer. | |
| 2072 The closest buffer position in CLOSEST, if not a null pointer. | |
| 2073 | |
| 2074 OBJ_X, OBJ_Y, OBJ1, and OBJ2 are as in pixel_to_glyph_translation(). | |
| 2075 */ | |
| 2076 | |
| 2077 static int | |
| 2078 event_pixel_translation (Lisp_Object event, int *char_x, int *char_y, | |
| 2079 int *obj_x, int *obj_y, | |
| 665 | 2080 struct window **w, Charbpos *bufp, Charbpos *closest, |
| 428 | 2081 Charcount *modeline_closest, |
| 2082 Lisp_Object *obj1, Lisp_Object *obj2) | |
| 2083 { | |
| 2084 int pix_x = 0; | |
| 2085 int pix_y = 0; | |
| 2086 int result; | |
| 2087 Lisp_Object frame; | |
| 2088 | |
| 2089 int ret_x, ret_y, ret_obj_x, ret_obj_y; | |
| 2090 struct window *ret_w; | |
| 665 | 2091 Charbpos ret_bufp, ret_closest; |
| 428 | 2092 Charcount ret_modeline_closest; |
| 2093 Lisp_Object ret_obj1, ret_obj2; | |
| 2094 | |
| 2095 CHECK_LIVE_EVENT (event); | |
| 934 | 2096 frame = XEVENT_CHANNEL (event); |
| 2097 switch (XEVENT_TYPE (event)) | |
| 2098 { | |
| 2099 case pointer_motion_event : | |
| 1204 | 2100 pix_x = XEVENT_MOTION_X (event); |
| 2101 pix_y = XEVENT_MOTION_Y (event); | |
| 934 | 2102 break; |
| 2103 case button_press_event : | |
| 2104 case button_release_event : | |
| 1204 | 2105 pix_x = XEVENT_BUTTON_X (event); |
| 2106 pix_y = XEVENT_BUTTON_Y (event); | |
| 934 | 2107 break; |
| 2108 case misc_user_event : | |
| 1204 | 2109 pix_x = XEVENT_MISC_USER_X (event); |
| 2110 pix_y = XEVENT_MISC_USER_Y (event); | |
| 934 | 2111 break; |
| 2112 default: | |
| 2113 dead_wrong_type_argument (Qmouse_event_p, event); | |
| 2114 } | |
| 428 | 2115 |
| 2116 result = pixel_to_glyph_translation (XFRAME (frame), pix_x, pix_y, | |
| 2117 &ret_x, &ret_y, &ret_obj_x, &ret_obj_y, | |
| 2118 &ret_w, &ret_bufp, &ret_closest, | |
| 2119 &ret_modeline_closest, | |
| 2120 &ret_obj1, &ret_obj2); | |
| 2121 | |
| 2122 if (result == OVER_NOTHING || result == OVER_OUTSIDE) | |
| 2123 ret_bufp = 0; | |
| 2124 else if (ret_w && NILP (ret_w->buffer)) | |
| 2125 /* Why does this happen? (Does it still happen?) | |
| 2126 I guess the window has gotten reused as a non-leaf... */ | |
| 2127 ret_w = 0; | |
| 2128 | |
| 2129 /* #### pixel_to_glyph_translation() sometimes returns garbage... | |
| 2130 The word has type Lisp_Type_Record (presumably meaning `extent') but the | |
| 2131 pointer points to random memory, often filled with 0, sometimes not. | |
| 2132 */ | |
| 2133 /* #### Chuck, do we still need this crap? */ | |
|
5055
79564cbad5f3
Simplify assertion in events.c so it will build under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
5052
diff
changeset
|
2134 #ifdef HAVE_TOOLBARS |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
2135 assert (NILP (ret_obj1) || GLYPHP (ret_obj1) |
|
5055
79564cbad5f3
Simplify assertion in events.c so it will build under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
5052
diff
changeset
|
2136 || TOOLBAR_BUTTONP (ret_obj1)); |
|
79564cbad5f3
Simplify assertion in events.c so it will build under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
5052
diff
changeset
|
2137 #else |
|
79564cbad5f3
Simplify assertion in events.c so it will build under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
5052
diff
changeset
|
2138 assert (NILP (ret_obj1) || GLYPHP (ret_obj1)); |
| 428 | 2139 #endif |
|
5050
6f2158fa75ed
Fix quick-build, use asserts() in place of ABORT()
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
2140 assert (NILP (ret_obj2) || EXTENTP (ret_obj2) || CONSP (ret_obj2)); |
| 428 | 2141 |
| 2142 if (char_x) | |
| 2143 *char_x = ret_x; | |
| 2144 if (char_y) | |
| 2145 *char_y = ret_y; | |
| 2146 if (obj_x) | |
| 2147 *obj_x = ret_obj_x; | |
| 2148 if (obj_y) | |
| 2149 *obj_y = ret_obj_y; | |
| 2150 if (w) | |
| 2151 *w = ret_w; | |
| 2152 if (bufp) | |
| 2153 *bufp = ret_bufp; | |
| 2154 if (closest) | |
| 2155 *closest = ret_closest; | |
| 2156 if (modeline_closest) | |
| 2157 *modeline_closest = ret_modeline_closest; | |
| 2158 if (obj1) | |
| 2159 *obj1 = ret_obj1; | |
| 2160 if (obj2) | |
| 2161 *obj2 = ret_obj2; | |
| 2162 | |
| 2163 return result; | |
| 2164 } | |
| 2165 | |
| 2166 DEFUN ("event-over-text-area-p", Fevent_over_text_area_p, 1, 1, 0, /* | |
| 2167 Return t if the mouse event EVENT occurred over the text area of a window. | |
| 2168 The modeline is not considered to be part of the text area. | |
| 2169 */ | |
| 2170 (event)) | |
| 2171 { | |
| 2172 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
| 2173 | |
| 2174 return result == OVER_TEXT || result == OVER_NOTHING ? Qt : Qnil; | |
| 2175 } | |
| 2176 | |
| 2177 DEFUN ("event-over-modeline-p", Fevent_over_modeline_p, 1, 1, 0, /* | |
| 2178 Return t if the mouse event EVENT occurred over the modeline of a window. | |
| 2179 */ | |
| 2180 (event)) | |
| 2181 { | |
| 2182 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
| 2183 | |
| 2184 return result == OVER_MODELINE ? Qt : Qnil; | |
| 2185 } | |
| 2186 | |
| 2187 DEFUN ("event-over-border-p", Fevent_over_border_p, 1, 1, 0, /* | |
| 2188 Return t if the mouse event EVENT occurred over an internal border. | |
| 2189 */ | |
| 2190 (event)) | |
| 2191 { | |
| 2192 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
| 2193 | |
| 2194 return result == OVER_BORDER ? Qt : Qnil; | |
| 2195 } | |
| 2196 | |
| 2197 DEFUN ("event-over-toolbar-p", Fevent_over_toolbar_p, 1, 1, 0, /* | |
| 2198 Return t if the mouse event EVENT occurred over a toolbar. | |
| 2199 */ | |
| 2200 (event)) | |
| 2201 { | |
| 2202 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
| 2203 | |
| 2204 return result == OVER_TOOLBAR ? Qt : Qnil; | |
| 2205 } | |
| 2206 | |
| 2207 DEFUN ("event-over-vertical-divider-p", Fevent_over_vertical_divider_p, 1, 1, 0, /* | |
| 2208 Return t if the mouse event EVENT occurred over a window divider. | |
| 2209 */ | |
| 2210 (event)) | |
| 2211 { | |
| 2212 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
| 2213 | |
| 2214 return result == OVER_V_DIVIDER ? Qt : Qnil; | |
| 2215 } | |
| 2216 | |
| 2217 struct console * | |
| 2218 event_console_or_selected (Lisp_Object event) | |
| 2219 { | |
| 2220 Lisp_Object channel = EVENT_CHANNEL (XEVENT (event)); | |
| 2221 Lisp_Object console = CDFW_CONSOLE (channel); | |
| 2222 | |
| 2223 if (NILP (console)) | |
| 2224 console = Vselected_console; | |
| 2225 | |
| 2226 return XCONSOLE (console); | |
| 2227 } | |
| 2228 | |
| 2229 DEFUN ("event-channel", Fevent_channel, 1, 1, 0, /* | |
| 2230 Return the channel that the event EVENT occurred on. | |
| 2231 This will be a frame, device, console, or nil for some types | |
| 2232 of events (e.g. eval events). | |
| 2233 */ | |
| 2234 (event)) | |
| 2235 { | |
| 2236 CHECK_LIVE_EVENT (event); | |
| 2237 return EVENT_CHANNEL (XEVENT (event)); | |
| 2238 } | |
| 2239 | |
| 2240 DEFUN ("event-window", Fevent_window, 1, 1, 0, /* | |
| 2241 Return the window over which mouse event EVENT occurred. | |
| 2242 This may be nil if the event occurred in the border or over a toolbar. | |
| 2243 The modeline is considered to be within the window it describes. | |
| 2244 */ | |
| 2245 (event)) | |
| 2246 { | |
| 2247 struct window *w; | |
| 2248 | |
| 2249 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, 0); | |
| 2250 | |
| 2251 if (!w) | |
| 2252 return Qnil; | |
| 2253 else | |
| 2254 { | |
| 793 | 2255 return wrap_window (w); |
| 428 | 2256 } |
| 2257 } | |
| 2258 | |
| 2259 DEFUN ("event-point", Fevent_point, 1, 1, 0, /* | |
| 2260 Return the character position of the mouse event EVENT. | |
| 2261 If the event did not occur over a window, or did not occur over text, | |
| 2262 then this returns nil. Otherwise, it returns a position in the buffer | |
| 2263 visible in the event's window. | |
| 2264 */ | |
| 2265 (event)) | |
| 2266 { | |
| 665 | 2267 Charbpos bufp; |
| 428 | 2268 struct window *w; |
| 2269 | |
| 2270 event_pixel_translation (event, 0, 0, 0, 0, &w, &bufp, 0, 0, 0, 0); | |
| 2271 | |
| 2272 return w && bufp ? make_int (bufp) : Qnil; | |
| 2273 } | |
| 2274 | |
| 2275 DEFUN ("event-closest-point", Fevent_closest_point, 1, 1, 0, /* | |
| 2276 Return the character position closest to the mouse event EVENT. | |
| 2277 If the event did not occur over a window or over text, return the | |
| 2278 closest point to the location of the event. If the Y pixel position | |
| 2279 overlaps a window and the X pixel position is to the left of that | |
| 2280 window, the closest point is the beginning of the line containing the | |
| 2281 Y position. If the Y pixel position overlaps a window and the X pixel | |
| 2282 position is to the right of that window, the closest point is the end | |
| 2283 of the line containing the Y position. If the Y pixel position is | |
| 2284 above a window, return 0. If it is below the last character in a window, | |
| 2285 return the value of (window-end). | |
| 2286 */ | |
| 2287 (event)) | |
| 2288 { | |
| 665 | 2289 Charbpos bufp; |
| 428 | 2290 |
| 2291 event_pixel_translation (event, 0, 0, 0, 0, 0, 0, &bufp, 0, 0, 0); | |
| 2292 | |
| 2293 return bufp ? make_int (bufp) : Qnil; | |
| 2294 } | |
| 2295 | |
| 2296 DEFUN ("event-x", Fevent_x, 1, 1, 0, /* | |
| 2297 Return the X position of the mouse event EVENT in characters. | |
| 2298 This is relative to the window the event occurred over. | |
| 2299 */ | |
| 2300 (event)) | |
| 2301 { | |
| 2302 int char_x; | |
| 2303 | |
| 2304 event_pixel_translation (event, &char_x, 0, 0, 0, 0, 0, 0, 0, 0, 0); | |
| 2305 | |
| 2306 return make_int (char_x); | |
| 2307 } | |
| 2308 | |
| 2309 DEFUN ("event-y", Fevent_y, 1, 1, 0, /* | |
| 2310 Return the Y position of the mouse event EVENT in characters. | |
| 2311 This is relative to the window the event occurred over. | |
| 2312 */ | |
| 2313 (event)) | |
| 2314 { | |
| 2315 int char_y; | |
| 2316 | |
| 2317 event_pixel_translation (event, 0, &char_y, 0, 0, 0, 0, 0, 0, 0, 0); | |
| 2318 | |
| 2319 return make_int (char_y); | |
| 2320 } | |
| 2321 | |
| 2322 DEFUN ("event-modeline-position", Fevent_modeline_position, 1, 1, 0, /* | |
| 2323 Return the character position in the modeline that EVENT occurred over. | |
| 2324 EVENT should be a mouse event. If EVENT did not occur over a modeline, | |
| 2325 nil is returned. You can determine the actual character that the | |
| 2326 event occurred over by looking in `generated-modeline-string' at the | |
| 2327 returned character position. Note that `generated-modeline-string' | |
| 2328 is buffer-local, and you must use EVENT's buffer when retrieving | |
| 2329 `generated-modeline-string' in order to get accurate results. | |
| 2330 */ | |
| 2331 (event)) | |
| 2332 { | |
| 2333 Charcount mbufp; | |
| 2334 int where; | |
| 2335 | |
| 2336 where = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, &mbufp, 0, 0); | |
| 2337 | |
| 2338 return (mbufp < 0 || where != OVER_MODELINE) ? Qnil : make_int (mbufp); | |
| 2339 } | |
| 2340 | |
| 2341 DEFUN ("event-glyph", Fevent_glyph, 1, 1, 0, /* | |
| 2342 Return the glyph that the mouse event EVENT occurred over, or nil. | |
| 2343 */ | |
| 2344 (event)) | |
| 2345 { | |
| 2346 Lisp_Object glyph; | |
| 2347 struct window *w; | |
| 2348 | |
| 2349 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, &glyph, 0); | |
| 2350 | |
| 2351 return w && GLYPHP (glyph) ? glyph : Qnil; | |
| 2352 } | |
| 2353 | |
| 2354 DEFUN ("event-glyph-extent", Fevent_glyph_extent, 1, 1, 0, /* | |
| 2355 Return the extent of the glyph that the mouse event EVENT occurred over. | |
| 2356 If the event did not occur over a glyph, nil is returned. | |
| 2357 */ | |
| 2358 (event)) | |
| 2359 { | |
| 2360 Lisp_Object extent; | |
| 2361 struct window *w; | |
| 2362 | |
| 2363 event_pixel_translation (event, 0, 0, 0, 0, &w, 0, 0, 0, 0, &extent); | |
| 2364 | |
| 2365 return w && EXTENTP (extent) ? extent : Qnil; | |
| 2366 } | |
| 2367 | |
| 2368 DEFUN ("event-glyph-x-pixel", Fevent_glyph_x_pixel, 1, 1, 0, /* | |
| 2369 Return the X pixel position of EVENT relative to the glyph it occurred over. | |
| 2370 EVENT should be a mouse event. If the event did not occur over a glyph, | |
| 2371 nil is returned. | |
| 2372 */ | |
| 2373 (event)) | |
| 2374 { | |
| 2375 Lisp_Object extent; | |
| 2376 struct window *w; | |
| 2377 int obj_x; | |
| 2378 | |
| 2379 event_pixel_translation (event, 0, 0, &obj_x, 0, &w, 0, 0, 0, 0, &extent); | |
| 2380 | |
| 2381 return w && EXTENTP (extent) ? make_int (obj_x) : Qnil; | |
| 2382 } | |
| 2383 | |
| 2384 DEFUN ("event-glyph-y-pixel", Fevent_glyph_y_pixel, 1, 1, 0, /* | |
| 2385 Return the Y pixel position of EVENT relative to the glyph it occurred over. | |
| 2386 EVENT should be a mouse event. If the event did not occur over a glyph, | |
| 2387 nil is returned. | |
| 2388 */ | |
| 2389 (event)) | |
| 2390 { | |
| 2391 Lisp_Object extent; | |
| 2392 struct window *w; | |
| 2393 int obj_y; | |
| 2394 | |
| 2395 event_pixel_translation (event, 0, 0, 0, &obj_y, &w, 0, 0, 0, 0, &extent); | |
| 2396 | |
| 2397 return w && EXTENTP (extent) ? make_int (obj_y) : Qnil; | |
| 2398 } | |
| 2399 | |
| 2400 DEFUN ("event-toolbar-button", Fevent_toolbar_button, 1, 1, 0, /* | |
| 2401 Return the toolbar button that the mouse event EVENT occurred over. | |
| 2402 If the event did not occur over a toolbar button, nil is returned. | |
| 2403 */ | |
| 2340 | 2404 (USED_IF_TOOLBARS (event))) |
| 428 | 2405 { |
| 2406 #ifdef HAVE_TOOLBARS | |
| 2407 Lisp_Object button; | |
| 2408 | |
| 2409 int result = event_pixel_translation (event, 0, 0, 0, 0, 0, 0, 0, 0, &button, 0); | |
| 2410 | |
| 2411 return result == OVER_TOOLBAR && TOOLBAR_BUTTONP (button) ? button : Qnil; | |
| 2412 #else | |
| 2413 return Qnil; | |
| 2414 #endif | |
| 2415 } | |
| 2416 | |
| 2417 DEFUN ("event-process", Fevent_process, 1, 1, 0, /* | |
| 444 | 2418 Return the process of the process-output event EVENT. |
| 428 | 2419 */ |
| 2420 (event)) | |
| 2421 { | |
| 934 | 2422 CHECK_EVENT_TYPE (event, process_event, Qprocess_event_p); |
| 1204 | 2423 return XEVENT_PROCESS_PROCESS (event); |
| 428 | 2424 } |
| 2425 | |
| 2426 DEFUN ("event-function", Fevent_function, 1, 1, 0, /* | |
| 2427 Return the callback function of EVENT. | |
| 2428 EVENT should be a timeout, misc-user, or eval event. | |
| 2429 */ | |
| 2430 (event)) | |
| 2431 { | |
| 2432 again: | |
| 2433 CHECK_LIVE_EVENT (event); | |
| 934 | 2434 switch (XEVENT_TYPE (event)) |
| 2435 { | |
| 2436 case timeout_event: | |
| 1204 | 2437 return XEVENT_TIMEOUT_FUNCTION (event); |
| 934 | 2438 case misc_user_event: |
| 1204 | 2439 return XEVENT_MISC_USER_FUNCTION (event); |
| 934 | 2440 case eval_event: |
| 1204 | 2441 return XEVENT_EVAL_FUNCTION (event); |
| 934 | 2442 default: |
| 2443 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event); | |
| 2444 goto again; | |
| 2445 } | |
| 428 | 2446 } |
| 2447 | |
| 2448 DEFUN ("event-object", Fevent_object, 1, 1, 0, /* | |
| 2449 Return the callback function argument of EVENT. | |
| 2450 EVENT should be a timeout, misc-user, or eval event. | |
| 2451 */ | |
| 2452 (event)) | |
| 2453 { | |
| 2454 again: | |
| 2455 CHECK_LIVE_EVENT (event); | |
| 934 | 2456 switch (XEVENT_TYPE (event)) |
| 2457 { | |
| 2458 case timeout_event: | |
| 1204 | 2459 return XEVENT_TIMEOUT_OBJECT (event); |
| 934 | 2460 case misc_user_event: |
| 1204 | 2461 return XEVENT_MISC_USER_OBJECT (event); |
| 934 | 2462 case eval_event: |
| 1204 | 2463 return XEVENT_EVAL_OBJECT (event); |
| 934 | 2464 default: |
| 2465 event = wrong_type_argument (intern ("timeout-or-eval-event-p"), event); | |
| 2466 goto again; | |
| 2467 } | |
| 428 | 2468 } |
| 2469 | |
| 2470 DEFUN ("event-properties", Fevent_properties, 1, 1, 0, /* | |
| 2471 Return a list of all of the properties of EVENT. | |
| 2472 This is in the form of a property list (alternating keyword/value pairs). | |
| 2473 */ | |
| 2474 (event)) | |
| 2475 { | |
| 2476 Lisp_Object props = Qnil; | |
| 440 | 2477 Lisp_Event *e; |
| 428 | 2478 struct gcpro gcpro1; |
| 2479 | |
| 2480 CHECK_LIVE_EVENT (event); | |
| 2481 e = XEVENT (event); | |
| 2482 GCPRO1 (props); | |
| 2483 | |
| 2484 props = cons3 (Qtimestamp, Fevent_timestamp (event), props); | |
| 2485 | |
| 934 | 2486 switch (EVENT_TYPE (e)) |
| 428 | 2487 { |
| 2500 | 2488 default: ABORT (); |
| 428 | 2489 |
| 2490 case process_event: | |
| 1204 | 2491 props = cons3 (Qprocess, EVENT_PROCESS_PROCESS (e), props); |
| 428 | 2492 break; |
| 2493 | |
| 2494 case timeout_event: | |
| 2495 props = cons3 (Qobject, Fevent_object (event), props); | |
| 2496 props = cons3 (Qfunction, Fevent_function (event), props); | |
| 1204 | 2497 props = cons3 (Qid, make_int (EVENT_TIMEOUT_ID_NUMBER (e)), props); |
| 428 | 2498 break; |
| 2499 | |
| 2500 case key_press_event: | |
| 2501 props = cons3 (Qmodifiers, Fevent_modifiers (event), props); | |
| 2502 props = cons3 (Qkey, Fevent_key (event), props); | |
| 2503 break; | |
| 2504 | |
| 2505 case button_press_event: | |
| 2506 case button_release_event: | |
| 2507 props = cons3 (Qy, Fevent_y_pixel (event), props); | |
| 2508 props = cons3 (Qx, Fevent_x_pixel (event), props); | |
| 2509 props = cons3 (Qmodifiers, Fevent_modifiers (event), props); | |
| 2510 props = cons3 (Qbutton, Fevent_button (event), props); | |
| 2511 break; | |
| 2512 | |
| 2513 case pointer_motion_event: | |
| 2514 props = cons3 (Qmodifiers, Fevent_modifiers (event), props); | |
| 2515 props = cons3 (Qy, Fevent_y_pixel (event), props); | |
| 2516 props = cons3 (Qx, Fevent_x_pixel (event), props); | |
| 2517 break; | |
| 2518 | |
| 2519 case misc_user_event: | |
| 2520 props = cons3 (Qobject, Fevent_object (event), props); | |
| 2521 props = cons3 (Qfunction, Fevent_function (event), props); | |
| 2522 props = cons3 (Qy, Fevent_y_pixel (event), props); | |
| 2523 props = cons3 (Qx, Fevent_x_pixel (event), props); | |
| 2524 props = cons3 (Qmodifiers, Fevent_modifiers (event), props); | |
| 2525 props = cons3 (Qbutton, Fevent_button (event), props); | |
| 2526 break; | |
| 2527 | |
| 2528 case eval_event: | |
| 2529 props = cons3 (Qobject, Fevent_object (event), props); | |
| 2530 props = cons3 (Qfunction, Fevent_function (event), props); | |
| 2531 break; | |
| 2532 | |
| 2533 case magic_eval_event: | |
| 2534 case magic_event: | |
| 2535 break; | |
| 2536 | |
| 2537 case empty_event: | |
| 2538 RETURN_UNGCPRO (Qnil); | |
| 2539 break; | |
| 2540 } | |
| 2541 | |
| 2542 props = cons3 (Qchannel, Fevent_channel (event), props); | |
| 2543 UNGCPRO; | |
| 2544 | |
| 2545 return props; | |
| 2546 } | |
| 2547 | |
| 2548 | |
| 2549 /************************************************************************/ | |
| 2550 /* initialization */ | |
| 2551 /************************************************************************/ | |
| 2552 | |
| 2553 void | |
| 2554 syms_of_events (void) | |
| 2555 { | |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2556 INIT_LISP_OBJECT (event); |
| 1204 | 2557 #ifdef EVENT_DATA_AS_OBJECTS |
|
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2558 INIT_LISP_OBJECT (key_data); |
|
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2559 INIT_LISP_OBJECT (button_data); |
|
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2560 INIT_LISP_OBJECT (motion_data); |
|
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2561 INIT_LISP_OBJECT (process_data); |
|
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2562 INIT_LISP_OBJECT (timeout_data); |
|
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2563 INIT_LISP_OBJECT (eval_data); |
|
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2564 INIT_LISP_OBJECT (misc_user_data); |
|
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2565 INIT_LISP_OBJECT (magic_eval_data); |
|
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3063
diff
changeset
|
2566 INIT_LISP_OBJECT (magic_data); |
| 1204 | 2567 #endif /* EVENT_DATA_AS_OBJECTS */ |
| 442 | 2568 |
| 428 | 2569 DEFSUBR (Fcharacter_to_event); |
| 2570 DEFSUBR (Fevent_to_character); | |
| 2571 | |
| 2572 DEFSUBR (Fmake_event); | |
| 2573 DEFSUBR (Fdeallocate_event); | |
| 2574 DEFSUBR (Fcopy_event); | |
| 2575 DEFSUBR (Feventp); | |
| 2576 DEFSUBR (Fevent_live_p); | |
| 2577 DEFSUBR (Fevent_type); | |
| 2578 DEFSUBR (Fevent_properties); | |
| 2579 | |
| 2580 DEFSUBR (Fevent_timestamp); | |
| 442 | 2581 DEFSUBR (Fevent_timestamp_lessp); |
| 428 | 2582 DEFSUBR (Fevent_key); |
| 2583 DEFSUBR (Fevent_button); | |
| 2584 DEFSUBR (Fevent_modifier_bits); | |
| 2585 DEFSUBR (Fevent_modifiers); | |
| 2586 DEFSUBR (Fevent_x_pixel); | |
| 2587 DEFSUBR (Fevent_y_pixel); | |
| 2588 DEFSUBR (Fevent_window_x_pixel); | |
| 2589 DEFSUBR (Fevent_window_y_pixel); | |
| 2590 DEFSUBR (Fevent_over_text_area_p); | |
| 2591 DEFSUBR (Fevent_over_modeline_p); | |
| 2592 DEFSUBR (Fevent_over_border_p); | |
| 2593 DEFSUBR (Fevent_over_toolbar_p); | |
| 2594 DEFSUBR (Fevent_over_vertical_divider_p); | |
| 2595 DEFSUBR (Fevent_channel); | |
| 2596 DEFSUBR (Fevent_window); | |
| 2597 DEFSUBR (Fevent_point); | |
| 2598 DEFSUBR (Fevent_closest_point); | |
| 2599 DEFSUBR (Fevent_x); | |
| 2600 DEFSUBR (Fevent_y); | |
| 2601 DEFSUBR (Fevent_modeline_position); | |
| 2602 DEFSUBR (Fevent_glyph); | |
| 2603 DEFSUBR (Fevent_glyph_extent); | |
| 2604 DEFSUBR (Fevent_glyph_x_pixel); | |
| 2605 DEFSUBR (Fevent_glyph_y_pixel); | |
| 2606 DEFSUBR (Fevent_toolbar_button); | |
| 2607 DEFSUBR (Fevent_process); | |
| 2608 DEFSUBR (Fevent_function); | |
| 2609 DEFSUBR (Fevent_object); | |
| 2610 | |
| 563 | 2611 DEFSYMBOL (Qeventp); |
| 2612 DEFSYMBOL (Qevent_live_p); | |
| 2613 DEFSYMBOL (Qkey_press_event_p); | |
| 2614 DEFSYMBOL (Qbutton_event_p); | |
| 2615 DEFSYMBOL (Qmouse_event_p); | |
| 2616 DEFSYMBOL (Qprocess_event_p); | |
| 2617 DEFSYMBOL (Qkey_press); | |
| 2618 DEFSYMBOL (Qbutton_press); | |
| 2619 DEFSYMBOL (Qbutton_release); | |
| 2620 DEFSYMBOL (Qmisc_user); | |
| 2828 | 2621 DEFSYMBOL (Qcharacter_of_keysym); |
| 563 | 2622 DEFSYMBOL (Qascii_character); |
| 428 | 2623 |
| 2624 defsymbol (&QKbackspace, "backspace"); | |
| 2625 defsymbol (&QKtab, "tab"); | |
| 2626 defsymbol (&QKlinefeed, "linefeed"); | |
| 2627 defsymbol (&QKreturn, "return"); | |
| 2628 defsymbol (&QKescape, "escape"); | |
| 2629 defsymbol (&QKspace, "space"); | |
| 2630 defsymbol (&QKdelete, "delete"); | |
| 2631 } | |
| 2632 | |
| 2633 | |
| 2634 void | |
| 2635 reinit_vars_of_events (void) | |
| 2636 { | |
| 2637 Vevent_resource = Qnil; | |
| 3092 | 2638 #ifdef NEW_GC |
|
5139
a48ef26d87ee
Clean up prototypes for Lisp variables/symbols. Put decls for them with
Ben Wing <ben@xemacs.org>
parents:
5055
diff
changeset
|
2639 staticpro_nodump (&Vevent_resource); |
| 3092 | 2640 #endif /* NEW_GC */ |
| 428 | 2641 } |
| 2642 | |
| 2643 void | |
| 2644 vars_of_events (void) | |
| 2645 { | |
| 2646 } |
