Beispiel #1
0
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);
}
Beispiel #2
0
// === WindowName() ===
QString LXCB::WindowName(WId win){ //_NET_WM_NAME
  if(DEBUG){ qDebug() << "XCB: WindowName()"; }
  if(win==0){ return ""; }
  QString out;
  xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name_unchecked(&EWMH, win);
  if(cookie.sequence == 0){ return out; } 
  xcb_ewmh_get_utf8_strings_reply_t data;
  if( 1 == xcb_ewmh_get_wm_name_reply(&EWMH, cookie, &data, NULL) ){
      out = QString::fromUtf8(data.strings, data.strings_len);
  }
  return out;
}
Beispiel #3
0
bool ewmh_get_window_title(const xcb_window_t win, char *name)
{
    const xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name_unchecked(cfg.ewmh, win);
    xcb_ewmh_get_utf8_strings_reply_t data;

    if (!xcb_ewmh_get_wm_name_reply(cfg.ewmh, cookie, &data, (void *)0))
        return false;

    size_t len = min(sizeof(name), data.strings_len + 1);
    memcpy(name, data.strings, len);
    name[len] = 0;

    xcb_ewmh_get_utf8_strings_reply_wipe(&data);

    return true;
}
Beispiel #4
0
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';
        }
    }
}