diff options
| author | Po Lu | 2022-07-14 18:47:10 +0800 |
|---|---|---|
| committer | Po Lu | 2022-07-14 18:49:19 +0800 |
| commit | ade1238bce1cf69ebce8809a2d73cb92db94b977 (patch) | |
| tree | 2eee5f604958e5bead901ce67c5299c935b98775 | |
| parent | 2a05479c221d4a13b15ed731e4eb1c0de99e97ed (diff) | |
| download | emacs-ade1238bce1cf69ebce8809a2d73cb92db94b977.tar.gz emacs-ade1238bce1cf69ebce8809a2d73cb92db94b977.zip | |
Try to restore the initial "daemon" frame when a display goes down
* src/xterm.c (x_try_restore_frame): New function.
(x_connection_closed): Call it if selected_frame is nil.
| -rw-r--r-- | src/xterm.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/xterm.c b/src/xterm.c index 1d0e69d32bc..85367b78e3c 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -23312,6 +23312,22 @@ x_trace_wire (Display *dpy) | |||
| 23312 | 23312 | ||
| 23313 | static char *error_msg; | 23313 | static char *error_msg; |
| 23314 | 23314 | ||
| 23315 | /* Try to find a frame in Vframe_list, and make it the selected frame. | ||
| 23316 | `delete_frame' sometimes misses the initial frame for an unknown | ||
| 23317 | reason when Emacs is running as a background daemon. */ | ||
| 23318 | |||
| 23319 | static void | ||
| 23320 | x_try_restore_frame (void) | ||
| 23321 | { | ||
| 23322 | Lisp_Object tail, frame; | ||
| 23323 | |||
| 23324 | FOR_EACH_FRAME (tail, frame) | ||
| 23325 | { | ||
| 23326 | if (!NILP (do_switch_frame (frame, 1, Qnil))) | ||
| 23327 | return; | ||
| 23328 | } | ||
| 23329 | } | ||
| 23330 | |||
| 23315 | /* Handle the loss of connection to display DPY. ERROR_MESSAGE is | 23331 | /* Handle the loss of connection to display DPY. ERROR_MESSAGE is |
| 23316 | the text of an error message that lead to the connection loss. */ | 23332 | the text of an error message that lead to the connection loss. */ |
| 23317 | 23333 | ||
| @@ -23529,6 +23545,11 @@ For details, see etc/PROBLEMS.\n", | |||
| 23529 | Fdelete_terminal (tmp, Qnoelisp); | 23545 | Fdelete_terminal (tmp, Qnoelisp); |
| 23530 | } | 23546 | } |
| 23531 | 23547 | ||
| 23548 | /* The initial "daemon" frame is sometimes not selected by | ||
| 23549 | `delete_frame' when Emacs is a background daemon. */ | ||
| 23550 | if (NILP (selected_frame)) | ||
| 23551 | x_try_restore_frame (); | ||
| 23552 | |||
| 23532 | unblock_input (); | 23553 | unblock_input (); |
| 23533 | 23554 | ||
| 23534 | /* Sometimes another terminal is still alive, but deleting this | 23555 | /* Sometimes another terminal is still alive, but deleting this |