[MPlayer-dev-eng] [Patch] Supporting unicode window title

Vladimir Mosgalin mosgalin at VM10124.spb.edu
Thu May 5 02:48:03 CEST 2011


Hi Reimar Döffinger!

 On 2011.05.04 at 23:24:57 +0200, Reimar Döffinger wrote next:

> > I'm running mplayer in window lately, and got sick watching at ugly
> > chars in window title with
> > use-filename-title = on
> > option (russian and asian letters look completely wrong, european
> > symbols like ä render with extra symbol/distorted). Fortunately, it's
> > easy to fix by adding a hint.. should work with any descent window
> > manager.
> 
> What else is it if not UTF-8? Personally I strongly think that
> needing this rather implies it is _not_ a decent window manager
> (though past experience says such a thing is as real as
> yellow unicorns).

Well normal XStoreName isn't unicode aware; according to manual
"If the string is not in the Host Portable Character Encoding, the
result is implementation-dependent."
where Host Portable Character Encoding is minimum subset that's
same in each and every encoding in Xlib, ie.
a..z A..Z 0..9 !"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ <space>, <tab>, and
<newline> 

And "implementation-dependent", of course, means "it's not going to
work, live with that". Hint is only real way that works. And by descent
window manager I mean one that follows standard,
http://standards.freedesktop.org/wm-spec/1.3/ar01s05.html, where if
WM_NAME is set, it's used instead of old-style title.

> >      XTranslateCoordinates(mDisplay, vo_window, mRootWin, 0, 0, &vo_dx, &vo_dy,
> >                            &dummy_win);
> >      if (vo_wintitle)
> > +    {
> >          XStoreName(mDisplay, vo_window, vo_wintitle);
> > +        XChangeProperty(mDisplay, vo_window,
> > +                        XInternAtom(mDisplay, "_NET_WM_NAME", False),
> > +                        XInternAtom(mDisplay, "UTF8_STRING", False),
> > +                        8, PropModeReplace, (unsigned char *) vo_wintitle,
> > +                        strlen(vo_wintitle));
> 
> Please handle this in the same way as other Atoms are handled,
> search the file for e.g. NET_WM_PID to see what to add where.
> Maybe a bit overkill but better to keep it as consistent as
> possible (though I admit _MOTIF_WM_HINTS and XV_COLORKEY atoms
> already aren't implemented consistently).

OK, attached. UTF8_STRING looks a bit ugly.. but oh well.

-- 

Vladimir
-------------- next part --------------
diff -ur mplayer-old/libvo/x11_common.c mplayer/libvo/x11_common.c
--- mplayer-old/libvo/x11_common.c	2011-05-05 04:45:26.991756820 +0400
+++ mplayer/libvo/x11_common.c	2011-05-05 04:43:57.141180757 +0400
@@ -117,11 +117,13 @@
 static Atom XA_NET_WM_STATE_STAYS_ON_TOP;
 static Atom XA_NET_WM_STATE_BELOW;
 static Atom XA_NET_WM_PID;
+static Atom XA_NET_WM_NAME;
 static Atom XA_WIN_PROTOCOLS;
 static Atom XA_WIN_LAYER;
 static Atom XA_WIN_HINTS;
 static Atom XAWM_PROTOCOLS;
 static Atom XAWM_DELETE_WINDOW;
+static Atom XAUTF8_STRING;
 
 #define XA_INIT(x) XA##x = XInternAtom(mDisplay, #x, False)
 
@@ -358,11 +360,13 @@
     XA_INIT(_NET_WM_STATE_STAYS_ON_TOP);
     XA_INIT(_NET_WM_STATE_BELOW);
     XA_INIT(_NET_WM_PID);
+    XA_INIT(_NET_WM_NAME);
     XA_INIT(_WIN_PROTOCOLS);
     XA_INIT(_WIN_LAYER);
     XA_INIT(_WIN_HINTS);
     XA_INIT(WM_PROTOCOLS);
     XA_INIT(WM_DELETE_WINDOW);
+    XA_INIT(UTF8_STRING);
 }
 
 void update_xinerama_info(void) {
@@ -1349,7 +1353,12 @@
     XTranslateCoordinates(mDisplay, vo_window, mRootWin, 0, 0, &vo_dx, &vo_dy,
                           &dummy_win);
     if (vo_wintitle)
+    {
         XStoreName(mDisplay, vo_window, vo_wintitle);
+        XChangeProperty(mDisplay, vo_window, XA_NET_WM_NAME, XAUTF8_STRING,
+                        8, PropModeReplace, (unsigned char *) vo_wintitle,
+                        strlen(vo_wintitle));
+    }
 
     return depth <= INT_MAX ? depth : 0;
 }


More information about the MPlayer-dev-eng mailing list