Mercurial > hg > xemacs-beta
diff src/events.h @ 771:943eaba38521
[xemacs-hg @ 2002-03-13 08:51:24 by ben]
The big ben-mule-21-5 check-in!
Various files were added and deleted. See CHANGES-ben-mule.
There are still some test suite failures. No crashes, though.
Many of the failures have to do with problems in the test suite itself
rather than in the actual code. I'll be addressing these in the next
day or so -- none of the test suite failures are at all critical.
Meanwhile I'll be trying to address the biggest issues -- i.e. build
or run failures, which will almost certainly happen on various platforms.
All comments should be sent to ben@xemacs.org -- use a Cc: if necessary
when sending to mailing lists. There will be pre- and post- tags,
something like
pre-ben-mule-21-5-merge-in, and
post-ben-mule-21-5-merge-in.
author | ben |
---|---|
date | Wed, 13 Mar 2002 08:54:06 +0000 |
parents | fdefd0186b75 |
children | 026c5bf9c134 |
line wrap: on
line diff
--- a/src/events.h Fri Mar 08 13:33:14 2002 +0000 +++ b/src/events.h Wed Mar 13 08:54:06 2002 +0000 @@ -128,141 +128,6 @@ XEmacs has its own event structures, which are distinct from the event structures used by X or any other window system. It is the job of the event_stream layer to translate to this format. - - NOTE: #### All timestamps should be measured as milliseconds since XEmacs - started. Currently they are raw server timestamps. (The X protocol - doesn't provide any easy way of translating between server time and - real process time; yuck.) - - Every event type has the following structures: - - channel Where this event occurred on. This will be - a frame, device, console, or nil, depending on the - event type. It is important that an object of - a more specific type than is actually generated - is not substituted -- e.g. there should not be - a frame inserted when a key-press event occurs, - because events on dead channels are automatically - ignored. - - Specifically: - - -- for button and mouse-motion events, channel - will be a frame. (The translation to a window - occurs later.) - -- for keyboard events, channel will be a console. - Note that fake keyboard events (generated - by `character-to-event' or something that - calls this, such as macros) need to have - the selected console stored into them when - the event is created. This is so that the - correct console-local variables (e.g. the - command builder) will get affected. - -- for timer, process, magic-eval, and eval events, - channel will be nil. - -- for misc-user events, channel will be a frame. - -- for magic events, channel will be a frame - (usually) or a device. - - timestamp When this event occurred -- if not known, this - is made up. - - In addition, the following structures are specific to particular event - types: - - key_press_event - key What keysym this is; an integer or a symbol. - If this is an integer, it will be in the printing - ASCII range: >32 and <127. - modifiers Bucky-bits on that key: control, meta, etc. - Also includes buttons. - For many keys, Shift is not a bit; that is implicit - in the keyboard layout. - - button_press_event - button_release_event - button What button went down or up. - modifiers Bucky-bits on that button: shift, control, meta, etc. - Also includes other buttons (not the one pressed). - x, y Where it was at the button-state-change (in pixels). - - pointer_motion_event - x, y Where it was after it moved (in pixels). - modifiers Bucky-bits down when the motion was detected. - - process_event - process the XEmacs "process" object in question - - timeout_event - interval_id The ID returned when the associated call to - add_timeout_cb() was made - ------ the rest of the fields are filled in by XEmacs ----- - id_number The XEmacs timeout ID for this timeout (more - than one timeout event can have the same value - here, since XEmacs timeouts, as opposed to - add_timeout_cb() timeouts, can resignal - themselves) - function An elisp function to call when this timeout is - processed. - object The object passed to that function. - - eval_event - function An elisp function to call with this event object. - internal_function An unexported function to call with this event - object. This allows eval events to call internal - functions. For a normal eval event, this field - will always be 0. - object Anything. - This kind of event is used internally; sometimes the - window system interface would like to inform XEmacs of - some user action (such as focusing on another frame) - but needs that to happen synchronously with the other - user input, like keypresses. This is useful when - events are reported through callbacks rather - than in the standard event stream. - - misc_user_event - function An elisp function to call with this event object. - internal_function Ignored. - object Anything. - button What button went down or up. - modifiers Bucky-bits on that button: shift, control, meta, etc. - x, y Where it was at the button-state-change (in pixels). - This is similar to an eval_event, except that it is - generated by user actions: selections in the - menubar, scrollbar actions, or drag and drop actions. - It is a "command" event, like key and mouse presses - (and unlike mouse motion, process output, and enter - and leave window hooks). In many ways, eval_events - are not the same as keypresses or misc_user_events. - The button, modifiers, x, and y parts are only used - by the XEmacs Drag'n'Drop system. Don't depend on their - values for other types of misc_user_events. - - magic_event - No user-serviceable parts within. This is for things - like KeymapNotify and ExposeRegion events and so on - that XEmacs itself doesn't care about, but which it - must do something with for proper interaction with - the window system. - - Magic_events are handled somewhat asynchronously, just - like subprocess filters. However, occasionally a - magic_event needs to be handled synchronously; in that - case, the asynchronous handling of the magic_event will - push an eval_event back onto the queue, which will be - handled synchronously later. This is one of the - reasons why eval_events exist; I'm not entirely happy - with this aspect of this event model. - - magic_eval_event - This is like an eval event but its contents are - not Lisp-accessible. This allows for "internal - eval events" that call non-Lisp-accessible functions. - Externally, a magic_eval_event just appears as - a magic_event; the Lisp programmer need not know - anything more. - */ /* @@ -364,58 +229,160 @@ #define first_event_type empty_event #define last_event_type dead_event +#ifdef MULE + +enum alternative_key_chars +{ + KEYCHAR_CURRENT_LANGENV, + KEYCHAR_DEFAULT_USER, + KEYCHAR_DEFAULT_SYSTEM, + KEYCHAR_UNDERLYING_VIRTUAL_KEY_CURRENT_LANGENV, + KEYCHAR_UNDERLYING_VIRTUAL_KEY_DEFAULT_USER, + KEYCHAR_UNDERLYING_VIRTUAL_KEY_DEFAULT_SYSTEM, + KEYCHAR_QWERTY, + KEYCHAR_LAST +}; + +#endif /* MULE */ struct key_data { - Lisp_Object keysym; - int modifiers; + /* What keysym this is; a character or a symbol. */ + Lisp_Object keysym; + /* Modifiers held down when key was pressed: control, meta, etc. + Also includes buttons. For many keys, Shift is not a bit; that + is implicit in the keyboard layout. */ + int modifiers; +#ifdef MULE + /* Alternate character interpretations for this key in different + keyboard layouts. This deals with the problem of pressing C-x in + the Russian layout (the so-called "Russian C-x problem"), for + example: `x' gets mapped to a Cyrillic character, so what do we + do? For that matter, what about `C-x b'? What we do is look the + key up in the default locales (current language environment, user + default, system default), then check to see if the underlying + virtual key is alphabetic in the same three defaults, then + finally check US ASCII. We ignore the underlying virtual key for + the current layout to avoid the problem of a French speaker + (AZERTY layout) who temporarily switches to Russian: The virtual + keys underlying Russian are US-ASCII, so what the French speaker + things of as C-a (the key just to the right of TAB) appears as + C-q. (#### We should probably ignore the current char and look + *ONLY* in alt_keychars for all control keys. What about the + English speaker who temporarily switches to the French layout and + finds C-q mapped to C-a?) */ + Emchar alt_keychars[KEYCHAR_LAST]; +#endif /* MULE */ }; struct button_data { - int button; - int modifiers; - int x, y; + /* What button went down or up. */ + int button; + /* Bucky-bits on that button: shift, control, meta, etc. Also + includes other buttons (not the one pressed). */ + int modifiers; + /* Where it was at the button-state-change (in pixels). */ + int x, y; }; struct motion_data { - int x, y; - int modifiers; + /* Where it was after it moved (in pixels). */ + int x, y; + /* Bucky-bits down when the motion was detected. */ + int modifiers; }; struct process_data { - Lisp_Object process; + /* the XEmacs "process" object in question */ + Lisp_Object process; }; struct timeout_data { - int interval_id; - int id_number; - Lisp_Object function; - Lisp_Object object; +/* + interval_id The ID returned when the associated call to + add_timeout_cb() was made + ------ the rest of the fields are filled in by XEmacs ----- + id_number The XEmacs timeout ID for this timeout (more + than one timeout event can have the same value + here, since XEmacs timeouts, as opposed to + add_timeout_cb() timeouts, can resignal + themselves) + function An elisp function to call when this timeout is + processed. + object The object passed to that function. +*/ + int interval_id; + int id_number; + Lisp_Object function; + Lisp_Object object; }; struct eval_data { - Lisp_Object function; - Lisp_Object object; +/* This kind of event is used internally; sometimes the window system + interface would like to inform XEmacs of some user action (such as + focusing on another frame) but needs that to happen synchronously + with the other user input, like keypresses. This is useful when + events are reported through callbacks rather than in the standard + event stream. + + function An elisp function to call with this event object. + object Argument of function. +*/ + Lisp_Object function; + Lisp_Object object; }; struct misc_user_data { - Lisp_Object function; - Lisp_Object object; - int button; - int modifiers; - int x, y; +/* #### The misc-user type is serious junk. It should be separated + out into different events. There's no reason to create + sub-subtypes of events. + + function An elisp function to call with this event object. + object Argument of function. + button What button went down or up. + modifiers Bucky-bits on that button: shift, control, meta, etc. + x, y Where it was at the button-state-change (in pixels). + This is similar to an eval_event, except that it is + generated by user actions: selections in the + menubar, scrollbar actions, or drag and drop actions. + It is a "command" event, like key and mouse presses + (and unlike mouse motion, process output, and enter + and leave window hooks). In many ways, eval_events + are not the same as keypresses or misc_user_events. + The button, modifiers, x, and y parts are only used + by the XEmacs Drag'n'Drop system. Don't depend on their + values for other types of misc_user_events. +*/ + Lisp_Object function; + Lisp_Object object; + int button; + int modifiers; + int x, y; }; struct magic_eval_data { - void (*internal_function) (Lisp_Object); - Lisp_Object object; +/* This is like an eval event but its contents are not + Lisp-accessible. This allows for "internal eval events" that call + non-Lisp-accessible functions. Externally, a magic_eval_event just + appears as a magic_event; the Lisp programmer need not know + anything more. + + internal_function An unexported function to call with this event + object. This allows eval events to call internal + functions. For a normal eval event, this field + will always be 0. + object Argument of function. + +*/ + void (*internal_function) (Lisp_Object); + Lisp_Object object; }; #if defined (HAVE_X_WINDOWS) && defined(emacs) @@ -428,17 +395,31 @@ union magic_data { +/* No user-serviceable parts within. This is for things like + KeymapNotify and ExposeRegion events and so on that XEmacs itself + doesn't care about, but which it must do something with for proper + interaction with the window system. + + Magic_events are handled somewhat asynchronously, just like + subprocess filters. However, occasionally a magic_event needs to + be handled synchronously; in that case, the asynchronous handling + of the magic_event will push an eval_event back onto the queue, + which will be handled synchronously later. This is one of the + reasons why eval_events exist; I'm not entirely happy with this + aspect of this event model. +*/ + #ifdef HAVE_TTY - char underlying_tty_event; + char underlying_tty_event; #endif #ifdef HAVE_GTK - GdkEvent underlying_gdk_event; + GdkEvent underlying_gdk_event; #endif #ifdef HAVE_X_WINDOWS - XEvent underlying_x_event; + XEvent underlying_x_event; #endif #ifdef HAVE_MS_WINDOWS - int underlying_mswindows_event; + int underlying_mswindows_event; #endif }; @@ -447,15 +428,15 @@ struct lcrecord_header header; int id; /* Id we use to identify the timeout over its lifetime */ int interval_id; /* Id for this particular interval; this may - be different each time the timeout is - signalled.*/ + be different each time the timeout is + signalled.*/ Lisp_Object function, object; /* Function and object associated - with timeout. */ + with timeout. */ EMACS_TIME next_signal_time; /* Absolute time when the timeout - is next going to be signalled. */ + is next going to be signalled. */ unsigned int resignal_msecs; /* How far after the next timeout - should the one after that - occur? */ + should the one after that + occur? */ }; typedef struct Lisp_Timeout Lisp_Timeout; @@ -476,21 +457,55 @@ - Otherwise it's Qnil. */ struct lrecord_header lheader; - Lisp_Object next; - emacs_event_type event_type; - Lisp_Object channel; - unsigned int timestamp; + Lisp_Object next; + emacs_event_type event_type; + + /* Where this event occurred on. This will be a frame, device, + console, or nil, depending on the event type. It is important + that an object of a more specific type than is actually generated + is not substituted -- e.g. there should not be a frame inserted + when a key-press event occurs, because events on dead channels + are automatically ignored. + + Specifically: + + -- for button and mouse-motion events, channel will be a + frame. (The translation to a window occurs later.) + + -- for keyboard events, channel will be a console. Note that + fake keyboard events (generated by `character-to-event' or + something that calls this, such as macros) need to have the + selected console stored into them when the event is created. + This is so that the correct console-local variables (e.g. the + command builder) will get affected. + + -- for timer, process, magic-eval, and eval events, channel will + be nil. + + -- for misc-user events, channel will be a frame. + + -- for magic events, channel will be a frame (usually) or a + device. */ + Lisp_Object channel; + + /* When this event occurred -- if not known, this is made up. #### + All timestamps should be measured as milliseconds since XEmacs + started. Currently they are raw server timestamps. (The X + protocol doesn't provide any easy way of translating between + server time and real process time; yuck.) */ + + unsigned int timestamp; union { - struct key_data key; - struct button_data button; - struct motion_data motion; - struct process_data process; - struct timeout_data timeout; - struct eval_data eval; /* misc_user_event no longer uses this */ - struct misc_user_data misc; /* because it needs position information */ - union magic_data magic; - struct magic_eval_data magic_eval; + struct key_data key; + struct button_data button; + struct motion_data motion; + struct process_data process; + struct timeout_data timeout; + struct eval_data eval; /* misc_user_event no longer uses this */ + struct misc_user_data misc; /* because it needs position information */ + union magic_data magic; + struct magic_eval_data magic_eval; } event; }; @@ -516,15 +531,15 @@ #define EVENT_LIVE_P(a) (EVENT_TYPE (a) != dead_event) -#define CHECK_LIVE_EVENT(x) do { \ - CHECK_EVENT (x); \ - if (! EVENT_LIVE_P (XEVENT (x))) \ - dead_wrong_type_argument (Qevent_live_p, (x)); \ +#define CHECK_LIVE_EVENT(x) do { \ + CHECK_EVENT (x); \ + if (! EVENT_LIVE_P (XEVENT (x))) \ + dead_wrong_type_argument (Qevent_live_p, (x)); \ } while (0) -#define CONCHECK_LIVE_EVENT(x) do { \ - CONCHECK_EVENT (x); \ - if (! EVENT_LIVE_P (XEVENT (x))) \ - x = wrong_type_argument (Qevent_live_p, (x)); \ +#define CONCHECK_LIVE_EVENT(x) do { \ + CONCHECK_EVENT (x); \ + if (! EVENT_LIVE_P (XEVENT (x))) \ + x = wrong_type_argument (Qevent_live_p, (x)); \ } while (0) @@ -546,17 +561,17 @@ /* The modifiers XEmacs knows about; these appear in key and button events. */ -#define XEMACS_MOD_CONTROL (1<<0) -#define XEMACS_MOD_META (1<<1) -#define XEMACS_MOD_SUPER (1<<2) -#define XEMACS_MOD_HYPER (1<<3) -#define XEMACS_MOD_ALT (1<<4) -#define XEMACS_MOD_SHIFT (1<<5) /* not used for dual-case characters */ -#define XEMACS_MOD_BUTTON1 (1<<6) -#define XEMACS_MOD_BUTTON2 (1<<7) -#define XEMACS_MOD_BUTTON3 (1<<8) -#define XEMACS_MOD_BUTTON4 (1<<9) -#define XEMACS_MOD_BUTTON5 (1<<10) +#define XEMACS_MOD_CONTROL (1<<0) +#define XEMACS_MOD_META (1<<1) +#define XEMACS_MOD_SUPER (1<<2) +#define XEMACS_MOD_HYPER (1<<3) +#define XEMACS_MOD_ALT (1<<4) +#define XEMACS_MOD_SHIFT (1<<5) /* not used for dual-case characters */ +#define XEMACS_MOD_BUTTON1 (1<<6) +#define XEMACS_MOD_BUTTON2 (1<<7) +#define XEMACS_MOD_BUTTON3 (1<<8) +#define XEMACS_MOD_BUTTON4 (1<<9) +#define XEMACS_MOD_BUTTON5 (1<<10) /* Note: under X Windows, XEMACS_MOD_ALT is generated by the Alt key if there are both Alt and Meta keys. If there are no Meta keys, @@ -570,21 +585,24 @@ /* from events.c */ void format_event_object (char *buf, Lisp_Event *e, int brief); void character_to_event (Emchar c, Lisp_Event *event, - struct console *con, - int use_console_meta_flag, - int do_backspace_mapping); + struct console *con, + int use_console_meta_flag, + int do_backspace_mapping); void zero_event (Lisp_Event *e); void deallocate_event_chain (Lisp_Object event); Lisp_Object event_chain_tail (Lisp_Object event); void enqueue_event (Lisp_Object event, Lisp_Object *head, Lisp_Object *tail); Lisp_Object dequeue_event (Lisp_Object *head, Lisp_Object *tail); void enqueue_event_chain (Lisp_Object event_chain, Lisp_Object *head, - Lisp_Object *tail); + Lisp_Object *tail); int event_chain_count (Lisp_Object event_chain); +Lisp_Object transfer_event_chain_pointer (Lisp_Object pointer, + Lisp_Object old_chain, + Lisp_Object new_chain); void nth_of_key_sequence_as_event (Lisp_Object seq, int n, Lisp_Object event); Lisp_Object key_sequence_to_event_chain (Lisp_Object seq); Lisp_Object event_chain_find_previous (Lisp_Object event_chain, - Lisp_Object event); + Lisp_Object event); Lisp_Object event_chain_nth (Lisp_Object event_chain, int n); Lisp_Object copy_event_chain (Lisp_Object event_chain); /* True if this is a non-internal event @@ -595,7 +613,7 @@ struct console *event_console_or_selected (Lisp_Object event); /* from event-stream.c */ -Lisp_Object allocate_command_builder (Lisp_Object console); +Lisp_Object allocate_command_builder (Lisp_Object console, int with_echo_buf); void enqueue_magic_eval_event (void (*fun) (Lisp_Object), Lisp_Object object); void event_stream_next_event (Lisp_Event *event); void event_stream_handle_magic_event (Lisp_Event *event); @@ -604,7 +622,7 @@ void event_stream_select_process (Lisp_Process *proc); void event_stream_unselect_process (Lisp_Process *proc); USID event_stream_create_stream_pair (void* inhandle, void* outhandle, - Lisp_Object* instream, Lisp_Object* outstream, int flags); + Lisp_Object* instream, Lisp_Object* outstream, int flags); USID event_stream_delete_stream_pair (Lisp_Object instream, Lisp_Object outstream); void event_stream_quit_p (void); @@ -616,20 +634,20 @@ }; int add_low_level_timeout (struct low_level_timeout **timeout_list, - EMACS_TIME thyme); + EMACS_TIME thyme); void remove_low_level_timeout (struct low_level_timeout **timeout_list, - int id); + int id); int get_low_level_timeout_interval (struct low_level_timeout * - timeout_list, EMACS_TIME *interval); + timeout_list, EMACS_TIME *interval); int pop_low_level_timeout (struct low_level_timeout **timeout_list, - EMACS_TIME *time_out); + EMACS_TIME *time_out); int event_stream_generate_wakeup (unsigned int milliseconds, - unsigned int vanilliseconds, - Lisp_Object function, - Lisp_Object object, - int async_p); + unsigned int vanilliseconds, + Lisp_Object function, + Lisp_Object object, + int async_p); int event_stream_resignal_wakeup (int interval_id, int async_p, - Lisp_Object *function, Lisp_Object *object); + Lisp_Object *function, Lisp_Object *object); void event_stream_disable_wakeup (int id, int async_p); /* from signal.c */ @@ -670,13 +688,13 @@ int event_stream_unixoid_select_process (Lisp_Process *proc); int event_stream_unixoid_unselect_process (Lisp_Process *proc); int read_event_from_tty_or_stream_desc (Lisp_Event *event, - struct console *con, int fd); + struct console *con); USID event_stream_unixoid_create_stream_pair (void* inhandle, void* outhandle, - Lisp_Object* instream, - Lisp_Object* outstream, - int flags); + Lisp_Object* instream, + Lisp_Object* outstream, + int flags); USID event_stream_unixoid_delete_stream_pair (Lisp_Object instream, - Lisp_Object outstream); + Lisp_Object outstream); /* Beware: this evil macro evaluates its arg many times */ #define FD_TO_USID(fd) ((fd)==0 ? (USID)999999 : ((fd)<0 ? USID_DONTHASH : (USID)(fd))) @@ -700,18 +718,19 @@ { struct lcrecord_header header; Lisp_Object console; /* back pointer to the console this command - builder is for */ - /* Qnil, or a Lisp_Event representing the first event read - * after the last command completed. Threaded. */ - /* #### NYI */ + builder is for */ +#if 0 + /* #### Not implemented: nil, or an event representing the first + event read after the last command completed. Threaded. */ Lisp_Object prefix_events; - /* Qnil, or a Lisp_Event representing event in the current - * keymap-lookup sequence. Subsequent events are threaded via - * the event's next slot */ +#endif /* 0 */ + /* nil, or an event chain representing the events in the current + keymap-lookup sequence. NOTE: All events in the chain MUST be + freshly allocated, with no pointers to them elsewhere. */ Lisp_Object current_events; - /* Last elt of above */ + /* Last elt of current_events */ Lisp_Object most_current_event; - /* Last elt before function map code took over. What this means is: + /* Last elt before function map code took over. What this means is: All prefixes up to (but not including) this event have non-nil bindings, but the prefix including this event has a nil binding. Any events in the chain after this one were read solely because @@ -737,7 +756,7 @@ Intbyte *echo_buf; Bytecount echo_buf_length; /* size of echo_buf */ Bytecount echo_buf_index; /* index into echo_buf - * -1 before doing echoing for new cmd */ + * -1 before doing echoing for new cmd */ /* Self-insert-command is magic in that it doesn't always push an undo- boundary: up to 20 consecutive self-inserts can happen before an undo- boundary is pushed. This variable is that counter.