コード例 #1
0
ファイル: atoms.c プロジェクト: jon-turney/libxcwm
void
set_window_name(xcwm_window_t *window, xcwm_property_t *property)
{
    xcb_get_property_cookie_t cookie;
    xcb_icccm_get_text_property_reply_t reply;
    xcb_ewmh_get_utf8_strings_reply_t data;

    /* Check _NET_WM_NAME first */
    cookie = xcb_ewmh_get_wm_name(&window->context->atoms.ewmh_conn,
                                  window->window_id);
    if (xcb_ewmh_get_wm_name_reply(&window->context->atoms.ewmh_conn,
                                   cookie, &data, NULL)) {
        window->name = strndup(data.strings, data.strings_len);
        xcb_ewmh_get_utf8_strings_reply_wipe(&data);
        return;
    }

    cookie = xcb_icccm_get_wm_name(window->context->conn, window->window_id);
    if (!xcb_icccm_get_wm_name_reply(window->context->conn,
                                     cookie, &reply, NULL)) {
        window->name = malloc(sizeof(char));
        window->name[0] = '\0';
        return;
    }

    window->name = strndup(reply.name, reply.name_len);
    xcb_icccm_get_text_property_reply_wipe(&reply);
}
コード例 #2
0
ファイル: x_client_name.cpp プロジェクト: nick87720z/x-choyce
void
x_client_name::update_wm_name(void)
{
  m_wm_name.clear();

  xcb_generic_error_t * error;
  xcb_icccm_get_text_property_reply_t wm_name;
  xcb_get_property_cookie_t c =
    xcb_icccm_get_wm_name(m_c(), m_x_client.window());
  xcb_icccm_get_wm_name_reply(m_c(), c, &wm_name, &error);

  // TODO: cause clang to crash, FILE A BUG REPORT
#if defined  __GNUC__
  if (error) {
    delete error;

  } else {
    m_wm_name = std::string(wm_name.name, wm_name.name_len);
    xcb_icccm_get_text_property_reply_wipe(&wm_name);
  }

#else
#error "Fix compilation with anything else but GNUC"
#endif
}
コード例 #3
0
ファイル: LuminaX11.cpp プロジェクト: LeFroid/lumina
// === 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 "";
  }	
}
コード例 #4
0
ファイル: Client.cpp プロジェクト: jhanssen/nwm
void Client::updateName(xcb_connection_t* conn, xcb_get_property_cookie_t cookie)
{
    xcb_icccm_get_text_property_reply_t prop;
    if (xcb_icccm_get_wm_name_reply(conn, cookie, &prop, 0)) {
        if (prop.format == 8) {
            mName = String(prop.name, prop.name_len);
        } else {
            mName.clear();
        }
        xcb_icccm_get_text_property_reply_wipe(&prop);
    } else {
        mName.clear();
    }
}
コード例 #5
0
ファイル: xtitle.c プロジェクト: mmso/xtitle
void get_window_title(xcb_window_t win, char *title, size_t len) {
    xcb_ewmh_get_utf8_strings_reply_t ewmh_txt_prop;
    xcb_icccm_get_text_property_reply_t icccm_txt_prop;
    ewmh_txt_prop.strings = icccm_txt_prop.name = NULL;
    title[0] = '\0';
    if (win != XCB_NONE && (xcb_ewmh_get_wm_name_reply(ewmh, xcb_ewmh_get_wm_name(ewmh, win), &ewmh_txt_prop, NULL) == 1 || xcb_icccm_get_wm_name_reply(dpy, xcb_icccm_get_wm_name(dpy, win), &icccm_txt_prop, NULL) == 1)) {
        char *src = NULL;
        size_t title_len = 0;
        if (ewmh_txt_prop.strings != NULL) {
            src = ewmh_txt_prop.strings;
            title_len = MIN(len, ewmh_txt_prop.strings_len);
        } else if (icccm_txt_prop.name != NULL) {
            src = icccm_txt_prop.name;
            title_len = MIN(len, icccm_txt_prop.name_len);
        }
        if (src != NULL) {
            strncpy(title, src, title_len);
            title[title_len] = '\0';
        }
    }
}
コード例 #6
0
ファイル: ecore_xcb_icccm.c プロジェクト: Limsik/e17
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;
}
コード例 #7
0
ファイル: dsimple.c プロジェクト: KenetJervet/GetWinID
static xcb_window_t
recursive_Window_With_Name  (
    xcb_connection_t *dpy,
    xcb_window_t window,
    struct wininfo_cookies *cookies,
    const char *name,
    size_t namelen)
{
    xcb_window_t *children;
    unsigned int nchildren;
    int i;
    xcb_window_t w = 0;
    xcb_generic_error_t *err;
    xcb_query_tree_reply_t *tree;
    struct wininfo_cookies *child_cookies;
    xcb_get_property_reply_t *prop;

    if (cookies->get_net_wm_name.sequence) {
	prop = xcb_get_property_reply (dpy, cookies->get_net_wm_name, &err);

	if (prop) {
	    if (prop->type == atom_utf8_string) {
		const char *prop_name = xcb_get_property_value (prop);
		int prop_name_len = xcb_get_property_value_length (prop);

		/* can't use strcmp, since prop.name is not null terminated */
		if ((namelen == prop_name_len) &&
		    memcmp (prop_name, name, namelen) == 0) {
		    w = window;
		}
	    }
	    free (prop);
	} else if (err) {
	    if (err->response_type == 0)
		Print_X_Error (dpy, err);
	    return 0;
	}
    }

    if (w) {
	xcb_discard_reply (dpy, cookies->get_wm_name.sequence);
    } else {
#ifdef USE_XCB_ICCCM
	xcb_icccm_get_text_property_reply_t nameprop;

	if (xcb_icccm_get_wm_name_reply (dpy, cookies->get_wm_name,
					 &nameprop, &err)) {
	    /* can't use strcmp, since nameprop.name is not null terminated */
	    if ((namelen == nameprop.name_len) &&
		memcmp (nameprop.name, name, namelen) == 0) {
		w = window;
	    }

	    xcb_icccm_get_text_property_reply_wipe (&nameprop);
	}
#else
	prop = xcb_get_property_reply (dpy, cookies->get_wm_name, &err);

	if (prop) {
	    if (prop->type == XCB_ATOM_STRING) {
		const char *prop_name = xcb_get_property_value (prop);
		int prop_name_len = xcb_get_property_value_length (prop);

		/* can't use strcmp, since prop.name is not null terminated */
		if ((namelen == prop_name_len) &&
		    memcmp (prop_name, name, namelen) == 0) {
		    w = window;
		}
	    }
	    free (prop);
	}
#endif
	else if (err) {
	    if (err->response_type == 0)
		Print_X_Error (dpy, err);
	    return 0;
	}
    }

    if (w)
    {
	xcb_discard_reply (dpy, cookies->query_tree.sequence);
	return w;
    }

    tree = xcb_query_tree_reply (dpy, cookies->query_tree, &err);
    if (!tree) {
	if (err->response_type == 0)
	    Print_X_Error (dpy, err);
	return 0;
    }

    nchildren = xcb_query_tree_children_length (tree);
    children = xcb_query_tree_children (tree);
    child_cookies = calloc(nchildren, sizeof(struct wininfo_cookies));

    if (child_cookies == NULL)
	Fatal_Error("Failed to allocate memory in recursive_Window_With_Name");

    for (i = 0; i < nchildren; i++) {
	if (atom_net_wm_name && atom_utf8_string)
	    child_cookies[i].get_net_wm_name =
		xcb_get_net_wm_name (dpy, children[i]);
	child_cookies[i].get_wm_name = xcb_icccm_get_wm_name (dpy, children[i]);
	child_cookies[i].query_tree = xcb_query_tree (dpy, children[i]);
    }
    xcb_flush (dpy);

    for (i = 0; i < nchildren; i++) {
	w = recursive_Window_With_Name (dpy, children[i],
					&child_cookies[i], name, namelen);
	if (w)
	    break;
    }

    if (w)
    {
	/* clean up remaining replies */
	for (/* keep previous i */; i < nchildren; i++) {
	    if (child_cookies[i].get_net_wm_name.sequence)
		xcb_discard_reply (dpy,
				   child_cookies[i].get_net_wm_name.sequence);
	    xcb_discard_reply (dpy, child_cookies[i].get_wm_name.sequence);
	    xcb_discard_reply (dpy, child_cookies[i].query_tree.sequence);
	}
    }

    free (child_cookies);
    free (tree); /* includes storage for children[] */
    return (w);
}