Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11modes.c @ 3500:4b594623401b
Work in progress on multi-display support:
* Added display parameter to many internal functions so video modes can be set on displays that aren't the public current one.
* The fullscreen mode is associated with fullscreen windows - not displays, so different windows more naturally have a mode associated with them based on their width and height. It's no longer necessary to specify a fullscreen mode, a default one will be picked automatically for fullscreen windows.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 01 Dec 2009 05:57:15 +0000 |
parents | ee331407574f |
children | 76f9b76ddf0f |
comparison
equal
deleted
inserted
replaced
3499:4cf8a1423d57 | 3500:4b594623401b |
---|---|
309 } | 309 } |
310 } | 310 } |
311 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ | 311 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ |
312 | 312 |
313 void | 313 void |
314 X11_GetDisplayModes(_THIS) | 314 X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) |
315 { | 315 { |
316 Display *display = ((SDL_VideoData *) _this->driverdata)->display; | 316 Display *display = ((SDL_VideoData *) _this->driverdata)->display; |
317 SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 317 SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata; |
318 #if SDL_VIDEO_DRIVER_X11_XINERAMA | 318 #if SDL_VIDEO_DRIVER_X11_XINERAMA |
319 int xinerama_major, xinerama_minor; | 319 int xinerama_major, xinerama_minor; |
320 int screens; | 320 int screens; |
321 SDL_NAME(XineramaScreenInfo) * xinerama; | 321 SDL_NAME(XineramaScreenInfo) * xinerama; |
322 #endif | 322 #endif |
339 * visual and depth ahead of time, but the SDL API allows you to create | 339 * visual and depth ahead of time, but the SDL API allows you to create |
340 * a window before setting the fullscreen display mode. This means that | 340 * a window before setting the fullscreen display mode. This means that |
341 * we have to use the same format for all windows and all display modes. | 341 * we have to use the same format for all windows and all display modes. |
342 * (or support recreating the window with a new visual behind the scenes) | 342 * (or support recreating the window with a new visual behind the scenes) |
343 */ | 343 */ |
344 mode.format = SDL_CurrentDisplay.current_mode.format; | 344 mode.format = sdl_display->current_mode.format; |
345 mode.driverdata = NULL; | 345 mode.driverdata = NULL; |
346 | 346 |
347 data->use_xinerama = 0; | 347 data->use_xinerama = 0; |
348 data->use_xrandr = 0; | 348 data->use_xrandr = 0; |
349 data->use_vidmode = 0; | 349 data->use_vidmode = 0; |
380 if (screen_w > data->xinerama_info.width || | 380 if (screen_w > data->xinerama_info.width || |
381 screen_h > data->xinerama_info.height) { | 381 screen_h > data->xinerama_info.height) { |
382 mode.w = screen_w; | 382 mode.w = screen_w; |
383 mode.h = screen_h; | 383 mode.h = screen_h; |
384 mode.refresh_rate = 0; | 384 mode.refresh_rate = 0; |
385 SDL_AddDisplayMode(_this->current_display, &mode); | 385 SDL_AddDisplayMode(sdl_display, &mode); |
386 } | 386 } |
387 | 387 |
388 /* Add the head xinerama mode */ | 388 /* Add the head xinerama mode */ |
389 mode.w = data->xinerama_info.width; | 389 mode.w = data->xinerama_info.width; |
390 mode.h = data->xinerama_info.height; | 390 mode.h = data->xinerama_info.height; |
391 mode.refresh_rate = 0; | 391 mode.refresh_rate = 0; |
392 SDL_AddDisplayMode(_this->current_display, &mode); | 392 SDL_AddDisplayMode(sdl_display, &mode); |
393 } | 393 } |
394 } | 394 } |
395 #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ | 395 #endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */ |
396 | 396 |
397 #if SDL_VIDEO_DRIVER_X11_XRANDR | 397 #if SDL_VIDEO_DRIVER_X11_XRANDR |
424 #ifdef X11MODES_DEBUG | 424 #ifdef X11MODES_DEBUG |
425 fprintf(stderr, | 425 fprintf(stderr, |
426 "XRANDR: mode = %4d[%d], w = %4d, h = %4d, rate = %4d\n", | 426 "XRANDR: mode = %4d[%d], w = %4d, h = %4d, rate = %4d\n", |
427 i, j, mode.w, mode.h, mode.refresh_rate); | 427 i, j, mode.w, mode.h, mode.refresh_rate); |
428 #endif | 428 #endif |
429 SDL_AddDisplayMode(_this->current_display, &mode); | 429 SDL_AddDisplayMode(sdl_display, &mode); |
430 } | 430 } |
431 } | 431 } |
432 | 432 |
433 data->use_xrandr = xrandr_major * 100 + xrandr_minor; | 433 data->use_xrandr = xrandr_major * 100 + xrandr_minor; |
434 data->saved_size = | 434 data->saved_size = |
460 #endif | 460 #endif |
461 for (i = 0; i < nmodes; ++i) { | 461 for (i = 0; i < nmodes; ++i) { |
462 mode.w = modes[i]->hdisplay; | 462 mode.w = modes[i]->hdisplay; |
463 mode.h = modes[i]->vdisplay; | 463 mode.h = modes[i]->vdisplay; |
464 mode.refresh_rate = calculate_rate(modes[i]); | 464 mode.refresh_rate = calculate_rate(modes[i]); |
465 SDL_AddDisplayMode(_this->current_display, &mode); | 465 SDL_AddDisplayMode(sdl_display, &mode); |
466 } | 466 } |
467 XFree(modes); | 467 XFree(modes); |
468 | 468 |
469 data->use_vidmode = vm_major * 100 + vm_minor; | 469 data->use_vidmode = vm_major * 100 + vm_minor; |
470 save_mode(display, data); | 470 save_mode(display, data); |
473 | 473 |
474 if (!data->use_xrandr && !data->use_vidmode) { | 474 if (!data->use_xrandr && !data->use_vidmode) { |
475 mode.w = screen_w; | 475 mode.w = screen_w; |
476 mode.h = screen_h; | 476 mode.h = screen_h; |
477 mode.refresh_rate = 0; | 477 mode.refresh_rate = 0; |
478 SDL_AddDisplayMode(_this->current_display, &mode); | 478 SDL_AddDisplayMode(sdl_display, &mode); |
479 } | 479 } |
480 #ifdef X11MODES_DEBUG | 480 #ifdef X11MODES_DEBUG |
481 if (data->use_xinerama) { | 481 if (data->use_xinerama) { |
482 printf("Xinerama is enabled\n"); | 482 printf("Xinerama is enabled\n"); |
483 } | 483 } |
670 } | 670 } |
671 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ | 671 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ |
672 } | 672 } |
673 | 673 |
674 int | 674 int |
675 X11_SetDisplayMode(_THIS, SDL_DisplayMode * mode) | 675 X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode) |
676 { | 676 { |
677 Display *display = ((SDL_VideoData *) _this->driverdata)->display; | 677 Display *display = ((SDL_VideoData *) _this->driverdata)->display; |
678 SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; | 678 SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata; |
679 | 679 |
680 set_best_resolution(display, data, mode->w, mode->h, mode->refresh_rate); | 680 set_best_resolution(display, data, mode->w, mode->h, mode->refresh_rate); |
681 return 0; | 681 return 0; |
682 } | 682 } |
683 | 683 |