Do not destroy window on resize, so we can go back to original size from maximized size
authorPatrice Mandin <patmandin@gmail.com>
Mon, 09 Aug 2004 11:53:14 +0000
changeset 92515ff92ae7e1b
parent 924 6e81ce1372d1
child 926 83db694556eb
Do not destroy window on resize, so we can go back to original size from maximized size
src/video/gem/SDL_gemvideo.c
     1.1 --- a/src/video/gem/SDL_gemvideo.c	Thu Aug 05 19:50:06 2004 +0000
     1.2 +++ b/src/video/gem/SDL_gemvideo.c	Mon Aug 09 11:53:14 2004 +0000
     1.3 @@ -479,13 +479,6 @@
     1.4  		free( GEM_buffer1 );
     1.5  		GEM_buffer1=NULL;
     1.6  	}
     1.7 -
     1.8 -	/* Destroy window */
     1.9 -	if (GEM_handle>=0) {
    1.10 -		wind_close(GEM_handle);
    1.11 -		wind_delete(GEM_handle);
    1.12 -		GEM_handle=-1;
    1.13 -	}
    1.14  }
    1.15  
    1.16  static void GEM_ClearRect(_THIS, short *rect)
    1.17 @@ -550,8 +543,6 @@
    1.18  	Uint32 modeflags, screensize;
    1.19  	SDL_bool use_shadow1, use_shadow2;
    1.20  
    1.21 -	GEM_FreeBuffers(this);
    1.22 -
    1.23  	/*--- Verify if asked mode can be used ---*/
    1.24  	if (flags & SDL_FULLSCREEN) {
    1.25  		maxwidth=VDI_w;
    1.26 @@ -585,6 +576,8 @@
    1.27  #endif
    1.28  
    1.29  	/*--- Allocate shadow buffers if needed, and conversion operations ---*/
    1.30 +	GEM_FreeBuffers(this);
    1.31 +
    1.32  	GEM_bufops=0;
    1.33  	use_shadow1=use_shadow2=SDL_FALSE;
    1.34  	if (VDI_screen && (flags & SDL_FULLSCREEN)) {
    1.35 @@ -633,6 +626,11 @@
    1.36  	}
    1.37  
    1.38  	if (flags & SDL_FULLSCREEN) {
    1.39 +		/* Close window if needed */
    1.40 +		if (GEM_handle >= 0) {
    1.41 +			wind_close(GEM_handle);
    1.42 +		}
    1.43 +
    1.44  		GEM_LockScreen(this);
    1.45  
    1.46  		GEM_ClearScreen(this);
    1.47 @@ -644,11 +642,13 @@
    1.48  			modeflags |= SDL_SWSURFACE;
    1.49  		}
    1.50  	} else {
    1.51 +		int old_win_type;
    1.52  		short x2,y2,w2,h2;
    1.53  
    1.54  		GEM_UnlockScreen(this);
    1.55  
    1.56  		/* Set window gadgets */
    1.57 +		old_win_type = GEM_win_type;
    1.58  		if (!(flags & SDL_NOFRAME)) {
    1.59  			GEM_win_type=NAME|MOVER|CLOSER|SMALLER;
    1.60  			if (flags & SDL_RESIZABLE) {
    1.61 @@ -659,38 +659,48 @@
    1.62  			GEM_win_type=0;
    1.63  			modeflags |= SDL_NOFRAME;
    1.64  		}
    1.65 +		modeflags |= SDL_SWSURFACE;
    1.66  
    1.67 -		/* Calculate window size */
    1.68 -		if (!wind_calc(WC_BORDER, GEM_win_type, 0,0,width,height, &x2,&y2,&w2,&h2)) {
    1.69 -			GEM_FreeBuffers(this);
    1.70 -			SDL_SetError("Can not calculate window attributes");
    1.71 -			return NULL;
    1.72 -		}
    1.73 +		/* Recreate window ? only for different widget or non-created window */
    1.74 +		if ((old_win_type == GEM_win_type) && (GEM_handle >= 0)) {
    1.75 +			wind_get(GEM_handle, WF_CURRXYWH, &x2,&y2,&w2,&h2);
    1.76 +		} else {
    1.77 +			/* Calculate window size */
    1.78 +			if (!wind_calc(WC_BORDER, GEM_win_type, 0,0,width,height, &x2,&y2,&w2,&h2)) {
    1.79 +				GEM_FreeBuffers(this);
    1.80 +				SDL_SetError("Can not calculate window attributes");
    1.81 +				return NULL;
    1.82 +			}
    1.83  
    1.84 -		/* Center window */
    1.85 -		x2 = GEM_desk_x+((GEM_desk_w-w2)>>1);
    1.86 -		y2 = GEM_desk_y+((GEM_desk_h-h2)>>1);
    1.87 +			/* Center window */
    1.88 +			x2 = GEM_desk_x+((GEM_desk_w-w2)>>1);
    1.89 +			y2 = GEM_desk_y+((GEM_desk_h-h2)>>1);
    1.90  
    1.91 -		/* Create window */
    1.92 -		GEM_handle=wind_create(GEM_win_type, x2,y2,w2,h2);
    1.93 -		if (GEM_handle<0) {
    1.94 -			GEM_FreeBuffers(this);
    1.95 -			SDL_SetError("Can not create window");
    1.96 -			return NULL;
    1.97 -		}
    1.98 +			/* Destroy existing window */
    1.99 +			if (GEM_handle >= 0) {
   1.100 +				wind_close(GEM_handle);
   1.101 +				wind_delete(GEM_handle);
   1.102 +			}
   1.103 +
   1.104 +			/* Create window */
   1.105 +			GEM_handle=wind_create(GEM_win_type, x2,y2,w2,h2);
   1.106 +			if (GEM_handle<0) {
   1.107 +				GEM_FreeBuffers(this);
   1.108 +				SDL_SetError("Can not create window");
   1.109 +				return NULL;
   1.110 +			}
   1.111  
   1.112  #ifdef DEBUG_VIDEO_GEM
   1.113 -		printf("sdl:video:gem: handle=%d\n", GEM_handle);
   1.114 +			printf("sdl:video:gem: handle=%d\n", GEM_handle);
   1.115  #endif
   1.116  
   1.117 -		/* Setup window name */
   1.118 -		wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0);
   1.119 -		GEM_refresh_name = SDL_FALSE;
   1.120 +			/* Setup window name */
   1.121 +			wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0);
   1.122 +			GEM_refresh_name = SDL_FALSE;
   1.123 +		}
   1.124  	
   1.125  		/* Open the window */
   1.126  		wind_open(GEM_handle,x2,y2,w2,h2);
   1.127 -
   1.128 -		modeflags |= SDL_SWSURFACE;
   1.129  	}
   1.130  
   1.131  	/* Set up the new mode framebuffer */
   1.132 @@ -1006,6 +1016,13 @@
   1.133  
   1.134  	GEM_FreeBuffers(this);
   1.135  
   1.136 +	/* Destroy window */
   1.137 +	if (GEM_handle>=0) {
   1.138 +		wind_close(GEM_handle);
   1.139 +		wind_delete(GEM_handle);
   1.140 +		GEM_handle=-1;
   1.141 +	}
   1.142 +
   1.143  	GEM_UnlockScreen(this);
   1.144  
   1.145  	appl_exit();