Esempio n. 1
0
/* 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;
}
Esempio n. 2
0
/**
 * Retrieves the name of the given atom.
 *
 * @param  atom
 * @return      The name of the atom.
 *
 * @ingroup Ecore_X_Atom_Group
 */
EAPI char *
ecore_x_atom_name_get(Ecore_X_Atom atom)
{
   xcb_get_atom_name_cookie_t cookie;
   xcb_get_atom_name_reply_t *reply;
   char *name;
   int len = 0;

   LOGFN(__FILE__, __LINE__, __FUNCTION__);
   CHECK_XCB_CONN;

   cookie = xcb_get_atom_name_unchecked(_ecore_xcb_conn, atom);
   reply = xcb_get_atom_name_reply(_ecore_xcb_conn, cookie, NULL);
   if (!reply) return NULL;
   len = xcb_get_atom_name_name_length(reply);
   name = (char *)malloc(sizeof(char) * (len + 1));
   if (!name)
     {
        free(reply);
        return NULL;
     }
   memcpy(name, xcb_get_atom_name_name(reply), len);
   name[len] = '\0';

   free(reply);
   return name;
}
Esempio n. 3
0
static void
screen_scan_randr_monitors(lua_State *L, screen_array_t *screens)
{
    xcb_randr_get_monitors_cookie_t monitors_c = xcb_randr_get_monitors(globalconf.connection, globalconf.screen->root, 1);
    xcb_randr_get_monitors_reply_t *monitors_r = xcb_randr_get_monitors_reply(globalconf.connection, monitors_c, NULL);
    xcb_randr_monitor_info_iterator_t monitor_iter;

    if (monitors_r == NULL) {
        warn("RANDR GetMonitors failed; this should not be possible");
        return;
    }

    for(monitor_iter = xcb_randr_get_monitors_monitors_iterator(monitors_r);
            monitor_iter.rem; xcb_randr_monitor_info_next(&monitor_iter))
    {
        screen_t *new_screen;
        screen_output_t output;
        xcb_randr_output_t *randr_outputs;
        xcb_get_atom_name_cookie_t name_c;
        xcb_get_atom_name_reply_t *name_r;

        if(!xcb_randr_monitor_info_outputs_length(monitor_iter.data))
            continue;

        new_screen = screen_add(L, screens);
        new_screen->geometry.x = monitor_iter.data->x;
        new_screen->geometry.y = monitor_iter.data->y;
        new_screen->geometry.width = monitor_iter.data->width;
        new_screen->geometry.height = monitor_iter.data->height;
        new_screen->xid = monitor_iter.data->name;

        output.mm_width = monitor_iter.data->width_in_millimeters;
        output.mm_height = monitor_iter.data->height_in_millimeters;

        name_c = xcb_get_atom_name_unchecked(globalconf.connection, monitor_iter.data->name);
        name_r = xcb_get_atom_name_reply(globalconf.connection, name_c, NULL);
        if (name_r) {
            const char *name = xcb_get_atom_name_name(name_r);
            size_t len = xcb_get_atom_name_name_length(name_r);

            output.name = memcpy(p_new(char *, len + 1), name, len);
            output.name[len] = '\0';
            p_delete(&name_r);
        } else {
            output.name = a_strdup("unknown");
        }
        randr_output_array_init(&output.outputs);

        randr_outputs = xcb_randr_monitor_info_outputs(monitor_iter.data);
        for(int i = 0; i < xcb_randr_monitor_info_outputs_length(monitor_iter.data); i++) {
            randr_output_array_append(&output.outputs, randr_outputs[i]);
        }

        screen_output_array_append(&new_screen->outputs, output);
    }
Esempio n. 4
0
    //_______________________________________________________
    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

    }
Esempio n. 5
0
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();
}
Esempio n. 6
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);
}
Esempio n. 7
0
// === 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);
}