From 70b5f5bce3dc600966560a2c398928e47524c164 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 3 Aug 2021 09:34:13 +0530 Subject: [PATCH] Fix kitty --title not overriding tab titles It must set the OS Window title permanently. Fixes #3893 --- docs/changelog.rst | 4 ++++ kitty/boss.py | 2 +- kitty/cli.py | 2 +- kitty/fast_data_types.pyi | 3 ++- kitty/glfw.c | 9 +++++---- kitty/main.py | 2 +- kitty/state.c | 1 + kitty/state.h | 1 + 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index e8eda1051..0d8c12125 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,10 @@ To update |kitty|, :doc:`follow the instructions `. - A new style for the tab bar that makes tabs looks like the tabs in a physical tabbed file, see :opt:`tab_bar_style` +- Fix :option:`kitty --title` not overriding the OS Window title when multiple + tabs are present (:iss:`3893`) + + 0.22.2 [2021-08-02] ---------------------- diff --git a/kitty/boss.py b/kitty/boss.py index 39cc4fc6d..39de2c857 100755 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -213,7 +213,7 @@ def add_os_window( os_window_id = create_os_window( initial_window_size_func(size_data, self.cached_values), pre_show_callback, - self.args.title or appname, wname, wclass) + self.args.title or appname, wname, wclass, disallow_override_title=bool(self.args.title)) else: wname = self.args.name or self.args.cls or appname wclass = self.args.cls or appname diff --git a/kitty/cli.py b/kitty/cli.py index fba2f1955..c750d1fb9 100644 --- a/kitty/cli.py +++ b/kitty/cli.py @@ -596,7 +596,7 @@ def options_spec() -> str: --title -T -Set the window title. This will override any title set by the program running inside kitty. So +Set the OS window title. This will override any title set by the program running inside kitty. So only use this if you are running a program that does not set titles. If combined with :option:`{appname} --session` the title will be used for all windows created by the session, that do not set their own titles. diff --git a/kitty/fast_data_types.pyi b/kitty/fast_data_types.pyi index 0516ed2bd..71fdef7ae 100644 --- a/kitty/fast_data_types.pyi +++ b/kitty/fast_data_types.pyi @@ -494,7 +494,8 @@ def create_os_window( wm_class_class: str, load_programs: Optional[Callable[[bool], None]] = None, x: int = -1, - y: int = -1 + y: int = -1, + disallow_override_title: bool = False, ) -> int: pass diff --git a/kitty/glfw.c b/kitty/glfw.c index 37894c580..6e4386fec 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -623,12 +623,12 @@ native_window_handle(GLFWwindow *w) { static PyObject* create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) { - int x = -1, y = -1; + int x = -1, y = -1, disallow_override_title = 0; char *title, *wm_class_class, *wm_class_name; PyObject *load_programs = NULL, *get_window_size, *pre_show_callback; - static const char* kwlist[] = {"get_window_size", "pre_show_callback", "title", "wm_class_name", "wm_class_class", "load_programs", "x", "y", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kw, "OOsss|Oii", (char**)kwlist, - &get_window_size, &pre_show_callback, &title, &wm_class_name, &wm_class_class, &load_programs, &x, &y)) return NULL; + static const char* kwlist[] = {"get_window_size", "pre_show_callback", "title", "wm_class_name", "wm_class_class", "load_programs", "x", "y", "disallow_override_title", NULL}; + if (!PyArg_ParseTupleAndKeywords(args, kw, "OOsss|Oiip", (char**)kwlist, + &get_window_size, &pre_show_callback, &title, &wm_class_name, &wm_class_class, &load_programs, &x, &y, &disallow_override_title)) return NULL; static bool is_first_window = true; if (is_first_window) { @@ -742,6 +742,7 @@ 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; update_os_window_references(); for (size_t i = 0; i < global_state.num_os_windows; i++) { // On some platforms (macOS) newly created windows don't get the initial focus in event diff --git a/kitty/main.py b/kitty/main.py index 3a7ce90f7..21304461f 100644 --- a/kitty/main.py +++ b/kitty/main.py @@ -157,7 +157,7 @@ def _run_app(opts: Options, args: CLIOptions, bad_lines: Sequence[BadLine] = ()) run_app.initial_window_size_func(get_os_window_sizing_data(opts), cached_values), pre_show_callback, args.title or appname, args.name or args.cls or appname, - args.cls or appname, load_all_shaders) + args.cls or appname, load_all_shaders, disallow_override_title=bool(args.title)) boss = Boss(opts, args, cached_values, global_shortcuts) boss.start(window_id) if bad_lines: diff --git a/kitty/state.c b/kitty/state.c index 8e91de0af..b5447c159 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -264,6 +264,7 @@ update_window_title(id_type os_window_id, id_type tab_id, id_type window_id, PyO void set_os_window_title_from_window(Window *w, OSWindow *os_window) { + if (os_window->disallow_title_changes) return; if (w->title && w->title != os_window->window_title) { Py_XDECREF(os_window->window_title); os_window->window_title = w->title; diff --git a/kitty/state.h b/kitty/state.h index 0b9af1ebf..95c95ea33 100644 --- a/kitty/state.h +++ b/kitty/state.h @@ -176,6 +176,7 @@ typedef struct { double logical_dpi_x, logical_dpi_y, font_sz_in_pts; bool mouse_button_pressed[32]; PyObject *window_title; + bool disallow_title_changes; bool viewport_size_dirty, viewport_updated_at_least_once; LiveResizeInfo live_resize; bool has_pending_resizes, is_semi_transparent, shown_once, is_damaged;