Fix kitty --title not overriding tab titles

It must set the OS Window title permanently.

Fixes #3893
This commit is contained in:
Kovid Goyal 2021-08-03 09:34:13 +05:30
parent be34af4555
commit 70b5f5bce3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
8 changed files with 16 additions and 8 deletions

View File

@ -10,6 +10,10 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- 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]
----------------------

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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:

View File

@ -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;

View File

@ -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;