Fix support of non-ASCII frame titles on MS-Windows (Bug#19590)
src/w32fns.c (w32_set_title_bar_text): New function, including support for titles with non-ASCII characters outside of the current system codepage. (x_set_name, x_set_title): Use it.
This commit is contained in:
parent
1e5902ac64
commit
61cc7bf8c4
2 changed files with 53 additions and 14 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2015-01-14 Eli Zaretskii <eliz@gnu.org>
|
||||||
|
|
||||||
|
* w32fns.c (w32_set_title_bar_text): New function, including
|
||||||
|
support for titles with non-ASCII characters outside of the
|
||||||
|
current system codepage.
|
||||||
|
(x_set_name, x_set_title): Use it. (Bug#19590)
|
||||||
|
|
||||||
2015-01-10 Eli Zaretskii <eliz@gnu.org>
|
2015-01-10 Eli Zaretskii <eliz@gnu.org>
|
||||||
|
|
||||||
* indent.c (Fvertical_motion): Return zero if we started from ZV
|
* indent.c (Fvertical_motion): Return zero if we started from ZV
|
||||||
|
|
60
src/w32fns.c
60
src/w32fns.c
|
@ -1732,6 +1732,50 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
|
||||||
run_window_configuration_change_hook (f);
|
run_window_configuration_change_hook (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
w32_set_title_bar_text (struct frame *f, Lisp_Object name)
|
||||||
|
{
|
||||||
|
if (FRAME_W32_WINDOW (f))
|
||||||
|
{
|
||||||
|
block_input ();
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f),
|
||||||
|
GUI_SDATA (GUI_ENCODE_SYSTEM (name)));
|
||||||
|
#else
|
||||||
|
/* The frame's title many times shows the name of the file
|
||||||
|
visited in the selected window's buffer, so it makes sense to
|
||||||
|
support non-ASCII characters outside of the current system
|
||||||
|
codepage in the title. */
|
||||||
|
if (w32_unicode_filenames)
|
||||||
|
{
|
||||||
|
Lisp_Object encoded_title = ENCODE_UTF_8 (name);
|
||||||
|
wchar_t *title_w;
|
||||||
|
int tlen = pMultiByteToWideChar (CP_UTF8, 0, SSDATA (encoded_title),
|
||||||
|
-1, NULL, 0);
|
||||||
|
|
||||||
|
if (tlen > 0)
|
||||||
|
{
|
||||||
|
/* Windows truncates the title text beyond what fits on
|
||||||
|
a single line, so we can limit the length to some
|
||||||
|
reasonably large value, and use alloca. */
|
||||||
|
if (tlen > 10000)
|
||||||
|
tlen = 10000;
|
||||||
|
title_w = alloca ((tlen + 1) * sizeof (wchar_t));
|
||||||
|
pMultiByteToWideChar (CP_UTF8, 0, SSDATA (encoded_title), -1,
|
||||||
|
title_w, tlen);
|
||||||
|
title_w[tlen] = L'\0';
|
||||||
|
SetWindowTextW (FRAME_W32_WINDOW (f), title_w);
|
||||||
|
}
|
||||||
|
else /* Conversion to UTF-16 failed, so we punt. */
|
||||||
|
SetWindowTextA (FRAME_W32_WINDOW (f),
|
||||||
|
SSDATA (ENCODE_SYSTEM (name)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SetWindowTextA (FRAME_W32_WINDOW (f), SSDATA (ENCODE_SYSTEM (name)));
|
||||||
|
#endif
|
||||||
|
unblock_input ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Change the name of frame F to NAME. If NAME is nil, set F's name to
|
/* Change the name of frame F to NAME. If NAME is nil, set F's name to
|
||||||
w32_id_name.
|
w32_id_name.
|
||||||
|
@ -1785,13 +1829,7 @@ x_set_name (struct frame *f, Lisp_Object name, int explicit)
|
||||||
if (! NILP (f->title))
|
if (! NILP (f->title))
|
||||||
name = f->title;
|
name = f->title;
|
||||||
|
|
||||||
if (FRAME_W32_WINDOW (f))
|
w32_set_title_bar_text (f, name);
|
||||||
{
|
|
||||||
block_input ();
|
|
||||||
GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f),
|
|
||||||
GUI_SDATA (GUI_ENCODE_SYSTEM (name)));
|
|
||||||
unblock_input ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function should be called when the user's lisp code has
|
/* This function should be called when the user's lisp code has
|
||||||
|
@ -1829,13 +1867,7 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
|
||||||
if (NILP (name))
|
if (NILP (name))
|
||||||
name = f->name;
|
name = f->name;
|
||||||
|
|
||||||
if (FRAME_W32_WINDOW (f))
|
w32_set_title_bar_text (f, name);
|
||||||
{
|
|
||||||
block_input ();
|
|
||||||
GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f),
|
|
||||||
GUI_SDATA (GUI_ENCODE_SYSTEM (name)));
|
|
||||||
unblock_input ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Add table
Reference in a new issue