Resize tweaks -- prevent crashes when sizing downward.

This commit is contained in:
William McBrine
2007-06-14 15:58:20 +00:00
parent 55cdf01e92
commit 59fab631a0
3 changed files with 22 additions and 14 deletions

View File

@@ -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:

View File

@@ -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;
}

View File

@@ -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 <curspriv.h>
@@ -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;