diff options
| author | Eli Zaretskii | 2015-01-14 20:14:02 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2015-01-14 20:14:02 +0200 |
| commit | 61cc7bf8c4059e0243903752189a13c88cc2cee5 (patch) | |
| tree | 474bf2bb37aca0670ccb349c0621de6782dbc081 /src | |
| parent | 1e5902ac64456fe9a68e3c9f92604df6e3128c5d (diff) | |
| download | emacs-61cc7bf8c4059e0243903752189a13c88cc2cee5.tar.gz emacs-61cc7bf8c4059e0243903752189a13c88cc2cee5.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/w32fns.c | 60 |
2 files changed, 53 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 6296302dc5e..a90cc41e601 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2015-01-14 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * w32fns.c (w32_set_title_bar_text): New function, including | ||
| 4 | support for titles with non-ASCII characters outside of the | ||
| 5 | current system codepage. | ||
| 6 | (x_set_name, x_set_title): Use it. (Bug#19590) | ||
| 7 | |||
| 1 | 2015-01-10 Eli Zaretskii <eliz@gnu.org> | 8 | 2015-01-10 Eli Zaretskii <eliz@gnu.org> |
| 2 | 9 | ||
| 3 | * indent.c (Fvertical_motion): Return zero if we started from ZV | 10 | * indent.c (Fvertical_motion): Return zero if we started from ZV |
diff --git a/src/w32fns.c b/src/w32fns.c index 412e91e045e..5af36b9a0c8 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -1732,6 +1732,50 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval) | |||
| 1732 | run_window_configuration_change_hook (f); | 1732 | run_window_configuration_change_hook (f); |
| 1733 | } | 1733 | } |
| 1734 | 1734 | ||
| 1735 | static void | ||
| 1736 | w32_set_title_bar_text (struct frame *f, Lisp_Object name) | ||
| 1737 | { | ||
| 1738 | if (FRAME_W32_WINDOW (f)) | ||
| 1739 | { | ||
| 1740 | block_input (); | ||
| 1741 | #ifdef __CYGWIN__ | ||
| 1742 | GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f), | ||
| 1743 | GUI_SDATA (GUI_ENCODE_SYSTEM (name))); | ||
| 1744 | #else | ||
| 1745 | /* The frame's title many times shows the name of the file | ||
| 1746 | visited in the selected window's buffer, so it makes sense to | ||
| 1747 | support non-ASCII characters outside of the current system | ||
| 1748 | codepage in the title. */ | ||
| 1749 | if (w32_unicode_filenames) | ||
| 1750 | { | ||
| 1751 | Lisp_Object encoded_title = ENCODE_UTF_8 (name); | ||
| 1752 | wchar_t *title_w; | ||
| 1753 | int tlen = pMultiByteToWideChar (CP_UTF8, 0, SSDATA (encoded_title), | ||
| 1754 | -1, NULL, 0); | ||
| 1755 | |||
| 1756 | if (tlen > 0) | ||
| 1757 | { | ||
| 1758 | /* Windows truncates the title text beyond what fits on | ||
| 1759 | a single line, so we can limit the length to some | ||
| 1760 | reasonably large value, and use alloca. */ | ||
| 1761 | if (tlen > 10000) | ||
| 1762 | tlen = 10000; | ||
| 1763 | title_w = alloca ((tlen + 1) * sizeof (wchar_t)); | ||
| 1764 | pMultiByteToWideChar (CP_UTF8, 0, SSDATA (encoded_title), -1, | ||
| 1765 | title_w, tlen); | ||
| 1766 | title_w[tlen] = L'\0'; | ||
| 1767 | SetWindowTextW (FRAME_W32_WINDOW (f), title_w); | ||
| 1768 | } | ||
| 1769 | else /* Conversion to UTF-16 failed, so we punt. */ | ||
| 1770 | SetWindowTextA (FRAME_W32_WINDOW (f), | ||
| 1771 | SSDATA (ENCODE_SYSTEM (name))); | ||
| 1772 | } | ||
| 1773 | else | ||
| 1774 | SetWindowTextA (FRAME_W32_WINDOW (f), SSDATA (ENCODE_SYSTEM (name))); | ||
| 1775 | #endif | ||
| 1776 | unblock_input (); | ||
| 1777 | } | ||
| 1778 | } | ||
| 1735 | 1779 | ||
| 1736 | /* Change the name of frame F to NAME. If NAME is nil, set F's name to | 1780 | /* Change the name of frame F to NAME. If NAME is nil, set F's name to |
| 1737 | w32_id_name. | 1781 | w32_id_name. |
| @@ -1785,13 +1829,7 @@ x_set_name (struct frame *f, Lisp_Object name, int explicit) | |||
| 1785 | if (! NILP (f->title)) | 1829 | if (! NILP (f->title)) |
| 1786 | name = f->title; | 1830 | name = f->title; |
| 1787 | 1831 | ||
| 1788 | if (FRAME_W32_WINDOW (f)) | 1832 | w32_set_title_bar_text (f, name); |
| 1789 | { | ||
| 1790 | block_input (); | ||
| 1791 | GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f), | ||
| 1792 | GUI_SDATA (GUI_ENCODE_SYSTEM (name))); | ||
| 1793 | unblock_input (); | ||
| 1794 | } | ||
| 1795 | } | 1833 | } |
| 1796 | 1834 | ||
| 1797 | /* This function should be called when the user's lisp code has | 1835 | /* 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) | |||
| 1829 | if (NILP (name)) | 1867 | if (NILP (name)) |
| 1830 | name = f->name; | 1868 | name = f->name; |
| 1831 | 1869 | ||
| 1832 | if (FRAME_W32_WINDOW (f)) | 1870 | w32_set_title_bar_text (f, name); |
| 1833 | { | ||
| 1834 | block_input (); | ||
| 1835 | GUI_FN (SetWindowText) (FRAME_W32_WINDOW (f), | ||
| 1836 | GUI_SDATA (GUI_ENCODE_SYSTEM (name))); | ||
| 1837 | unblock_input (); | ||
| 1838 | } | ||
| 1839 | } | 1871 | } |
| 1840 | 1872 | ||
| 1841 | void | 1873 | void |