"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "caca/driver/x11.c" between
libcaca-0.99.beta19.tar.gz and libcaca-0.99.beta20.tar.bz2

About: libcaca is a graphics library that outputs text instead of pixels, so that it can work on older video cards or text terminals (something like an advanced AAlib library).

x11.c  (libcaca-0.99.beta19):x11.c  (libcaca-0.99.beta20.tar.bz2)
/* /*
* libcaca Colour ASCII-Art library * libcaca Colour ASCII-Art library
* Copyright (c) 2002-2014 Sam Hocevar <sam@hocevar.net> * Copyright © 2002—2016 Sam Hocevar <sam@hocevar.net>
* 2007 Ben Wiley Sittler <bsittler@gmail.com> * 2007 Ben Wiley Sittler <bsittler@gmail.com>
* All Rights Reserved * All Rights Reserved
* *
* This library is free software. It comes without any warranty, to * This library is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it * the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What the Fuck You Want * and/or modify it under the terms of the Do What the Fuck You Want
* to Public License, Version 2, as published by Sam Hocevar. See * to Public License, Version 2, as published by Sam Hocevar. See
* http://www.wtfpl.net/ for more details. * http://www.wtfpl.net/ for more details.
*/ */
/* /*
* This file contains the libcaca X11 input and output driver * This file contains the libcaca X11 input and output driver
skipping to change at line 109 skipping to change at line 109
#endif #endif
caca_add_dirty_rect(dp->cv, 0, 0, dp->cv->width, dp->cv->height); caca_add_dirty_rect(dp->cv, 0, 0, dp->cv->width, dp->cv->height);
dp->resize.allow = 1; dp->resize.allow = 1;
caca_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32); caca_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32);
width = caca_get_canvas_width(dp->cv); width = caca_get_canvas_width(dp->cv);
height = caca_get_canvas_height(dp->cv); height = caca_get_canvas_height(dp->cv);
dp->resize.allow = 0; dp->resize.allow = 0;
#if defined HAVE_LOCALE_H #if defined HAVE_LOCALE_H
setlocale(LC_ALL, ""); /* FIXME: some better code here would be:
* locale_t old_locale = uselocale(newlocale(LC_CTYPE_MASK,
* "", (locale_t)0);
* … but XOpenDisplay only works properly with setlocale(),
* not uselocale(). */
char const *old_locale = setlocale(LC_CTYPE, "");
#endif #endif
dp->drv.p->dpy = XOpenDisplay(NULL); dp->drv.p->dpy = XOpenDisplay(NULL);
if(dp->drv.p->dpy == NULL) if(dp->drv.p->dpy == NULL)
return -1; return -1;
#if defined HAVE_LOCALE_H
setlocale(LC_CTYPE, old_locale);
#endif
#if defined HAVE_GETENV #if defined HAVE_GETENV
fonts[0] = getenv("CACA_FONT"); fonts[0] = getenv("CACA_FONT");
if(fonts[0] && *fonts[0]) if(fonts[0] && *fonts[0])
parser = fonts; parser = fonts;
else else
#endif #endif
parser = fonts + 1; parser = fonts + 1;
/* Ignore font errors */ /* Ignore font errors */
old_error_handler = XSetErrorHandler(x11_error_handler); old_error_handler = XSetErrorHandler(x11_error_handler);
skipping to change at line 336 skipping to change at line 345
DefaultScreen(dp->drv.p->dpy))); DefaultScreen(dp->drv.p->dpy)));
dp->drv.p->pointer = None; dp->drv.p->pointer = None;
dp->drv.p->cursor_flags = 0; dp->drv.p->cursor_flags = 0;
dp->drv.p->dirty_cursor_x = -1; dp->drv.p->dirty_cursor_x = -1;
dp->drv.p->dirty_cursor_y = -1; dp->drv.p->dirty_cursor_y = -1;
#if defined X_HAVE_UTF8_STRING #if defined X_HAVE_UTF8_STRING
list = XVaCreateNestedList(0, XNFontSet, dp->drv.p->font_set, NULL); list = XVaCreateNestedList(0, XNFontSet, dp->drv.p->font_set, NULL);
dp->drv.p->im = XOpenIM(dp->drv.p->dpy, NULL, NULL, NULL); dp->drv.p->im = XOpenIM(dp->drv.p->dpy, NULL, NULL, NULL);
if (dp->drv.p->im == NULL) {
fprintf(stderr, "x11 driver error: unable to open input method\n");
return -1;
}
dp->drv.p->ic = XCreateIC(dp->drv.p->im, dp->drv.p->ic = XCreateIC(dp->drv.p->im,
XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, dp->drv.p->window, XNClientWindow, dp->drv.p->window,
XNPreeditAttributes, list, XNPreeditAttributes, list,
XNStatusAttributes, list, XNStatusAttributes, list,
NULL); NULL);
if (dp->drv.p->ic == NULL) {
fprintf(stderr, "x11 driver error: unable to create input context\n");
return -1;
}
#endif #endif
return 0; return 0;
} }
static int x11_end_graphics(caca_display_t *dp) static int x11_end_graphics(caca_display_t *dp)
{ {
XSync(dp->drv.p->dpy, False); XSync(dp->drv.p->dpy, False);
#if defined HAVE_X11_XKBLIB_H #if defined HAVE_X11_XKBLIB_H
if(!dp->drv.p->autorepeat) if(!dp->drv.p->autorepeat)
skipping to change at line 629 skipping to change at line 649
#endif #endif
if(XLookupString(&xevent.xkey, &key, 1, NULL, NULL)) if(XLookupString(&xevent.xkey, &key, 1, NULL, NULL))
{ {
ev->data.key.ch = key; ev->data.key.ch = key;
ev->data.key.utf32 = key; ev->data.key.utf32 = key;
ev->data.key.utf8[0] = key; ev->data.key.utf8[0] = key;
ev->data.key.utf8[1] = '\0'; ev->data.key.utf8[1] = '\0';
return 1; return 1;
} }
keysym = XKeycodeToKeysym(dp->drv.p->dpy, xevent.xkey.keycode, 0); keysym = XLookupKeysym(&xevent.xkey, 0);
switch(keysym) switch(keysym)
{ {
case XK_F1: ev->data.key.ch = CACA_KEY_F1; break; case XK_F1: ev->data.key.ch = CACA_KEY_F1; break;
case XK_F2: ev->data.key.ch = CACA_KEY_F2; break; case XK_F2: ev->data.key.ch = CACA_KEY_F2; break;
case XK_F3: ev->data.key.ch = CACA_KEY_F3; break; case XK_F3: ev->data.key.ch = CACA_KEY_F3; break;
case XK_F4: ev->data.key.ch = CACA_KEY_F4; break; case XK_F4: ev->data.key.ch = CACA_KEY_F4; break;
case XK_F5: ev->data.key.ch = CACA_KEY_F5; break; case XK_F5: ev->data.key.ch = CACA_KEY_F5; break;
case XK_F6: ev->data.key.ch = CACA_KEY_F6; break; case XK_F6: ev->data.key.ch = CACA_KEY_F6; break;
case XK_F7: ev->data.key.ch = CACA_KEY_F7; break; case XK_F7: ev->data.key.ch = CACA_KEY_F7; break;
case XK_F8: ev->data.key.ch = CACA_KEY_F8; break; case XK_F8: ev->data.key.ch = CACA_KEY_F8; break;
 End of changes. 6 change blocks. 
6 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)