summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2020-06-21 12:15:01 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2020-06-21 12:15:01 -0400
commit58a64fd73dd7a840fadebbc81126282cf3979b30 (patch)
tree8b8ac4595be7d956016e70945e689441ce02078b
parenta754e9f5c5735787a8e22839824a33546a9c43ef (diff)
issue #8: twm displays all windows as "Untitled"
adapt the suggestion to use XFetchName to work around a system whose locale support is broken, but rather than break existing configurations, use that call as a fallback when the existing/working calls fail. Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
-rw-r--r--src/util.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/util.c b/src/util.c
index e15c31a..d89dcfe 100644
--- a/src/util.c
+++ b/src/util.c
@@ -729,23 +729,38 @@ I18N_FetchName(Display *dpy2, Window w, char **winname)
{
int status;
XTextProperty text_prop;
- char **list;
- int num;
+ int rc = 0;
+
+ *winname = NULL;
status = XGetWMName(dpy2, w, &text_prop);
- if (!status || !text_prop.value || !text_prop.nitems) {
- *winname = NULL;
- return 0;
- }
- status = XmbTextPropertyToTextList(dpy2, &text_prop, &list, &num);
- if (status < Success || !num || !*list) {
- *winname = NULL;
- return 0;
+ if (status && text_prop.value && text_prop.nitems) {
+ char **list = NULL;
+ int num;
+
+ status = XmbTextPropertyToTextList(dpy2, &text_prop, &list, &num);
+ if (status >= Success && num && list && *list) {
+ XFree(text_prop.value);
+ *winname = strdup(*list);
+ XFreeStringList(list);
+ rc = 1;
+ }
+ else {
+ char *value = NULL;
+
+ /*
+ * If the system's locale support is broken (e.g., missing useful
+ * parts), the preceding Xmb call may fail.
+ */
+ if (XFetchName(dpy2, w, &value) && value != NULL) {
+ *winname = strdup(value);
+ XFree(value);
+ rc = 1;
+ }
+ }
}
- XFree(text_prop.value);
- *winname = (char *) strdup(*list);
- XFreeStringList(list);
- return 1;
+
+ return rc;
}
Status