Example #1
0
// === OldWindowName() ===
QString LXCB::OldWindowName(WId win){ //WM_NAME (old standard)
  if(DEBUG){ qDebug() << "XCB: OldWindowName()"; }
  if(win==0){ return ""; }
  xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_name_unchecked(QX11Info::connection(), win);
  xcb_icccm_get_text_property_reply_t reply;
  if(1 == xcb_icccm_get_wm_name_reply(QX11Info::connection(), cookie, &reply, NULL) ){
    QString name = QString::fromLocal8Bit(reply.name);
    xcb_icccm_get_text_property_reply_wipe(&reply);
    return name;
  }else{
    return "";
  }	
}
Example #2
0
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;
}