comparison src/video/gem/SDL_gemvideo.c @ 925:15ff92ae7e1b

Do not destroy window on resize, so we can go back to original size from maximized size
author Patrice Mandin <patmandin@gmail.com>
date Mon, 09 Aug 2004 11:53:14 +0000
parents 6e81ce1372d1
children 83db694556eb
comparison
equal deleted inserted replaced
924:6e81ce1372d1 925:15ff92ae7e1b
477 477
478 if ( GEM_buffer1 ) { 478 if ( GEM_buffer1 ) {
479 free( GEM_buffer1 ); 479 free( GEM_buffer1 );
480 GEM_buffer1=NULL; 480 GEM_buffer1=NULL;
481 } 481 }
482
483 /* Destroy window */
484 if (GEM_handle>=0) {
485 wind_close(GEM_handle);
486 wind_delete(GEM_handle);
487 GEM_handle=-1;
488 }
489 } 482 }
490 483
491 static void GEM_ClearRect(_THIS, short *rect) 484 static void GEM_ClearRect(_THIS, short *rect)
492 { 485 {
493 short oldrgb[3], rgb[3]={0,0,0}; 486 short oldrgb[3], rgb[3]={0,0,0};
547 int width, int height, int bpp, Uint32 flags) 540 int width, int height, int bpp, Uint32 flags)
548 { 541 {
549 int maxwidth, maxheight; 542 int maxwidth, maxheight;
550 Uint32 modeflags, screensize; 543 Uint32 modeflags, screensize;
551 SDL_bool use_shadow1, use_shadow2; 544 SDL_bool use_shadow1, use_shadow2;
552
553 GEM_FreeBuffers(this);
554 545
555 /*--- Verify if asked mode can be used ---*/ 546 /*--- Verify if asked mode can be used ---*/
556 if (flags & SDL_FULLSCREEN) { 547 if (flags & SDL_FULLSCREEN) {
557 maxwidth=VDI_w; 548 maxwidth=VDI_w;
558 maxheight=VDI_h; 549 maxheight=VDI_h;
583 #ifdef DEBUG_VIDEO_GEM 574 #ifdef DEBUG_VIDEO_GEM
584 printf("sdl:video:gem: setvideomode(): %dx%dx%d = %d\n", width, height, bpp, screensize); 575 printf("sdl:video:gem: setvideomode(): %dx%dx%d = %d\n", width, height, bpp, screensize);
585 #endif 576 #endif
586 577
587 /*--- Allocate shadow buffers if needed, and conversion operations ---*/ 578 /*--- Allocate shadow buffers if needed, and conversion operations ---*/
579 GEM_FreeBuffers(this);
580
588 GEM_bufops=0; 581 GEM_bufops=0;
589 use_shadow1=use_shadow2=SDL_FALSE; 582 use_shadow1=use_shadow2=SDL_FALSE;
590 if (VDI_screen && (flags & SDL_FULLSCREEN)) { 583 if (VDI_screen && (flags & SDL_FULLSCREEN)) {
591 if (VDI_format==VDI_FORMAT_INTER) { 584 if (VDI_format==VDI_FORMAT_INTER) {
592 use_shadow1=SDL_TRUE; 585 use_shadow1=SDL_TRUE;
631 if (VDI_bpp == 8) { 624 if (VDI_bpp == 8) {
632 modeflags |= SDL_HWPALETTE; 625 modeflags |= SDL_HWPALETTE;
633 } 626 }
634 627
635 if (flags & SDL_FULLSCREEN) { 628 if (flags & SDL_FULLSCREEN) {
629 /* Close window if needed */
630 if (GEM_handle >= 0) {
631 wind_close(GEM_handle);
632 }
633
636 GEM_LockScreen(this); 634 GEM_LockScreen(this);
637 635
638 GEM_ClearScreen(this); 636 GEM_ClearScreen(this);
639 637
640 modeflags |= SDL_FULLSCREEN; 638 modeflags |= SDL_FULLSCREEN;
642 modeflags |= SDL_HWSURFACE; 640 modeflags |= SDL_HWSURFACE;
643 } else { 641 } else {
644 modeflags |= SDL_SWSURFACE; 642 modeflags |= SDL_SWSURFACE;
645 } 643 }
646 } else { 644 } else {
645 int old_win_type;
647 short x2,y2,w2,h2; 646 short x2,y2,w2,h2;
648 647
649 GEM_UnlockScreen(this); 648 GEM_UnlockScreen(this);
650 649
651 /* Set window gadgets */ 650 /* Set window gadgets */
651 old_win_type = GEM_win_type;
652 if (!(flags & SDL_NOFRAME)) { 652 if (!(flags & SDL_NOFRAME)) {
653 GEM_win_type=NAME|MOVER|CLOSER|SMALLER; 653 GEM_win_type=NAME|MOVER|CLOSER|SMALLER;
654 if (flags & SDL_RESIZABLE) { 654 if (flags & SDL_RESIZABLE) {
655 GEM_win_type |= FULLER|SIZER; 655 GEM_win_type |= FULLER|SIZER;
656 modeflags |= SDL_RESIZABLE; 656 modeflags |= SDL_RESIZABLE;
657 } 657 }
658 } else { 658 } else {
659 GEM_win_type=0; 659 GEM_win_type=0;
660 modeflags |= SDL_NOFRAME; 660 modeflags |= SDL_NOFRAME;
661 } 661 }
662 662 modeflags |= SDL_SWSURFACE;
663 /* Calculate window size */ 663
664 if (!wind_calc(WC_BORDER, GEM_win_type, 0,0,width,height, &x2,&y2,&w2,&h2)) { 664 /* Recreate window ? only for different widget or non-created window */
665 GEM_FreeBuffers(this); 665 if ((old_win_type == GEM_win_type) && (GEM_handle >= 0)) {
666 SDL_SetError("Can not calculate window attributes"); 666 wind_get(GEM_handle, WF_CURRXYWH, &x2,&y2,&w2,&h2);
667 return NULL; 667 } else {
668 } 668 /* Calculate window size */
669 669 if (!wind_calc(WC_BORDER, GEM_win_type, 0,0,width,height, &x2,&y2,&w2,&h2)) {
670 /* Center window */ 670 GEM_FreeBuffers(this);
671 x2 = GEM_desk_x+((GEM_desk_w-w2)>>1); 671 SDL_SetError("Can not calculate window attributes");
672 y2 = GEM_desk_y+((GEM_desk_h-h2)>>1); 672 return NULL;
673 673 }
674 /* Create window */ 674
675 GEM_handle=wind_create(GEM_win_type, x2,y2,w2,h2); 675 /* Center window */
676 if (GEM_handle<0) { 676 x2 = GEM_desk_x+((GEM_desk_w-w2)>>1);
677 GEM_FreeBuffers(this); 677 y2 = GEM_desk_y+((GEM_desk_h-h2)>>1);
678 SDL_SetError("Can not create window"); 678
679 return NULL; 679 /* Destroy existing window */
680 } 680 if (GEM_handle >= 0) {
681 wind_close(GEM_handle);
682 wind_delete(GEM_handle);
683 }
684
685 /* Create window */
686 GEM_handle=wind_create(GEM_win_type, x2,y2,w2,h2);
687 if (GEM_handle<0) {
688 GEM_FreeBuffers(this);
689 SDL_SetError("Can not create window");
690 return NULL;
691 }
681 692
682 #ifdef DEBUG_VIDEO_GEM 693 #ifdef DEBUG_VIDEO_GEM
683 printf("sdl:video:gem: handle=%d\n", GEM_handle); 694 printf("sdl:video:gem: handle=%d\n", GEM_handle);
684 #endif 695 #endif
685 696
686 /* Setup window name */ 697 /* Setup window name */
687 wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0); 698 wind_set(GEM_handle,WF_NAME,(short)(((unsigned long)GEM_title_name)>>16),(short)(((unsigned long)GEM_title_name) & 0xffff),0,0);
688 GEM_refresh_name = SDL_FALSE; 699 GEM_refresh_name = SDL_FALSE;
700 }
689 701
690 /* Open the window */ 702 /* Open the window */
691 wind_open(GEM_handle,x2,y2,w2,h2); 703 wind_open(GEM_handle,x2,y2,w2,h2);
692
693 modeflags |= SDL_SWSURFACE;
694 } 704 }
695 705
696 /* Set up the new mode framebuffer */ 706 /* Set up the new mode framebuffer */
697 current->flags = modeflags; 707 current->flags = modeflags;
698 current->w = width; 708 current->w = width;
1004 { 1014 {
1005 SDL_AtariXbios_RestoreVectors(); 1015 SDL_AtariXbios_RestoreVectors();
1006 1016
1007 GEM_FreeBuffers(this); 1017 GEM_FreeBuffers(this);
1008 1018
1019 /* Destroy window */
1020 if (GEM_handle>=0) {
1021 wind_close(GEM_handle);
1022 wind_delete(GEM_handle);
1023 GEM_handle=-1;
1024 }
1025
1009 GEM_UnlockScreen(this); 1026 GEM_UnlockScreen(this);
1010 1027
1011 appl_exit(); 1028 appl_exit();
1012 1029
1013 /* Restore palette */ 1030 /* Restore palette */