Changeset 3372:92c4d8a5d8b7 in roaraudio


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

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/roarx11.h

    r3371 r3372  
    4747 
    4848struct roar_x11_connection * roar_x11_connect(char * display); 
    49 int roar_x11_disconnect(struct roar_x11_connection * con); 
     49int    roar_x11_disconnect(struct roar_x11_connection * con); 
    5050 
    51 int roar_x11_set_prop(struct roar_x11_connection * con, const char * key, const char * val); 
    52 int roar_x11_delete_prop(struct roar_x11_connection * con, const char * key); 
     51int    roar_x11_set_prop(struct roar_x11_connection * con, const char * key, const char * val); 
     52int    roar_x11_delete_prop(struct roar_x11_connection * con, const char * key); 
     53char * roar_x11_get_prop(struct roar_x11_connection * con, const char * key); 
    5354 
    5455#endif 
  • libroar/basic.c

    r3077 r3372  
    22 
    33/* 
    4  *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008 
     4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2010 
    55 * 
    66 *  This file is part of libroar a part of RoarAudio, 
     
    4949 struct stat decnet_stat; 
    5050#endif 
     51#ifdef ROAR_HAVE_LIBX11 
     52 struct roar_x11_connection * x11con; 
     53#endif 
    5154 
    5255 roar_errno = ROAR_ERROR_UNKNOWN; 
     
    6063 if ( server == NULL && (roar_server = getenv("ROAR_SERVER")) != NULL ) 
    6164  server = roar_server; 
     65 
     66#ifdef ROAR_HAVE_LIBX11 
     67 if ( server == NULL ) { 
     68  if ( (x11con = roar_x11_connect(NULL)) != NULL ) { 
     69   server = roar_x11_get_prop(x11con, "ROAR_SERVER"); 
     70   roar_x11_disconnect(x11con); 
     71  } 
     72 } 
     73#endif 
    6274 
    6375#if !defined(ROAR_TARGET_WIN32) && !defined(ROAR_TARGET_MICROCONTROLLER) 
  • 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.