Commit a446c418 authored by dimbor's avatar dimbor

nxagent: add setlocale for nxwin windows titles recoding (UTF8_STRING <-> COMPOUND_TEXT)

parent 0d460dcd
......@@ -551,3 +551,8 @@
*
#define X86EMU_LIBPATH /usr/local/lib
*/
/* Build locales for nxagent */
#define MotifDir $(LIBDIR)
#define XLocaleDir /usr/share/locale
#define XLocaleLibDir $(LIBDIR)
......@@ -88,6 +88,9 @@ is" without express or implied warranty.
#define NXAGENT_VERSION NX_VERSION_CURRENT
#define NXAGENT_VERSION_STRING NX_VERSION_CURRENT_STRING
/* by dimbor */
#include <X11/Xlocale.h>
/*
* ProcVector array defined in tables.c.
*/
......@@ -413,6 +416,20 @@ FIXME: These variables, if not removed at all because have probably
blackRoot = TRUE;
/* by dimbor */
char *locale = setlocale(LC_ALL, "");
if (!locale)
fprintf(stderr, "InitOutput: failed to set locale, reverting to \"C\"\n");
else
{
if (!XSupportsLocale())
fprintf(stderr, "InitOutput: Locale %s not supported by X\n",locale);
else
fprintf(stderr, "InitOutput: Set %s locale\n",locale);
}
if (!XSetLocaleModifiers(""))
fprintf(stderr,"InitOutput: cannot set locale modifiers.\n");
nxagentInitKeystrokes(False);
}
......
......@@ -42,6 +42,10 @@
#include "compext/Compext.h"
/* by dimbor */
#include "Xatom.h"
#include <X11/Xlocale.h>
/*
* Set here the required log level.
*/
......@@ -110,6 +114,10 @@ static TopLevelParentMap topLevelParentMap = { NULL, 0, 0 };
static void nxagentRemovePropertyFromList(void);
/* by dimbor */
static char szAgentUTF8_STRING[] = "UTF8_STRING";
static Atom agentUTF8_STRING;
/*
* This is currently unused.
*/
......@@ -436,6 +444,28 @@ Window nxagentRootlessWindowParent(WindowPtr pWin)
}
}
/* by dimbor */
char *textToUTF8String(char *text, int nitems)
{
XTextProperty t_prop;
char *ret=NULL;
t_prop.value=((unsigned char *)text);
t_prop.nitems=nitems;
if (!t_prop.nitems)
return ret;
t_prop.format=8;
t_prop.encoding=XInternAtom(nxagentDisplay, "COMPOUND_TEXT", 0);
char **list;
int num;
int r = XmbTextPropertyToTextList(nxagentDisplay, &t_prop,&list, &num);
if ((r == Success || r > 0) && num > 0 && *list)
{
ret=(char *)strdup (*list);
XFreeStringList(list);
}
return ret;
}
int nxagentExportAllProperty(pWin)
WindowPtr pWin;
{
......@@ -481,6 +511,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
if (strncmp(propertyS, "WM_", 3) != 0 &&
strncmp(propertyS, "_NET_", 5) != 0 &&
strncmp(propertyS, "_MOTIF_", 7) != 0 &&
strcmp(propertyS, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR") != 0)
{
#ifdef TEST
......@@ -492,6 +523,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
}
else if (strcmp(typeS, "STRING") == 0 ||
#ifndef _XSERVER64
strcmp(typeS, "_MOTIF_WM_HINTS") == 0 ||
strcmp(typeS, "CARDINAL") == 0 ||
strcmp(typeS, "WM_SIZE_HINTS") == 0 ||
#endif
......@@ -500,8 +532,18 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value)
output = value;
export = True;
}
/* add by dimbor */
else if (strcmp(typeS, "COMPOUND_TEXT") == 0)
{
output = textToUTF8String(value, nUnits);
nUnits = strlen((char *) output);
type = MakeAtom(szAgentUTF8_STRING, strlen(szAgentUTF8_STRING), True);
freeMem = True;
export = True;
}
#ifdef _XSERVER64
else if (strcmp(typeS, "CARDINAL") == 0 || strcmp(typeS, "WM_SIZE_HINTS") == 0)
else if (strcmp(typeS, "CARDINAL") == 0 || strcmp(typeS, "WM_SIZE_HINTS") == 0 ||
strcmp(typeS, "_MOTIF_WM_HINTS") == 0)
{
/* FIXME: is it okay here to ignore malloc fails? */
unsigned long *buffer = malloc(nUnits * sizeof(*buffer));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment