Correctly center window on creation
authorPatrice Mandin <patmandin@gmail.com>
Thu, 05 Aug 2004 19:43:07 +0000
changeset 9232748679027ff
parent 922 7b920743ce57
child 924 6e81ce1372d1
Correctly center window on creation
src/video/gem/SDL_gemvideo.c
     1.1 --- a/src/video/gem/SDL_gemvideo.c	Thu Aug 05 19:40:23 2004 +0000
     1.2 +++ b/src/video/gem/SDL_gemvideo.c	Thu Aug 05 19:43:07 2004 +0000
     1.3 @@ -644,20 +644,11 @@
     1.4  			modeflags |= SDL_SWSURFACE;
     1.5  		}
     1.6  	} else {
     1.7 -		int posx,posy;
     1.8  		short x2,y2,w2,h2;
     1.9  
    1.10  		GEM_UnlockScreen(this);
    1.11  
    1.12 -		/* Center our window */
    1.13 -		posx = GEM_desk_x;
    1.14 -		posy = GEM_desk_y;
    1.15 -		if (width<GEM_desk_w)
    1.16 -			posx += (GEM_desk_w - width) >> 1;
    1.17 -		if (height<GEM_desk_h)
    1.18 -			posy += (GEM_desk_h - height) >> 1;
    1.19 -
    1.20 -		/* Calculate our window size and position */
    1.21 +		/* Set window gadgets */
    1.22  		if (!(flags & SDL_NOFRAME)) {
    1.23  			GEM_win_type=NAME|MOVER|CLOSER|SMALLER;
    1.24  			if (flags & SDL_RESIZABLE) {
    1.25 @@ -669,14 +660,19 @@
    1.26  			modeflags |= SDL_NOFRAME;
    1.27  		}
    1.28  
    1.29 -		if (!wind_calc(WC_BORDER, GEM_win_type, posx, posy, width, height, &x2, &y2, &w2, &h2)) {
    1.30 +		/* Calculate window size */
    1.31 +		if (!wind_calc(WC_BORDER, GEM_win_type, 0,0,width,height, &x2,&y2,&w2,&h2)) {
    1.32  			GEM_FreeBuffers(this);
    1.33  			SDL_SetError("Can not calculate window attributes\n");
    1.34  			return NULL;
    1.35  		}
    1.36  
    1.37 +		/* Center window */
    1.38 +		x2 = GEM_desk_x+((GEM_desk_w-w2)>>1);
    1.39 +		y2 = GEM_desk_y+((GEM_desk_h-h2)>>1);
    1.40 +
    1.41  		/* Create window */
    1.42 -		GEM_handle=wind_create(GEM_win_type, x2, y2, w2, h2);
    1.43 +		GEM_handle=wind_create(GEM_win_type, x2,y2,w2,h2);
    1.44  		if (GEM_handle<0) {
    1.45  			GEM_FreeBuffers(this);
    1.46  			SDL_SetError("Can not create window\n");