static xcb_window_t xdndProxy(QXcbConnection *c, xcb_window_t w) { xcb_window_t proxy = XCB_NONE; xcb_get_property_cookie_t cookie = Q_XCB_CALL2(xcb_get_property(c->xcb_connection(), false, w, c->atom(QXcbAtom::XdndProxy), XCB_ATOM_WINDOW, 0, 1), c); xcb_get_property_reply_t *reply = xcb_get_property_reply(c->xcb_connection(), cookie, 0); if (reply && reply->type == XCB_ATOM_WINDOW) proxy = *((xcb_window_t *)xcb_get_property_value(reply)); free(reply); if (proxy == XCB_NONE) return proxy; // exists and is real? cookie = Q_XCB_CALL2(xcb_get_property(c->xcb_connection(), false, proxy, c->atom(QXcbAtom::XdndProxy), XCB_ATOM_WINDOW, 0, 1), c); reply = xcb_get_property_reply(c->xcb_connection(), cookie, 0); if (reply && reply->type == XCB_ATOM_WINDOW) { xcb_window_t p = *((xcb_window_t *)xcb_get_property_value(reply)); if (proxy != p) proxy = 0; } else { proxy = 0; } free(reply); return proxy; }
QXcbScreen::QXcbScreen(QXcbConnection *connection, xcb_screen_t *screen, int number) : QXcbObject(connection) , m_screen(screen) , m_number(number) { printf ("\n"); printf ("Information of screen %d:\n", screen->root); printf (" width.........: %d\n", screen->width_in_pixels); printf (" height........: %d\n", screen->height_in_pixels); printf (" depth.........: %d\n", screen->root_depth); printf (" white pixel...: %x\n", screen->white_pixel); printf (" black pixel...: %x\n", screen->black_pixel); printf ("\n"); const quint32 mask = XCB_CW_EVENT_MASK; const quint32 values[] = { // XCB_CW_EVENT_MASK XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | XCB_EVENT_MASK_PROPERTY_CHANGE }; xcb_change_window_attributes(xcb_connection(), screen->root, mask, values); xcb_generic_error_t *error; xcb_get_property_reply_t *reply = xcb_get_property_reply(xcb_connection(), xcb_get_property(xcb_connection(), false, screen->root, atom(QXcbAtom::_NET_SUPPORTING_WM_CHECK), XCB_ATOM_WINDOW, 0, 1024), &error); if (reply && reply->format == 32 && reply->type == XCB_ATOM_WINDOW) { xcb_window_t windowManager = *((xcb_window_t *)xcb_get_property_value(reply)); if (windowManager != XCB_WINDOW_NONE) { xcb_get_property_reply_t *windowManagerReply = xcb_get_property_reply(xcb_connection(), xcb_get_property(xcb_connection(), false, windowManager, atom(QXcbAtom::_NET_WM_NAME), atom(QXcbAtom::UTF8_STRING), 0, 1024), &error); if (windowManagerReply && windowManagerReply->format == 8 && windowManagerReply->type == atom(QXcbAtom::UTF8_STRING)) { m_windowManagerName = QString::fromUtf8((const char *)xcb_get_property_value(windowManagerReply), xcb_get_property_value_length(windowManagerReply)); printf("Running window manager: %s\n", qPrintable(m_windowManagerName)); } else if (error) { connection->handleXcbError(error); free(error); } free(windowManagerReply); } } else if (error) { connection->handleXcbError(error); free(error); } free(reply); m_syncRequestSupported = m_windowManagerName != QLatin1String("KWin"); }
/* * Find virtual roots (_NET_VIRTUAL_ROOTS) */ static xcb_window_t * Find_Roots(xcb_connection_t * dpy, xcb_window_t root, unsigned int *num) { xcb_atom_t atom_virtual_root; xcb_get_property_cookie_t prop_cookie; xcb_get_property_reply_t *prop_reply; xcb_window_t *prop_ret = NULL; *num = 0; atom_virtual_root = Get_Atom (dpy, "_NET_VIRTUAL_ROOTS"); if (atom_virtual_root == XCB_ATOM_NONE) return NULL; prop_cookie = xcb_get_property (dpy, False, root, atom_virtual_root, XCB_ATOM_WINDOW, 0, 0x7fffffff); prop_reply = xcb_get_property_reply (dpy, prop_cookie, NULL); if (!prop_reply) return NULL; if ((prop_reply->value_len > 0) && (prop_reply->type == XCB_ATOM_WINDOW) && (prop_reply->format == 32)) { int length = xcb_get_property_value_length (prop_reply); prop_ret = malloc(length); if (prop_ret) { memcpy (prop_ret, xcb_get_property_value(prop_reply), length); *num = prop_reply->value_len; } } free (prop_reply); return prop_ret; }
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); }
static void weston_wm_get_incr_chunk(struct weston_wm *wm) { xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *reply; cookie = xcb_get_property(wm->conn, 0, /* delete */ wm->selection_window, wm->atom.wl_selection, XCB_GET_PROPERTY_TYPE_ANY, 0, /* offset */ 0x1fffffff /* length */); reply = xcb_get_property_reply(wm->conn, cookie, NULL); dump_property(wm, wm->atom.wl_selection, reply); if (xcb_get_property_value_length(reply) > 0) { weston_wm_write_property(wm, reply); } else { weston_log("transfer complete\n"); close(wm->data_source_fd); free(reply); } }
static void weston_wm_get_selection_data(struct weston_wm *wm) { xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *reply; cookie = xcb_get_property(wm->conn, 1, /* delete */ wm->selection_window, wm->atom.wl_selection, XCB_GET_PROPERTY_TYPE_ANY, 0, /* offset */ 0x1fffffff /* length */); reply = xcb_get_property_reply(wm->conn, cookie, NULL); if (reply->type == wm->atom.incr) { dump_property(wm, wm->atom.wl_selection, reply); wm->incr = 1; free(reply); } else { dump_property(wm, wm->atom.wl_selection, reply); wm->incr = 0; weston_wm_write_property(wm, reply); } }
char *xcb_util_get_property(xcb_connection_t *conn, xcb_window_t window, xcb_atom_t atom, xcb_atom_t type, size_t size) { xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *reply; xcb_generic_error_t *err; int reply_length; char *content; cookie = xcb_get_property(conn, 0, window, atom, type, 0, size); reply = xcb_get_property_reply(conn, cookie, &err); if (err != NULL) { FREE(err); return NULL; } if (reply == NULL || (reply_length = xcb_get_property_value_length(reply)) == 0) { FREE(reply); return NULL; } if (reply->bytes_after > 0) { size_t adjusted_size = size + ceil(reply->bytes_after / 4.0); FREE(reply); return xcb_util_get_property(conn, window, atom, type, adjusted_size); } if (asprintf(&content, "%.*s", reply_length, (char *)xcb_get_property_value(reply)) < 0) { FREE(reply); return NULL; } FREE(reply); return content; }
//_________________________________________________________ WId DetectDialog::findWindow() { #if BREEZE_HAVE_X11 if (!QX11Info::isPlatformX11()) { return 0; } // check atom if( !m_wmStateAtom ) return 0; xcb_connection_t* connection( QX11Info::connection() ); xcb_window_t parent( QX11Info::appRootWindow() ); // why is there a loop of only 10 here for( int i = 0; i < 10; ++i ) { // query pointer xcb_query_pointer_cookie_t pointerCookie( xcb_query_pointer( connection, parent ) ); QScopedPointer<xcb_query_pointer_reply_t, QScopedPointerPodDeleter> pointerReply( xcb_query_pointer_reply( connection, pointerCookie, nullptr ) ); if( !( pointerReply && pointerReply->child ) ) return 0; const xcb_window_t child( pointerReply->child ); xcb_get_property_cookie_t cookie( xcb_get_property( connection, 0, child, m_wmStateAtom, XCB_GET_PROPERTY_TYPE_ANY, 0, 0 ) ); QScopedPointer<xcb_get_property_reply_t, QScopedPointerPodDeleter> reply( xcb_get_property_reply( connection, cookie, nullptr ) ); if( reply && reply->type ) return child; else parent = child; } #endif return 0; }
void find_window_by_property(xcb_window_t window, xcb_atom_t property, xcb_window_t *res) { *res = XCB_WINDOW_NONE; xcb_get_property_cookie_t get_property_cookie = xcb_get_property(display, 0, window, property, XCB_ATOM_ANY, 0, 0); xcb_get_property_reply_t *get_property_reply = xcb_get_property_reply(display, get_property_cookie, NULL); if (get_property_reply != NULL) { if (get_property_reply->type != XCB_ATOM_NONE) { *res = window; free(get_property_reply); return; } free(get_property_reply); } xcb_query_tree_cookie_t query_tree_cookie = xcb_query_tree(display, window); xcb_query_tree_reply_t *query_tree_reply = xcb_query_tree_reply(display, query_tree_cookie, NULL); if (query_tree_reply == NULL) return; int length = xcb_query_tree_children_length(query_tree_reply); xcb_window_t *children = xcb_query_tree_children(query_tree_reply); for (int i = 0; i < length; i++) { find_window_by_property(children[i], property, res); if (*res != XCB_WINDOW_NONE) break; } free(query_tree_reply); }
static void weston_wm_get_selection_data(struct weston_wm *wm) { xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *reply; cookie = xcb_get_property(wm->conn, 1, /* delete */ wm->selection_window, wm->atom.wl_selection, XCB_GET_PROPERTY_TYPE_ANY, 0, /* offset */ 0x1fffffff /* length */); reply = xcb_get_property_reply(wm->conn, cookie, NULL); if (reply->type == wm->atom.incr) { dump_property(wm, wm->atom.wl_selection, reply); wm->incr = 1; free(reply); } else { dump_property(wm, wm->atom.wl_selection, reply); wm->incr = 0; wm->property_start = 0; wm->property_source = wl_event_loop_add_fd(wm->server->loop, wm->data_source_fd, WL_EVENT_WRITABLE, weston_wm_write_property, wm); wm->property_reply = reply; } }
uint32_t get_wm_state(xcb_drawable_t win) { xcb_get_property_reply_t *reply; xcb_get_property_cookie_t cookie; uint32_t *statep; uint32_t state = 0; cookie = xcb_get_property(conn, false, win, wm_state, wm_state, 0, sizeof (int32_t)); reply = xcb_get_property_reply(conn, cookie, NULL); if (NULL == reply) { fprintf(stderr, "qtwm: Couldn't get properties for win %d\n", win); return -1; } /* Length is 0 if we didn't find it. */ if (0 == xcb_get_property_value_length(reply)) { goto bad; } statep = xcb_get_property_value(reply); state = *statep; bad: free(reply); return state; }
bool KWinKScreenHelperEffect::nativeEventFilter(const QByteArray &eventType, void *message, long int *result) { Q_UNUSED(result); if (eventType != "xcb_generic_event_t") { return false; } #ifdef HAVE_XCB if (m_isValid && QX11Info::isPlatformX11()) { auto e = static_cast<xcb_generic_event_t *>(message); const uint8_t type = e->response_type & ~0x80; if (type == XCB_PROPERTY_NOTIFY) { auto *event = reinterpret_cast<xcb_property_notify_event_t *>(e); if (event->window == QX11Info::appRootWindow()) { if (event->atom != m_atom) { return false; } auto cookie = xcb_get_property(QX11Info::connection(), false, QX11Info::appRootWindow(), m_atom, XCB_ATOM_CARDINAL, 0, 1); QScopedPointer<xcb_get_property_reply_t, QScopedPointerPodDeleter> reply(xcb_get_property_reply(QX11Info::connection(), cookie, NULL)); if (reply.isNull() || reply.data()->value_len != 1 || reply.data()->format != uint8_t(32)) { return false; } auto *data = reinterpret_cast<uint32_t *>(xcb_get_property_value(reply.data())); if (!data) { return false; } switch(*data) { case 1: m_state = FadingOutState; break; case 2: m_state = FadedOutState; if (m_running) { Q_EMIT fadedOut(); } break; case 3: m_state = FadingInState; m_running = false; m_abortTimer.stop(); break; default: m_state = NormalState; m_running = false; } Q_EMIT stateChanged(m_state); } } } #else Q_UNUSED(message); #endif return false; }
static void weston_wm_get_selection_data(struct weston_wm *wm) { xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *reply; cookie = xcb_get_property(wm->conn, 1, /* delete */ wm->selection_window, wm->atom.wl_selection, XCB_GET_PROPERTY_TYPE_ANY, 0, /* offset */ 0x1fffffff /* length */); reply = xcb_get_property_reply(wm->conn, cookie, NULL); dump_property(wm, wm->atom.wl_selection, reply); if (reply == NULL) { return; } else if (reply->type == wm->atom.incr) { wm->incr = 1; free(reply); } else { wm->incr = 0; /* reply's ownership is transferred to wm, which is responsible * for freeing it */ weston_wm_write_property(wm, reply); } }
static void weston_wm_get_selection_targets(struct weston_wm *wm) { struct x11_data_source *source; struct weston_compositor *compositor; struct weston_seat *seat = weston_wm_pick_seat(wm); xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *reply; xcb_atom_t *value; char **p; uint32_t i; cookie = xcb_get_property(wm->conn, 1, /* delete */ wm->selection_window, wm->atom.wl_selection, XCB_GET_PROPERTY_TYPE_ANY, 0, /* offset */ 4096 /* length */); reply = xcb_get_property_reply(wm->conn, cookie, NULL); if (reply == NULL) return; dump_property(wm, wm->atom.wl_selection, reply); if (reply->type != XCB_ATOM_ATOM) { free(reply); return; } source = zalloc(sizeof *source); if (source == NULL) { free(reply); return; } wl_signal_init(&source->base.destroy_signal); source->base.accept = data_source_accept; source->base.send = data_source_send; source->base.cancel = data_source_cancel; source->wm = wm; wl_array_init(&source->base.mime_types); value = xcb_get_property_value(reply); for (i = 0; i < reply->value_len; i++) { if (value[i] == wm->atom.utf8_string) { p = wl_array_add(&source->base.mime_types, sizeof *p); if (p) *p = strdup("text/plain;charset=utf-8"); } } compositor = wm->server->compositor; weston_seat_set_selection(seat, &source->base, wl_display_next_serial(compositor->wl_display)); free(reply); }
Property readProperty(xcb_connection_t& connection, xcb_atom_t atom, xcb_window_t window, xcb_generic_error_t* error, bool del) { error = nullptr; xcb_generic_error_t* errorPtr; auto length = 1; auto cookie = xcb_get_property(&connection, false, window, atom, XCB_ATOM_ANY, 0, length); auto reply = xcb_get_property_reply(&connection, cookie, &errorPtr); if(reply && !errorPtr && (reply->bytes_after || del)) { length = reply->length; free(reply); cookie = xcb_get_property(&connection, del, window, atom, XCB_ATOM_ANY, 0, length); reply = xcb_get_property_reply(&connection, cookie, &errorPtr); } Property ret {}; if(!errorPtr && reply) { ret.format = reply->format; ret.type = reply->type; auto begin = static_cast<uint8_t*>(xcb_get_property_value(reply)); ret.data = {begin, begin + xcb_get_property_value_length(reply)}; free(reply); } else if(errorPtr) { if(error) *error = *errorPtr; free(errorPtr); } return ret; }
//_______________________________________________________ bool ShadowHelper::checkSupported( void ) const { // create atom #if MENDA_HAVE_X11 // make sure we are on X11 if( !Helper::isX11() ) return false; // create atom xcb_atom_t netSupportedAtom( _helper.createAtom( "_NET_SUPPORTED" ) ); if( !netSupportedAtom ) return false; // store connection locally xcb_connection_t* connection( Helper::connection() ); // get property const quint32 maxLength = std::string().max_size(); xcb_get_property_cookie_t cookie( xcb_get_property( connection, 0, QX11Info::appRootWindow(), netSupportedAtom, XCB_ATOM_ATOM, 0, (maxLength+3) / 4 ) ); ScopedPointer<xcb_get_property_reply_t> reply( xcb_get_property_reply( connection, cookie, nullptr ) ); if( !reply ) return false; // get reply length and data const int count( xcb_get_property_value_length( reply.data() )/sizeof( xcb_atom_t ) ); xcb_atom_t *atoms = reinterpret_cast<xcb_atom_t*>( xcb_get_property_value( reply.data() ) ); bool found( false ); for( int i = 0; i < count && !found; ++i ) { // get atom name and print xcb_atom_t atom( atoms[i] ); xcb_get_atom_name_cookie_t cookie( xcb_get_atom_name( connection, atom ) ); ScopedPointer<xcb_get_atom_name_reply_t> reply( xcb_get_atom_name_reply( connection, cookie, 0 ) ); if( !reply ) continue; // get name and compare const QString name( QByteArray( xcb_get_atom_name_name( reply.data() ), xcb_get_atom_name_name_length( reply.data() ) ) ); if( strcmp( netWMShadowAtomName, xcb_get_atom_name_name( reply.data() ) ) == 0 ) found = true; } return found; #else return false; #endif }
static void print_client_properties(xcb_connection_t *dpy, xcb_window_t w, int verbose, int maxcmdlen) { client_state *cs = malloc(sizeof(*cs)); if (!cs) return; /* TODO: print OOM message */ cs->c = dpy; cs->w = w; cs->verbose = verbose; cs->maxcmdlen = maxcmdlen; /* * get the WM_CLIENT_MACHINE and WM_COMMAND list of strings */ cs->client_machine = xcb_get_property(dpy, 0, w, XCB_ATOM_WM_CLIENT_MACHINE, XCB_GET_PROPERTY_TYPE_ANY, 0, 1000000L); cs->command = xcb_get_property(dpy, 0, w, XCB_ATOM_WM_COMMAND, XCB_GET_PROPERTY_TYPE_ANY, 0, 1000000L); if (verbose) { cs->name = xcb_get_property(dpy, 0, w, XCB_ATOM_WM_NAME, XCB_GET_PROPERTY_TYPE_ANY, 0, 1000000L); cs->icon_name = xcb_get_property(dpy, 0, w, XCB_ATOM_WM_ICON_NAME, XCB_GET_PROPERTY_TYPE_ANY, 0, 1000000L); cs->wm_class = xcb_get_property(dpy, 0, w, XCB_ATOM_WM_CLASS, XCB_ATOM_STRING, 0, 1000000L); } enqueue(show_client_properties, cs); }
char * get_prop_string(xcb_atom_t atom, xcb_window_t w) { xcb_get_property_cookie_t c; xcb_get_property_reply_t *r; char *string = 0; c = xcb_get_property(conn, 0, w, atom, XCB_ATOM_STRING, 0, 32); r = xcb_get_property_reply(conn, c, NULL); if (r) { string = (char *) xcb_get_property_value(r); } free(r); return string; }
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); } }
static void UpdateApps (services_discovery_t *sd) { services_discovery_sys_t *p_sys = sd->p_sys; xcb_connection_t *conn = p_sys->conn; xcb_get_property_reply_t *r = xcb_get_property_reply (conn, xcb_get_property (conn, false, p_sys->root_window, p_sys->net_client_list, XA_WINDOW, 0, 1024), NULL); if (r == NULL) return; /* FIXME: remove all entries */ xcb_window_t *ent = xcb_get_property_value (r); int n = xcb_get_property_value_length (r) / 4; void *newnodes = NULL, *oldnodes = p_sys->apps; for (int i = 0; i < n; i++) { xcb_window_t id = *(ent++); struct app *app; struct app **pa = tfind (&id, &oldnodes, cmpapp); if (pa != NULL) /* existing entry */ { app = *pa; tdelete (app, &oldnodes, cmpapp); } else /* new entry */ { app = AddApp (sd, id); if (app == NULL) continue; } pa = tsearch (app, &newnodes, cmpapp); if (pa == NULL /* OOM */ || *pa != app /* buggy window manager */) DelApp (app); } free (r); /* Remove old nodes */ tdestroy (oldnodes, DelApp); p_sys->apps = newnodes; }
int desktop_of_window(xcb_window_t w) { xcb_get_property_cookie_t c; xcb_get_property_reply_t *r; int desktop = 0; xcb_atom_t atom = get_atom("_NET_WM_DESKTOP"); c = xcb_get_property(conn, 0, w, atom, XCB_ATOM_CARDINAL, 0, 1); r = xcb_get_property_reply(conn, c, NULL); if (r) { desktop = *((int *) xcb_get_property_value(r)); } free(r); return desktop; }
/** The property notify event handler. * \param state currently unused * \param window The window to obtain update the property with. * \param name The protocol atom, currently unused. * \param reply (Optional) An existing reply. */ static int property_handle_xembed_info(uint8_t state, xcb_window_t window) { xembed_window_t *emwin = xembed_getbywin(&globalconf.embedded, window); if(emwin) { xcb_get_property_cookie_t cookie = xcb_get_property(globalconf.connection, 0, window, _XEMBED_INFO, XCB_GET_PROPERTY_TYPE_ANY, 0, 3); xcb_get_property_reply_t *propr = xcb_get_property_reply(globalconf.connection, cookie, 0); xembed_property_update(globalconf.connection, emwin, propr); p_delete(&propr); } return 0; }
static struct app *AddApp (services_discovery_t *sd, xcb_window_t xid) { services_discovery_sys_t *p_sys = sd->p_sys; char *mrl, *name; if (asprintf (&mrl, "window://0x%"PRIx8, xid) == -1) return NULL; xcb_get_property_reply_t *r = xcb_get_property_reply (p_sys->conn, xcb_get_property (p_sys->conn, 0, xid, p_sys->net_wm_name, 0, 0, 1023 /* max size */), NULL); if (r != NULL) { name = strndup (xcb_get_property_value (r), xcb_get_property_value_length (r)); if (name != NULL) EnsureUTF8 (name); /* don't trust third party apps too much ;-) */ free (r); } /* TODO: use WM_NAME (Latin-1) for very old apps */ else name = NULL; input_item_t *item = input_item_NewCard (mrl, name ? name : mrl); /* FIXME */ free (mrl); free (name); if (item == NULL) return NULL; struct app *app = malloc (sizeof (*app)); if (app == NULL) { input_item_Release (item); return NULL; } app->xid = xid; app->item = item; app->owner = sd; services_discovery_AddSubItem(sd, p_sys->apps_root, item); return app; }
static void get_wm_info (el_backend_x11_t self) { xcb_get_property_cookie_t cookie = xcb_get_property(self->connection, 0, self->screen->root, self->atom.net_supported, XCB_ATOM_ATOM, 0, 1024); xcb_get_property_reply_t* reply; if ((reply = xcb_get_property_reply(self->connection, cookie, NULL)) == NULL) { return; } xcb_atom_t* atom = (xcb_atom_t*) xcb_get_property_value(reply); for (size_t i = 0; i < reply->value_len; i++) { if (atom[i] == self->atom.net_wm_state_fullscreen) { self->has.fullscreen = true; } } }
void set_window_opacity(xcwm_window_t *window, xcwm_property_t *property) { xcb_get_property_cookie_t cookie; cookie = xcb_get_property(window->context->conn, 0, window->window_id, property->atom, XCB_ATOM_CARDINAL, 0L, 4L); xcb_get_property_reply_t *reply = xcb_get_property_reply(window->context->conn, cookie, NULL); if (reply) { int nitems = xcb_get_property_value_length(reply); uint32_t *value = xcb_get_property_value(reply); if (value && nitems == 4) { window->opacity = *value; } free(reply); } }
/* * Check if window has given property */ static Bool Window_Has_Property(xcb_connection_t * dpy, xcb_window_t win, xcb_atom_t atom) { xcb_get_property_cookie_t prop_cookie; xcb_get_property_reply_t *prop_reply; prop_cookie = xcb_get_property (dpy, False, win, atom, XCB_GET_PROPERTY_TYPE_ANY, 0, 0); prop_reply = xcb_get_property_reply (dpy, prop_cookie, NULL); if (prop_reply) { xcb_atom_t reply_type = prop_reply->type; free (prop_reply); if (reply_type != XCB_NONE) return True; } return False; }
static void root_list(void *closure) { int i; xcb_window_t *child; xcb_query_tree_reply_t *reply; root_list_state *rl = closure; reply = xcb_query_tree_reply(rl->c, rl->cookie, NULL); if (!reply) goto done; child = xcb_query_tree_children(reply); for (i = 0; i < reply->children_len; i++) { /* Get information about each child */ child_wm_state *cs = malloc(sizeof(*cs) + sizeof(*cs->prop_cookie) + sizeof(*cs->tree_cookie) + sizeof(*cs->win)); if (!cs) goto done; /* TODO: print OOM message */ cs->c = rl->c; cs->verbose = rl->verbose; cs->maxcmdlen = rl->maxcmdlen; cs->prop_cookie = (void *)&cs[1]; cs->tree_cookie = (void *)&cs->prop_cookie[1]; cs->win = (void *)&cs->tree_cookie[1]; cs->orig_win = child[i]; cs->win[0] = child[i]; cs->prop_cookie[0] = xcb_get_property(rl->c, 0, child[i], WM_STATE, XCB_GET_PROPERTY_TYPE_ANY, 0, 0); /* Just in case the property isn't there, get the tree too */ cs->tree_cookie[0] = xcb_query_tree(rl->c, child[i]); cs->list_length = 1; enqueue(child_info, cs); } free(reply); done: free(rl); }
static void get_resources(xcb_connection_t *connection, xcb_screen_t *screen, cairo_xcb_resources_t *resources) { xcb_get_property_cookie_t cookie; xcb_get_property_reply_t *reply; struct resource_parser parser; int offset; cairo_bool_t has_more_data; resources->xft_antialias = TRUE; resources->xft_lcdfilter = -1; resources->xft_hinting = TRUE; resources->xft_hintstyle = FC_HINT_FULL; resources->xft_rgba = FC_RGBA_UNKNOWN; resource_parser_init (&parser, resources); offset = 0; has_more_data = FALSE; do { cookie = xcb_get_property (connection, 0, screen->root, XCB_ATOM_RESOURCE_MANAGER, XCB_ATOM_STRING, offset, 1024); reply = xcb_get_property_reply (connection, cookie, NULL); if (reply) { if (reply->format == 8 && reply->type == XCB_ATOM_STRING) { char *value = (char *) xcb_get_property_value (reply); int length = xcb_get_property_value_length (reply); offset += length / 4; /* X needs the offset in 'long' units */ has_more_data = reply->bytes_after > 0; if (! resource_parser_update (&parser, value, length)) has_more_data = FALSE; /* early exit on error */ } free (reply); } } while (has_more_data); resource_parser_done (&parser); }
int client_list(xcb_window_t w, xcb_window_t **windows) { xcb_get_property_cookie_t c; xcb_get_property_reply_t *r; int wn = 0; xcb_atom_t atom = get_atom("_NET_CLIENT_LIST"); c = xcb_get_property(conn, 0, w, atom, XCB_ATOM_WINDOW, 0L, 32L); r = xcb_get_property_reply(conn, c, NULL); if (r) { *windows = malloc(sizeof(xcb_window_t) * r->length); memcpy(*windows, xcb_get_property_value(r), sizeof(xcb_window_t) * r->length); wn = r->length; } free(r); return wn; }
void get_net_frame_window(xcb_window_t window, xcb_window_t *res) { xcb_atom_t net_frame_window; if (create_atom("_NET_FRAME_WINDOW", 1, &net_frame_window)) { *res = window; return; } xcb_get_property_cookie_t cookie = xcb_get_property(display, 0, window, net_frame_window, XCB_ATOM_ANY, 0, 1); xcb_get_property_reply_t *reply = xcb_get_property_reply(display, cookie, NULL); if ( reply == NULL || reply->type == XCB_ATOM_NONE || reply->format != 32 || xcb_get_property_value_length(reply) != sizeof (xcb_window_t) ) { *res = window; return; } *res = *(xcb_window_t *) xcb_get_property_value(reply); free(reply); }