Mercurial > sdl-ios-xcode
comparison src/video/cybergfx/SDL_cgxvideo.c @ 21:75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
author | Sam Lantinga <slouken@lokigames.com> |
---|---|
date | Thu, 10 May 2001 20:13:29 +0000 |
parents | 74212992fb08 |
children | e8157fcb3114 |
comparison
equal
deleted
inserted
replaced
20:3dc008dc229d | 21:75a95f82bc1f |
---|---|
62 /* Initialization/Query functions */ | 62 /* Initialization/Query functions */ |
63 static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat); | 63 static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat); |
64 static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | 64 static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); |
65 static int CGX_ToggleFullScreen(_THIS, int on); | 65 static int CGX_ToggleFullScreen(_THIS, int on); |
66 static void CGX_UpdateMouse(_THIS); | 66 static void CGX_UpdateMouse(_THIS); |
67 static int CGX_SetColors(_THIS, int firstcolor, int ncolors, | 67 static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors); |
68 SDL_Color *colors); | |
69 static void CGX_VideoQuit(_THIS); | 68 static void CGX_VideoQuit(_THIS); |
70 | 69 |
71 /* CGX driver bootstrap functions */ | 70 /* CGX driver bootstrap functions */ |
72 | 71 |
73 struct Library *CyberGfxBase=NULL; | 72 struct Library *CyberGfxBase=NULL; |
108 free(SDL_RastPort); | 107 free(SDL_RastPort); |
109 SDL_RastPort=NULL; | 108 SDL_RastPort=NULL; |
110 this->hidden->dbuffer=0; | 109 this->hidden->dbuffer=0; |
111 } | 110 } |
112 CloseScreen(GFX_Display); | 111 CloseScreen(GFX_Display); |
112 currently_fullscreen=0; | |
113 } | 113 } |
114 else | 114 else |
115 UnlockPubScreen(NULL,GFX_Display); | 115 UnlockPubScreen(NULL,GFX_Display); |
116 | 116 |
117 GFX_Display = NULL; | 117 GFX_Display = NULL; |
171 device->VideoInit = CGX_VideoInit; | 171 device->VideoInit = CGX_VideoInit; |
172 device->ListModes = CGX_ListModes; | 172 device->ListModes = CGX_ListModes; |
173 device->SetVideoMode = CGX_SetVideoMode; | 173 device->SetVideoMode = CGX_SetVideoMode; |
174 device->ToggleFullScreen = CGX_ToggleFullScreen; | 174 device->ToggleFullScreen = CGX_ToggleFullScreen; |
175 device->UpdateMouse = CGX_UpdateMouse; | 175 device->UpdateMouse = CGX_UpdateMouse; |
176 #ifdef XFREE86_XV | |
177 device->CreateYUVOverlay = X11_CreateYUVOverlay; | |
178 #endif | |
176 device->SetColors = CGX_SetColors; | 179 device->SetColors = CGX_SetColors; |
177 device->UpdateRects = NULL; | 180 device->UpdateRects = NULL; |
178 device->VideoQuit = CGX_VideoQuit; | 181 device->VideoQuit = CGX_VideoQuit; |
179 device->AllocHWSurface = CGX_AllocHWSurface; | 182 device->AllocHWSurface = CGX_AllocHWSurface; |
180 device->CheckHWBlit = CGX_CheckHWBlit; | 183 device->CheckHWBlit = CGX_CheckHWBlit; |
190 device->GL_GetProcAddress = X11_GL_GetProcAddress; | 193 device->GL_GetProcAddress = X11_GL_GetProcAddress; |
191 device->GL_GetAttribute = X11_GL_GetAttribute; | 194 device->GL_GetAttribute = X11_GL_GetAttribute; |
192 device->GL_MakeCurrent = X11_GL_MakeCurrent; | 195 device->GL_MakeCurrent = X11_GL_MakeCurrent; |
193 device->GL_SwapBuffers = X11_GL_SwapBuffers; | 196 device->GL_SwapBuffers = X11_GL_SwapBuffers; |
194 #endif | 197 #endif |
198 device->SetIcon = CGX_SetIcon; | |
195 device->SetCaption = CGX_SetCaption; | 199 device->SetCaption = CGX_SetCaption; |
196 device->SetIcon = CGX_SetIcon; | |
197 device->IconifyWindow = NULL; /* CGX_IconifyWindow; */ | 200 device->IconifyWindow = NULL; /* CGX_IconifyWindow; */ |
198 device->GrabInput = NULL /* CGX_GrabInput*/; | 201 device->GrabInput = NULL /* CGX_GrabInput*/; |
199 device->GetWMInfo = CGX_GetWMInfo; | 202 device->GetWMInfo = CGX_GetWMInfo; |
200 device->FreeWMCursor = amiga_FreeWMCursor; | 203 device->FreeWMCursor = amiga_FreeWMCursor; |
201 device->CreateWMCursor = amiga_CreateWMCursor; | 204 device->CreateWMCursor = amiga_CreateWMCursor; |
209 | 212 |
210 return device; | 213 return device; |
211 } | 214 } |
212 | 215 |
213 VideoBootStrap CGX_bootstrap = { | 216 VideoBootStrap CGX_bootstrap = { |
214 "CGX", "Amiga CyberGFX video", | 217 "CGX", "AmigaOS CyberGraphics", CGX_Available, CGX_CreateDevice |
215 CGX_Available, CGX_CreateDevice | |
216 }; | 218 }; |
217 | 219 |
220 #if 0 | |
221 | |
222 /* Create auxiliary (toplevel) windows with the current visual */ | |
223 static void create_aux_windows(_THIS) | |
224 { | |
225 XSetWindowAttributes xattr; | |
226 XWMHints *hints; | |
227 XTextProperty titleprop, iconprop; | |
228 int def_vis = (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen)); | |
229 | |
230 /* Don't create any extra windows if we are being managed */ | |
231 if ( SDL_windowid ) { | |
232 FSwindow = 0; | |
233 WMwindow = strtol(SDL_windowid, NULL, 0); | |
234 return; | |
235 } | |
236 | |
237 if(FSwindow) | |
238 XDestroyWindow(SDL_Display, FSwindow); | |
239 | |
240 xattr.override_redirect = True; | |
241 xattr.background_pixel = def_vis ? BlackPixel(SDL_Display, SDL_Screen) : 0; | |
242 xattr.border_pixel = 0; | |
243 xattr.colormap = SDL_XColorMap; | |
244 | |
245 FSwindow = XCreateWindow(SDL_Display, SDL_Root, 0, 0, 32, 32, 0, | |
246 this->hidden->depth, InputOutput, SDL_Visual, | |
247 CWOverrideRedirect | CWBackPixel | CWBorderPixel | |
248 | CWColormap, | |
249 &xattr); | |
250 | |
251 XSelectInput(SDL_Display, FSwindow, StructureNotifyMask); | |
252 | |
253 /* Tell KDE to keep the fullscreen window on top */ | |
254 { | |
255 XEvent ev; | |
256 long mask; | |
257 | |
258 memset(&ev, 0, sizeof(ev)); | |
259 ev.xclient.type = ClientMessage; | |
260 ev.xclient.window = SDL_Root; | |
261 ev.xclient.message_type = XInternAtom(SDL_Display, | |
262 "KWM_KEEP_ON_TOP", False); | |
263 ev.xclient.format = 32; | |
264 ev.xclient.data.l[0] = FSwindow; | |
265 ev.xclient.data.l[1] = CurrentTime; | |
266 mask = SubstructureRedirectMask; | |
267 XSendEvent(SDL_Display, SDL_Root, False, mask, &ev); | |
268 } | |
269 | |
270 hints = NULL; | |
271 titleprop.value = iconprop.value = NULL; | |
272 if(WMwindow) { | |
273 /* All window attributes must survive the recreation */ | |
274 hints = XGetWMHints(SDL_Display, WMwindow); | |
275 XGetWMName(SDL_Display, WMwindow, &titleprop); | |
276 XGetWMIconName(SDL_Display, WMwindow, &iconprop); | |
277 XDestroyWindow(SDL_Display, WMwindow); | |
278 } | |
279 | |
280 /* Create the window for windowed management */ | |
281 /* (reusing the xattr structure above) */ | |
282 WMwindow = XCreateWindow(SDL_Display, SDL_Root, 0, 0, 32, 32, 0, | |
283 this->hidden->depth, InputOutput, SDL_Visual, | |
284 CWBackPixel | CWBorderPixel | CWColormap, | |
285 &xattr); | |
286 | |
287 /* Set the input hints so we get keyboard input */ | |
288 if(!hints) { | |
289 hints = XAllocWMHints(); | |
290 hints->input = True; | |
291 hints->flags = InputHint; | |
292 } | |
293 XSetWMHints(SDL_Display, WMwindow, hints); | |
294 XFree(hints); | |
295 if(titleprop.value) { | |
296 XSetWMName(SDL_Display, WMwindow, &titleprop); | |
297 XFree(titleprop.value); | |
298 } | |
299 if(iconprop.value) { | |
300 XSetWMIconName(SDL_Display, WMwindow, &iconprop); | |
301 XFree(iconprop.value); | |
302 } | |
303 | |
304 XSelectInput(SDL_Display, WMwindow, | |
305 FocusChangeMask | KeyPressMask | KeyReleaseMask | |
306 | PropertyChangeMask | StructureNotifyMask); | |
307 | |
308 /* Set the class hints so we can get an icon (AfterStep) */ | |
309 { | |
310 XClassHint *classhints; | |
311 classhints = XAllocClassHint(); | |
312 if(classhints != NULL) { | |
313 classhints->res_name = "SDL_App"; | |
314 classhints->res_class = "SDL_App"; | |
315 XSetClassHint(SDL_Display, WMwindow, classhints); | |
316 XFree(classhints); | |
317 } | |
318 } | |
319 | |
320 /* Allow the window to be deleted by the window manager */ | |
321 WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False); | |
322 XSetWMProtocols(SDL_Display, WMwindow, &WM_DELETE_WINDOW, 1); | |
323 } | |
324 #endif | |
218 | 325 |
219 Uint32 MakeBitMask(_THIS,int type,int format,int *bpp) | 326 Uint32 MakeBitMask(_THIS,int type,int format,int *bpp) |
220 { | 327 { |
221 D(if(type==0)bug("REAL pixel format: ")); | 328 D(if(type==0)bug("REAL pixel format: ")); |
222 | 329 |
466 /* default visual was useless, take the deepest one instead */ | 573 /* default visual was useless, take the deepest one instead */ |
467 i = 0; | 574 i = 0; |
468 } | 575 } |
469 SDL_Visual = this->hidden->visuals[i].visual; | 576 SDL_Visual = this->hidden->visuals[i].visual; |
470 | 577 |
578 // SDL_XColorMap = SDL_DisplayColormap; | |
579 | |
471 this->hidden->depth = this->hidden->visuals[i].depth; | 580 this->hidden->depth = this->hidden->visuals[i].depth; |
472 D(bug("Setto la profiondita' dello schermo a: %ld\n",this->hidden->depth)); | 581 D(bug("Setto la profiondita' dello schermo a: %ld\n",this->hidden->depth)); |
473 vformat->BitsPerPixel = this->hidden->visuals[i].depth; /* this->hidden->visuals[i].bpp; */ | 582 vformat->BitsPerPixel = this->hidden->visuals[i].depth; /* this->hidden->visuals[i].bpp; */ |
474 | 583 |
475 { | 584 { |
492 vformat->Rmask = MakeBitMask(this,0,form,&this->hidden->depth); | 601 vformat->Rmask = MakeBitMask(this,0,form,&this->hidden->depth); |
493 vformat->Gmask = MakeBitMask(this,1,form,&this->hidden->depth); | 602 vformat->Gmask = MakeBitMask(this,1,form,&this->hidden->depth); |
494 vformat->Bmask = MakeBitMask(this,2,form,&this->hidden->depth); | 603 vformat->Bmask = MakeBitMask(this,2,form,&this->hidden->depth); |
495 } | 604 } |
496 } | 605 } |
606 | |
607 /* See if we have been passed a window to use */ | |
608 /* SDL_windowid = getenv("SDL_WINDOWID"); */ | |
609 SDL_windowid=NULL; | |
497 | 610 |
498 /* Create the fullscreen and managed windows */ | 611 /* Create the fullscreen and managed windows */ |
499 // create_aux_windows(this); | 612 // create_aux_windows(this); |
500 | 613 |
501 /* Create the blank cursor */ | 614 /* Create the blank cursor */ |
515 return(0); | 628 return(0); |
516 } | 629 } |
517 | 630 |
518 void CGX_DestroyWindow(_THIS, SDL_Surface *screen) | 631 void CGX_DestroyWindow(_THIS, SDL_Surface *screen) |
519 { | 632 { |
520 /* Hide the managed window */ | 633 if ( ! SDL_windowid ) { |
521 int was_fullscreen=0; | 634 /* Hide the managed window */ |
522 | 635 int was_fullscreen=0; |
523 if ( screen && (screen->flags & SDL_FULLSCREEN) ) { | 636 |
524 was_fullscreen=1; | 637 if ( screen && (screen->flags & SDL_FULLSCREEN) ) { |
525 screen->flags &= ~SDL_FULLSCREEN; | 638 was_fullscreen=1; |
526 CGX_LeaveFullScreen(this); | 639 screen->flags &= ~SDL_FULLSCREEN; |
527 } | 640 // CGX_LeaveFullScreen(this); tolto x crash |
528 | 641 } |
529 /* Destroy the output window */ | 642 |
530 if ( SDL_Window ) { | 643 /* Destroy the output window */ |
531 CloseWindow(SDL_Window); | 644 if ( SDL_Window ) { |
532 SDL_Window=NULL; | 645 CloseWindow(SDL_Window); |
533 } | 646 SDL_Window=NULL; |
534 | 647 } |
535 /* Free the colormap entries */ | 648 |
536 if ( SDL_XPixels ) { | 649 /* Free the colormap entries */ |
537 int numcolors; | 650 if ( SDL_XPixels ) { |
538 unsigned long pixel; | 651 int numcolors; |
539 | 652 unsigned long pixel; |
540 if(this->screen->format&&this->hidden->depth==8&&!was_fullscreen) | 653 |
541 { | 654 if(this->screen->format&&this->hidden->depth==8&&!was_fullscreen) |
542 numcolors = 1<<this->screen->format->BitsPerPixel; | 655 { |
543 | 656 numcolors = 1<<this->screen->format->BitsPerPixel; |
544 if(numcolors>256) | 657 |
545 numcolors=256; | 658 if(numcolors>256) |
546 | 659 numcolors=256; |
547 if(!was_fullscreen&&this->hidden->depth==8) | 660 |
548 { | 661 if(!was_fullscreen&&this->hidden->depth==8) |
549 for ( pixel=0; pixel<numcolors; pixel++ ) | |
550 { | 662 { |
551 if(SDL_XPixels[pixel]>=0) | 663 for ( pixel=0; pixel<numcolors; pixel++ ) |
552 ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]); | 664 { |
665 if(SDL_XPixels[pixel]>=0) | |
666 ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]); | |
667 } | |
553 } | 668 } |
554 } | 669 } |
555 } | 670 free(SDL_XPixels); |
556 free(SDL_XPixels); | 671 SDL_XPixels = NULL; |
557 SDL_XPixels = NULL; | 672 } |
558 } | 673 } |
559 } | 674 } |
560 | 675 |
561 static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags) | 676 static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags) |
562 { | 677 { |
563 if ( flags & SDL_RESIZABLE ) { | 678 if ( flags & SDL_RESIZABLE ) { |
588 #endif | 703 #endif |
589 /* If a window is already present, destroy it and start fresh */ | 704 /* If a window is already present, destroy it and start fresh */ |
590 if ( SDL_Window ) { | 705 if ( SDL_Window ) { |
591 CGX_DestroyWindow(this, screen); | 706 CGX_DestroyWindow(this, screen); |
592 } | 707 } |
593 SDL_Window = 0; | 708 |
709 /* See if we have been given a window id */ | |
710 if ( SDL_windowid ) { | |
711 SDL_Window = (struct Window *)atol(SDL_windowid); | |
712 } else { | |
713 SDL_Window = 0; | |
714 } | |
594 | 715 |
595 /* find out which visual we are going to use */ | 716 /* find out which visual we are going to use */ |
596 #if 0 | 717 #if 0 |
597 /* questo l'ho spostato nell'apertura dello schermo, in quanto su Amiga le finestre | 718 /* questo l'ho spostato nell'apertura dello schermo, in quanto su Amiga le finestre |
598 hanno il pixel mode degli schermi. | 719 hanno il pixel mode degli schermi. |
654 D(bug("AFTER screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth)); | 775 D(bug("AFTER screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth)); |
655 | 776 |
656 } | 777 } |
657 | 778 |
658 /* Create the appropriate colormap */ | 779 /* Create the appropriate colormap */ |
780 /* | |
781 if ( SDL_XColorMap != SDL_DisplayColormap ) { | |
782 XFreeColormap(SDL_Display, SDL_XColorMap); | |
783 } | |
784 */ | |
659 if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT)==PIXFMT_LUT8 || bpp==8 ) { | 785 if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT)==PIXFMT_LUT8 || bpp==8 ) { |
660 int ncolors; | 786 int ncolors; |
661 D(bug("Alloco XPixels x la palette...\n")); | 787 D(bug("Alloco XPixels x la palette...\n")); |
662 | 788 |
663 /* Allocate the pixel flags */ | 789 /* Allocate the pixel flags */ |
679 /* always allocate a private colormap on non-default visuals */ | 805 /* always allocate a private colormap on non-default visuals */ |
680 if(bpp==8) | 806 if(bpp==8) |
681 flags |= SDL_HWPALETTE; | 807 flags |= SDL_HWPALETTE; |
682 | 808 |
683 if ( flags & SDL_HWPALETTE ) { | 809 if ( flags & SDL_HWPALETTE ) { |
684 screen->flags |= SDL_HWPALETTE; | 810 screen->flags |= SDL_HWPALETTE; |
811 /* | |
812 SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root, | |
813 SDL_Visual, AllocAll); | |
814 */ | |
815 } else { | |
816 /* | |
817 SDL_XColorMap = SDL_DisplayColormap; | |
818 */ | |
685 } | 819 } |
686 } | 820 } else { |
821 /* | |
822 SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root, | |
823 SDL_Visual, AllocNone); | |
824 */ | |
825 } | |
826 | |
827 /* Recreate the auxiliary windows, if needed (required for GL) */ | |
828 /* | |
829 if ( vis_change ) | |
830 create_aux_windows(this); | |
831 */ | |
687 | 832 |
688 /* resize the (possibly new) window manager window */ | 833 /* resize the (possibly new) window manager window */ |
689 | 834 |
690 /* Create (or use) the X11 display window */ | 835 /* Create (or use) the X11 display window */ |
691 if ( flags & SDL_OPENGL ) { | 836 if ( !SDL_windowid ) { |
692 return(-1); | 837 if ( flags & SDL_OPENGL ) { |
693 } else { | 838 return(-1); |
694 if(flags & SDL_FULLSCREEN) | 839 } |
695 SDL_Window = OpenWindowTags(NULL,WA_Width,w,WA_Height,h, | 840 else |
841 { | |
842 if(flags & SDL_FULLSCREEN) | |
843 { | |
844 SDL_Window = OpenWindowTags(NULL,WA_Width,w,WA_Height,h, | |
696 WA_Flags,WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_BORDERLESS|WFLG_BACKDROP|WFLG_REPORTMOUSE, | 845 WA_Flags,WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_BORDERLESS|WFLG_BACKDROP|WFLG_REPORTMOUSE, |
697 WA_IDCMP,IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE, | 846 WA_IDCMP,IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE, |
698 WA_CustomScreen,(ULONG)SDL_Display, | 847 WA_CustomScreen,(ULONG)SDL_Display, |
699 TAG_DONE); | 848 TAG_DONE); |
700 else | 849 |
701 SDL_Window = OpenWindowTags(NULL,WA_InnerWidth,w,WA_InnerHeight,h, | 850 D(bug("Apro finestra backdrop %ldx%ld su %lx!\n",w,h,SDL_Display)); |
702 WA_Flags,WFLG_REPORTMOUSE|WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_DRAGBAR| ((screen->flags&SDL_RESIZABLE) ? WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM : 0), | 851 } |
852 else | |
853 { | |
854 SDL_Window = OpenWindowTags(NULL,WA_InnerWidth,w,WA_InnerHeight,h, | |
855 WA_Flags,WFLG_REPORTMOUSE|WFLG_ACTIVATE|WFLG_RMBTRAP | ((flags&SDL_NOFRAME) ? 0 : (WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_DRAGBAR | ((flags&SDL_RESIZABLE) ? WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM : 0))), | |
703 WA_IDCMP,IDCMP_RAWKEY|IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_NEWSIZE|IDCMP_MOUSEMOVE, | 856 WA_IDCMP,IDCMP_RAWKEY|IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_NEWSIZE|IDCMP_MOUSEMOVE, |
704 WA_PubScreen,(ULONG)SDL_Display, | 857 WA_PubScreen,(ULONG)SDL_Display, |
705 TAG_DONE); | 858 TAG_DONE); |
706 } | 859 D(bug("Apro finestra %ldx%ld sul wb!\n",w,h)); |
707 /* Only manage our input if we own the window */ | 860 } |
708 if(!SDL_Window) | 861 |
709 return -1; | 862 } |
863 /* Only manage our input if we own the window */ | |
864 /* | |
865 XSelectInput(SDL_Display, SDL_Window, | |
866 ( EnterWindowMask | LeaveWindowMask | |
867 | ButtonPressMask | ButtonReleaseMask | |
868 | PointerMotionMask | ExposureMask )); | |
869 */ | |
870 | |
871 if(!SDL_Window) | |
872 return -1; | |
873 } | |
710 | 874 |
711 this->hidden->BytesPerPixel=GetCyberMapAttr(SDL_Window->RPort->BitMap,CYBRMATTR_BPPIX); | 875 this->hidden->BytesPerPixel=GetCyberMapAttr(SDL_Window->RPort->BitMap,CYBRMATTR_BPPIX); |
712 | 876 |
713 if(screen->flags & SDL_DOUBLEBUF) | 877 if(screen->flags & SDL_DOUBLEBUF) |
714 { | 878 { |
734 #endif | 898 #endif |
735 | 899 |
736 if(flags&SDL_HWSURFACE) | 900 if(flags&SDL_HWSURFACE) |
737 screen->flags|=SDL_HWSURFACE; | 901 screen->flags|=SDL_HWSURFACE; |
738 | 902 |
739 CGX_SetSizeHints(this, w, h, flags); | 903 if( !SDL_windowid ) { |
740 current_w = w; | 904 CGX_SetSizeHints(this, w, h, flags); |
741 current_h = h; | 905 current_w = w; |
906 current_h = h; | |
907 } | |
908 | |
909 /* Set our colormaps when not setting a GL mode */ | |
910 /* | |
911 if ( ! (flags & SDL_OPENGL) ) { | |
912 XSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap); | |
913 } | |
914 */ | |
742 | 915 |
743 /* Map them both and go fullscreen, if requested */ | 916 /* Map them both and go fullscreen, if requested */ |
744 if ( flags & SDL_FULLSCREEN ) { | 917 if ( ! SDL_windowid ) { |
745 screen->flags |= SDL_FULLSCREEN; | 918 if ( flags & SDL_FULLSCREEN ) { |
746 currently_fullscreen=1; | 919 screen->flags |= SDL_FULLSCREEN; |
747 // CGX_EnterFullScreen(this); Ci siamo gia'! | 920 currently_fullscreen=1; |
748 } else { | 921 // CGX_EnterFullScreen(this); Ci siamo gia'! |
749 screen->flags &= ~SDL_FULLSCREEN; | 922 } else { |
750 } | 923 screen->flags &= ~SDL_FULLSCREEN; |
924 } | |
925 } | |
926 screen->w = w; | |
927 screen->h = h; | |
928 screen->pitch = SDL_CalculatePitch(screen); | |
929 CGX_ResizeImage(this, screen, flags); | |
930 | |
751 return(0); | 931 return(0); |
752 } | 932 } |
753 | 933 |
754 int CGX_ResizeWindow(_THIS, | 934 int CGX_ResizeWindow(_THIS, |
755 SDL_Surface *screen, int w, int h, Uint32 flags) | 935 SDL_Surface *screen, int w, int h, Uint32 flags) |
756 { | 936 { |
757 /* Resize the window manager window */ | 937 if ( ! SDL_windowid ) { |
758 CGX_SetSizeHints(this, w, h, flags); | 938 /* Resize the window manager window */ |
759 current_w = w; | 939 CGX_SetSizeHints(this, w, h, flags); |
760 current_h = h; | 940 current_w = w; |
761 | 941 current_h = h; |
762 ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight, | 942 |
763 h+SDL_Window->BorderTop+SDL_Window->BorderBottom); | 943 ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight, |
764 | 944 h+SDL_Window->BorderTop+SDL_Window->BorderBottom); |
765 /* Resize the fullscreen and display windows */ | 945 |
766 if ( flags & SDL_FULLSCREEN ) { | 946 /* Resize the fullscreen and display windows */ |
767 if ( screen->flags & SDL_FULLSCREEN ) { | 947 /* |
768 CGX_ResizeFullScreen(this); | 948 if ( flags & SDL_FULLSCREEN ) { |
949 if ( screen->flags & SDL_FULLSCREEN ) { | |
950 CGX_ResizeFullScreen(this); | |
951 } else { | |
952 screen->flags |= SDL_FULLSCREEN; | |
953 CGX_EnterFullScreen(this); | |
954 } | |
769 } else { | 955 } else { |
770 screen->flags |= SDL_FULLSCREEN; | 956 if ( screen->flags & SDL_FULLSCREEN ) { |
771 CGX_EnterFullScreen(this); | 957 screen->flags &= ~SDL_FULLSCREEN; |
772 } | 958 CGX_LeaveFullScreen(this); |
773 } else { | 959 } |
774 if ( screen->flags & SDL_FULLSCREEN ) { | 960 } |
775 screen->flags &= ~SDL_FULLSCREEN; | 961 */ |
776 CGX_LeaveFullScreen(this); | 962 screen->w = w; |
777 } | 963 screen->h = h; |
964 screen->pitch = SDL_CalculatePitch(screen); | |
965 CGX_ResizeImage(this, screen, flags); | |
778 } | 966 } |
779 return(0); | 967 return(0); |
780 } | 968 } |
781 | 969 |
782 static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, | 970 static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, |
783 int width, int height, int bpp, Uint32 flags) | 971 int width, int height, int bpp, Uint32 flags) |
784 { | 972 { |
785 Uint32 saved_flags; | 973 Uint32 saved_flags; |
974 int needcreate=0; | |
786 | 975 |
787 /* Lock the event thread, in multi-threading environments */ | 976 /* Lock the event thread, in multi-threading environments */ |
788 SDL_Lock_EventThread(); | 977 SDL_Lock_EventThread(); |
789 | 978 |
979 // Check if the window needs to be closed or can be resized | |
980 | |
981 if( (flags&SDL_FULLSCREEN) || (current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN))) | |
982 needcreate=1; | |
983 | |
790 // Check if we need to close an already existing videomode... | 984 // Check if we need to close an already existing videomode... |
791 | 985 |
792 if(current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN)) | 986 if(current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN)) |
793 { | 987 { |
988 unsigned long i; | |
794 CGX_DestroyImage(this,current); | 989 CGX_DestroyImage(this,current); |
795 CGX_DestroyWindow(this,current); | 990 CGX_DestroyWindow(this,current); |
796 DestroyScreen(this); | 991 DestroyScreen(this); |
992 D(bug("Distrutte immagine, finestra e schermo!\n")); | |
993 GFX_Display=SDL_Display=LockPubScreen(NULL); | |
994 | |
995 bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH); | |
996 | |
997 for ( i = 0; i < this->hidden->nvisuals; i++ ) { | |
998 if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */ | |
999 break; | |
1000 } | |
1001 if ( i == this->hidden->nvisuals ) { | |
1002 SDL_SetError("No matching visual for requested depth"); | |
1003 return NULL; /* should never happen */ | |
1004 } | |
1005 SDL_Visual = this->hidden->visuals[i].visual; | |
1006 | |
1007 D(bug("Setto la profiondita' dello schermo a: %ld\n",this->hidden->depth)); | |
1008 | |
797 } | 1009 } |
798 /* Check the combination of flags we were passed */ | 1010 /* Check the combination of flags we were passed */ |
799 if ( flags & SDL_FULLSCREEN ) { | 1011 if ( flags & SDL_FULLSCREEN ) { |
800 int i; | 1012 int i; |
801 | 1013 |
802 /* Clear fullscreen flag if not supported */ | 1014 /* Clear fullscreen flag if not supported */ |
803 if(current->flags&SDL_FULLSCREEN ) | 1015 if ( SDL_windowid ) { |
1016 flags &= ~SDL_FULLSCREEN; | |
1017 } | |
1018 else if(current->flags&SDL_FULLSCREEN ) | |
804 { | 1019 { |
805 if(current->w!=width || | 1020 if(current->w!=width || |
806 current->h!=height || | 1021 current->h!=height || |
807 this->hidden->depth!=bpp) | 1022 this->hidden->depth!=bpp) |
808 { | 1023 { |
928 | 1143 |
929 /* Set up the X11 window */ | 1144 /* Set up the X11 window */ |
930 saved_flags = current->flags; | 1145 saved_flags = current->flags; |
931 | 1146 |
932 if (SDL_Window && (saved_flags&SDL_OPENGL) == (flags&SDL_OPENGL) | 1147 if (SDL_Window && (saved_flags&SDL_OPENGL) == (flags&SDL_OPENGL) |
933 && bpp == current->format->BitsPerPixel) { | 1148 && bpp == current->format->BitsPerPixel && !needcreate) { |
934 if (CGX_ResizeWindow(this, current, width, height, flags) < 0) { | 1149 if (CGX_ResizeWindow(this, current, width, height, flags) < 0) { |
935 current = NULL; | 1150 current = NULL; |
936 goto done; | 1151 goto done; |
937 } | 1152 } |
938 } else { | 1153 } else { |
940 current = NULL; | 1155 current = NULL; |
941 goto done; | 1156 goto done; |
942 } | 1157 } |
943 } | 1158 } |
944 | 1159 |
1160 #if 0 | |
945 /* Set up the new mode framebuffer */ | 1161 /* Set up the new mode framebuffer */ |
946 if ( ((current->w != width) || (current->h != height)) || | 1162 if ( ((current->w != width) || (current->h != height)) || |
947 ((saved_flags&SDL_OPENGL) != (flags&SDL_OPENGL)) ) { | 1163 ((saved_flags&SDL_OPENGL) != (flags&SDL_OPENGL)) ) { |
948 current->w = width; | 1164 current->w = width; |
949 current->h = height; | 1165 current->h = height; |
950 current->pitch = SDL_CalculatePitch(current); | 1166 current->pitch = SDL_CalculatePitch(current); |
951 CGX_ResizeImage(this, current, flags); | 1167 CGX_ResizeImage(this, current, flags); |
952 } | 1168 } |
1169 #endif | |
1170 | |
953 current->flags |= (flags&SDL_RESIZABLE); // Resizable only if the user asked it | 1171 current->flags |= (flags&SDL_RESIZABLE); // Resizable only if the user asked it |
954 | 1172 |
955 done: | 1173 done: |
956 /* Release the event thread */ | 1174 /* Release the event thread */ |
957 SDL_Unlock_EventThread(); | 1175 SDL_Unlock_EventThread(); |
961 } | 1179 } |
962 | 1180 |
963 static int CGX_ToggleFullScreen(_THIS, int on) | 1181 static int CGX_ToggleFullScreen(_THIS, int on) |
964 { | 1182 { |
965 Uint32 event_thread; | 1183 Uint32 event_thread; |
1184 | |
1185 /* Don't switch if we don't own the window */ | |
1186 if ( SDL_windowid ) { | |
1187 return(0); | |
1188 } | |
966 | 1189 |
967 /* Don't lock if we are the event thread */ | 1190 /* Don't lock if we are the event thread */ |
968 event_thread = SDL_EventThreadID(); | 1191 event_thread = SDL_EventThreadID(); |
969 if ( event_thread && (SDL_ThreadID() == event_thread) ) { | 1192 if ( event_thread && (SDL_ThreadID() == event_thread) ) { |
970 event_thread = 0; | 1193 event_thread = 0; |
1088 { | 1311 { |
1089 int i; | 1312 int i; |
1090 | 1313 |
1091 /* Check to make sure we have a colormap allocated */ | 1314 /* Check to make sure we have a colormap allocated */ |
1092 | 1315 |
1093 // It's not needed to reload the whole palette each time on Amiga! | |
1094 // ncolors = this->screen->format->palette->ncolors; | |
1095 | |
1096 /* It's easy if we have a hidden colormap */ | 1316 /* It's easy if we have a hidden colormap */ |
1097 if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen ) | 1317 if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen ) |
1098 { | 1318 { |
1099 ULONG xcmap[256*3+2]; | 1319 ULONG xcmap[256*3+2]; |
1100 | 1320 |
1102 xcmap[0]+=firstcolor; | 1322 xcmap[0]+=firstcolor; |
1103 | 1323 |
1104 // D(bug("Setting %ld colors on an HWPALETTE screen\n",ncolors)); | 1324 // D(bug("Setting %ld colors on an HWPALETTE screen\n",ncolors)); |
1105 | 1325 |
1106 for ( i=0; i<ncolors; i++ ) { | 1326 for ( i=0; i<ncolors; i++ ) { |
1107 xcmap[i*3+1] = colors[i].r<<24; | 1327 xcmap[i*3+1] = colors[i+firstcolor].r<<24; |
1108 xcmap[i*3+2] = colors[i].g<<24; | 1328 xcmap[i*3+2] = colors[i+firstcolor].g<<24; |
1109 xcmap[i*3+3] = colors[i].b<<24; | 1329 xcmap[i*3+3] = colors[i+firstcolor].b<<24; |
1110 } | 1330 } |
1111 xcmap[ncolors*3+1]=0; | 1331 xcmap[ncolors*3+1]=0; |
1112 LoadRGB32(&GFX_Display->ViewPort,xcmap); | 1332 LoadRGB32(&GFX_Display->ViewPort,xcmap); |
1113 } else { | 1333 } else { |
1114 // XPixels are not needed on 8bit screen with hwpalette | 1334 // XPixels are not needed on 8bit screen with hwpalette |
1117 if ( SDL_XPixels == NULL ) { | 1337 if ( SDL_XPixels == NULL ) { |
1118 D(bug("SetColors without colormap!")); | 1338 D(bug("SetColors without colormap!")); |
1119 return(0); | 1339 return(0); |
1120 } | 1340 } |
1121 | 1341 |
1122 colors = this->screen->format->palette->colors; | |
1123 if(this->hidden->depth==8) | 1342 if(this->hidden->depth==8) |
1124 { | 1343 { |
1125 // In this case I have to unalloc and realloc the full palette | 1344 // In this case I have to unalloc and realloc the full palette |
1126 D(bug("Obtaining %ld colors on the screen\n",ncolors)); | 1345 D(bug("Obtaining %ld colors on the screen\n",ncolors)); |
1127 | 1346 |
1176 CGX_DestroyWindow(this, this->screen); | 1395 CGX_DestroyWindow(this, this->screen); |
1177 // Otherwise SDL_VideoQuit will try to free it! | 1396 // Otherwise SDL_VideoQuit will try to free it! |
1178 SDL_VideoSurface=NULL; | 1397 SDL_VideoSurface=NULL; |
1179 CGX_FreeVideoModes(this); | 1398 CGX_FreeVideoModes(this); |
1180 | 1399 |
1400 /* | |
1401 if ( SDL_iconcolors ) { | |
1402 unsigned long pixel; | |
1403 int numcolors = | |
1404 ((this->screen->format)->palette)->ncolors; | |
1405 for ( pixel=0; pixel<numcolors; ++pixel ) { | |
1406 while ( SDL_iconcolors[pixel] > 0 ) { | |
1407 XFreeColors(SDL_Display, | |
1408 SDL_DisplayColormap,&pixel,1,0); | |
1409 --SDL_iconcolors[pixel]; | |
1410 } | |
1411 } | |
1412 free(SDL_iconcolors); | |
1413 SDL_iconcolors = NULL; | |
1414 } | |
1415 */ | |
1181 /* Free that blank cursor */ | 1416 /* Free that blank cursor */ |
1182 if ( SDL_BlankCursor != NULL ) { | 1417 if ( SDL_BlankCursor != NULL ) { |
1183 FreeMem(SDL_BlankCursor,16); | 1418 FreeMem(SDL_BlankCursor,16); |
1184 SDL_BlankCursor = NULL; | 1419 SDL_BlankCursor = NULL; |
1185 } | 1420 } |