This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch tymux-10-quiet-head
in repository terminology.

View the commit online.

commit cb21ec6d76735ec711f6c1609a7f1c1d38d6a63b
Author: [email protected] <[email protected]>
AuthorDate: Fri Sep 25 12:46:11 2026 -0600

    win: show the tymux session name in titles
    
    The tab and window titles of a terminal attached to a session start
    with the session's name, "[NAME] title", or read "[NAME]" when the
    application set no title, so the session a window shows can be seen
    from its tab or from the window list. Terminals that are not attached
    keep their title as it is.
---
 src/bin/termio.c     | 14 ++++++++++++++
 src/bin/termio.h     |  7 +++++++
 src/bin/termtymux.c  | 38 ++++++++++++++++++++++++++++++++++++++
 src/bin/termtymux.h  |  8 ++++++++
 src/bin/tytest.c     |  1 +
 src/bin/unit_tests.h |  1 +
 src/bin/win.c        | 30 ++++++++++++++++++++++++++----
 7 files changed, 95 insertions(+), 4 deletions(-)

diff --git a/src/bin/termio.c b/src/bin/termio.c
index 17cda02f..3d3bb69e 100644
--- a/src/bin/termio.c
+++ b/src/bin/termio.c
@@ -4160,6 +4160,7 @@ _termio_tymux_leave(Evas_Object *obj, Termio *sd)
 
    term_tymux_pause_apply(obj); /* clears the pause overlay */
    term_tymux_indicator_apply(obj); /* clears the session indicator */
+   evas_object_smart_callback_call(obj, "title,change", NULL);
    _smart_apply(obj);
 }
 #endif
@@ -4363,6 +4364,18 @@ termio_tymux_name_get(const Evas_Object *obj)
 #endif
 }
 
+Eina_Stringshare *
+termio_tymux_title_get(const Evas_Object *obj, const char *title)
+{
+#ifdef HAVE_TYMUX
+   return termtymux_title_compose(termio_tymux_name_get(obj), title);
+#else
+   (void)obj;
+   (void)title;
+   return NULL;
+#endif
+}
+
 #ifdef HAVE_TYMUX
 static void _smart_pty_command(void *data);
 
@@ -4464,6 +4477,7 @@ _termio_tymux_switch_job(void *data)
    termtymux_resize(tymux, sd->grid.w, sd->grid.h);
    term_tymux_pause_apply(obj);
    term_tymux_indicator_apply(obj);
+   evas_object_smart_callback_call(obj, "title,change", NULL);
    _smart_apply(obj);
 }
 
diff --git a/src/bin/termio.h b/src/bin/termio.h
index fa7aaba7..1a1b6950 100644
--- a/src/bin/termio.h
+++ b/src/bin/termio.h
@@ -30,6 +30,13 @@ Eina_Bool termio_tymux_paused_get(const Evas_Object *obj);
  * whose hand-off is still pending, or a build without HAVE_TYMUX. */
 const char *termio_tymux_name_get(const Evas_Object *obj);
 
+/* Composes the title to display for obj given its own title: "[session]
+ * title" when obj is attached to a tymux session, NULL otherwise (the
+ * caller then keeps using title unchanged). See termtymux_title_compose()
+ * for how title is folded in. Returned string is an Eina_Stringshare the
+ * caller must release with eina_stringshare_del(). */
+Eina_Stringshare *termio_tymux_title_get(const Evas_Object *obj, const char *title);
+
 Termio *termio_get_from_obj(Evas_Object *obj);
 void         termio_win_set(Evas_Object *obj, Evas_Object *win);
 void         termio_theme_set(Evas_Object *obj, Evas_Object *theme);
diff --git a/src/bin/termtymux.c b/src/bin/termtymux.c
index b964fd72..10f8559b 100644
--- a/src/bin/termtymux.c
+++ b/src/bin/termtymux.c
@@ -602,6 +602,16 @@ termtymux_name_get(const TermTymux *ts)
    return ts->name;
 }
 
+Eina_Stringshare *
+termtymux_title_compose(const char *tymux_name, const char *title)
+{
+   if (!tymux_name || !*tymux_name) return NULL;
+
+   if (title && *title)
+     return eina_stringshare_printf("[%s] %s", tymux_name, title);
+   return eina_stringshare_printf("[%s]", tymux_name);
+}
+
 /* arg is everything after "at" in ty->cur_cmd, which is also where the
  * pre-existing 'at[on/true/yes/off/false/no]' temporary-alpha command
  * (win.c _cb_command(), values "on"/"true"/"yes"/"off"/"false"/"no")
@@ -1153,4 +1163,32 @@ tytest_termtymux_backlog_apply(void)
    return 0;
 }
 
+/* Test: termtymux_title_compose() prefixes the session name in brackets,
+ * drops the title when it is empty, and returns NULL (no session to show)
+ * when tymux_name is NULL or empty, whatever title is. */
+int
+tytest_termtymux_title_compose(void)
+{
+   Eina_Stringshare *title;
+
+   title = termtymux_title_compose("work", "vim");
+   assert(!strcmp(title, "[work] vim"));
+   eina_stringshare_del(title);
+
+   title = termtymux_title_compose("work", NULL);
+   assert(!strcmp(title, "[work]"));
+   eina_stringshare_del(title);
+
+   title = termtymux_title_compose("work", "");
+   assert(!strcmp(title, "[work]"));
+   eina_stringshare_del(title);
+
+   assert(!termtymux_title_compose(NULL, "vim"));
+   assert(!termtymux_title_compose("", "vim"));
+   assert(!termtymux_title_compose(NULL, NULL));
+   assert(!termtymux_title_compose("", ""));
+
+   return 0;
+}
+
 #endif /* BINARY_TYTEST */
diff --git a/src/bin/termtymux.h b/src/bin/termtymux.h
index b2f0c569..e3e03eea 100644
--- a/src/bin/termtymux.h
+++ b/src/bin/termtymux.h
@@ -117,6 +117,14 @@ TermTymuxEndReason termtymux_end_reason_get(const TermTymux *ts);
  * termtymux_free(). */
 const char *termtymux_name_get(const TermTymux *ts);
 
+/* Composes the title shown in a tab or window for a terminal attached to
+ * tymux_name: "[tymux_name] title", or just "[tymux_name]" when title is
+ * NULL or empty. Returns NULL when tymux_name is NULL or empty (the caller
+ * then keeps using title as-is). Otherwise returns an Eina_Stringshare the
+ * caller must release with eina_stringshare_del(). */
+Eina_Stringshare *termtymux_title_compose(const char *tymux_name,
+                                          const char *title);
+
 /* Parses the argument of Terminology's private native hand-off escape,
  * "\033}at<variant>;NAME\0", where arg points right after "at":
  *   ";NAME"   -> TSRV_ATTACH_HIJACK
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index 080e7bf0..6880315e 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -182,6 +182,7 @@ static struct {
        { "termtymux_backlog_apply", tytest_termtymux_backlog_apply},
        { "termtymux_input_action_get", tytest_termtymux_input_action_get},
        { "termtymux_input_filter_long", tytest_termtymux_input_filter_long},
+       { "termtymux_title_compose", tytest_termtymux_title_compose},
 #endif
        { NULL, NULL},
 };
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index eb939f42..4cc90ee9 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -140,6 +140,7 @@ int tytest_termtymux_attach_escape_parse(void);
 int tytest_termtymux_backlog_apply(void);
 int tytest_termtymux_input_action_get(void);
 int tytest_termtymux_input_filter_long(void);
+int tytest_termtymux_title_compose(void);
 #endif
 
 #endif
diff --git a/src/bin/win.c b/src/bin/win.c
index e28b4278..e63be829 100644
--- a/src/bin/win.c
+++ b/src/bin/win.c
@@ -830,6 +830,21 @@ _solo_unfocus(Term_Container *tc, Term_Container *relative)
      }
 }
 
+/* Title shown in a tab or window for term: its own title, prefixed with
+ * "[session]" when its terminal is attached to a tymux session (see
+ * termio_tymux_title_get()). *allocated is set to the stringshare to
+ * release with eina_stringshare_del() once the caller is done with the
+ * returned pointer, or to NULL when term->termio has no session and the
+ * returned pointer is term's own title, owned by termio. */
+static const char *
+_term_display_title_get(Term *term, Eina_Stringshare **allocated)
+{
+   const char *title = termio_title_get(term->termio);
+
+   *allocated = termio_tymux_title_get(term->termio, title);
+   return *allocated ? *allocated : title;
+}
+
 static void
 _solo_focus(Term_Container *tc, Term_Container *relative)
 {
@@ -871,9 +886,14 @@ _solo_focus(Term_Container *tc, Term_Container *relative)
    termio_event_feed_mouse_in(term->termio);
    termio_focus_in(term->termio);
 
-   title = termio_title_get(term->termio);
-   if (title)
-      tc->set_title(tc, tc, title);
+   {
+      Eina_Stringshare *allocated;
+
+      title = _term_display_title_get(term, &allocated);
+      if (title)
+        tc->set_title(tc, tc, title);
+      eina_stringshare_del(allocated);
+   }
 
    if (term->missed_bell)
      term->missed_bell = EINA_FALSE;
@@ -7156,10 +7176,12 @@ _cb_title(void *data,
 {
    Term *term = data;
    Term_Container *tc = term->container;
-   const char *title = termio_title_get(term->termio);
+   Eina_Stringshare *allocated;
+   const char *title = _term_display_title_get(term, &allocated);
 
    if (title)
      tc->set_title(tc, tc, title);
+   eina_stringshare_del(allocated);
 }
 
 static void

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to