Show custom OS window and tab titles in the detach_tab chooser
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run

Store fixed OS window titles at creation time so they can be queried,
and add an only_if_overridden flag to get_os_window_title so callers
can distinguish a custom title from the cached active window title.
The detach_tab chooser now uses the custom OS window title if any,
falling back to the tab's effective title.

This also fixes launch --os-window-title=current not copying a fixed
title and Wayland CSD titles of fixed title windows not being
re-rendered on font size changes.

Closes #10681
This commit is contained in:
Kovid Goyal 2026-10-17 12:35:09 +05:30
parent bea239edb1
commit f7a16a9319
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
5 changed files with 21 additions and 8 deletions

View file

@ -511,6 +511,12 @@ Detailed list of changes
:ac:`remote_control` mappings when kitty's standard input is not a terminal.
The mapping no longer reads kitty's own standard input.
- :ac:`detach_tab`: Show custom OS Window titles and tab titles in the OS
Window chooser
- :option:`launch --os-window-title`: Fix the value :code:`current` not copying
a fixed title set with :option:`kitty --title`
0.49.2 [2026-10-01]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -97,6 +97,7 @@ from .fast_data_types import (
get_boss,
get_options,
get_os_window_size,
get_os_window_title,
get_tab_being_dragged,
get_window_being_dragged,
glfw_get_monitor_workarea,
@ -4006,7 +4007,7 @@ class Boss:
ct = self.active_tab_manager_with_dispatch
for osw_id, tm in self.os_window_map.items():
if tm is not ct and tm.active_tab:
items.append((osw_id, tm.active_tab.title))
items.append((osw_id, get_os_window_title(osw_id, True) or tm.active_tab.effective_title))
items.append(('new', 'New OS Window'))
w = self.window_for_dispatch or self.active_window
target_tab = w.tabref() if w else None

View file

@ -1508,7 +1508,7 @@ def send_data_to_peer(peer_id: int, data: Union[str, bytes], is_async_response:
def set_os_window_title(os_window_id: int, title: str) -> None:
pass
def get_os_window_title(os_window_id: int) -> Optional[str]:
def get_os_window_title(os_window_id: int, only_if_overridden: bool = False) -> Optional[str]:
pass
def update_ime_position_for_window(window_id: int, force: bool = False, update_focus: int = 0) -> bool:

View file

@ -2240,9 +2240,9 @@ is_visible_on_a_monitor(int x, int y, int width, int height) {
static PyObject *
create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
int x = INT_MIN, y = INT_MIN, window_state = WINDOW_NORMAL, disallow_override_title = 0;
char *title, *wm_class_class, *wm_class_name;
PyObject *optional_window_state = NULL, *load_programs = NULL, *get_window_size, *pre_show_callback, *optional_x = NULL, *optional_y = NULL,
*layer_shell_config = NULL;
char *wm_class_class, *wm_class_name;
PyObject *title, *optional_window_state = NULL, *load_programs = NULL, *get_window_size, *pre_show_callback, *optional_x = NULL, *optional_y = NULL,
*layer_shell_config = NULL;
static const char *kwlist[] = {
"get_window_size",
"pre_show_callback",
@ -2259,7 +2259,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
if (!PyArg_ParseTupleAndKeywords(
args,
kw,
"OOsss|OOOOpO",
"OOUss|OOOOpO",
(char **)kwlist,
&get_window_size,
&pre_show_callback,
@ -2273,6 +2273,8 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
&disallow_override_title,
&layer_shell_config))
return NULL;
const char *title_utf8 = PyUnicode_AsUTF8(title);
if (!title_utf8) return NULL;
GLFWLayerShellConfig *lsc = NULL, lsc_stack = {0};
if (optional_window_state && optional_window_state != Py_None) {
if (!PyLong_Check(optional_window_state)) {
@ -2440,7 +2442,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
initial_window_size_py_callback = get_window_size;
}
glfwGetError(NULL); // clear any stale error
GLFWwindow *glfw_window = glfwCreateWindow(width, height, title, NULL, temp_window ? temp_window : common_context, lsc);
GLFWwindow *glfw_window = glfwCreateWindow(width, height, title_utf8, NULL, temp_window ? temp_window : common_context, lsc);
initial_window_size_py_callback = NULL;
if (temp_window) {
glfwDestroyWindow(temp_window);
@ -2493,6 +2495,8 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
OSWindow *w = add_os_window();
w->handle = glfw_window;
w->disallow_title_changes = disallow_override_title;
// A fixed title is never synced from the active window, so store it here
if (disallow_override_title) w->window_title = Py_NewRef(title);
if (lsc != NULL) {
w->is_layer_shell = true;
w->hide_on_focus_loss = lsc->hide_on_focus_loss;

View file

@ -1485,8 +1485,10 @@ PYWRAP1(set_os_window_title) {
PYWRAP1(get_os_window_title) {
id_type os_window_id;
PA("K", &os_window_id);
int only_if_overridden = 0;
PA("K|p", &os_window_id, &only_if_overridden);
WITH_OS_WINDOW(os_window_id)
if (only_if_overridden && !os_window->disallow_title_changes && !os_window->title_is_overriden) break;
if (os_window->window_title) return Py_BuildValue("O", os_window->window_title);
END_WITH_OS_WINDOW
Py_RETURN_NONE;