re-add support for legacy window titles (WM_NAME)

This commit is contained in:
Michael Stapelberg
2010-04-13 17:46:54 +02:00
parent fd8735a6fd
commit dd7acf73e9
8 changed files with 118 additions and 94 deletions

View 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 dont 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);
/* If the client is a dock window, we dont need to render anything */
if (client->dock)
return 1;
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);
Con *con;
if ((con = con_by_window_id(window)) == NULL || con->window == NULL)
return 1;
window_update_name_legacy(con->window, prop);
x_push_changes(croot);
return 1;
}
#endif
/*
* Updates the clients WM_CLASS property