]> git.sur5r.net Git - i3/i3/blobdiff - src/handlers.c
re-add support for legacy window titles (WM_NAME)
[i3/i3] / src / handlers.c
index 2f89afe9b4f81d11db7cab1541b17b1dcfc5c3f8..b56095409440fdcfc8ef26c885e6877d76de4bea 100644 (file)
@@ -582,74 +582,24 @@ int handle_windowname_change(void *data, xcb_connection_t *conn, uint8_t state,
 
     return 1;
 }
-#if 0
+
 /*
- * We handle legacy window names (titles) which are in COMPOUND_TEXT encoding. However, we
- * just pass them along, so when containing non-ASCII characters, those will be rendering
- * incorrectly. In order to correctly render unicode window titles in i3, an application
- * has to set _NET_WM_NAME, which is in UTF-8 encoding.
- *
- * On every update, a message is put out to the user, so he may improve the situation and
- * update applications which display filenames in their title to correctly use
- * _NET_WM_NAME and therefore support unicode.
+ * Handles legacy window name updates (WM_NAME), see also src/window.c,
+ * window_update_name_legacy().
  *
  */
 int handle_windowname_change_legacy(void *data, xcb_connection_t *conn, uint8_t state,
                                 xcb_window_t window, xcb_atom_t atom, xcb_get_property_reply_t *prop) {
-        if (prop == NULL || xcb_get_property_value_length(prop) == 0) {
-                DLOG("prop == NULL\n");
-                return 1;
-        }
-        Client *client = table_get(&by_child, window);
-        if (client == NULL)
-                return 1;
-
-        /* Client capable of _NET_WM_NAME, ignore legacy name changes */
-        if (client->uses_net_wm_name)
-                return 1;
-
-        /* Save the old pointer to make the update atomic */
-        char *new_name;
-        if (asprintf(&new_name, "%.*s", xcb_get_property_value_length(prop), (char*)xcb_get_property_value(prop)) == -1) {
-                perror("Could not get old name");
-                DLOG("Could not get old name\n");
-                return 1;
-        }
-        /* Convert it to UCS-2 here for not having to convert it later every time we want to pass it to X */
-        LOG("WM_NAME changed to \"%s\"\n", new_name);
-
-        /* Check if they are the same and don’t update if so. */
-        if (client->name != NULL &&
-            strlen(new_name) == strlen(client->name) &&
-            strcmp(client->name, new_name) == 0) {
-                free(new_name);
-                return 1;
-        }
-
-        LOG("Using legacy window title. Note that in order to get Unicode window titles in i3, "
-            "the application has to set _NET_WM_NAME which is in UTF-8 encoding.\n");
-
-        char *old_name = client->name;
-        client->name = new_name;
-        client->name_len = -1;
-
-        if (old_name != NULL)
-                free(old_name);
+    Con *con;
+    if ((con = con_by_window_id(window)) == NULL || con->window == NULL)
+        return 1;
 
-        /* If the client is a dock window, we don’t need to render anything */
-        if (client->dock)
-                return 1;
+    window_update_name_legacy(con->window, prop);
 
-        if (client->container != NULL &&
-            (client->container->mode == MODE_STACK ||
-             client->container->mode == MODE_TABBED))
-                render_container(conn, client->container);
-        else decorate_window(conn, client, client->frame, client->titlegc, 0, 0);
-        xcb_flush(conn);
+    x_push_changes(croot);
 
-        return 1;
+    return 1;
 }
-#endif
 
 /*
  * Updates the client’s WM_CLASS property