comparison src/video/gem/SDL_gemvideo.c @ 923:2748679027ff

Correctly center window on creation
author Patrice Mandin <patmandin@gmail.com>
date Thu, 05 Aug 2004 19:43:07 +0000
parents 6126849e59a6
children 6e81ce1372d1
comparison
equal deleted inserted replaced
922:7b920743ce57 923:2748679027ff
642 modeflags |= SDL_HWSURFACE; 642 modeflags |= SDL_HWSURFACE;
643 } else { 643 } else {
644 modeflags |= SDL_SWSURFACE; 644 modeflags |= SDL_SWSURFACE;
645 } 645 }
646 } else { 646 } else {
647 int posx,posy;
648 short x2,y2,w2,h2; 647 short x2,y2,w2,h2;
649 648
650 GEM_UnlockScreen(this); 649 GEM_UnlockScreen(this);
651 650
652 /* Center our window */ 651 /* Set window gadgets */
653 posx = GEM_desk_x;
654 posy = GEM_desk_y;
655 if (width<GEM_desk_w)
656 posx += (GEM_desk_w - width) >> 1;
657 if (height<GEM_desk_h)
658 posy += (GEM_desk_h - height) >> 1;
659
660 /* Calculate our window size and position */
661 if (!(flags & SDL_NOFRAME)) { 652 if (!(flags & SDL_NOFRAME)) {
662 GEM_win_type=NAME|MOVER|CLOSER|SMALLER; 653 GEM_win_type=NAME|MOVER|CLOSER|SMALLER;
663 if (flags & SDL_RESIZABLE) { 654 if (flags & SDL_RESIZABLE) {
664 GEM_win_type |= FULLER|SIZER; 655 GEM_win_type |= FULLER|SIZER;
665 modeflags |= SDL_RESIZABLE; 656 modeflags |= SDL_RESIZABLE;
667 } else { 658 } else {
668 GEM_win_type=0; 659 GEM_win_type=0;
669 modeflags |= SDL_NOFRAME; 660 modeflags |= SDL_NOFRAME;
670 } 661 }
671 662
672 if (!wind_calc(WC_BORDER, GEM_win_type, posx, posy, width, height, &x2, &y2, &w2, &h2)) { 663 /* Calculate window size */
664 if (!wind_calc(WC_BORDER, GEM_win_type, 0,0,width,height, &x2,&y2,&w2,&h2)) {
673 GEM_FreeBuffers(this); 665 GEM_FreeBuffers(this);
674 SDL_SetError("Can not calculate window attributes\n"); 666 SDL_SetError("Can not calculate window attributes\n");
675 return NULL; 667 return NULL;
676 } 668 }
677 669
670 /* Center window */
671 x2 = GEM_desk_x+((GEM_desk_w-w2)>>1);
672 y2 = GEM_desk_y+((GEM_desk_h-h2)>>1);
673
678 /* Create window */ 674 /* Create window */
679 GEM_handle=wind_create(GEM_win_type, x2, y2, w2, h2); 675 GEM_handle=wind_create(GEM_win_type, x2,y2,w2,h2);
680 if (GEM_handle<0) { 676 if (GEM_handle<0) {
681 GEM_FreeBuffers(this); 677 GEM_FreeBuffers(this);
682 SDL_SetError("Can not create window\n"); 678 SDL_SetError("Can not create window\n");
683 return NULL; 679 return NULL;
684 } 680 }