resizes it later, or the driver changes it to fit the display.tags/v0.99.beta14
| @@ -86,7 +86,7 @@ static int gl_init_graphics(caca_display_t *dp) | |||||
| char const *geometry; | char const *geometry; | ||||
| char *argv[2] = { "", NULL }; | char *argv[2] = { "", NULL }; | ||||
| char const * const * fonts; | char const * const * fonts; | ||||
| unsigned int width = 0, height = 0; | |||||
| unsigned int width = dp->cv->width, height = dp->cv->height; | |||||
| int argc = 1; | int argc = 1; | ||||
| dp->drv.p = malloc(sizeof(struct driver_private)); | dp->drv.p = malloc(sizeof(struct driver_private)); | ||||
| @@ -99,9 +99,7 @@ static int gl_init_graphics(caca_display_t *dp) | |||||
| sscanf(geometry, "%ux%u", &width, &height); | sscanf(geometry, "%ux%u", &width, &height); | ||||
| #endif | #endif | ||||
| if(width && height) | |||||
| _cucul_set_canvas_size(dp->cv, width, height); | |||||
| _cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32); | |||||
| /* Load a libcucul internal font */ | /* Load a libcucul internal font */ | ||||
| fonts = cucul_get_font_list(); | fonts = cucul_get_font_list(); | ||||
| @@ -21,6 +21,7 @@ | |||||
| #if !defined(__KERNEL__) | #if !defined(__KERNEL__) | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <stdlib.h> | |||||
| #include "caca.h" | #include "caca.h" | ||||
| #include "caca_internals.h" | #include "caca_internals.h" | ||||
| @@ -29,6 +30,17 @@ | |||||
| static int raw_init_graphics(caca_display_t *dp) | static int raw_init_graphics(caca_display_t *dp) | ||||
| { | { | ||||
| unsigned int width = dp->cv->width, height = dp->cv->height; | |||||
| char const *geometry; | |||||
| #if defined(HAVE_GETENV) | |||||
| geometry = getenv("CACA_GEOMETRY"); | |||||
| if(geometry && *geometry) | |||||
| sscanf(geometry, "%ux%u", &width, &height); | |||||
| #endif | |||||
| _cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 24); | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -112,8 +112,8 @@ static int win32_init_graphics(caca_display_t *dp) | |||||
| return -1; | return -1; | ||||
| /* Set the new console size */ | /* Set the new console size */ | ||||
| size.X = dp->cv->width; | |||||
| size.Y = dp->cv->height; | |||||
| size.X = dp->cv->width ? dp->cv->width : 80; | |||||
| size.Y = dp->cv->height ? dp->cv->height : 25; | |||||
| SetConsoleScreenBufferSize(dp->drv.p->screen, size); | SetConsoleScreenBufferSize(dp->drv.p->screen, size); | ||||
| rect.Left = rect.Top = 0; | rect.Left = rect.Top = 0; | ||||
| @@ -67,7 +67,7 @@ static int x11_init_graphics(caca_display_t *dp) | |||||
| int (*old_error_handler)(Display *, XErrorEvent *); | int (*old_error_handler)(Display *, XErrorEvent *); | ||||
| char const *fonts[] = { NULL, "8x13bold", "fixed" }, **parser; | char const *fonts[] = { NULL, "8x13bold", "fixed" }, **parser; | ||||
| char const *geometry; | char const *geometry; | ||||
| unsigned int width = 0, height = 0; | |||||
| unsigned int width = dp->cv->width, height = dp->cv->height; | |||||
| int i; | int i; | ||||
| dp->drv.p = malloc(sizeof(struct driver_private)); | dp->drv.p = malloc(sizeof(struct driver_private)); | ||||
| @@ -78,8 +78,7 @@ static int x11_init_graphics(caca_display_t *dp) | |||||
| sscanf(geometry, "%ux%u", &width, &height); | sscanf(geometry, "%ux%u", &width, &height); | ||||
| #endif | #endif | ||||
| if(width && height) | |||||
| _cucul_set_canvas_size(dp->cv, width, height); | |||||
| _cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 32); | |||||
| dp->drv.p->dpy = XOpenDisplay(NULL); | dp->drv.p->dpy = XOpenDisplay(NULL); | ||||
| if(dp->drv.p->dpy == NULL) | if(dp->drv.p->dpy == NULL) | ||||
| @@ -43,9 +43,6 @@ | |||||
| * \e libcucul function to be called in a function. cucul_free_canvas() | * \e libcucul function to be called in a function. cucul_free_canvas() | ||||
| * should be called at the end of the program to free all allocated resources. | * should be called at the end of the program to free all allocated resources. | ||||
| * | * | ||||
| * If one of the desired canvas coordinates is zero, a default canvas size | |||||
| * of 80x32 is used instead. | |||||
| * | |||||
| * If an error occurs, NULL is returned and \b errno is set accordingly: | * If an error occurs, NULL is returned and \b errno is set accordingly: | ||||
| * - \c ENOMEM Not enough memory for the requested canvas size. | * - \c ENOMEM Not enough memory for the requested canvas size. | ||||
| * | * | ||||
| @@ -56,7 +53,6 @@ | |||||
| cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height) | cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height) | ||||
| { | { | ||||
| cucul_canvas_t *cv = malloc(sizeof(cucul_canvas_t)); | cucul_canvas_t *cv = malloc(sizeof(cucul_canvas_t)); | ||||
| int ret; | |||||
| if(!cv) | if(!cv) | ||||
| goto nomem; | goto nomem; | ||||
| @@ -88,15 +84,7 @@ cucul_canvas_t * cucul_create_canvas(unsigned int width, unsigned int height) | |||||
| cv->allchars[0] = NULL; | cv->allchars[0] = NULL; | ||||
| cv->allattr[0] = NULL; | cv->allattr[0] = NULL; | ||||
| /* Initialise to a default size. 80x32 is arbitrary but matches AAlib's | |||||
| * default X11 window. When a graphic driver attaches to us, it can set | |||||
| * a different size. */ | |||||
| if(width && height) | |||||
| ret = _cucul_set_canvas_size(cv, width, height); | |||||
| else | |||||
| ret = _cucul_set_canvas_size(cv, 80, 32); | |||||
| if(ret < 0) | |||||
| if(_cucul_set_canvas_size(cv, width, height) < 0) | |||||
| { | { | ||||
| #if defined(HAVE_ERRNO_H) | #if defined(HAVE_ERRNO_H) | ||||
| int saved_errno = errno; | int saved_errno = errno; | ||||