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; } } }
void x_client_name::update_wm_class(void) { m_class_name.clear(); m_instance_name.clear(); xcb_generic_error_t * error; xcb_get_property_cookie_t c = xcb_icccm_get_wm_class(m_c(), m_x_client.window()); xcb_get_property_reply_t * r = xcb_get_property_reply(m_c(), c, &error); if (error) { delete error; } else { xcb_icccm_get_wm_class_reply_t wm_class; if (xcb_icccm_get_wm_class_from_reply(&wm_class, r)) { m_class_name = wm_class.class_name; m_instance_name = wm_class.instance_name; xcb_icccm_get_wm_class_reply_wipe(&wm_class); r = NULL; } } if (r) delete r; }
void Client::updateState(xcb_ewmh_connection_t* ewmhConn) { xcb_connection_t* conn = ewmhConn->connection; xcb_get_geometry_cookie_t geomCookie; if (!mOwned) geomCookie = xcb_get_geometry_unchecked(conn, mWindow); const xcb_get_property_cookie_t normalHintsCookie = xcb_icccm_get_wm_normal_hints(conn, mWindow); const xcb_get_property_cookie_t leaderCookie = xcb_get_property(conn, 0, mWindow, Atoms::WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 0, 1); const xcb_get_property_cookie_t transientCookie = xcb_icccm_get_wm_transient_for(conn, mWindow); const xcb_get_property_cookie_t hintsCookie = xcb_icccm_get_wm_hints(conn, mWindow); const xcb_get_property_cookie_t classCookie = xcb_icccm_get_wm_class(conn, mWindow); const xcb_get_property_cookie_t nameCookie = xcb_icccm_get_wm_name(conn, mWindow); const xcb_get_property_cookie_t protocolsCookie = xcb_icccm_get_wm_protocols(conn, mWindow, Atoms::WM_PROTOCOLS); const xcb_get_property_cookie_t strutCookie = xcb_ewmh_get_wm_strut(ewmhConn, mWindow); const xcb_get_property_cookie_t partialStrutCookie = xcb_ewmh_get_wm_strut_partial(ewmhConn, mWindow); const xcb_get_property_cookie_t stateCookie = xcb_ewmh_get_wm_state(ewmhConn, mWindow); const xcb_get_property_cookie_t typeCookie = xcb_ewmh_get_wm_window_type(ewmhConn, mWindow); const xcb_get_property_cookie_t pidCookie = xcb_ewmh_get_wm_pid(ewmhConn, mWindow); if (!mOwned) updateSize(conn, geomCookie); updateNormalHints(conn, normalHintsCookie); updateLeader(conn, leaderCookie); updateTransient(conn, transientCookie); updateHints(conn, hintsCookie); updateClass(conn, classCookie); updateName(conn, nameCookie); updateProtocols(conn, protocolsCookie); updateStrut(ewmhConn, strutCookie); updatePartialStrut(ewmhConn, partialStrutCookie); updateEwmhState(ewmhConn, stateCookie); updateWindowTypes(ewmhConn, typeCookie); updatePid(ewmhConn, pidCookie); }
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::propertyNotify(xcb_atom_t atom) { #warning Need to notify js that properties have changed warning() << "Got propertyNotify" << Atoms::name(atom) << mWindow; auto ewmhConnection = WindowManager::instance()->ewmhConnection(); auto conn = ewmhConnection->connection; if (atom == XCB_ATOM_WM_NORMAL_HINTS) { const xcb_get_property_cookie_t normalHintsCookie = xcb_icccm_get_wm_normal_hints(conn, mWindow); updateNormalHints(conn, normalHintsCookie); } else if (atom == XCB_ATOM_WM_TRANSIENT_FOR) { const xcb_get_property_cookie_t transientCookie = xcb_icccm_get_wm_transient_for(conn, mWindow); updateTransient(conn, transientCookie); } else if (atom == Atoms::WM_CLIENT_LEADER) { const xcb_get_property_cookie_t leaderCookie = xcb_get_property(conn, 0, mWindow, Atoms::WM_CLIENT_LEADER, XCB_ATOM_WINDOW, 0, 1); updateLeader(conn, leaderCookie); } else if (atom == XCB_ATOM_WM_HINTS) { const xcb_get_property_cookie_t hintsCookie = xcb_icccm_get_wm_hints(conn, mWindow); updateHints(conn, hintsCookie); } else if (atom == XCB_ATOM_WM_CLASS) { const xcb_get_property_cookie_t classCookie = xcb_icccm_get_wm_class(conn, mWindow); updateClass(conn, classCookie); } else if (atom == XCB_ATOM_WM_NAME) { const xcb_get_property_cookie_t nameCookie = xcb_icccm_get_wm_name(conn, mWindow); updateName(conn, nameCookie); } else if (atom == Atoms::WM_PROTOCOLS) { const xcb_get_property_cookie_t protocolsCookie = xcb_icccm_get_wm_protocols(conn, mWindow, Atoms::WM_PROTOCOLS); updateProtocols(conn, protocolsCookie); } else if (atom == ewmhConnection->_NET_WM_STRUT) { const xcb_get_property_cookie_t strutCookie = xcb_ewmh_get_wm_strut(ewmhConnection, mWindow); updateStrut(ewmhConnection, strutCookie); } else if (atom == ewmhConnection->_NET_WM_STRUT_PARTIAL) { const xcb_get_property_cookie_t partialStrutCookie = xcb_ewmh_get_wm_strut_partial(ewmhConnection, mWindow); updatePartialStrut(ewmhConnection, partialStrutCookie); } else if (atom == ewmhConnection->_NET_WM_STATE) { const xcb_get_property_cookie_t stateCookie = xcb_ewmh_get_wm_state(ewmhConnection, mWindow); updateEwmhState(ewmhConnection, stateCookie); } else if (atom == ewmhConnection->_NET_WM_WINDOW_TYPE) { const xcb_get_property_cookie_t typeCookie = xcb_ewmh_get_wm_window_type(ewmhConnection, mWindow); updateWindowTypes(ewmhConnection, typeCookie); } else if (atom == ewmhConnection->_NET_WM_PID) { const xcb_get_property_cookie_t pidCookie = xcb_ewmh_get_wm_pid(ewmhConnection, mWindow); updatePid(ewmhConnection, pidCookie); } else { warning() << "Unhandled propertyNotify atom" << Atoms::name(atom); } }
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; } } }
//! Query WM_CLASS property xcb_get_property_cookie_t Client::query_wm_class() { return xcb_icccm_get_wm_class(g_xcb.connection, window()); }