Commit ab022a89 authored by Sam Lantinga's avatar Sam Lantinga

Added current_w and current_h to the SDL_VideoInfo structure, which is set to...

Added current_w and current_h to the SDL_VideoInfo structure, which is set to the desktop resolution during video intialization, and then set to the current resolution when a video mode is set.

SDL_SetVideoMode() now accepts 0 for width or height and will use the current video mode (or the desktop mode if no mode has been set.)

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401549
parent 5ab18443
...@@ -4,7 +4,15 @@ This is a list of API changes in SDL's version history. ...@@ -4,7 +4,15 @@ This is a list of API changes in SDL's version history.
Version 1.0: Version 1.0:
1.2.10: 1.2.10:
Added current_w and current_h to the SDL_VideoInfo structure,
which is set to the desktop resolution during video intialization,
and then set to the current resolution when a video mode is set.
SDL_SetVideoMode() now accepts 0 for width or height and will use
the current video mode (or the desktop mode if no mode has been set.)
Added SDL_GetKeyRepeat() Added SDL_GetKeyRepeat()
Added SDL_config.h, with defaults for various build environments. Added SDL_config.h, with defaults for various build environments.
1.2.7: 1.2.7:
......
...@@ -161,6 +161,8 @@ typedef struct SDL_VideoInfo { ...@@ -161,6 +161,8 @@ typedef struct SDL_VideoInfo {
Uint32 UnusedBits3 :16; Uint32 UnusedBits3 :16;
Uint32 video_mem; /* The total amount of video memory (in K) */ Uint32 video_mem; /* The total amount of video memory (in K) */
SDL_PixelFormat *vfmt; /* Value: The format of the video surface */ SDL_PixelFormat *vfmt; /* Value: The format of the video surface */
int current_w; /* Value: The current video mode width */
int current_h; /* Value: The current video mode height */
} SDL_VideoInfo; } SDL_VideoInfo;
......
...@@ -587,6 +587,13 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) ...@@ -587,6 +587,13 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
} }
this = video = current_video; this = video = current_video;
/* Default to the current width and height */
if ( width == 0 ) {
width = video->info.current_w;
}
if ( height == 0 ) {
height = video->info.current_h;
}
/* Default to the current video bpp */ /* Default to the current video bpp */
if ( bpp == 0 ) { if ( bpp == 0 ) {
flags |= SDL_ANYFORMAT; flags |= SDL_ANYFORMAT;
...@@ -889,6 +896,8 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) ...@@ -889,6 +896,8 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
SDL_PublicSurface = SDL_VideoSurface; SDL_PublicSurface = SDL_VideoSurface;
} }
video->info.vfmt = SDL_VideoSurface->format; video->info.vfmt = SDL_VideoSurface->format;
video->info.current_w = SDL_VideoSurface->w;
video->info.current_h = SDL_VideoSurface->h;
/* We're done! */ /* We're done! */
return(SDL_PublicSurface); return(SDL_PublicSurface);
......
...@@ -275,6 +275,8 @@ int BE_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -275,6 +275,8 @@ int BE_VideoInit(_THIS, SDL_PixelFormat *vformat)
/* Save the current display mode */ /* Save the current display mode */
bscreen.GetMode(&saved_mode); bscreen.GetMode(&saved_mode);
_this->info.current_w = saved_mode.virtual_width;
_this->info.current_h = saved_mode.virtual_height;
/* Determine the screen depth */ /* Determine the screen depth */
vformat->BitsPerPixel = ColorSpaceToBitsPerPixel(bscreen.ColorSpace()); vformat->BitsPerPixel = ColorSpaceToBitsPerPixel(bscreen.ColorSpace());
......
...@@ -463,6 +463,8 @@ static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -463,6 +463,8 @@ static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat)
SDL_SetError("Couldn't lock the display"); SDL_SetError("Couldn't lock the display");
return(-1); return(-1);
} }
this->info.current_w = SDL_Display->Width;
this->info.current_h = SDL_Display->Height;
D(bug("Checking if we are using a CGX native display...\n")); D(bug("Checking if we are using a CGX native display...\n"));
...@@ -834,8 +836,6 @@ int CGX_CreateWindow(_THIS, SDL_Surface *screen, ...@@ -834,8 +836,6 @@ int CGX_CreateWindow(_THIS, SDL_Surface *screen,
if( !SDL_windowid ) { if( !SDL_windowid ) {
CGX_SetSizeHints(this, w, h, flags); CGX_SetSizeHints(this, w, h, flags);
current_w = w;
current_h = h;
} }
/* Set our colormaps when not setting a GL mode */ /* Set our colormaps when not setting a GL mode */
...@@ -885,8 +885,6 @@ int CGX_ResizeWindow(_THIS, ...@@ -885,8 +885,6 @@ int CGX_ResizeWindow(_THIS,
if ( ! SDL_windowid ) { if ( ! SDL_windowid ) {
/* Resize the window manager window */ /* Resize the window manager window */
CGX_SetSizeHints(this, w, h, flags); CGX_SetSizeHints(this, w, h, flags);
current_w = w;
current_h = h;
ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight, ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight,
h+SDL_Window->BorderTop+SDL_Window->BorderBottom); h+SDL_Window->BorderTop+SDL_Window->BorderBottom);
......
...@@ -67,10 +67,6 @@ struct SDL_PrivateVideoData { ...@@ -67,10 +67,6 @@ struct SDL_PrivateVideoData {
Uint8 *Ximage; /* The X image for our window */ Uint8 *Ximage; /* The X image for our window */
int swap_pixels; /* Flag: true if display is swapped endian */ int swap_pixels; /* Flag: true if display is swapped endian */
/* The current width and height of the fullscreen mode */
int current_w;
int current_h;
/* Support for internal mouse warping */ /* Support for internal mouse warping */
struct { struct {
int x; int x;
...@@ -132,8 +128,6 @@ struct SDL_PrivateVideoData { ...@@ -132,8 +128,6 @@ struct SDL_PrivateVideoData {
#define SDL_Ximage (this->hidden->Ximage) #define SDL_Ximage (this->hidden->Ximage)
#define SDL_GC (this->hidden->gc) #define SDL_GC (this->hidden->gc)
#define swap_pixels (this->hidden->swap_pixels) #define swap_pixels (this->hidden->swap_pixels)
#define current_w (this->hidden->current_w)
#define current_h (this->hidden->current_h)
#define mouse_last (this->hidden->mouse_last) #define mouse_last (this->hidden->mouse_last)
#define mouse_accel (this->hidden->mouse_accel) #define mouse_accel (this->hidden->mouse_accel)
#define mouse_relative (this->hidden->mouse_relative) #define mouse_relative (this->hidden->mouse_relative)
......
...@@ -349,6 +349,10 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -349,6 +349,10 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
} }
DGA_event_base = event_base; DGA_event_base = event_base;
/* Determine the current screen size */
this->info.current_w = DisplayWidth(DGA_Display, DGA_Screen);
this->info.current_h = DisplayHeight(DGA_Display, DGA_Screen);
/* Determine the current screen depth */ /* Determine the current screen depth */
visual = DefaultVisual(DGA_Display, DGA_Screen); visual = DefaultVisual(DGA_Display, DGA_Screen);
{ {
......
...@@ -291,6 +291,9 @@ int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -291,6 +291,9 @@ int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat)
#endif /* __WINS__ */ #endif /* __WINS__ */
_this->info.current_w = Private->EPOC_ScreenSize.iWidth;
_this->info.current_h = Private->EPOC_ScreenSize.iHeight;
/* The "best" video format should be returned to caller. */ /* The "best" video format should be returned to caller. */
vformat->BitsPerPixel = /*!!GetBpp(displayMode) */ 8; vformat->BitsPerPixel = /*!!GetBpp(displayMode) */ 8;
......
...@@ -636,6 +636,8 @@ static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -636,6 +636,8 @@ static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat)
} }
/* Fill in our hardware acceleration capabilities */ /* Fill in our hardware acceleration capabilities */
this->info.current_w = current_w;
this->info.current_h = current_h;
this->info.wm_available = 0; this->info.wm_available = 0;
this->info.hw_available = 1; this->info.hw_available = 1;
this->info.video_mem = finfo.smem_len/1024; this->info.video_mem = finfo.smem_len/1024;
......
...@@ -529,6 +529,10 @@ int GAPI_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -529,6 +529,10 @@ int GAPI_VideoInit(_THIS, SDL_PixelFormat *vformat)
GAPI_AddMode(this, bpp, gapi->gxProperties.cxWidth, gapi->gxProperties.cyHeight); GAPI_AddMode(this, bpp, gapi->gxProperties.cxWidth, gapi->gxProperties.cyHeight);
} }
/* Determine the current screen size */
this->info.current_w = gapi->gxProperties.cxWidth;
this->info.current_h = gapi->gxProperties.cyHeight;
/* Sort the mode lists */ /* Sort the mode lists */
for ( i=0; i<NUM_MODELISTS; ++i ) { for ( i=0; i<NUM_MODELISTS; ++i ) {
if ( gapi->SDL_nummodes[i] > 0 ) { if ( gapi->SDL_nummodes[i] > 0 ) {
......
...@@ -430,9 +430,9 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -430,9 +430,9 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat)
/* Setup destination mfdb */ /* Setup destination mfdb */
VDI_dst_mfdb.fd_addr = NULL; VDI_dst_mfdb.fd_addr = NULL;
/* Update hardware info */ /* Determine the current screen size */
this->info.hw_available = 0; this->info.current_w = VDI_w;
this->info.video_mem = 0; this->info.current_h = VDI_h;
/* Determine the screen depth */ /* Determine the screen depth */
/* we change this during the SDL_SetVideoMode implementation... */ /* we change this during the SDL_SetVideoMode implementation... */
......
...@@ -197,6 +197,10 @@ int GGI_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -197,6 +197,10 @@ int GGI_VideoInit(_THIS, SDL_PixelFormat *vformat)
GGI_VideoQuit(NULL); GGI_VideoQuit(NULL);
} }
/* Determine the current screen size */
this->info.current_w = mode.virt.x;
this->info.current_h = mode.virt.y;
/* Set a palette for palletized modes */ /* Set a palette for palletized modes */
if (GT_SCHEME(mode.graphtype) == GT_PALETTE) if (GT_SCHEME(mode.graphtype) == GT_PALETTE)
{ {
......
...@@ -287,6 +287,10 @@ static int iPod_VideoInit (_THIS, SDL_PixelFormat *vformat) ...@@ -287,6 +287,10 @@ static int iPod_VideoInit (_THIS, SDL_PixelFormat *vformat)
fcntl (kbfd, F_SETFL, O_RDWR | O_NONBLOCK); fcntl (kbfd, F_SETFL, O_RDWR | O_NONBLOCK);
/* Determine the current screen size */
this->info.current_w = lcd_width;
this->info.current_h = lcd_height;
if ((generation >= 60000) && (generation < 70000)) { if ((generation >= 60000) && (generation < 70000)) {
vformat->BitsPerPixel = 16; vformat->BitsPerPixel = 16;
vformat->Rmask = 0xF800; vformat->Rmask = 0xF800;
......
...@@ -329,7 +329,7 @@ VideoBootStrap DSp_bootstrap = { ...@@ -329,7 +329,7 @@ VideoBootStrap DSp_bootstrap = {
}; };
/* Use DSp/Display Manager to build mode list for given screen */ /* Use DSp/Display Manager to build mode list for given screen */
static SDL_Rect** DSp_BuildModeList (const GDHandle gDevice) static SDL_Rect** DSp_BuildModeList (const GDHandle gDevice, int *displayWidth, int *displayHeight)
{ {
DSpContextAttributes attributes; DSpContextAttributes attributes;
DSpContextReference context; DSpContextReference context;
...@@ -356,6 +356,9 @@ static SDL_Rect** DSp_BuildModeList (const GDHandle gDevice) ...@@ -356,6 +356,9 @@ static SDL_Rect** DSp_BuildModeList (const GDHandle gDevice)
if ( DSpContext_GetAttributes (context, &attributes) != noErr ) if ( DSpContext_GetAttributes (context, &attributes) != noErr )
return NULL; return NULL;
*displayWidth = attributes.displayWidth;
*displayHeight = attributes.displayHeight;
for ( i = 0; i < SDL_arraysize(temp_list); i++ ) { for ( i = 0; i < SDL_arraysize(temp_list); i++ ) {
width = attributes.displayWidth; width = attributes.displayWidth;
height = attributes.displayHeight; height = attributes.displayHeight;
...@@ -557,13 +560,13 @@ static int DSp_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -557,13 +560,13 @@ static int DSp_VideoInit(_THIS, SDL_PixelFormat *vformat)
} }
if ( DSp_CreatePalette (this) < 0 ) { if ( DSp_CreatePalette (this) < 0 ) {
SDL_SetError ("Could not create palette"); SDL_SetError ("Could not create palette");
return (-1); return (-1);
} }
/* Get a list of available fullscreen modes */ /* Get a list of available fullscreen modes */
SDL_modelist = DSp_BuildModeList (SDL_Display); SDL_modelist = DSp_BuildModeList (SDL_Display,
&this->info.current_w, &this->info.current_h);
if (SDL_modelist == NULL) { if (SDL_modelist == NULL) {
SDL_SetError ("DrawSprocket could not build a mode list"); SDL_SetError ("DrawSprocket could not build a mode list");
return (-1); return (-1);
......
...@@ -203,6 +203,10 @@ static int ROM_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -203,6 +203,10 @@ static int ROM_VideoInit(_THIS, SDL_PixelFormat *vformat)
/* Get a handle to the main monitor */ /* Get a handle to the main monitor */
SDL_Display = GetMainDevice(); SDL_Display = GetMainDevice();
/* Determine the current screen size */
this->info.current_w = (**SDL_Display).gdRect.right;
this->info.current_h = (**SDL_Display).gdRect.bottom;
/* Determine pixel format */ /* Determine pixel format */
vformat->BitsPerPixel = (**(**SDL_Display).gdPMap).pixelSize; vformat->BitsPerPixel = (**(**SDL_Display).gdPMap).pixelSize;
switch (vformat->BitsPerPixel) { switch (vformat->BitsPerPixel) {
......
...@@ -209,6 +209,10 @@ int NX_VideoInit (_THIS, SDL_PixelFormat * vformat) ...@@ -209,6 +209,10 @@ int NX_VideoInit (_THIS, SDL_PixelFormat * vformat)
GrGetScreenInfo (& si) ; GrGetScreenInfo (& si) ;
SDL_Visual.bpp = si.bpp ; SDL_Visual.bpp = si.bpp ;
/* Determine the current screen size */
this->info.current_w = si.cols ;
this->info.current_h = si.rows ;
// GetVideoMode // GetVideoMode
SDL_modelist = (SDL_Rect **) SDL_malloc (sizeof (SDL_Rect *) * 2) ; SDL_modelist = (SDL_Rect **) SDL_malloc (sizeof (SDL_Rect *) * 2) ;
if (SDL_modelist) { if (SDL_modelist) {
......
...@@ -2724,6 +2724,10 @@ static int os2fslib_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -2724,6 +2724,10 @@ static int os2fslib_VideoInit(_THIS, SDL_PixelFormat *vformat)
return -1; return -1;
} }
/* Determine the current screen size */
_this->info.current_w = 0; // FIXME!
_this->info.current_h = 0; // FIXME!
/* Determine the screen depth */ /* Determine the screen depth */
vformat->BitsPerPixel = pDesktopMode->uiBPP; vformat->BitsPerPixel = pDesktopMode->uiBPP;
vformat->BytesPerPixel = (vformat->BitsPerPixel+7)/8; vformat->BytesPerPixel = (vformat->BitsPerPixel+7)/8;
......
...@@ -400,6 +400,10 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat* vformat) ...@@ -400,6 +400,10 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat* vformat)
return -1; return -1;
} }
/* Determine the current screen size */
this->info.current_w = desktop_mode.width;
this->info.current_h = desktop_mode.height;
/* We need to return BytesPerPixel as it in used by CreateRGBsurface */ /* We need to return BytesPerPixel as it in used by CreateRGBsurface */
vformat->BitsPerPixel = desktop_mode.bits_per_pixel; vformat->BitsPerPixel = desktop_mode.bits_per_pixel;
vformat->BytesPerPixel = desktop_mode.bytes_per_scanline/desktop_mode.width; vformat->BytesPerPixel = desktop_mode.bytes_per_scanline/desktop_mode.width;
......
...@@ -166,6 +166,10 @@ int PG_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -166,6 +166,10 @@ int PG_VideoInit(_THIS, SDL_PixelFormat *vformat)
PG_InitEvents(this); PG_InitEvents(this);
/* Determine the current screen size */
this->info.current_w = this->hidden->mi.lxres;
this->info.current_h = this->hidden->mi.lyres;
/* Determine the screen depth. /* Determine the screen depth.
* We change this during the SDL_SetVideoMode implementation... * We change this during the SDL_SetVideoMode implementation...
* Round up to the nearest Bytes per pixel * Round up to the nearest Bytes per pixel
......
...@@ -298,7 +298,6 @@ static int GS_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -298,7 +298,6 @@ static int GS_VideoInit(_THIS, SDL_PixelFormat *vformat)
return(-1); return(-1);
} }
/* Determine the current screen depth */
if ( ioctl(console_fd, PS2IOC_GSCREENINFO, &vinfo) < 0 ) { if ( ioctl(console_fd, PS2IOC_GSCREENINFO, &vinfo) < 0 ) {
close(memory_fd); close(memory_fd);
close(console_fd); close(console_fd);
...@@ -306,6 +305,12 @@ static int GS_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -306,6 +305,12 @@ static int GS_VideoInit(_THIS, SDL_PixelFormat *vformat)
SDL_SetError("Couldn't get console pixel format"); SDL_SetError("Couldn't get console pixel format");
return(-1); return(-1);
} }
/* Determine the current screen size */
this->info.current_w = vinfo.w;
this->info.current_h = vinfo.h;
/* Determine the current screen depth */
switch (vinfo.psm) { switch (vinfo.psm) {
/* Supported pixel formats */ /* Supported pixel formats */
case PS2_GS_PSMCT32: case PS2_GS_PSMCT32:
......
...@@ -226,6 +226,10 @@ extern "C" { ...@@ -226,6 +226,10 @@ extern "C" {
QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1, QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1,
desktop_size.height(), desktop_size.width()); desktop_size.height(), desktop_size.width());
/* Determine the current screen size */
this->info.current_w = desktop_size.width();
this->info.current_h = desktop_size.height();
/* Create the window / widget */ /* Create the window / widget */
SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE)); SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE));
((QPEApplication*)qApp)->showMainWidget(SDL_Win); ((QPEApplication*)qApp)->showMainWidget(SDL_Win);
......
...@@ -200,6 +200,11 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) { ...@@ -200,6 +200,11 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) {
CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayHeight), CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayHeight),
kCFNumberSInt32Type, &device_height); kCFNumberSInt32Type, &device_height);
/* Determine the current screen size */
this->info.current_w = device_width;
this->info.current_h = device_height;
/* Determine the default screen depth */
video_format->BitsPerPixel = device_bpp; video_format->BitsPerPixel = device_bpp;
/* Set misc globals */ /* Set misc globals */
......
...@@ -175,6 +175,10 @@ int RISCOS_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -175,6 +175,10 @@ int RISCOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
_kernel_swi(OS_ReadModeVariable, &regs, &regs); _kernel_swi(OS_ReadModeVariable, &regs, &regs);
vformat->BitsPerPixel = (1 << regs.r[2]); vformat->BitsPerPixel = (1 << regs.r[2]);
/* Determine the current screen size */
this->info.current_w = 0; /* FIXME! */
this->info.current_h = 0; /* FIXME! */
/* Minimum bpp for SDL is 8 */ /* Minimum bpp for SDL is 8 */
if (vformat->BitsPerPixel < 8) vformat->BitsPerPixel = 8; if (vformat->BitsPerPixel < 8) vformat->BitsPerPixel = 8;
......
...@@ -257,6 +257,10 @@ int SVGA_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -257,6 +257,10 @@ int SVGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
} }
keyboard_seteventhandler(SVGA_keyboardcallback); keyboard_seteventhandler(SVGA_keyboardcallback);
/* Determine the current screen size */
this->info.current_w = 0;
this->info.current_h = 0;
/* Determine the screen depth (use default 8-bit depth) */ /* Determine the screen depth (use default 8-bit depth) */
vformat->BitsPerPixel = 8; vformat->BitsPerPixel = 8;
......
...@@ -257,6 +257,12 @@ int VGL_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -257,6 +257,12 @@ int VGL_VideoInit(_THIS, SDL_PixelFormat *vformat)
return -1; return -1;
} }
/* Determine the current screen size */
if (VGLCurMode != NULL) {
this->info.current_w = VGLCurMode->ModeInfo.Xsize;
this->info.current_h = VGLCurMode->ModeInfo.Ysize;
}
/* Determine the screen depth */ /* Determine the screen depth */
if (VGLCurMode != NULL) if (VGLCurMode != NULL)
vformat->BitsPerPixel = VGLCurMode->Depth; vformat->BitsPerPixel = VGLCurMode->Depth;
......
...@@ -334,6 +334,8 @@ int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -334,6 +334,8 @@ int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat)
#endif #endif
/* Query for the desktop resolution */ /* Query for the desktop resolution */
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode); EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode);
this->info.current_w = SDL_desktop_mode.dmPelsWidth;
this->info.current_h = SDL_desktop_mode.dmPelsHeight;
/* Query for the list of available video modes */ /* Query for the list of available video modes */
for ( i=0; EnumDisplaySettings(NULL, i, &settings); ++i ) { for ( i=0; EnumDisplaySettings(NULL, i, &settings); ++i ) {
......
...@@ -930,6 +930,8 @@ int DX5_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -930,6 +930,8 @@ int DX5_VideoInit(_THIS, SDL_PixelFormat *vformat)
#ifndef NO_CHANGEDISPLAYSETTINGS #ifndef NO_CHANGEDISPLAYSETTINGS
/* Query for the desktop resolution */ /* Query for the desktop resolution */
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode); EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &SDL_desktop_mode);
this->info.current_w = SDL_desktop_mode.dmPelsWidth;
this->info.current_h = SDL_desktop_mode.dmPelsHeight;
#endif #endif
/* Enumerate the available fullscreen modes */ /* Enumerate the available fullscreen modes */
......
...@@ -300,6 +300,9 @@ int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -300,6 +300,9 @@ int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat)
height = private->info.height; height = private->info.height;
} }
this->info.current_w = width;
this->info.current_h = height;
if (private->shadowFB) { if (private->shadowFB) {
private->shadowmem = (Uint8 *)SDL_malloc(len); private->shadowmem = (Uint8 *)SDL_malloc(len);
if (private->shadowmem == NULL) { if (private->shadowmem == NULL) {
......
...@@ -652,21 +652,21 @@ int X11_ResizeFullScreen(_THIS) ...@@ -652,21 +652,21 @@ int X11_ResizeFullScreen(_THIS)
if ( currently_fullscreen ) { if ( currently_fullscreen ) {
/* Switch resolution and cover it with the FSwindow */ /* Switch resolution and cover it with the FSwindow */
move_cursor_to(this, x, y); move_cursor_to(this, x, y);
set_best_resolution(this, current_w, current_h); set_best_resolution(this, window_w, window_h);
move_cursor_to(this, x, y); move_cursor_to(this, x, y);
get_real_resolution(this, &real_w, &real_h); get_real_resolution(this, &real_w, &real_h);
if ( current_w > real_w ) { if ( window_w > real_w ) {
real_w = MAX(real_w, screen_w); real_w = MAX(real_w, screen_w);
} }
if ( current_h > real_h ) { if ( window_h > real_h ) {
real_h = MAX(real_h, screen_h); real_h = MAX(real_h, screen_h);
} }
pXMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h); pXMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h);
move_cursor_to(this, real_w/2, real_h/2); move_cursor_to(this, real_w/2, real_h/2);
/* Center and reparent the drawing window */ /* Center and reparent the drawing window */
x = (real_w - current_w)/2; x = (real_w - window_w)/2;
y = (real_h - current_h)/2; y = (real_h - window_h)/2;
pXReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y); pXReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y);
/* FIXME: move the mouse to the old relative location */ /* FIXME: move the mouse to the old relative location */
pXSync(SDL_Display, True); /* Flush spurious mode change events */ pXSync(SDL_Display, True); /* Flush spurious mode change events */
...@@ -706,10 +706,10 @@ int X11_EnterFullScreen(_THIS) ...@@ -706,10 +706,10 @@ int X11_EnterFullScreen(_THIS)
screen_w = DisplayWidth(SDL_Display, SDL_Screen); screen_w = DisplayWidth(SDL_Display, SDL_Screen);
screen_h = DisplayHeight(SDL_Display, SDL_Screen); screen_h = DisplayHeight(SDL_Display, SDL_Screen);
get_real_resolution(this, &real_w, &real_h); get_real_resolution(this, &real_w, &real_h);
if ( current_w > real_w ) { if ( window_w > real_w ) {
real_w = MAX(real_w, screen_w); real_w = MAX(real_w, screen_w);
} }
if ( current_h > real_h ) { if ( window_h > real_h ) {
real_h = MAX(real_h, screen_h); real_h = MAX(real_h, screen_h);
} }
pXMoveResizeWindow(SDL_Display, FSwindow, pXMoveResizeWindow(SDL_Display, FSwindow,
......
...@@ -508,6 +508,10 @@ static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -508,6 +508,10 @@ static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat)
if(X11_GetVideoModes(this) < 0) if(X11_GetVideoModes(this) < 0)
return -1; return -1;
/* Determine the current screen size */
this->info.current_w = DisplayWidth(SDL_Display, SDL_Screen);
this->info.current_h = DisplayHeight(SDL_Display, SDL_Screen);
/* Determine the default screen depth: /* Determine the default screen depth:
Use the default visual (or at least one with the same depth) */ Use the default visual (or at least one with the same depth) */
SDL_DisplayColormap = DefaultColormap(SDL_Display, SDL_Screen); SDL_DisplayColormap = DefaultColormap(SDL_Display, SDL_Screen);
...@@ -863,8 +867,8 @@ static int X11_CreateWindow(_THIS, SDL_Surface *screen, ...@@ -863,8 +867,8 @@ static int X11_CreateWindow(_THIS, SDL_Surface *screen,
/* resize the (possibly new) window manager window */ /* resize the (possibly new) window manager window */
if( !SDL_windowid ) { if( !SDL_windowid ) {
X11_SetSizeHints(this, w, h, flags); X11_SetSizeHints(this, w, h, flags);
current_w = w; window_w = w;
current_h = h; window_h = h;
pXResizeWindow(SDL_Display, WMwindow, w, h); pXResizeWindow(SDL_Display, WMwindow, w, h);
} }
...@@ -985,8 +989,8 @@ static int X11_ResizeWindow(_THIS, ...@@ -985,8 +989,8 @@ static int X11_ResizeWindow(_THIS,
if ( ! SDL_windowid ) { if ( ! SDL_windowid ) {
/* Resize the window manager window */ /* Resize the window manager window */
X11_SetSizeHints(this, w, h, flags); X11_SetSizeHints(this, w, h, flags);
current_w = w; window_w = w;
current_h = h; window_h = h;
pXResizeWindow(SDL_Display, WMwindow, w, h); pXResizeWindow(SDL_Display, WMwindow, w, h);
/* Resize the fullscreen and display windows */ /* Resize the fullscreen and display windows */
......
...@@ -76,8 +76,8 @@ struct SDL_PrivateVideoData { ...@@ -76,8 +76,8 @@ struct SDL_PrivateVideoData {
GC gc; /* The graphic context for drawing */ GC gc; /* The graphic context for drawing */
/* The current width and height of the fullscreen mode */ /* The current width and height of the fullscreen mode */
int current_w; int window_w;
int current_h; int window_h;
/* Support for internal mouse warping */ /* Support for internal mouse warping */
struct { struct {
...@@ -159,8 +159,8 @@ struct SDL_PrivateVideoData { ...@@ -159,8 +159,8 @@ struct SDL_PrivateVideoData {
#define shminfo (this->hidden->shminfo) #define shminfo (this->hidden->shminfo)
#define SDL_Ximage (this->hidden->Ximage) #define SDL_Ximage (this->hidden->Ximage)
#define SDL_GC (this->hidden->gc) #define SDL_GC (this->hidden->gc)
#define current_w (this->hidden->current_w) #define window_w (this->hidden->window_w)
#define current_h (this->hidden->current_h) #define window_h (this->hidden->window_h)
#define mouse_last (this->hidden->mouse_last) #define mouse_last (this->hidden->mouse_last)
#define mouse_accel (this->hidden->mouse_accel) #define mouse_accel (this->hidden->mouse_accel)
#define mouse_relative (this->hidden->mouse_relative) #define mouse_relative (this->hidden->mouse_relative)
......
...@@ -416,6 +416,12 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) ...@@ -416,6 +416,12 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat)
break; break;
} }
/* Determine the current screen size */
if ( XBIOS_nummodes > 0 ) {
this->info.current_w = XBIOS_modelist[0].width;
this->info.current_h = XBIOS_modelist[0].height;
}
current_mode = XBIOS_modelist; current_mode = XBIOS_modelist;
j8 = j16 = 0; j8 = j16 = 0;
for (i=0; i<XBIOS_nummodes; i++, current_mode++) { for (i=0; i<XBIOS_nummodes; i++, current_mode++) {
......
...@@ -400,7 +400,8 @@ int main(int argc, char *argv[]) ...@@ -400,7 +400,8 @@ int main(int argc, char *argv[])
} }
info = SDL_GetVideoInfo(); info = SDL_GetVideoInfo();
printf( printf(
"Current display: %d bits-per-pixel\n",info->vfmt->BitsPerPixel); "Current display: %dx%d, %d bits-per-pixel\n",
info->current_w, info->current_h, info->vfmt->BitsPerPixel);
if ( info->vfmt->palette == NULL ) { if ( info->vfmt->palette == NULL ) {
printf(" Red Mask = 0x%.8x\n", info->vfmt->Rmask); printf(" Red Mask = 0x%.8x\n", info->vfmt->Rmask);
printf(" Green Mask = 0x%.8x\n", info->vfmt->Gmask); printf(" Green Mask = 0x%.8x\n", info->vfmt->Gmask);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment