Browse Source

* src/graphics.c:

+ When resizing under X11, copy the old pixmap to the new one.
  * examples/cacaview.c:
    + Resizing support.
tags/v0.99.beta14
Sam Hocevar sam 21 years ago
parent
commit
8b7bd031a7
3 changed files with 28 additions and 10 deletions
  1. +17
    -6
      examples/cacaview.c
  2. +2
    -2
      src/event.c
  3. +9
    -2
      src/graphics.c

+ 17
- 6
examples/cacaview.c View File

@@ -111,21 +111,22 @@ int main(int argc, char **argv)
/* Go ! */
while(!quit)
{
int ww = caca_get_width();
int wh = caca_get_height();

int ww, wh;
unsigned int event, new_status = 0, new_help = 0;

ww = caca_get_width();
wh = caca_get_height();

if(update)
event = caca_get_event(CACA_EVENT_KEY_PRESS);
event = caca_get_event(CACA_EVENT_KEY_PRESS | CACA_EVENT_RESIZE);
else
event = caca_wait_event(CACA_EVENT_KEY_PRESS);
event = caca_wait_event(CACA_EVENT_KEY_PRESS | CACA_EVENT_RESIZE);

while(event)
{
unsigned int key = event & 0x00ffffff;

switch(key)
if(key) switch(key)
{
case 'n':
case 'N':
@@ -231,6 +232,14 @@ int main(int argc, char **argv)
break;
}

if(event == CACA_EVENT_RESIZE)
{
caca_refresh();
ww = caca_get_width();
wh = caca_get_height();
update = 1;
}

if(status || new_status)
status = new_status;

@@ -258,6 +267,8 @@ int main(int argc, char **argv)
caca_set_color(CACA_COLOR_WHITE, CACA_COLOR_BLUE);
caca_putstr((ww - strlen(buffer)) / 2, wh / 2, buffer);
caca_refresh();
ww = caca_get_width();
wh = caca_get_height();

unload_image();
load_image(list[current]);


+ 2
- 2
src/event.c View File

@@ -273,10 +273,10 @@ static unsigned int _lowlevel_event(void)
{
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;
h = (xevent.xconfigure.height + x11_font_height / 3)
/ x11_font_height;

if(w == _caca_width && h == _caca_height)
continue;


+ 9
- 2
src/graphics.c View File

@@ -1320,18 +1320,25 @@ static void caca_handle_resize(void)
#if defined(USE_X11)
if(_caca_driver == CACA_DRIVER_X11)
{
Pixmap new_pixmap;

_caca_width = x11_new_width;
_caca_height = x11_new_height;

XFreePixmap(x11_dpy, x11_pixmap);
free(x11_char);
free(x11_attr);

x11_pixmap = XCreatePixmap(x11_dpy, x11_window,
new_pixmap = XCreatePixmap(x11_dpy, x11_window,
_caca_width * x11_font_width,
_caca_height * x11_font_height,
DefaultDepth(x11_dpy,
DefaultScreen(x11_dpy)));
XCopyArea(x11_dpy, x11_pixmap, new_pixmap, x11_gc, 0, 0,
old_width * x11_font_width, old_height * x11_font_height,
0, 0);
XFreePixmap(x11_dpy, x11_pixmap);
x11_pixmap = new_pixmap;

x11_char = malloc(_caca_width * _caca_height * sizeof(int));
memset(x11_char, 0, _caca_width * _caca_height * sizeof(int));
x11_attr = malloc(_caca_width * _caca_height * sizeof(int));


Loading…
Cancel
Save