Skip to content

Commit

Permalink
Correctly center window on creation
Browse files Browse the repository at this point in the history
  • Loading branch information
pmandin committed Aug 5, 2004
1 parent 91cfbe0 commit 347d51e
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/video/gem/SDL_gemvideo.c
Expand Up @@ -644,20 +644,11 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
modeflags |= SDL_SWSURFACE; modeflags |= SDL_SWSURFACE;
} }
} else { } else {
int posx,posy;
short x2,y2,w2,h2; short x2,y2,w2,h2;


GEM_UnlockScreen(this); GEM_UnlockScreen(this);


/* Center our window */ /* Set window gadgets */
posx = GEM_desk_x;
posy = GEM_desk_y;
if (width<GEM_desk_w)
posx += (GEM_desk_w - width) >> 1;
if (height<GEM_desk_h)
posy += (GEM_desk_h - height) >> 1;

/* Calculate our window size and position */
if (!(flags & SDL_NOFRAME)) { if (!(flags & SDL_NOFRAME)) {
GEM_win_type=NAME|MOVER|CLOSER|SMALLER; GEM_win_type=NAME|MOVER|CLOSER|SMALLER;
if (flags & SDL_RESIZABLE) { if (flags & SDL_RESIZABLE) {
Expand All @@ -669,14 +660,19 @@ SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface *current,
modeflags |= SDL_NOFRAME; modeflags |= SDL_NOFRAME;
} }


if (!wind_calc(WC_BORDER, GEM_win_type, posx, posy, width, height, &x2, &y2, &w2, &h2)) { /* Calculate window size */
if (!wind_calc(WC_BORDER, GEM_win_type, 0,0,width,height, &x2,&y2,&w2,&h2)) {
GEM_FreeBuffers(this); GEM_FreeBuffers(this);
SDL_SetError("Can not calculate window attributes\n"); SDL_SetError("Can not calculate window attributes\n");
return NULL; return NULL;
} }


/* Center window */
x2 = GEM_desk_x+((GEM_desk_w-w2)>>1);
y2 = GEM_desk_y+((GEM_desk_h-h2)>>1);

/* Create window */ /* Create window */
GEM_handle=wind_create(GEM_win_type, x2, y2, w2, h2); GEM_handle=wind_create(GEM_win_type, x2,y2,w2,h2);
if (GEM_handle<0) { if (GEM_handle<0) {
GEM_FreeBuffers(this); GEM_FreeBuffers(this);
SDL_SetError("Can not create window\n"); SDL_SetError("Can not create window\n");
Expand Down

0 comments on commit 347d51e

Please sign in to comment.