From 7560d73ba0b611810bc1cf82feaad0204a994a86 Mon Sep 17 00:00:00 2001 From: Sadrul Habib Chowdhury Date: Tue, 13 Mar 2012 20:56:08 -0400 Subject: Make sure a remote command is executed from the foreground window of a display. If a remote command is executed from a window inside the session, and it does not pre-select a window, and the window that issued the command is not visible in any display, and there is an existing display for the user, then execute the command in that display's foreground window's context. --- src/socket.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/socket.c b/src/socket.c index 940034d..8f9a315 100644 --- a/src/socket.c +++ b/src/socket.c @@ -1715,6 +1715,13 @@ struct msg *mp; { if (!display) display = fore->w_layer.l_cvlist ? fore->w_layer.l_cvlist->c_display : 0; + + /* If the window is not visibile in any display, then do not use the originating window as + * the foreground window for the command. This way, if there is an existing display, then + * the command will execute from the foreground window of that display. This is necessary so + * that commands that are relative to the window (e.g. 'next' etc.) do the right thing. */ + if (!fore->w_layer.l_cvlist || !fore->w_layer.l_cvlist->c_display) + fore = NULL; break; } if (!display) -- cgit v1.2.1