Node: Event Loop, Next: , Previous: Keymaps, Up: Top



Event Loop

The event loop reads all X events received on any of the windows that Sawfish is aware off. Many of these events invoke hooks, as described in Standard Hooks. Keyboard and pointer events are translated to their Lisp equivalents (see Events) and then used to scan all active keymaps for a binding. If a binding is found, the associated command is invoked through the call-command function.

The active keymaps are determined as follows:

Note that for ButtonRelease events, the frame part's keymap is only searched if the pointer is actually within the frame part when the release event occurs.

If no binding may be found in any of the active keymaps, then the unbound-key-hook hook is called. This is an or type hook--the first function that returns non-nil will terminate the hook call.

lookup-event-binding event Function
Perform the usual binding lookup for the event object object. Returns the command found, or nil if no binding exists.

By default, both key-release events, and events that are bound to modifier keys (e.g. <Control_L>), are ignored. However, this behavior may be changed:

eval-modifier-events Variable
When non-nil, key events bound to modifier keys are evaluated.

eval-key-release-events Variable
When non-nil, key-release events are evaluated.

While a command is being evaluated, information about the event that caused it may be found:

current-event Function
Return the event which caused the current command to be invoked

current-event-string Function
Returns the string which the current event would usually insert.

current-event-window &optional win Function
Extract the owning window of the current X event (this is a window object, or the symbol root for the root window, or nil if there is no window or no event). This is stored internally as the current event window, and returned.

last-event Function
Return the previous event which occurred.

proxy-current-event window &optional mask propagate Function
Send the current X event to window, either a window object, a numeric window id, or the symbol root. If a ButtonPress event the pointer grab will be released first.

Mask may be an integer defining the X event mask to pass to the XSendEvent function. If not defined, a mask is chosen that would usually be used to select the type of event being proxied.

Propagate is a flag (nil/non-nil) passed directly to an underlying XSendEvent call. (And if someone would like to explain what that means, please do so ....

allow-events mode Function
This is a wrapper for the XAllowEvents function. The mode parameter may be one of the following symbols: async-pointer, async-keyboard, sync-pointer, sync-keyboard, replay-pointer, replay-keyboard, async-both, sync-both.

Events that have to be grabbed to be received (i.e. all bindings in the global-keymap and the window-keymap) are grabbed synchronously. This means that no more events will be received until either the command returns, or allow-events is called.

This is normally not important, but if the command expects to receive further events it must call allow-events. See the interactive move and resize functions for an example.

forget-button-press Function
Cause the next button press to be treated as a single click event, no matter how soon it occurs after the prevous button-press event.

accept-x-input &optional mask Function
Handle any X events received. If mask is non-nil then only events matching this numeric value are handled (see the X header files for details).

x-events-queued Function
Returns the number of X events waiting to be handled.