diff --git a/docs/changelog.rst b/docs/changelog.rst index 3c174a7f5..62138830a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/boss.py b/kitty/boss.py index 1c78e7221..3ded83189 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -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 diff --git a/kitty/fast_data_types.pyi b/kitty/fast_data_types.pyi index d467bf14b..3ca12e0ae 100644 --- a/kitty/fast_data_types.pyi +++ b/kitty/fast_data_types.pyi @@ -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: diff --git a/kitty/glfw.c b/kitty/glfw.c index b5222b125..4c4e39f3c 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -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; diff --git a/kitty/state.c b/kitty/state.c index a829785d5..da1b97dc3 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -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;