diff --git a/src/caca_internals.h b/src/caca_internals.h index 90973bf..1b680b3 100644 --- a/src/caca_internals.h +++ b/src/caca_internals.h @@ -85,6 +85,8 @@ extern enum caca_feature _caca_antialiasing; #include extern Display *x11_dpy; extern Window x11_window; +extern Pixmap x11_pixmap; +extern GC x11_gc; extern long int x11_event_mask; extern int x11_font_width, x11_font_height; extern unsigned int x11_new_width, x11_new_height; diff --git a/src/event.c b/src/event.c index 2894449..3cb9cda 100644 --- a/src/event.c +++ b/src/event.c @@ -259,11 +259,24 @@ static unsigned int _lowlevel_event(void) { KeySym keysym; + /* Expose event */ + if(xevent.type == Expose) + { + XCopyArea(x11_dpy, x11_pixmap, x11_window, x11_gc, 0, 0, + _caca_width * x11_font_width, + _caca_height * x11_font_height, 0, 0); + continue; + } + /* Resize event */ if(xevent.type == ConfigureNotify) { - unsigned int w = xevent.xconfigure.width / x11_font_width; - unsigned int h = xevent.xconfigure.height / x11_font_height; + unsigned int w, h; + + h = (xevent.xconfigure.height + x11_font_height / 3) + / x11_font_height; + w = (xevent.xconfigure.width + x11_font_width / 3) + / x11_font_width; if(w == _caca_width && h == _caca_height) continue; diff --git a/src/graphics.c b/src/graphics.c index 796b674..8287957 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -163,12 +163,13 @@ static char *conio_screen; #if defined(USE_X11) && !defined(_DOXYGEN_SKIP_ME) Display *x11_dpy; Window x11_window; +Pixmap x11_pixmap; +GC x11_gc; long int x11_event_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask - | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask; + | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask + | ExposureMask; int x11_font_width, x11_font_height; unsigned int x11_new_width, x11_new_height; -static GC x11_gc; -static Pixmap x11_pixmap; static uint8_t *x11_char, *x11_attr; static int x11_colors[16]; static Font x11_font;