Changeset 251
- Timestamp:
- Dec 15, 2003, 11:38:03 AM (17 years ago)
- Location:
- libcaca/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/configure.ac
r250 r251 24 24 AC_ARG_ENABLE(conio, 25 25 [ --enable-conio DOS conio.h graphics support (default disabled)]) 26 AC_ARG_ENABLE(x11, 27 [ --enable-x11 X11 support (default disabled)]) 26 28 27 29 AC_CHECK_HEADERS(inttypes.h endian.h) … … 42 44 AC_DEFINE(USE_SLANG, 1, Define if the backend driver is slang) 43 45 CACA_LIBS="${CACA_LIBS} -lslang" 46 elif test "${enable_x11}" = "yes"; then 47 AC_PATH_X 48 AC_CHECK_LIB(X11, XOpenDisplay, 49 [ac_cv_my_have_x11=yes 50 X_CFLAGS="-I${x_includes}" 51 X_LIBS="-lX11 -L${x_libraries}"], 52 [ac_cv_my_have_x11=no], 53 [[-lXt -L${x_libraries}]]) 54 if test "${ac_cv_my_have_x11}" != "yes"; then 55 AC_MSG_ERROR([cannot find X11 development files]) 56 fi 57 AC_DEFINE(USE_X11, 1, Define if the backend driver is X11) 58 CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}" 59 CACA_LIBS="${CACA_LIBS} ${X_LIBS}" 44 60 elif test "${enable_ncurses}" != "no"; then 45 61 AC_CHECK_HEADER(ncurses.h,:,AC_MSG_ERROR([cannot find ncurses headers])) -
libcaca/trunk/src/caca.c
r250 r251 39 39 # include <dos.h> 40 40 # include <conio.h> 41 #elif defined(USE_X11) 42 # include <X11/Xlib.h> 41 43 #else 42 44 # error "no graphics library detected" … … 113 115 _setcursortype(_NOCURSOR); 114 116 clrscr(); 117 118 #elif defined(USE_X11) 119 /* Nothing to do */ 115 120 116 121 #endif … … 230 235 void caca_end(void) 231 236 { 237 _caca_end_graphics(); 238 232 239 #if defined(USE_SLANG) 233 240 SLtt_set_mouse_mode(0, 0); … … 246 253 cputs("\r\n"); 247 254 _setcursortype(_NORMALCURSOR); 255 #elif defined(USE_X11) 256 /* Nothing to do */ 248 257 #endif 249 258 } … … 295 304 static void caca_init_terminal(void) 296 305 { 297 #if defined(HAVE_GETENV) && defined(HAVE_PUTENV) 306 #if defined(HAVE_GETENV) && defined(HAVE_PUTENV) \ 307 && (defined(USE_SLANG) || defined(USE_NCURSES)) 298 308 char *term, *colorterm, *other; 299 309 -
libcaca/trunk/src/caca_internals.h
r249 r251 32 32 33 33 extern int _caca_init_graphics(void); 34 extern int _caca_end_graphics(void); 34 35 35 36 /* Cached screen size */ … … 42 43 extern enum caca_feature _caca_antialiasing; 43 44 45 #if defined(USE_X11) 46 #include <X11/Xlib.h> 47 extern Display *_caca_dpy; 48 extern Window _caca_window; 49 #endif 50 44 51 #endif /* __CACA_INTERNALS_H__ */ -
libcaca/trunk/src/graphics.c
r247 r251 39 39 # include <pc.h> 40 40 # endif 41 #elif defined(USE_X11) 42 # include <X11/Xlib.h> 41 43 #else 42 44 # error "no graphics library detected" … … 76 78 #endif 77 79 80 #if defined(USE_X11) 81 Display *_caca_dpy; 82 Window _caca_window; 83 GC _caca_gc; 84 #endif 85 78 86 static char *_caca_empty_line; 79 87 static char *_caca_scratch_line; … … 99 107 textbackground(bgcolor); 100 108 textcolor(fgcolor); 109 #elif defined(USE_X11) 110 /* FIXME */ 101 111 #endif 102 112 } … … 133 143 // gotoxy(x + 1, y + 1); 134 144 // putch(c); 145 #elif defined(USE_X11) 146 /* FIXME */ 135 147 #endif 136 148 } … … 176 188 // gotoxy(x + 1, y + 1); 177 189 // cputs(s); 190 #elif defined(USE_X11) 191 /* FIXME */ 178 192 #endif 179 193 } … … 336 350 _caca_height = ti.screenheight; 337 351 352 #elif defined(USE_X11) 353 int black_color; 354 int white_color; 355 356 _caca_dpy = XOpenDisplay(NULL); 357 if(_caca_dpy == NULL) 358 return -1; 359 360 black_color = BlackPixel(_caca_dpy, DefaultScreen(_caca_dpy)); 361 white_color = WhitePixel(_caca_dpy, DefaultScreen(_caca_dpy)); 362 363 _caca_window = XCreateSimpleWindow(_caca_dpy, DefaultRootWindow(_caca_dpy), 364 0, 0, 400, 300, 0, 365 black_color, black_color); 366 XSelectInput(_caca_dpy, _caca_window, StructureNotifyMask); 367 XMapWindow(_caca_dpy, _caca_window); 368 369 _caca_gc = XCreateGC(_caca_dpy, _caca_window, 0, NULL); 370 XSetForeground(_caca_dpy, _caca_gc, white_color); 371 372 for(;;) 373 { 374 XEvent event; 375 XNextEvent(_caca_dpy, &event); 376 if (event.type == MapNotify) 377 break; 378 } 379 380 XSelectInput(_caca_dpy, _caca_window, KeyPressMask); 381 382 /* FIXME */ 383 _caca_width = 80; 384 _caca_height = 24; 385 386 XSync(_caca_dpy, False); 387 338 388 #endif 339 389 _caca_empty_line = malloc(_caca_width + 1); … … 349 399 } 350 400 401 int _caca_end_graphics(void) 402 { 403 #if defined(USE_SLANG) 404 /* Nothing to do */ 405 #elif defined(USE_NCURSES) 406 /* Nothing to do */ 407 #elif defined(USE_CONIO) 408 free(_caca_screen); 409 #elif defined(USE_X11) 410 XSync(_caca_dpy, False); 411 XFreeGC(_caca_dpy, _caca_gc); 412 XUnmapWindow(_caca_dpy, _caca_window); 413 XDestroyWindow(_caca_dpy, _caca_window); 414 XCloseDisplay(_caca_dpy); 415 #endif 416 free(_caca_empty_line); 417 418 return 0; 419 } 420 351 421 void caca_set_delay(unsigned int usec) 352 422 { … … 395 465 /* FIXME */ 396 466 # endif 467 #elif defined(USE_X11) 468 /* FIXME */ 469 XFlush(_caca_dpy); 397 470 #endif 398 471 -
libcaca/trunk/src/io.c
r240 r251 36 36 #elif defined(USE_CONIO) 37 37 # include <conio.h> 38 #elif defined(USE_X11) 39 # include <X11/Xlib.h> 40 # include <X11/Xutil.h> 38 41 #else 39 42 # error "no graphics library detected" … … 205 208 #elif defined(USE_CONIO) 206 209 return _conio_kbhit() ? getch() : 0; 210 #elif defined(USE_X11) 211 XEvent event; 212 char key; 213 214 while(XCheckWindowEvent(_caca_dpy, _caca_window, KeyPressMask, &event) 215 == True) 216 { 217 if(event.type == KeyPress) 218 { 219 //KeySym keysym; 220 //keysym = XKeycodeToKeysym(_caca_dpy, event.xkey.keycode, 0); 221 if(XLookupString(&event.xkey, &key, 1, NULL, NULL)) 222 return key; 223 } 224 } 225 226 return 0; 207 227 #endif 208 228 }
Note: See TracChangeset
for help on using the changeset viewer.