コード例 #1
0
ファイル: dsimple.c プロジェクト: aosm/X11apps
/* Get the name for an atom when it is needed. */
const char *Get_Atom_Name (xcb_connection_t * dpy, xcb_atom_t atom)
{
    struct atom_cache_entry *a;

    for (a = atom_cache ; a != NULL ; a = a->next) {
	if (a->atom == atom)
	    return a->name; /* already requested or found */
    }

    a = calloc(1, sizeof(struct atom_cache_entry));
    if (a != NULL) {
	xcb_get_atom_name_cookie_t cookie = xcb_get_atom_name (dpy, atom);
	xcb_get_atom_name_reply_t *reply
	    = xcb_get_atom_name_reply (dpy, cookie, NULL);

	a->atom = atom;
	if (reply) {
	    int len = xcb_get_atom_name_name_length (reply);
	    char *name = malloc(len + 1);
	    if (name) {
		memcpy (name, xcb_get_atom_name_name (reply), len);
		name[len] = '\0';
		a->name = name;
	    }
	    free (reply);
	}

	a->next = atom_cache;
	atom_cache = a;

	return a->name;
    }
    return NULL;
}
コード例 #2
0
ファイル: xlsatoms.c プロジェクト: Bluerise/bitrig-xenocara
static int
say_batch(xcb_connection_t *c, const char *format, xcb_get_atom_name_cookie_t *cookie, long low, long count)
{
    xcb_generic_error_t *e;
    char atom_name[1024];
    long i;
    int done = 0;

    for (i = 0; i < count; i++)
	cookie[i] = xcb_get_atom_name(c, i + low);

    for (i = 0; i < count; i++) {
	xcb_get_atom_name_reply_t *r;
	r = xcb_get_atom_name_reply(c, cookie[i], &e);
	if (r) {
	    /* We could just use %.*s in 'format', but we want to be compatible
	       with legacy command line usage */
	    snprintf(atom_name, sizeof(atom_name), "%.*s",
		r->name_len, xcb_get_atom_name_name(r));

	    printf (format, i + low, atom_name);
	    putchar ('\n');
	    free(r);
	}
	if (e) {
	    done = 1;
	    free(e);
	}
    }

    return done;
}
コード例 #3
0
ファイル: mendashadowhelper.cpp プロジェクト: anexation/test
    //_______________________________________________________
    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

    }
コード例 #4
0
ファイル: qxcbconnection.cpp プロジェクト: IGLOU-EU/krita
QByteArray QXcbConnection::atomName(xcb_atom_t atom)
{
    if (!atom)
        return QByteArray();

    xcb_generic_error_t *error = 0;
    xcb_get_atom_name_cookie_t cookie = Q_XCB_CALL(xcb_get_atom_name(xcb_connection(), atom));
    xcb_get_atom_name_reply_t *reply = xcb_get_atom_name_reply(xcb_connection(), cookie, &error);
    if (error) {
        qWarning() << "QXcbConnection::atomName: bad Atom" << atom;
        free(error);
    }
    if (reply) {
        QByteArray result(xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply));
        free(reply);
        return result;
    }
    return QByteArray();
}
コード例 #5
0
static void
unknown(xcb_connection_t *dpy, xcb_atom_t actual_type, int actual_format)
{
    printf ("<unknown type ");
    if (actual_type == XCB_NONE)
	printf ("None");
    else {
	/* This should happen so rarely as to make no odds. Eat a round-trip: */
	xcb_get_atom_name_reply_t *atom =
	    xcb_get_atom_name_reply(dpy,
		xcb_get_atom_name(dpy, actual_type), NULL);
	if (atom) {
	    printf("%.*s", xcb_get_atom_name_name_length(atom),
			  xcb_get_atom_name_name(atom));
	    free(atom);
	} else
	    fputs (Nil, stdout);
    }
    printf (" (%" PRIu32 ") or format %d>", actual_type, actual_format);
}
コード例 #6
0
ファイル: LInputDevice.cpp プロジェクト: Nanolx/lumina
// === PRIVATE ===
void LInputDevice::getProperties(){
  devProps.clear();
  xcb_input_list_device_properties_cookie_t cookie = xcb_input_list_device_properties_unchecked(QX11Info::connection(), devID);
  xcb_input_list_device_properties_reply_t *reply = xcb_input_list_device_properties_reply(QX11Info::connection(), cookie, NULL);
  //Get the atoms
  xcb_atom_t *atoms = xcb_input_list_device_properties_atoms(reply);
  //qDebug() << "Property Response Type:" << reply->response_type; //Always seems to be "1"
  QList<xcb_get_atom_name_cookie_t> cookies;
  for(int i=0; i<reply->num_atoms; i++){  cookies <<  xcb_get_atom_name(QX11Info::connection(), atoms[i]);  }
  for(int i=0; i<reply->num_atoms; i++){
    xcb_get_atom_name_reply_t *nr = xcb_get_atom_name_reply(QX11Info::connection(), cookies[i], NULL);
    propData DATA;
      DATA.name = QString::fromUtf8( xcb_get_atom_name_name(nr), xcb_get_atom_name_name_length(nr) );
      DATA.atom = atoms[i];
      DATA.id = (int)(atoms[i]);
    devProps.insert(DATA.id,DATA);
    ::free(nr);
  }
  //Done with data structure
  ::free(reply);
}