Ensure CSI are stripped from menbar title as well

This commit is contained in:
Kovid Goyal 2022-02-09 08:07:18 +05:30
parent 7448789951
commit 0dbe27438d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 14 additions and 3 deletions

View File

@ -553,8 +553,6 @@ pyset_iutf8(ChildMonitor *self, PyObject *args) {
#undef INCREF_CHILD
#undef DECREF_CHILD
extern void cocoa_update_menu_bar_title(PyObject*);
static bool
cursor_needs_render(Window *w) {
return w->cursor_visible_at_last_render != w->render_data.screen->cursor_render_info.is_visible || w->last_cursor_x != w->render_data.screen->cursor_render_info.x || w->last_cursor_y != w->render_data.screen->cursor_render_info.y || w->last_cursor_shape != w->render_data.screen->cursor_render_info.shape;
@ -592,7 +590,7 @@ change_menubar_title(PyObject *title UNUSED) {
static PyObject *current_title = NULL;
if (title != current_title) {
current_title = title;
if (title && OPT(macos_show_window_title_in) & MENUBAR) cocoa_update_menu_bar_title(title);
if (title && OPT(macos_show_window_title_in) & MENUBAR) update_menu_bar_title(title);
}
#endif
}

View File

@ -25,6 +25,7 @@ extern void cocoa_set_titlebar_appearance(void *w, unsigned int theme);
extern void cocoa_set_titlebar_color(void *w, color_type color);
extern bool cocoa_alt_option_key_pressed(unsigned long);
extern void cocoa_toggle_secure_keyboard_entry(void);
extern void cocoa_update_menu_bar_title(PyObject*);
extern size_t cocoa_get_workspace_ids(void *w, size_t *workspace_ids, size_t array_sz);
extern monotonic_t cocoa_cursor_blink_interval(void);
@ -72,6 +73,17 @@ strip_csi_(const char *title, char *buf, size_t bufsz) {
}
void
update_menu_bar_title(PyObject *title UNUSED) {
#ifdef __APPLE__
static char buf[2048];
strip_csi_(PyUnicode_AsUTF8(title), buf, arraysz(buf));
DECREF_AFTER_FUNCTION PyObject *stitle = PyUnicode_FromString(buf);
cocoa_update_menu_bar_title(stitle);
#endif
}
void
request_tick_callback(void) {
glfwPostEmptyEvent();

View File

@ -341,3 +341,4 @@ void update_ime_focus(OSWindow* osw, bool focused);
void update_ime_position(Window* w, Screen *screen);
bool update_ime_position_for_window(id_type window_id, bool force, bool lost_focus);
void set_ignore_os_keyboard_processing(bool enabled);
void update_menu_bar_title(PyObject *title UNUSED);