diff options
| author | Po Lu | 2022-01-14 19:47:35 +0800 |
|---|---|---|
| committer | Po Lu | 2022-01-14 19:50:40 +0800 |
| commit | 30dbdecd4a402e296045e9e787a3066ca0e907cc (patch) | |
| tree | bdf060f5da76644e57e40147b568957181cc272d /src | |
| parent | 85299991e41dc60c655fdac4229e05376ecbb6e3 (diff) | |
| download | emacs-30dbdecd4a402e296045e9e787a3066ca0e907cc.tar.gz emacs-30dbdecd4a402e296045e9e787a3066ca0e907cc.zip | |
* src/xterm.c: Add a small writeup on input handling on X.
Hopefully I will extend this section with details about more
aspects of X11 support in the future.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/xterm.c b/src/xterm.c index d17eaf0cccf..ec415f5ffaf 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -20,6 +20,72 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 20 | /* New display code by Gerd Moellmann <gerd@gnu.org>. */ | 20 | /* New display code by Gerd Moellmann <gerd@gnu.org>. */ |
| 21 | /* Xt features made by Fred Pierresteguy. */ | 21 | /* Xt features made by Fred Pierresteguy. */ |
| 22 | 22 | ||
| 23 | /* X window system support for GNU Emacs | ||
| 24 | |||
| 25 | This file is part of the X window system support for GNU Emacs. It | ||
| 26 | contains subroutines comprising the redisplay interface, setting up | ||
| 27 | scroll bars and widgets, and handling input. | ||
| 28 | |||
| 29 | INPUT | ||
| 30 | |||
| 31 | Emacs handles input by running pselect in a loop, which returns | ||
| 32 | whenever there is input available on the connection to the X | ||
| 33 | server. On some systems, Emacs also arranges for any new input on | ||
| 34 | that connection to send an asynchronous signal. Whenever pselect | ||
| 35 | returns, or such a signal is received and input is not blocked, | ||
| 36 | XTread_socket is called and translates X11 events read by Xlib into | ||
| 37 | struct input_events, which are then stored in the keyboard buffer, | ||
| 38 | to be processed and acted upon at some later time. The function | ||
| 39 | handle_one_xevent is responsible for handling core events after | ||
| 40 | they are filtered, and filtering X Input Extension events. It also | ||
| 41 | performs actions on some special events, such as updating the | ||
| 42 | dimensions of a frame after a ConfigureNotify is sent by the X | ||
| 43 | server to inform us that it changed. | ||
| 44 | |||
| 45 | Before such events are translated, an Emacs build with | ||
| 46 | internationalization enabled (the default since X11R6) will filter | ||
| 47 | events through an X Input Method (XIM) or GTK, which might decide | ||
| 48 | to intercept the event and send a different one in its place, for | ||
| 49 | reasons such as enabling the user to insert international | ||
| 50 | characters that aren't on his keyboard by typing a sequence of | ||
| 51 | characters which are. See the function x_filter_event and its | ||
| 52 | callers for more details. | ||
| 53 | |||
| 54 | Events that cause Emacs to quit are treated specially by the code | ||
| 55 | that stores them in the keyboard buffer and generally cause an | ||
| 56 | immediate interrupt. Such an interrupt can lead to a longjmp from | ||
| 57 | the code that stored the keyboard event, which isn't safe inside | ||
| 58 | XTread_socket. To avoid this problem, XTread_socket is provided a | ||
| 59 | special event buffer named hold_quit. When a quit event is | ||
| 60 | encountered, it is stored inside this special buffer, which will | ||
| 61 | cause the keyboard code that called XTread_socket to store it at a | ||
| 62 | later time when it is safe to do so. | ||
| 63 | |||
| 64 | handle_one_xevent will generally have to determine which frame an | ||
| 65 | event should be attributed to. This is not easy, because events | ||
| 66 | can come from multiple X windows, and a frame can also have | ||
| 67 | multiple windows. handle_one_xevent usually calls the function | ||
| 68 | x_any_window_to_frame, which searches for a frame by toplevel | ||
| 69 | window and widget windows. There are also some other functions for | ||
| 70 | searching by specific types of window, such as | ||
| 71 | x_top_window_to_frame (which only searches for frames by toplevel | ||
| 72 | window), and x_menubar_window_to_frame (which will only search | ||
| 73 | through frame menu bars). | ||
| 74 | |||
| 75 | INPUT FOCUS | ||
| 76 | |||
| 77 | Under X, the window where keyboard input is sent is not always | ||
| 78 | explictly defined. When there is a focus window, it receives what | ||
| 79 | is referred to as "explicit focus", but when there is none, it | ||
| 80 | receives "implicit focus" whenever the pointer enters it, and loses | ||
| 81 | that focus when the pointer leaves. When the toplevel window of a | ||
| 82 | frame receives an explicit focus event (FocusIn or FocusOut), we | ||
| 83 | treat that frame as having the current input focus, but when there | ||
| 84 | is no focus window, we treat each frame as having the input focus | ||
| 85 | whenever the pointer enters it, and undo that treatment when the | ||
| 86 | pointer leaves it. See the callers of x_detect_focus_change for | ||
| 87 | more details. */ | ||
| 88 | |||
| 23 | #include <config.h> | 89 | #include <config.h> |
| 24 | #include <stdlib.h> | 90 | #include <stdlib.h> |
| 25 | #include <math.h> | 91 | #include <math.h> |