+
+/*
+ * Updates the name by using WM_NAME (encoded in COMPOUND_TEXT). We do not
+ * touch what the client sends us but pass it to xcb_image_text_8. To get
+ * proper unicode rendering, the application has to use _NET_WM_NAME (see
+ * window_update_name()).
+ *
+ */
+void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop) {
+ if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
+ DLOG("prop == NULL\n");
+ return;
+ }
+
+ /* ignore update when the window is known to already have a UTF-8 name */
+ if (win->uses_net_wm_name)
+ return;
+
+ char *new_name;
+ if (asprintf(&new_name, "%.*s", xcb_get_property_value_length(prop),
+ (char*)xcb_get_property_value(prop)) == -1) {
+ perror("asprintf()");
+ DLOG("Could not get legacy window name\n");
+ return;
+ }
+
+ LOG("Using legacy window title. Note that in order to get Unicode window "
+ "titles in i3, the application has to set _NET_WM_NAME (UTF-8)\n");
+
+ FREE(win->name_x);
+ FREE(win->name_json);
+ win->name_x = new_name;
+ win->name_json = strdup(new_name);
+ win->name_len = strlen(new_name);
+}