diff options
| author | Po Lu | 2022-10-24 19:18:17 +0800 |
|---|---|---|
| committer | Po Lu | 2022-10-24 19:18:49 +0800 |
| commit | eb3f8d1b648d0aa5e5fcaec66d9003817f00ce42 (patch) | |
| tree | ab204b2023f6a509c7ba1047d619ed3e6437c7f6 /src | |
| parent | d083075b458ac532e114e6af09e990fba422d0ed (diff) | |
| download | emacs-eb3f8d1b648d0aa5e5fcaec66d9003817f00ce42.tar.gz emacs-eb3f8d1b648d0aa5e5fcaec66d9003817f00ce42.zip | |
Fix focus stealing in the Emacs server for old window managers
* src/xterm.c (x_focus_frame): Apply focus stealing preference
to non-EWMH focus as well. Otherwise frames get raised but not
focused.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/src/xterm.c b/src/xterm.c index 06c84e2b534..205c948c461 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -27348,6 +27348,7 @@ static void | |||
| 27348 | x_focus_frame (struct frame *f, bool noactivate) | 27348 | x_focus_frame (struct frame *f, bool noactivate) |
| 27349 | { | 27349 | { |
| 27350 | struct x_display_info *dpyinfo; | 27350 | struct x_display_info *dpyinfo; |
| 27351 | Time time; | ||
| 27351 | 27352 | ||
| 27352 | dpyinfo = FRAME_DISPLAY_INFO (f); | 27353 | dpyinfo = FRAME_DISPLAY_INFO (f); |
| 27353 | 27354 | ||
| @@ -27373,16 +27374,25 @@ x_focus_frame (struct frame *f, bool noactivate) | |||
| 27373 | /* Ignore any BadMatch error this request might result in. */ | 27374 | /* Ignore any BadMatch error this request might result in. */ |
| 27374 | x_ignore_errors_for_next_request (dpyinfo); | 27375 | x_ignore_errors_for_next_request (dpyinfo); |
| 27375 | if (NILP (Vx_no_window_manager)) | 27376 | if (NILP (Vx_no_window_manager)) |
| 27376 | XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), | 27377 | { |
| 27377 | /* It is invalid to use CurrentTime according to | 27378 | /* Use the last user time. It is invalid to use CurrentTime |
| 27378 | the ICCCM: | 27379 | according to the ICCCM: |
| 27379 | 27380 | ||
| 27380 | Clients that use a SetInputFocus request must | 27381 | Clients that use a SetInputFocus request must set the |
| 27381 | set the time field to the timestamp of the | 27382 | time field to the timestamp of the event that caused |
| 27382 | event that caused them to make the | 27383 | them to make the attempt. [...] Note that clients must |
| 27383 | attempt. [...] Note that clients must not use | 27384 | not use CurrentTime in the time field. */ |
| 27384 | CurrentTime in the time field. */ | 27385 | time = dpyinfo->last_user_time; |
| 27385 | RevertToParent, dpyinfo->last_user_time); | 27386 | |
| 27387 | /* Unless the focus doesn't belong to Emacs anymore and | ||
| 27388 | `x-allow-focus-stealing' is set to Qnewer_time. */ | ||
| 27389 | if (EQ (Vx_allow_focus_stealing, Qnewer_time) | ||
| 27390 | && !dpyinfo->x_focus_frame) | ||
| 27391 | time = x_get_server_time (f); | ||
| 27392 | |||
| 27393 | XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), | ||
| 27394 | RevertToParent, time); | ||
| 27395 | } | ||
| 27386 | else | 27396 | else |
| 27387 | XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), | 27397 | XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), |
| 27388 | /* But when no window manager is in use, we | 27398 | /* But when no window manager is in use, we |
| @@ -31049,10 +31059,16 @@ connection setup. */); | |||
| 31049 | 31059 | ||
| 31050 | Some window managers prevent `x-focus-frame' from activating the given | 31060 | Some window managers prevent `x-focus-frame' from activating the given |
| 31051 | frame when Emacs is in the background, which is especially prone to | 31061 | frame when Emacs is in the background, which is especially prone to |
| 31052 | cause problems when the Emacs server wants to activate itself. This | 31062 | cause problems when the Emacs server wants to activate itself. |
| 31053 | variable specifies the strategy used to activate frames when that is | 31063 | |
| 31054 | the case, and has several valid values (any other value means to not | 31064 | In addition, when an old-fashioned (pre-EWMH) window manager is being |
| 31055 | bypass window manager focus stealing prevention): | 31065 | run and `x-no-window-manager' is nil, the X server will not let Emacs |
| 31066 | focus itself if another program was focused after the last time Emacs | ||
| 31067 | obtained the input focus. | ||
| 31068 | |||
| 31069 | This variable specifies the strategy used to activate frames when that | ||
| 31070 | is the case, and has several valid values (any other value means to | ||
| 31071 | not bypass window manager focus stealing prevention): | ||
| 31056 | 31072 | ||
| 31057 | - The symbol `imitate-pager', which means to pretend that Emacs is a | 31073 | - The symbol `imitate-pager', which means to pretend that Emacs is a |
| 31058 | pager. | 31074 | pager. |