EAPI char * ecore_x_window_prop_string_get(Ecore_X_Window win, Ecore_X_Atom type) { xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *reply; char *str = NULL; int len = 0; LOGFN(__FILE__, __LINE__, __FUNCTION__); CHECK_XCB_CONN; cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, win ? win : ((xcb_screen_t *)_ecore_xcb_screen)->root, type, XCB_GET_PROPERTY_TYPE_ANY, 0, 1000000L); reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL); if (!reply) return NULL; len = ((reply->value_len * reply->format) / 8); str = (char *)malloc((len + 1) * sizeof(char)); memcpy(str, xcb_get_property_value(reply), len); str[len] = '\0'; if (reply->type != ECORE_X_ATOM_UTF8_STRING) { Ecore_Xcb_Textproperty prop; int count = 0; char **list = NULL; Eina_Bool ret = EINA_FALSE; prop.value = strdup(str); prop.nitems = len; prop.encoding = reply->type; #ifdef HAVE_ICONV ret = _ecore_xcb_utf8_textproperty_to_textlist(&prop, &list, &count); #else ret = _ecore_xcb_mb_textproperty_to_textlist(&prop, &list, &count); #endif if (ret) { if (count > 0) str = strdup(list[0]); else str = strdup((char *)prop.value); if (list) free(list); } else str = strdup((char *)prop.value); } free(reply); return str; }
EAPI char * ecore_x_icccm_title_get(Ecore_X_Window win) { xcb_get_property_cookie_t cookie; #ifdef OLD_XCB_VERSION xcb_get_text_property_reply_t prop; #else xcb_icccm_get_text_property_reply_t prop; #endif uint8_t ret = 0; char *title = NULL; LOGFN(__FILE__, __LINE__, __FUNCTION__); CHECK_XCB_CONN; if (!win) return NULL; #ifdef OLD_XCB_VERSION cookie = xcb_get_wm_name_unchecked(_ecore_xcb_conn, win); ret = xcb_get_wm_name_reply(_ecore_xcb_conn, cookie, &prop, NULL); #else cookie = xcb_icccm_get_wm_name_unchecked(_ecore_xcb_conn, win); ret = xcb_icccm_get_wm_name_reply(_ecore_xcb_conn, cookie, &prop, NULL); #endif if (ret == 0) return NULL; if (prop.name_len < 1) { #ifdef OLD_XCB_VERSION xcb_get_text_property_reply_wipe(&prop); #else xcb_icccm_get_text_property_reply_wipe(&prop); #endif return NULL; } if (!(title = malloc((prop.name_len + 1) * sizeof(char *)))) { #ifdef OLD_XCB_VERSION xcb_get_text_property_reply_wipe(&prop); #else xcb_icccm_get_text_property_reply_wipe(&prop); #endif return NULL; } memcpy(title, prop.name, sizeof(char *) * prop.name_len); title[prop.name_len] = '\0'; if (prop.encoding != ECORE_X_ATOM_UTF8_STRING) { Ecore_Xcb_Textproperty tp; int count = 0; char **list = NULL; Eina_Bool ret = EINA_FALSE; tp.value = strdup(title); tp.nitems = prop.name_len; tp.encoding = prop.encoding; #ifdef HAVE_ICONV ret = _ecore_xcb_utf8_textproperty_to_textlist(&tp, &list, &count); #else ret = _ecore_xcb_mb_textproperty_to_textlist(&tp, &list, &count); #endif if (ret) { if (count > 0) title = strdup(list[0]); if (list) free(list); } } #ifdef OLD_XCB_VERSION xcb_get_text_property_reply_wipe(&prop); #else xcb_icccm_get_text_property_reply_wipe(&prop); #endif return title; }