aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-10-24 19:18:17 +0800
committerPo Lu2022-10-24 19:18:49 +0800
commiteb3f8d1b648d0aa5e5fcaec66d9003817f00ce42 (patch)
treeab204b2023f6a509c7ba1047d619ed3e6437c7f6 /src
parentd083075b458ac532e114e6af09e990fba422d0ed (diff)
downloademacs-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.c44
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
27348x_focus_frame (struct frame *f, bool noactivate) 27348x_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
31050Some window managers prevent `x-focus-frame' from activating the given 31060Some window managers prevent `x-focus-frame' from activating the given
31051frame when Emacs is in the background, which is especially prone to 31061frame when Emacs is in the background, which is especially prone to
31052cause problems when the Emacs server wants to activate itself. This 31062cause problems when the Emacs server wants to activate itself.
31053variable specifies the strategy used to activate frames when that is 31063
31054the case, and has several valid values (any other value means to not 31064In addition, when an old-fashioned (pre-EWMH) window manager is being
31055bypass window manager focus stealing prevention): 31065run and `x-no-window-manager' is nil, the X server will not let Emacs
31066focus itself if another program was focused after the last time Emacs
31067obtained the input focus.
31068
31069This variable specifies the strategy used to activate frames when that
31070is the case, and has several valid values (any other value means to
31071not 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.