Changeset 3372:92c4d8a5d8b7 in roaraudio for libroar/roarx11.c


Ignore:
Timestamp:
02/09/10 19:11:30 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

support to read props from X11, use ROAR_SERVER prop to find a roard

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/roarx11.c

    r3371 r3372  
    102102} 
    103103 
     104char * roar_x11_get_prop(struct roar_x11_connection * con, const char * key) { 
     105 unsigned long   nitems; 
     106 unsigned long   nbytes_after; 
     107 unsigned char * prop = NULL; 
     108 char          * ret = NULL; 
     109 int             actual_format; 
     110 Atom            actual_type; 
     111 Atom            a; 
     112 
     113 a = XInternAtom(con->display, key, False); 
     114 
     115 if ( XGetWindowProperty(con->display, RootWindow(con->display, 0), a, 
     116                         0, 256, False, XA_STRING, &actual_type, 
     117                         &actual_format, &nitems, &nbytes_after, &prop) != Success ) { 
     118  if ( prop != NULL ) 
     119   XFree(prop); 
     120 
     121  return NULL; 
     122 } 
     123 
     124 if ( prop == NULL ) 
     125  return NULL; 
     126 
     127 if (actual_type != XA_STRING) { 
     128  XFree(prop); 
     129 
     130  return NULL; 
     131 } 
     132 
     133 ret = roar_mm_malloc(nitems+1); 
     134 
     135 memcpy(ret, prop, nitems); 
     136 ret[nitems] = 0; 
     137 
     138 XFree(prop); 
     139 
     140 return ret; 
     141} 
     142 
    104143//ll 
Note: See TracChangeset for help on using the changeset viewer.