This behavior was hidden behind the configure option '--enable-rxvt_osc'
introduced in 3.9.11 (and was orn without even configure support in
3.9.8) so it didn't see widespread usage.

It became the default in commit 2168239005ee587fdec417c987a632e81f86c80e
which was first released in 5.0.

By disabling this, users can use hardstatus formats to include the
screen window number in the xterm window title.
---
 src/ansi.c             | 2 +-
 src/comm.c             | 1 +
 src/display.c          | 5 ++++-
 src/display.h          | 1 +
 src/doc/screen.1       | 8 ++++++++
 src/doc/screen.texinfo | 4 ++++
 src/process.c          | 4 ++++
 7 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/ansi.c b/src/ansi.c
index 9ee4ffa..e55f6a9 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -1263,7 +1263,7 @@ static int StringEnd(Window *win)
                        }
                        break;
                }
-               if (typ == 0 || typ == 1 || typ == 2 || typ == 11 || typ == 20 
|| typ == 39 || typ == 49) {
+               if (typ == 1 || typ == 11 || typ == 20 || typ == 39 || typ == 
49 || (osctitle && (typ == 0 || typ == 2))) {
                        int typ2;
                        typ2 = typ / 10;
                        if (strcmp(win->w_xtermosc[typ2], p)) {
diff --git a/src/comm.c b/src/comm.c
index dd7f650..d1a5bf9 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -159,6 +159,7 @@ struct comm comms[RC_LAST + 1] =
   { "number",          CAN_QUERY|NEED_FORE|ARGS_01,    {NULL} },
   { "obuflimit",       NEED_DISPLAY|ARGS_01,           {NULL} },
   { "only",            NEED_DISPLAY|ARGS_0,            {NULL} },
+  { "osctitle",                ARGS_1,                         {NULL} },
   { "other",           ARGS_0,                         {NULL} },
   { "parent",          ARGS_0,                         {NULL} },
   { "partial",         NEED_FORE|ARGS_01,              {NULL} },
diff --git a/src/display.c b/src/display.c
index 8a940c1..112597b 100644
--- a/src/display.c
+++ b/src/display.c
@@ -2153,6 +2153,9 @@ void SetXtermOSC(int i, char *s, char *t)
                {"49;", "white"}        /* default background (white?) */
        };
 
+       if (i == 0 && !osctitle)
+               return;
+
        if (!D_CXT)
                return;
        if (!s)
@@ -2174,7 +2177,7 @@ void ClearAllXtermOSC(void)
 {
        for (int i = 4; i >= 0; i--)
                SetXtermOSC(i, NULL, "\a");
-       if (D_xtermosc[0])
+       if (osctitle && D_xtermosc[0])
                AddStr("\033[23;" WT_FLAG "t"); /* unstack titles (xterm patch 
#251) */
 }
 
diff --git a/src/display.h b/src/display.h
index a6ea092..f93900d 100644
--- a/src/display.h
+++ b/src/display.h
@@ -391,6 +391,7 @@ extern int defobuflimit;
 extern int focusminheight;
 extern int focusminwidth;
 extern int hardstatusemu;
+extern bool osctitle;
 
 extern Display *display, *displays;
 
diff --git a/src/doc/screen.1 b/src/doc/screen.1
index 7817c8b..781d8ce 100644
--- a/src/doc/screen.1
+++ b/src/doc/screen.1
@@ -2885,6 +2885,14 @@ Switch to the window displayed previously. If this 
window does no longer exist,
 \fIother\fP has the same effect as \fInext\fP.
 .RE
 .TP
+.BR "osctitle [ on | off ]"
+.RS 0
+.PP
+Defines whether to use OSC codes to update the window titles of terminal
+emulators such as xterm.
+Default is `on'.
+.RE
+.TP
 .BR "partial [ on | off ]"
 .RS 0
 .PP
diff --git a/src/doc/screen.texinfo b/src/doc/screen.texinfo
index ab8f3ac..e61d4ed 100644
--- a/src/doc/screen.texinfo
+++ b/src/doc/screen.texinfo
@@ -1132,6 +1132,10 @@ Select output buffer limit.  @xref{Obuflimit}.
 Kill all other regions.  @xref{Regions}.
 @item other
 Switch to the window you were in last.  @xref{Selecting}.
+@item osctitle [@var{on}|@var{off}]
+Defines whether to use OSC codes to update the window titles of terminal
+emulators such as xterm.
+It is on by default.
 @item parent
 Switch to the parent window.  @xref{Selecting}.
 @item partial @var{state}
diff --git a/src/process.c b/src/process.c
index 470e70a..e075857 100644
--- a/src/process.c
+++ b/src/process.c
@@ -122,6 +122,7 @@ struct plop plop_tab[MAX_PLOP_DEFS];
 
 int TtyMode = PTY_MODE;
 bool hardcopy_append = false;
+bool osctitle = true;
 bool all_norefresh = 0;
 int zmodem_mode = 0;
 char *zmodem_sendcmd;
@@ -5105,6 +5106,9 @@ void DoAction(struct action *act)
        case RC_COMPACTHIST:
                DoCommandCompacthist(act);
                break;
+       case RC_OSCTITLE:
+               (void)ParseOnOff(act, &osctitle);
+               break;
        case RC_HARDCOPY_APPEND:
                DoCommandHardcopy_append(act);
                break;
-- 
2.47.0


Reply via email to