[dev] [PATCH] Changed the way title is set to support UTF-8.

From: Alexander Sedov <alex0player_AT_gmail.com>
Date: Fri, 22 Feb 2013 19:55:01 +0400

---
 TODO |    1 -
 st.c |   17 +++++++++++------
 2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/TODO b/TODO
index 2f42720..67615f8 100644
--- a/TODO
+++ b/TODO
_AT_@ -18,7 +18,6 @@ bugs
 
 * fix shift up/down (shift selection in emacs)
 * fix selection paste for xatom STRING
-* fix umlaut handling in settitle
 * fix rows and column definition in fixed geometry
 * fix -e handling
 * remove DEC test sequence when appropriate
diff --git a/st.c b/st.c
index c25f24c..094e8ca 100644
--- a/st.c
+++ b/st.c
_AT_@ -352,6 +352,7 @@ static void xloadcols(void);
 static int xsetcolorname(int, const char *);
 static int xloadfont(Font *, FcPattern *);
 static void xloadfonts(char *, int);
+static void xsettitle(char *);
 static void xresettitle(void);
 static void xseturgency(int);
 static void xsetsel(char*);
_AT_@ -1891,11 +1892,8 @@ strhandle(void) {
 		case 0:
 		case 1:
 		case 2:
-			/*
-			 * TODO: Handle special chars in string, like umlauts.
-			 */
 			if(narg > 1)
-				XStoreName(xw.dpy, xw.win, strescseq.args[2]);
+				xsettitle(strescseq.args[2]);
 			break;
 		case 4: /* color set */
 			if(narg < 3)
_AT_@ -1917,7 +1915,7 @@ strhandle(void) {
 		}
 		break;
 	case 'k': /* old title set compatibility */
-		XStoreName(xw.dpy, xw.win, strescseq.buf);
+		xsettitle(strescseq.arg[1]);
 		break;
 	case 'P': /* DSC -- Device Control String */
 	case '_': /* APC -- Application Program Command */
_AT_@ -2986,8 +2984,15 @@ xdrawcursor(void) {
 }
 
 void
+xsettitle(char *p) {
+	XTextProperty prop;
+	Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle, &prop);
+	XSetWMName(xw.dpy, xw.win, &prop);
+}
+
+void
 xresettitle(void) {
-	XStoreName(xw.dpy, xw.win, opt_title ? opt_title : "st");
+	xsettitle(opt_title ? opt_title : "st");
 }
 
 void
-- 
1.7.10.4
Received on Fri Feb 22 2013 - 16:55:01 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 22 2013 - 17:00:06 CET