Changeset 3371:dbd3f8c59d29 in roaraudio


Ignore:
Timestamp:
02/08/10 23:10:43 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

wrote most of the X11 stuff

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/libroar.h

    r3370 r3371  
    9494#endif 
    9595 
     96#ifdef ROAR_HAVE_LIBX11 
     97#include <X11/Xlib.h> 
     98#include <X11/Xatom.h> 
     99#endif 
     100 
    96101#include "error.h" 
    97102#include "config.h" 
  • include/libroar/roarx11.h

    r3370 r3371  
    3838#include "libroar.h" 
    3939 
     40struct roar_x11_connection { 
     41#ifdef ROAR_HAVE_LIBX11 
     42 Display * display; 
     43#else 
     44 char dummy[8]; 
     45#endif 
     46}; 
     47 
     48struct roar_x11_connection * roar_x11_connect(char * display); 
     49int roar_x11_disconnect(struct roar_x11_connection * con); 
     50 
     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); 
     53 
    4054#endif 
    4155 
  • libroar/roarx11.c

    r3370 r3371  
    3535#include "libroar.h" 
    3636 
     37struct roar_x11_connection * roar_x11_connect(char * display) { 
     38#ifdef ROAR_HAVE_LIBX11 
     39 struct roar_x11_connection * con; 
     40 
     41 if ( (con = roar_mm_malloc(sizeof(struct roar_x11_connection))) == NULL ) 
     42  return NULL; 
     43 
     44 if ( (con->display = XOpenDisplay(display)) == NULL ) { 
     45  roar_mm_free(con); 
     46  return NULL; 
     47 } 
     48 
     49 return con; 
     50#else 
     51 return NULL; 
     52#endif 
     53} 
     54 
     55int roar_x11_disconnect(struct roar_x11_connection * con) { 
     56#ifdef ROAR_HAVE_LIBX11 
     57 int ret; 
     58 
     59 if ( con == NULL ) 
     60  return -1; 
     61 
     62 ret = XCloseDisplay(con->display); 
     63 
     64 roar_mm_free(con); 
     65 
     66 return ret; 
     67#else 
     68 return -1; 
     69#endif 
     70} 
     71 
     72int roar_x11_set_prop(struct roar_x11_connection * con, const char * key, const char * val) { 
     73#ifdef ROAR_HAVE_LIBX11 
     74 Atom a; 
     75 
     76 if ( con == NULL ) 
     77  return -1; 
     78 
     79 a = XInternAtom(con->display, key, False); 
     80 
     81 XChangeProperty(con->display, RootWindow(con->display, 0), a, XA_STRING, 8, PropModeReplace, (const unsigned char*) val, strlen(val)+1); 
     82 
     83 return 0; 
     84#else 
     85 return -1; 
     86#endif 
     87} 
     88 
     89int roar_x11_delete_prop(struct roar_x11_connection * con, const char * key) { 
     90#ifdef ROAR_HAVE_LIBX11 
     91 Atom a; 
     92 if ( con == NULL ) 
     93  return -1; 
     94 
     95 a = XInternAtom(con->display, key, False); 
     96 XDeleteProperty(con->display, RootWindow(con->display, 0), a); 
     97 
     98 return 0; 
     99#else 
     100 return -1; 
     101#endif 
     102} 
     103 
    37104//ll 
Note: See TracChangeset for help on using the changeset viewer.