Mercurial > sdl-ios-xcode
comparison src/video/SDL_video.c @ 1970:db3ba6c0d0df
Allow the render context to do necessary work when the video mode changes.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 06 Aug 2006 04:39:13 +0000 |
parents | 5d3724f64f2b |
children | 754847f19490 |
comparison
equal
deleted
inserted
replaced
1969:5d3724f64f2b | 1970:db3ba6c0d0df |
---|---|
643 | 643 |
644 int | 644 int |
645 SDL_SetFullscreenDisplayMode(const SDL_DisplayMode * mode) | 645 SDL_SetFullscreenDisplayMode(const SDL_DisplayMode * mode) |
646 { | 646 { |
647 SDL_VideoDisplay *display; | 647 SDL_VideoDisplay *display; |
648 SDL_DisplayMode fullscreen_mode; | |
648 int i; | 649 int i; |
649 | 650 |
650 if (!_this) { | 651 if (!_this) { |
651 SDL_UninitializedVideo(); | 652 SDL_UninitializedVideo(); |
652 return -1; | 653 return -1; |
653 } | 654 } |
654 | 655 |
655 display = &SDL_CurrentDisplay; | 656 display = &SDL_CurrentDisplay; |
656 if (mode) { | 657 if (!mode) { |
657 SDL_GetClosestDisplayMode(mode, &display->desired_mode); | 658 mode = &display->desktop_mode; |
658 display->fullscreen_mode = &display->desired_mode; | 659 } |
659 } else { | 660 |
660 display->fullscreen_mode = NULL; | 661 SDL_GetClosestDisplayMode(mode, &fullscreen_mode); |
661 } | 662 if (SDL_memcmp |
663 (&fullscreen_mode, &display->fullscreen_mode, | |
664 sizeof(fullscreen_mode)) == 0) { | |
665 /* Nothing to do... */ | |
666 return 0; | |
667 } | |
668 display->fullscreen_mode = fullscreen_mode; | |
662 | 669 |
663 /* Actually set the mode if we have a fullscreen window visible */ | 670 /* Actually set the mode if we have a fullscreen window visible */ |
664 for (i = 0; i < display->num_windows; ++i) { | 671 for (i = 0; i < display->num_windows; ++i) { |
665 SDL_Window *window = &display->windows[i]; | 672 SDL_Window *window = &display->windows[i]; |
666 if (FULLSCREEN_VISIBLE(window)) { | 673 if (FULLSCREEN_VISIBLE(window)) { |
667 return SDL_SetDisplayMode(display->fullscreen_mode); | 674 if (SDL_SetDisplayMode(&display->fullscreen_mode) < 0) { |
675 return -1; | |
676 } | |
677 } | |
678 if (window->flags & SDL_WINDOW_FULLSCREEN) { | |
679 SDL_OnWindowResized(window); | |
668 } | 680 } |
669 } | 681 } |
670 return 0; | 682 return 0; |
671 } | 683 } |
672 | 684 |
676 if (!_this) { | 688 if (!_this) { |
677 SDL_UninitializedVideo(); | 689 SDL_UninitializedVideo(); |
678 return -1; | 690 return -1; |
679 } | 691 } |
680 if (mode) { | 692 if (mode) { |
681 *mode = *SDL_CurrentDisplay.fullscreen_mode; | 693 *mode = SDL_CurrentDisplay.fullscreen_mode; |
682 } | 694 } |
683 return 0; | 695 return 0; |
684 } | 696 } |
685 | 697 |
686 int | 698 int |
1195 if (other->id != windowID && FULLSCREEN_VISIBLE(other)) { | 1207 if (other->id != windowID && FULLSCREEN_VISIBLE(other)) { |
1196 SDL_MinimizeWindow(other->id); | 1208 SDL_MinimizeWindow(other->id); |
1197 } | 1209 } |
1198 } | 1210 } |
1199 | 1211 |
1200 SDL_SetDisplayMode(display->fullscreen_mode); | 1212 SDL_SetDisplayMode(&display->fullscreen_mode); |
1201 } | 1213 } |
1202 } else { | 1214 } else { |
1203 window->flags &= ~SDL_WINDOW_FULLSCREEN; | 1215 window->flags &= ~SDL_WINDOW_FULLSCREEN; |
1204 | 1216 |
1205 if (FULLSCREEN_VISIBLE(window)) { | 1217 if (FULLSCREEN_VISIBLE(window)) { |
1250 SDL_OnWindowHidden(SDL_Window * window) | 1262 SDL_OnWindowHidden(SDL_Window * window) |
1251 { | 1263 { |
1252 } | 1264 } |
1253 | 1265 |
1254 void | 1266 void |
1267 SDL_OnWindowResized(SDL_Window * window) | |
1268 { | |
1269 SDL_Renderer *renderer = window->renderer; | |
1270 | |
1271 if (renderer && renderer->DisplayModeChanged) { | |
1272 renderer->DisplayModeChanged(renderer); | |
1273 } | |
1274 } | |
1275 | |
1276 void | |
1255 SDL_OnWindowFocusGained(SDL_Window * window) | 1277 SDL_OnWindowFocusGained(SDL_Window * window) |
1256 { | 1278 { |
1257 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); | 1279 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
1258 | 1280 |
1259 if (window->flags & SDL_WINDOW_FULLSCREEN) { | 1281 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
1260 SDL_SetDisplayMode(display->fullscreen_mode); | 1282 SDL_SetDisplayMode(&display->fullscreen_mode); |
1261 } | 1283 } |
1262 if (display->gamma && _this->SetDisplayGammaRamp) { | 1284 if (display->gamma && _this->SetDisplayGammaRamp) { |
1263 _this->SetDisplayGammaRamp(_this, display->gamma); | 1285 _this->SetDisplayGammaRamp(_this, display->gamma); |
1264 } | 1286 } |
1265 if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && _this->SetWindowGrab) { | 1287 if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && _this->SetWindowGrab) { |