xcb_window_t LinuxWindowCapture::FindWindow( const QString& instanceName, const QString& windowClass ) { xcb_window_t window = static_cast< xcb_window_t > ( 0 ); xcb_connection_t* dpy = xcb_connect( NULL, NULL ); if ( xcb_connection_has_error( dpy ) ) { qDebug() << "Can't open display"; } xcb_screen_t* screen = xcb_setup_roots_iterator( xcb_get_setup( dpy ) ).data; if( !screen ) { qDebug() << "Can't acquire screen"; } xcb_window_t root = screen->root; QList< xcb_window_t > windows = listWindowsRecursive( dpy, root ); foreach( const xcb_window_t& win, windows ) { xcb_icccm_get_wm_class_reply_t wmNameR; xcb_get_property_cookie_t wmClassC = xcb_icccm_get_wm_class( dpy, win ); if ( xcb_icccm_get_wm_class_reply( dpy, wmClassC, &wmNameR, NULL ) ) { if( !qstrcmp( wmNameR.class_name, windowClass.toStdString().c_str() ) || !qstrcmp( wmNameR.instance_name, instanceName.toStdString().c_str() ) ) { qDebug() << wmNameR.instance_name; qDebug() << wmNameR.class_name; window = win; break; } } }
/** Update WM_CLASS of a client. * \param c The client. * \param reply The reply to get property request, or NULL if none. */ void property_update_wm_class(client_t *c, xcb_get_property_reply_t *reply) { xcb_icccm_get_wm_class_reply_t hint; if(reply) { if(!xcb_icccm_get_wm_class_from_reply(&hint, reply)) return; } else { if(!xcb_icccm_get_wm_class_reply(globalconf.connection, xcb_icccm_get_wm_class_unchecked(globalconf.connection, c->window), &hint, NULL)) return; } luaA_object_push(globalconf.L, c); client_set_class_instance(globalconf.L, -1, hint.class_name, hint.instance_name); lua_pop(globalconf.L, 1); /* only delete reply if we get it ourselves */ if(!reply) xcb_icccm_get_wm_class_reply_wipe(&hint); }
bool is_match(rule_t *r, xcb_window_t win) { xcb_icccm_get_wm_class_reply_t reply; if (xcb_icccm_get_wm_class_reply(dpy, xcb_icccm_get_wm_class(dpy, win), &reply, NULL) == 1 && (strcmp(reply.class_name, r->cause.name) == 0 || strcmp(reply.instance_name, r->cause.name) == 0)) { xcb_icccm_get_wm_class_reply_wipe(&reply); return true; } return false; }
bool is_presel_window(xcb_window_t win) { xcb_icccm_get_wm_class_reply_t reply; bool ret = false; if (xcb_icccm_get_wm_class_reply(dpy, xcb_icccm_get_wm_class(dpy, win), &reply, NULL) == 1) { if (streq(BSPWM_CLASS_NAME, reply.class_name) && streq(PRESEL_FEEDBACK_I, reply.instance_name)) { ret = true; } xcb_icccm_get_wm_class_reply_wipe(&reply); } return ret; }
void Client::updateClass(xcb_connection_t* conn, xcb_get_property_cookie_t cookie) { xcb_icccm_get_wm_class_reply_t prop; if (xcb_icccm_get_wm_class_reply(conn, cookie, &prop, 0)) { mClass.instanceName = prop.instance_name; mClass.className = prop.class_name; xcb_icccm_get_wm_class_reply_wipe(&prop); } else { mClass.instanceName.clear(); mClass.className.clear(); } }
// === WindowClass() === QString LXCB::WindowClass(WId win){ if(DEBUG){ qDebug() << "XCB: WindowClass()" << win; } QString out; if(win==0){ return ""; } xcb_get_property_cookie_t cookie = xcb_icccm_get_wm_class_unchecked(QX11Info::connection(), win); if(cookie.sequence == 0){ return out; } xcb_icccm_get_wm_class_reply_t value; if( 1== xcb_icccm_get_wm_class_reply( QX11Info::connection(), cookie, &value, NULL) ){ out = QString::fromUtf8(value.class_name); xcb_icccm_get_wm_class_reply_wipe(&value); } return out; }
/** Update WM_CLASS of a client. * \param c The client. * \param cookie Cookie returned by property_get_wm_class. */ void property_update_wm_class(client_t *c, xcb_get_property_cookie_t cookie) { xcb_icccm_get_wm_class_reply_t hint; if(!xcb_icccm_get_wm_class_reply(globalconf.connection, cookie, &hint, NULL)) return; luaA_object_push(globalconf.L, c); client_set_class_instance(globalconf.L, -1, hint.class_name, hint.instance_name); lua_pop(globalconf.L, 1); xcb_icccm_get_wm_class_reply_wipe(&hint); }
xcb_window_t LinuxWindowCapture::FindWindow( const QString& instanceName, const QString& windowClass ) { xcb_window_t winID = XCB_WINDOW_NONE; QList< xcb_window_t > windows = listWindowsRecursive( QX11Info::appRootWindow() ); xcb_connection_t* xcbConn = QX11Info::connection(); foreach( const xcb_window_t& win, windows ) { xcb_icccm_get_wm_class_reply_t wmNameR; xcb_get_property_cookie_t wmClassC = xcb_icccm_get_wm_class( xcbConn, win ); if ( xcb_icccm_get_wm_class_reply( xcbConn, wmClassC, &wmNameR, nullptr ) ) { if( !qstricmp( wmNameR.class_name, qt2cstr( windowClass ) ) || !qstricmp( wmNameR.instance_name, qt2cstr ( instanceName ) ) ) { winID = win; break; } } }
//! Process WM_CLASS reply and update fields void Client::process_wm_class(xcb_get_property_cookie_t gpc) { xcb_icccm_get_wm_class_reply_t igwcr; if (xcb_icccm_get_wm_class_reply(g_xcb.connection, gpc, &igwcr, NULL)) { TRACE << "ICCCM: " << igwcr; INFO << "WM_CLASS = " << igwcr.class_name << " - INSTANCE = " << igwcr.instance_name; m_wm_class = igwcr.class_name; m_wm_class_instance = igwcr.instance_name; xcb_icccm_get_wm_class_reply_wipe(&igwcr); } else { WARN << "ICCCM WM_CLASS could not be retrieved."; m_wm_class = "<no WM_CLASS name>"; m_wm_class_instance = "<no WM_CLASS instance>"; } }