Fix restoring of OS window title after visual selection

This commit is contained in:
Kovid Goyal 2021-11-06 11:28:56 +05:30
parent d30c761b3b
commit 9cda076c93
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 15 additions and 12 deletions

View File

@ -38,8 +38,8 @@ from .fast_data_types import (
redirect_mouse_handling, ring_bell, safe_pipe,
set_application_quit_request, set_background_image, set_boss,
set_clipboard_string, set_in_sequence_mode, set_options,
set_os_window_size, set_os_window_title, sync_os_window_title,
thread_write, toggle_fullscreen, toggle_maximized
set_os_window_size, set_os_window_title, thread_write, toggle_fullscreen,
toggle_maximized
)
from .key_encoding import get_name_to_functional_number_map
from .keys import get_shortcut, shortcut_matches
@ -171,7 +171,7 @@ class VisualSelect:
self.callback(tab, w)
def clear_global_state(self) -> 'Boss':
sync_os_window_title(self.os_window_id)
set_os_window_title(self.os_window_id, '')
boss = get_boss()
redirect_mouse_handling(False)
boss.clear_pending_sequences()

View File

@ -1323,5 +1323,5 @@ def send_data_to_peer(peer_id: int, data: Union[str, bytes]) -> None:
pass
def set_os_window_title(os_window_id: int, title: str) -> Optional[str]:
def set_os_window_title(os_window_id: int, title: str) -> None:
pass

View File

@ -265,7 +265,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 (os_window->disallow_title_changes || os_window->title_is_overriden) return;
if (w->title && w->title != os_window->window_title) {
Py_XDECREF(os_window->window_title);
os_window->window_title = w->title;
@ -844,14 +844,17 @@ PYWRAP1(set_os_window_title) {
id_type os_window_id;
const char *title;
PA("Ks", &os_window_id, &title);
PyObject *old_title = NULL;
WITH_OS_WINDOW(os_window_id)
old_title = os_window->window_title;
Py_XINCREF(old_title);
if (strlen(title)) {
os_window->title_is_overriden = true;
set_os_window_title(os_window, title);
} else {
os_window->title_is_overriden = false;
if (os_window->window_title) set_os_window_title(os_window, PyUnicode_AsUTF8(os_window->window_title));
update_os_window_title(os_window);
}
END_WITH_OS_WINDOW
if (!old_title) Py_RETURN_NONE;
return old_title;
Py_RETURN_NONE;
}

View File

@ -185,7 +185,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 disallow_title_changes, title_is_overriden;
bool viewport_size_dirty, viewport_updated_at_least_once;
LiveResizeInfo live_resize;
bool has_pending_resizes, is_semi_transparent, shown_once, is_damaged;