From 59fab631a0c265cee79ef36e3b08fd896d2b72b0 Mon Sep 17 00:00:00 2001 From: William McBrine Date: Thu, 14 Jun 2007 15:58:20 +0000 Subject: [PATCH] Resize tweaks -- prevent crashes when sizing downward. --- sdl1/pdckbd.c | 13 +++++++++---- sdl1/pdcscrn.c | 20 +++++++++++--------- sdl1/pdcsdl.h | 3 ++- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/sdl1/pdckbd.c b/sdl1/pdckbd.c index a9de5bea..c1a33f4e 100644 --- a/sdl1/pdckbd.c +++ b/sdl1/pdckbd.c @@ -13,7 +13,7 @@ #include "pdcsdl.h" -RCSID("$Id: pdckbd.c,v 1.12 2007/06/14 14:43:53 wmcbrine Exp $") +RCSID("$Id: pdckbd.c,v 1.13 2007/06/14 15:58:20 wmcbrine Exp $") /*man-start************************************************************** @@ -332,9 +332,14 @@ int PDC_get_key(void) case SDL_QUIT: exit(1); case SDL_VIDEORESIZE: - pdc_sheight = event.resize.h; - pdc_swidth = event.resize.w; - return KEY_RESIZE; + if (pdc_own_screen) + { + pdc_sheight = event.resize.h; + pdc_swidth = event.resize.w; + SP->resized = TRUE; + return KEY_RESIZE; + } + break; case SDL_MOUSEMOTION: SDL_ShowCursor(SDL_ENABLE); case SDL_MOUSEBUTTONUP: diff --git a/sdl1/pdcscrn.c b/sdl1/pdcscrn.c index dd93e5aa..e386d82b 100644 --- a/sdl1/pdcscrn.c +++ b/sdl1/pdcscrn.c @@ -13,7 +13,7 @@ #include "pdcsdl.h" -RCSID("$Id: pdcscrn.c,v 1.11 2007/06/14 14:43:53 wmcbrine Exp $") +RCSID("$Id: pdcscrn.c,v 1.12 2007/06/14 15:58:20 wmcbrine Exp $") #include "deffont.h" #include "deficon.h" @@ -22,8 +22,7 @@ SDL_Surface *pdc_screen = NULL, *pdc_font = NULL, *pdc_icon = NULL; SDL_Color pdc_color[16]; Uint32 pdc_mapped[16]; int pdc_fheight, pdc_fwidth, pdc_sheight, pdc_swidth; - -static bool own_screen; +bool pdc_own_screen; void PDC_scr_close(void) { @@ -52,9 +51,9 @@ int PDC_scr_open(int argc, char **argv) if (!SP || !pdc_atrtab) return ERR; - own_screen = !pdc_screen; + pdc_own_screen = !pdc_screen; - if (own_screen) + if (pdc_own_screen) { if (SDL_Init(SDL_INIT_VIDEO) < 0) { @@ -85,7 +84,7 @@ int PDC_scr_open(int argc, char **argv) SP->lines = PDC_get_rows(); SP->cols = PDC_get_columns(); - if (own_screen && !pdc_icon) + if (pdc_own_screen && !pdc_icon) { pdc_icon = SDL_LoadBMP("pdcicon.bmp"); @@ -97,7 +96,7 @@ int PDC_scr_open(int argc, char **argv) SDL_WM_SetIcon(pdc_icon, NULL); } - if (own_screen) + if (pdc_own_screen) pdc_screen = SDL_SetVideoMode(SP->cols * pdc_fwidth, SP->lines * pdc_fheight, 0, SDL_SWSURFACE|SDL_ANYFORMAT|SDL_RESIZABLE); @@ -130,7 +129,7 @@ int PDC_scr_open(int argc, char **argv) PDC_mouse_set(); - if (own_screen) + if (pdc_own_screen) PDC_set_title(argc ? argv[1] : "PDCurses"); PDC_flushinp(); @@ -147,7 +146,7 @@ int PDC_scr_open(int argc, char **argv) int PDC_resize_screen(int nlines, int ncols) { - if (!own_screen) + if (!pdc_own_screen) return ERR; if (nlines && ncols) @@ -161,6 +160,9 @@ int PDC_resize_screen(int nlines, int ncols) pdc_screen = SDL_SetVideoMode(pdc_swidth, pdc_sheight, 0, SDL_SWSURFACE|SDL_ANYFORMAT|SDL_RESIZABLE); + SP->resized = FALSE; + SP->cursrow = SP->curscol = 0; + return OK; } diff --git a/sdl1/pdcsdl.h b/sdl1/pdcsdl.h index 46179a9f..90f02f5b 100644 --- a/sdl1/pdcsdl.h +++ b/sdl1/pdcsdl.h @@ -11,7 +11,7 @@ * See the file maintain.er for details of the current maintainer. * ************************************************************************/ -/* $Id: pdcsdl.h,v 1.3 2007/06/13 19:53:36 wmcbrine Exp $ */ +/* $Id: pdcsdl.h,v 1.4 2007/06/14 15:58:20 wmcbrine Exp $ */ #include @@ -21,3 +21,4 @@ extern SDL_Surface *pdc_screen, *pdc_font; extern SDL_Color pdc_color[16]; extern Uint32 pdc_mapped[16]; extern int pdc_fheight, pdc_fwidth, pdc_sheight, pdc_swidth; +extern bool pdc_own_screen;