Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11modes.c @ 1575:3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 22 Mar 2006 05:00:59 +0000 |
parents | 8d9bb0cf2c2a |
children | 34cca785be57 |
comparison
equal
deleted
inserted
replaced
1574:0fd72308659e | 1575:3ba88cb7eb1b |
---|---|
133 match: | 133 match: |
134 if ( (modes[i]->hdisplay != mode.hdisplay) || | 134 if ( (modes[i]->hdisplay != mode.hdisplay) || |
135 (modes[i]->vdisplay != mode.vdisplay) ) { | 135 (modes[i]->vdisplay != mode.vdisplay) ) { |
136 SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[i]); | 136 SDL_NAME(XF86VidModeSwitchToMode)(SDL_Display, SDL_Screen, modes[i]); |
137 } | 137 } |
138 pXFree(modes); | 138 XFree(modes); |
139 } | 139 } |
140 } | 140 } |
141 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ | 141 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ |
142 | 142 |
143 /* XiG */ | 143 /* XiG */ |
172 SDL_Screen, | 172 SDL_Screen, |
173 0, /* view */ | 173 0, /* view */ |
174 SDL_modelist[i]->w, | 174 SDL_modelist[i]->w, |
175 SDL_modelist[i]->h, | 175 SDL_modelist[i]->h, |
176 0); | 176 0); |
177 pXSync(SDL_Display, False); | 177 XSync(SDL_Display, False); |
178 } | 178 } |
179 } | 179 } |
180 } | 180 } |
181 #endif /* SDL_VIDEO_DRIVER_X11_XME */ | 181 #endif /* SDL_VIDEO_DRIVER_X11_XME */ |
182 | 182 |
222 /* Called after mapping a window - waits until the window is mapped */ | 222 /* Called after mapping a window - waits until the window is mapped */ |
223 void X11_WaitMapped(_THIS, Window win) | 223 void X11_WaitMapped(_THIS, Window win) |
224 { | 224 { |
225 XEvent event; | 225 XEvent event; |
226 do { | 226 do { |
227 pXMaskEvent(SDL_Display, StructureNotifyMask, &event); | 227 XMaskEvent(SDL_Display, StructureNotifyMask, &event); |
228 } while ( (event.type != MapNotify) || (event.xmap.event != win) ); | 228 } while ( (event.type != MapNotify) || (event.xmap.event != win) ); |
229 } | 229 } |
230 | 230 |
231 /* Called after unmapping a window - waits until the window is unmapped */ | 231 /* Called after unmapping a window - waits until the window is unmapped */ |
232 void X11_WaitUnmapped(_THIS, Window win) | 232 void X11_WaitUnmapped(_THIS, Window win) |
233 { | 233 { |
234 XEvent event; | 234 XEvent event; |
235 do { | 235 do { |
236 pXMaskEvent(SDL_Display, StructureNotifyMask, &event); | 236 XMaskEvent(SDL_Display, StructureNotifyMask, &event); |
237 } while ( (event.type != UnmapNotify) || (event.xunmap.event != win) ); | 237 } while ( (event.type != UnmapNotify) || (event.xunmap.event != win) ); |
238 } | 238 } |
239 | 239 |
240 static void move_cursor_to(_THIS, int x, int y) | 240 static void move_cursor_to(_THIS, int x, int y) |
241 { | 241 { |
242 pXWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); | 242 XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); |
243 } | 243 } |
244 | 244 |
245 static int add_visual(_THIS, int depth, int class) | 245 static int add_visual(_THIS, int depth, int class) |
246 { | 246 { |
247 XVisualInfo vi; | 247 XVisualInfo vi; |
248 if(pXMatchVisualInfo(SDL_Display, SDL_Screen, depth, class, &vi)) { | 248 if(XMatchVisualInfo(SDL_Display, SDL_Screen, depth, class, &vi)) { |
249 int n = this->hidden->nvisuals; | 249 int n = this->hidden->nvisuals; |
250 this->hidden->visuals[n].depth = vi.depth; | 250 this->hidden->visuals[n].depth = vi.depth; |
251 this->hidden->visuals[n].visual = vi.visual; | 251 this->hidden->visuals[n].visual = vi.visual; |
252 this->hidden->nvisuals++; | 252 this->hidden->nvisuals++; |
253 } | 253 } |
259 int nvis; | 259 int nvis; |
260 | 260 |
261 if ( visual_id ) { | 261 if ( visual_id ) { |
262 SDL_memset(&template, 0, (sizeof template)); | 262 SDL_memset(&template, 0, (sizeof template)); |
263 template.visualid = SDL_strtol(visual_id, NULL, 0); | 263 template.visualid = SDL_strtol(visual_id, NULL, 0); |
264 vi = pXGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis); | 264 vi = XGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis); |
265 if ( vi ) { | 265 if ( vi ) { |
266 int n = this->hidden->nvisuals; | 266 int n = this->hidden->nvisuals; |
267 this->hidden->visuals[n].depth = vi->depth; | 267 this->hidden->visuals[n].depth = vi->depth; |
268 this->hidden->visuals[n].visual = vi->visual; | 268 this->hidden->visuals[n].visual = vi->visual; |
269 this->hidden->nvisuals++; | 269 this->hidden->nvisuals++; |
270 pXFree(vi); | 270 XFree(vi); |
271 } | 271 } |
272 } | 272 } |
273 return(this->hidden->nvisuals); | 273 return(this->hidden->nvisuals); |
274 } | 274 } |
275 | 275 |
401 SDL_modelist[n]->h = h; | 401 SDL_modelist[n]->h = h; |
402 ++n; | 402 ++n; |
403 } | 403 } |
404 SDL_modelist[n] = NULL; | 404 SDL_modelist[n] = NULL; |
405 } | 405 } |
406 pXFree(modes); | 406 XFree(modes); |
407 | 407 |
408 use_vidmode = vm_major * 100 + vm_minor; | 408 use_vidmode = vm_major * 100 + vm_minor; |
409 save_mode(this); | 409 save_mode(this); |
410 } | 410 } |
411 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ | 411 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ |
475 saved_res = modelist[ractive]; /* save the current resolution */ | 475 saved_res = modelist[ractive]; /* save the current resolution */ |
476 } else { | 476 } else { |
477 use_xme = 0; | 477 use_xme = 0; |
478 } | 478 } |
479 if ( modelist ) { | 479 if ( modelist ) { |
480 pXFree(modelist); | 480 XFree(modelist); |
481 } | 481 } |
482 #endif /* SDL_VIDEO_DRIVER_X11_XME */ | 482 #endif /* SDL_VIDEO_DRIVER_X11_XME */ |
483 | 483 |
484 { | 484 { |
485 static int depth_list[] = { 32, 24, 16, 15, 8 }; | 485 static int depth_list[] = { 32, 24, 16, 15, 8 }; |
510 SDL_SetError("Found no sufficiently capable X11 visuals"); | 510 SDL_SetError("Found no sufficiently capable X11 visuals"); |
511 return -1; | 511 return -1; |
512 } | 512 } |
513 | 513 |
514 /* look up the pixel quantum for each depth */ | 514 /* look up the pixel quantum for each depth */ |
515 pf = pXListPixmapFormats(SDL_Display, &np); | 515 pf = XListPixmapFormats(SDL_Display, &np); |
516 for(i = 0; i < this->hidden->nvisuals; i++) { | 516 for(i = 0; i < this->hidden->nvisuals; i++) { |
517 int d = this->hidden->visuals[i].depth; | 517 int d = this->hidden->visuals[i].depth; |
518 for(j = 0; j < np; j++) | 518 for(j = 0; j < np; j++) |
519 if(pf[j].depth == d) | 519 if(pf[j].depth == d) |
520 break; | 520 break; |
521 this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d; | 521 this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d; |
522 } | 522 } |
523 | 523 |
524 pXFree(pf); | 524 XFree(pf); |
525 } | 525 } |
526 | 526 |
527 if ( SDL_modelist == NULL ) { | 527 if ( SDL_modelist == NULL ) { |
528 SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *)); | 528 SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *)); |
529 if ( SDL_modelist ) { | 529 if ( SDL_modelist ) { |
593 if ( xinerama[i].screen_number == desired ) { | 593 if ( xinerama[i].screen_number == desired ) { |
594 xinerama_x = xinerama[i].x_org; | 594 xinerama_x = xinerama[i].x_org; |
595 xinerama_y = xinerama[i].y_org; | 595 xinerama_y = xinerama[i].y_org; |
596 } | 596 } |
597 } | 597 } |
598 pXFree(xinerama); | 598 XFree(xinerama); |
599 } | 599 } |
600 #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ | 600 #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ |
601 | 601 |
602 return 0; | 602 return 0; |
603 } | 603 } |
659 real_w = MAX(real_w, screen_w); | 659 real_w = MAX(real_w, screen_w); |
660 } | 660 } |
661 if ( window_h > real_h ) { | 661 if ( window_h > real_h ) { |
662 real_h = MAX(real_h, screen_h); | 662 real_h = MAX(real_h, screen_h); |
663 } | 663 } |
664 pXMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h); | 664 XMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h); |
665 move_cursor_to(this, real_w/2, real_h/2); | 665 move_cursor_to(this, real_w/2, real_h/2); |
666 | 666 |
667 /* Center and reparent the drawing window */ | 667 /* Center and reparent the drawing window */ |
668 x = (real_w - window_w)/2; | 668 x = (real_w - window_w)/2; |
669 y = (real_h - window_h)/2; | 669 y = (real_h - window_h)/2; |
670 pXReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y); | 670 XReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y); |
671 /* FIXME: move the mouse to the old relative location */ | 671 /* FIXME: move the mouse to the old relative location */ |
672 pXSync(SDL_Display, True); /* Flush spurious mode change events */ | 672 XSync(SDL_Display, True); /* Flush spurious mode change events */ |
673 } | 673 } |
674 return(1); | 674 return(1); |
675 } | 675 } |
676 | 676 |
677 void X11_QueueEnterFullScreen(_THIS) | 677 void X11_QueueEnterFullScreen(_THIS) |
678 { | 678 { |
679 switch_waiting = 0x01 | SDL_FULLSCREEN; | 679 switch_waiting = 0x01 | SDL_FULLSCREEN; |
680 switch_time = SDL_GetTicks() + 1500; | 680 switch_time = SDL_GetTicks() + 1500; |
681 #if 0 /* This causes a BadMatch error if the window is iconified (not needed) */ | 681 #if 0 /* This causes a BadMatch error if the window is iconified (not needed) */ |
682 pXSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime); | 682 XSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime); |
683 #endif | 683 #endif |
684 } | 684 } |
685 | 685 |
686 int X11_EnterFullScreen(_THIS) | 686 int X11_EnterFullScreen(_THIS) |
687 { | 687 { |
710 real_w = MAX(real_w, screen_w); | 710 real_w = MAX(real_w, screen_w); |
711 } | 711 } |
712 if ( window_h > real_h ) { | 712 if ( window_h > real_h ) { |
713 real_h = MAX(real_h, screen_h); | 713 real_h = MAX(real_h, screen_h); |
714 } | 714 } |
715 pXMoveResizeWindow(SDL_Display, FSwindow, | 715 XMoveResizeWindow(SDL_Display, FSwindow, |
716 xinerama_x, xinerama_y, real_w, real_h); | 716 xinerama_x, xinerama_y, real_w, real_h); |
717 pXMapRaised(SDL_Display, FSwindow); | 717 XMapRaised(SDL_Display, FSwindow); |
718 X11_WaitMapped(this, FSwindow); | 718 X11_WaitMapped(this, FSwindow); |
719 | 719 |
720 #if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */ | 720 #if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */ |
721 /* Make sure we got to the top of the window stack */ | 721 /* Make sure we got to the top of the window stack */ |
722 if ( pXQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin, | 722 if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin, |
723 &windows, &nwindows) && windows ) { | 723 &windows, &nwindows) && windows ) { |
724 /* If not, try to put us there - if fail... oh well */ | 724 /* If not, try to put us there - if fail... oh well */ |
725 if ( windows[nwindows-1] != FSwindow ) { | 725 if ( windows[nwindows-1] != FSwindow ) { |
726 tmpwin = windows[nwindows-1]; | 726 tmpwin = windows[nwindows-1]; |
727 for ( i=0; i<nwindows; ++i ) { | 727 for ( i=0; i<nwindows; ++i ) { |
730 (nwindows-i-1)*sizeof(windows[i])); | 730 (nwindows-i-1)*sizeof(windows[i])); |
731 break; | 731 break; |
732 } | 732 } |
733 } | 733 } |
734 windows[nwindows-1] = FSwindow; | 734 windows[nwindows-1] = FSwindow; |
735 pXRestackWindows(SDL_Display, windows, nwindows); | 735 XRestackWindows(SDL_Display, windows, nwindows); |
736 pXSync(SDL_Display, False); | 736 XSync(SDL_Display, False); |
737 } | 737 } |
738 pXFree(windows); | 738 XFree(windows); |
739 } | 739 } |
740 #else | 740 #else |
741 pXRaiseWindow(SDL_Display, FSwindow); | 741 XRaiseWindow(SDL_Display, FSwindow); |
742 #endif | 742 #endif |
743 | 743 |
744 #if SDL_VIDEO_DRIVER_X11_VIDMODE | 744 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
745 /* Save the current video mode */ | 745 /* Save the current video mode */ |
746 if ( use_vidmode ) { | 746 if ( use_vidmode ) { |
754 if ( ! okay ) { | 754 if ( ! okay ) { |
755 X11_LeaveFullScreen(this); | 755 X11_LeaveFullScreen(this); |
756 } | 756 } |
757 /* Set the colormap */ | 757 /* Set the colormap */ |
758 if ( SDL_XColorMap ) { | 758 if ( SDL_XColorMap ) { |
759 pXInstallColormap(SDL_Display, SDL_XColorMap); | 759 XInstallColormap(SDL_Display, SDL_XColorMap); |
760 } | 760 } |
761 if ( okay ) | 761 if ( okay ) |
762 X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN); | 762 X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN); |
763 | 763 |
764 /* We may need to refresh the screen at this point (no backing store) | 764 /* We may need to refresh the screen at this point (no backing store) |
775 } | 775 } |
776 | 776 |
777 int X11_LeaveFullScreen(_THIS) | 777 int X11_LeaveFullScreen(_THIS) |
778 { | 778 { |
779 if ( currently_fullscreen ) { | 779 if ( currently_fullscreen ) { |
780 pXReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0); | 780 XReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0); |
781 #if SDL_VIDEO_DRIVER_X11_VIDMODE | 781 #if SDL_VIDEO_DRIVER_X11_VIDMODE |
782 if ( use_vidmode ) { | 782 if ( use_vidmode ) { |
783 restore_mode(this); | 783 restore_mode(this); |
784 SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, False); | 784 SDL_NAME(XF86VidModeLockModeSwitch)(SDL_Display, SDL_Screen, False); |
785 } | 785 } |
797 SDL_Screen, | 797 SDL_Screen, |
798 0, /* view */ | 798 0, /* view */ |
799 saved_res.width, | 799 saved_res.width, |
800 saved_res.height, | 800 saved_res.height, |
801 0); | 801 0); |
802 pXSync(SDL_Display, False); | 802 XSync(SDL_Display, False); |
803 } | 803 } |
804 } | 804 } |
805 #endif | 805 #endif |
806 | 806 |
807 pXUnmapWindow(SDL_Display, FSwindow); | 807 XUnmapWindow(SDL_Display, FSwindow); |
808 X11_WaitUnmapped(this, FSwindow); | 808 X11_WaitUnmapped(this, FSwindow); |
809 pXSync(SDL_Display, True); /* Flush spurious mode change events */ | 809 XSync(SDL_Display, True); /* Flush spurious mode change events */ |
810 currently_fullscreen = 0; | 810 currently_fullscreen = 0; |
811 } | 811 } |
812 /* If we get popped out of fullscreen mode for some reason, input_grab | 812 /* If we get popped out of fullscreen mode for some reason, input_grab |
813 will still have the SDL_GRAB_FULLSCREEN flag set, since this is only | 813 will still have the SDL_GRAB_FULLSCREEN flag set, since this is only |
814 temporary. In this case, release the grab unless the input has been | 814 temporary. In this case, release the grab unless the input has been |