From d532c736691527b105164225957ce1545e9aea84 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 15 Mar 2006 17:46:41 +0000 Subject: [PATCH] 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.) --- WhatsNew | 8 ++++++++ include/SDL_video.h | 2 ++ src/video/SDL_video.c | 9 +++++++++ src/video/bwindow/SDL_sysvideo.cc | 2 ++ src/video/cybergfx/SDL_cgxvideo.c | 6 ++---- src/video/cybergfx/SDL_cgxvideo.h | 6 ------ src/video/dga/SDL_dgavideo.c | 4 ++++ src/video/epoc/SDL_epocvideo.cpp | 3 +++ src/video/fbcon/SDL_fbvideo.c | 2 ++ src/video/gapi/SDL_gapivideo.c | 4 ++++ src/video/gem/SDL_gemvideo.c | 6 +++--- src/video/ggi/SDL_ggivideo.c | 4 ++++ src/video/ipod/SDL_ipodvideo.c | 4 ++++ src/video/macdsp/SDL_dspvideo.c | 17 ++++++++++------- src/video/macrom/SDL_romvideo.c | 4 ++++ src/video/nanox/SDL_nxvideo.c | 4 ++++ src/video/os2fslib/SDL_os2fslib.c | 4 ++++ src/video/photon/SDL_ph_video.c | 4 ++++ src/video/picogui/SDL_pgvideo.c | 4 ++++ src/video/ps2gs/SDL_gsvideo.c | 7 ++++++- src/video/qtopia/SDL_sysvideo.cc | 4 ++++ src/video/quartz/SDL_QuartzVideo.m | 5 +++++ src/video/riscos/SDL_riscosvideo.c | 4 ++++ src/video/svga/SDL_svgavideo.c | 4 ++++ src/video/vgl/SDL_vglvideo.c | 6 ++++++ src/video/windib/SDL_dibvideo.c | 2 ++ src/video/windx5/SDL_dx5video.c | 2 ++ src/video/wscons/SDL_wsconsvideo.c | 3 +++ src/video/x11/SDL_x11modes.c | 14 +++++++------- src/video/x11/SDL_x11video.c | 12 ++++++++---- src/video/x11/SDL_x11video.h | 8 ++++---- src/video/xbios/SDL_xbios.c | 6 ++++++ test/testvidinfo.c | 3 ++- 33 files changed, 140 insertions(+), 37 deletions(-) diff --git a/WhatsNew b/WhatsNew index 9ac90f771..2a1206b0f 100644 --- a/WhatsNew +++ b/WhatsNew @@ -4,7 +4,15 @@ This is a list of API changes in SDL's version history. Version 1.0: 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_config.h, with defaults for various build environments. 1.2.7: diff --git a/include/SDL_video.h b/include/SDL_video.h index d70330e1a..ba7585340 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -161,6 +161,8 @@ typedef struct SDL_VideoInfo { Uint32 UnusedBits3 :16; Uint32 video_mem; /* The total amount of video memory (in K) */ 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; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index a28a3e8fa..02a521de9 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -587,6 +587,13 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) } 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 */ if ( bpp == 0 ) { flags |= SDL_ANYFORMAT; @@ -889,6 +896,8 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) SDL_PublicSurface = SDL_VideoSurface; } video->info.vfmt = SDL_VideoSurface->format; + video->info.current_w = SDL_VideoSurface->w; + video->info.current_h = SDL_VideoSurface->h; /* We're done! */ return(SDL_PublicSurface); diff --git a/src/video/bwindow/SDL_sysvideo.cc b/src/video/bwindow/SDL_sysvideo.cc index 659263434..0a6f4ac8c 100644 --- a/src/video/bwindow/SDL_sysvideo.cc +++ b/src/video/bwindow/SDL_sysvideo.cc @@ -275,6 +275,8 @@ int BE_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Save the current display 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 */ vformat->BitsPerPixel = ColorSpaceToBitsPerPixel(bscreen.ColorSpace()); diff --git a/src/video/cybergfx/SDL_cgxvideo.c b/src/video/cybergfx/SDL_cgxvideo.c index 417ab70af..e3067464d 100644 --- a/src/video/cybergfx/SDL_cgxvideo.c +++ b/src/video/cybergfx/SDL_cgxvideo.c @@ -463,6 +463,8 @@ static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat) SDL_SetError("Couldn't lock the display"); 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")); @@ -834,8 +836,6 @@ int CGX_CreateWindow(_THIS, SDL_Surface *screen, if( !SDL_windowid ) { CGX_SetSizeHints(this, w, h, flags); - current_w = w; - current_h = h; } /* Set our colormaps when not setting a GL mode */ @@ -885,8 +885,6 @@ int CGX_ResizeWindow(_THIS, if ( ! SDL_windowid ) { /* Resize the window manager window */ 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, h+SDL_Window->BorderTop+SDL_Window->BorderBottom); diff --git a/src/video/cybergfx/SDL_cgxvideo.h b/src/video/cybergfx/SDL_cgxvideo.h index b5ed8f129..9ef76ea55 100644 --- a/src/video/cybergfx/SDL_cgxvideo.h +++ b/src/video/cybergfx/SDL_cgxvideo.h @@ -67,10 +67,6 @@ struct SDL_PrivateVideoData { Uint8 *Ximage; /* The X image for our window */ 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 */ struct { int x; @@ -132,8 +128,6 @@ struct SDL_PrivateVideoData { #define SDL_Ximage (this->hidden->Ximage) #define SDL_GC (this->hidden->gc) #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_accel (this->hidden->mouse_accel) #define mouse_relative (this->hidden->mouse_relative) diff --git a/src/video/dga/SDL_dgavideo.c b/src/video/dga/SDL_dgavideo.c index 055222fa2..2cf5b52f0 100644 --- a/src/video/dga/SDL_dgavideo.c +++ b/src/video/dga/SDL_dgavideo.c @@ -349,6 +349,10 @@ static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat) } 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 */ visual = DefaultVisual(DGA_Display, DGA_Screen); { diff --git a/src/video/epoc/SDL_epocvideo.cpp b/src/video/epoc/SDL_epocvideo.cpp index 13f4a1317..020752d21 100644 --- a/src/video/epoc/SDL_epocvideo.cpp +++ b/src/video/epoc/SDL_epocvideo.cpp @@ -291,6 +291,9 @@ int EPOC_VideoInit(_THIS, SDL_PixelFormat *vformat) #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. */ vformat->BitsPerPixel = /*!!GetBpp(displayMode) */ 8; diff --git a/src/video/fbcon/SDL_fbvideo.c b/src/video/fbcon/SDL_fbvideo.c index 4e5262ff8..412317d5f 100644 --- a/src/video/fbcon/SDL_fbvideo.c +++ b/src/video/fbcon/SDL_fbvideo.c @@ -636,6 +636,8 @@ static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat) } /* 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.hw_available = 1; this->info.video_mem = finfo.smem_len/1024; diff --git a/src/video/gapi/SDL_gapivideo.c b/src/video/gapi/SDL_gapivideo.c index ca074bfc4..93648f983 100644 --- a/src/video/gapi/SDL_gapivideo.c +++ b/src/video/gapi/SDL_gapivideo.c @@ -529,6 +529,10 @@ int GAPI_VideoInit(_THIS, SDL_PixelFormat *vformat) 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 */ for ( i=0; iSDL_nummodes[i] > 0 ) { diff --git a/src/video/gem/SDL_gemvideo.c b/src/video/gem/SDL_gemvideo.c index 6477076c5..d517f5432 100644 --- a/src/video/gem/SDL_gemvideo.c +++ b/src/video/gem/SDL_gemvideo.c @@ -430,9 +430,9 @@ int GEM_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Setup destination mfdb */ VDI_dst_mfdb.fd_addr = NULL; - /* Update hardware info */ - this->info.hw_available = 0; - this->info.video_mem = 0; + /* Determine the current screen size */ + this->info.current_w = VDI_w; + this->info.current_h = VDI_h; /* Determine the screen depth */ /* we change this during the SDL_SetVideoMode implementation... */ diff --git a/src/video/ggi/SDL_ggivideo.c b/src/video/ggi/SDL_ggivideo.c index 909df324e..a55154a83 100644 --- a/src/video/ggi/SDL_ggivideo.c +++ b/src/video/ggi/SDL_ggivideo.c @@ -197,6 +197,10 @@ int GGI_VideoInit(_THIS, SDL_PixelFormat *vformat) 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 */ if (GT_SCHEME(mode.graphtype) == GT_PALETTE) { diff --git a/src/video/ipod/SDL_ipodvideo.c b/src/video/ipod/SDL_ipodvideo.c index ce3dad380..cac476602 100644 --- a/src/video/ipod/SDL_ipodvideo.c +++ b/src/video/ipod/SDL_ipodvideo.c @@ -287,6 +287,10 @@ static int iPod_VideoInit (_THIS, SDL_PixelFormat *vformat) 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)) { vformat->BitsPerPixel = 16; vformat->Rmask = 0xF800; diff --git a/src/video/macdsp/SDL_dspvideo.c b/src/video/macdsp/SDL_dspvideo.c index a0f0210f9..f0df4e920 100644 --- a/src/video/macdsp/SDL_dspvideo.c +++ b/src/video/macdsp/SDL_dspvideo.c @@ -329,7 +329,7 @@ VideoBootStrap DSp_bootstrap = { }; /* 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; DSpContextReference context; @@ -355,6 +355,9 @@ static SDL_Rect** DSp_BuildModeList (const GDHandle gDevice) if ( DSpContext_GetAttributes (context, &attributes) != noErr ) return NULL; + + *displayWidth = attributes.displayWidth; + *displayHeight = attributes.displayHeight; for ( i = 0; i < SDL_arraysize(temp_list); i++ ) { width = attributes.displayWidth; @@ -556,14 +559,14 @@ static int DSp_VideoInit(_THIS, SDL_PixelFormat *vformat) break; } - if ( DSp_CreatePalette (this) < 0 ) { - - SDL_SetError ("Could not create palette"); - return (-1); - } + if ( DSp_CreatePalette (this) < 0 ) { + SDL_SetError ("Could not create palette"); + return (-1); + } /* 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) { SDL_SetError ("DrawSprocket could not build a mode list"); return (-1); diff --git a/src/video/macrom/SDL_romvideo.c b/src/video/macrom/SDL_romvideo.c index af3b8248e..ef83d93f6 100644 --- a/src/video/macrom/SDL_romvideo.c +++ b/src/video/macrom/SDL_romvideo.c @@ -203,6 +203,10 @@ static int ROM_VideoInit(_THIS, SDL_PixelFormat *vformat) /* Get a handle to the main monitor */ 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 */ vformat->BitsPerPixel = (**(**SDL_Display).gdPMap).pixelSize; switch (vformat->BitsPerPixel) { diff --git a/src/video/nanox/SDL_nxvideo.c b/src/video/nanox/SDL_nxvideo.c index d52b84e9d..12df7e2b6 100644 --- a/src/video/nanox/SDL_nxvideo.c +++ b/src/video/nanox/SDL_nxvideo.c @@ -209,6 +209,10 @@ int NX_VideoInit (_THIS, SDL_PixelFormat * vformat) GrGetScreenInfo (& si) ; SDL_Visual.bpp = si.bpp ; + /* Determine the current screen size */ + this->info.current_w = si.cols ; + this->info.current_h = si.rows ; + // GetVideoMode SDL_modelist = (SDL_Rect **) SDL_malloc (sizeof (SDL_Rect *) * 2) ; if (SDL_modelist) { diff --git a/src/video/os2fslib/SDL_os2fslib.c b/src/video/os2fslib/SDL_os2fslib.c index 267dfe8a2..c05a0c1ae 100644 --- a/src/video/os2fslib/SDL_os2fslib.c +++ b/src/video/os2fslib/SDL_os2fslib.c @@ -2724,6 +2724,10 @@ static int os2fslib_VideoInit(_THIS, SDL_PixelFormat *vformat) return -1; } + /* Determine the current screen size */ + _this->info.current_w = 0; // FIXME! + _this->info.current_h = 0; // FIXME! + /* Determine the screen depth */ vformat->BitsPerPixel = pDesktopMode->uiBPP; vformat->BytesPerPixel = (vformat->BitsPerPixel+7)/8; diff --git a/src/video/photon/SDL_ph_video.c b/src/video/photon/SDL_ph_video.c index 5df23a367..ad6266ee8 100644 --- a/src/video/photon/SDL_ph_video.c +++ b/src/video/photon/SDL_ph_video.c @@ -400,6 +400,10 @@ static int ph_VideoInit(_THIS, SDL_PixelFormat* vformat) 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 */ vformat->BitsPerPixel = desktop_mode.bits_per_pixel; vformat->BytesPerPixel = desktop_mode.bytes_per_scanline/desktop_mode.width; diff --git a/src/video/picogui/SDL_pgvideo.c b/src/video/picogui/SDL_pgvideo.c index b4b2087e9..04464afb0 100644 --- a/src/video/picogui/SDL_pgvideo.c +++ b/src/video/picogui/SDL_pgvideo.c @@ -166,6 +166,10 @@ int PG_VideoInit(_THIS, SDL_PixelFormat *vformat) 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. * We change this during the SDL_SetVideoMode implementation... * Round up to the nearest Bytes per pixel diff --git a/src/video/ps2gs/SDL_gsvideo.c b/src/video/ps2gs/SDL_gsvideo.c index e0f5b1612..878b32abf 100644 --- a/src/video/ps2gs/SDL_gsvideo.c +++ b/src/video/ps2gs/SDL_gsvideo.c @@ -298,7 +298,6 @@ static int GS_VideoInit(_THIS, SDL_PixelFormat *vformat) return(-1); } - /* Determine the current screen depth */ if ( ioctl(console_fd, PS2IOC_GSCREENINFO, &vinfo) < 0 ) { close(memory_fd); close(console_fd); @@ -306,6 +305,12 @@ static int GS_VideoInit(_THIS, SDL_PixelFormat *vformat) SDL_SetError("Couldn't get console pixel format"); 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) { /* Supported pixel formats */ case PS2_GS_PSMCT32: diff --git a/src/video/qtopia/SDL_sysvideo.cc b/src/video/qtopia/SDL_sysvideo.cc index 5231e0653..c556d79d3 100644 --- a/src/video/qtopia/SDL_sysvideo.cc +++ b/src/video/qtopia/SDL_sysvideo.cc @@ -226,6 +226,10 @@ extern "C" { QT_AddMode(_this, ((vformat->BitsPerPixel+7)/8)-1, 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 */ SDL_Win = new SDL_QWin(QSize(QT_HIDDEN_SIZE, QT_HIDDEN_SIZE)); ((QPEApplication*)qApp)->showMainWidget(SDL_Win); diff --git a/src/video/quartz/SDL_QuartzVideo.m b/src/video/quartz/SDL_QuartzVideo.m index 1d926fc73..69d4a36b5 100644 --- a/src/video/quartz/SDL_QuartzVideo.m +++ b/src/video/quartz/SDL_QuartzVideo.m @@ -200,6 +200,11 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) { CFNumberGetValue (CFDictionaryGetValue (save_mode, kCGDisplayHeight), 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; /* Set misc globals */ diff --git a/src/video/riscos/SDL_riscosvideo.c b/src/video/riscos/SDL_riscosvideo.c index 3c50daff3..13f36f89d 100644 --- a/src/video/riscos/SDL_riscosvideo.c +++ b/src/video/riscos/SDL_riscosvideo.c @@ -175,6 +175,10 @@ int RISCOS_VideoInit(_THIS, SDL_PixelFormat *vformat) _kernel_swi(OS_ReadModeVariable, ®s, ®s); 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 */ if (vformat->BitsPerPixel < 8) vformat->BitsPerPixel = 8; diff --git a/src/video/svga/SDL_svgavideo.c b/src/video/svga/SDL_svgavideo.c index ed432cae6..64019ec60 100644 --- a/src/video/svga/SDL_svgavideo.c +++ b/src/video/svga/SDL_svgavideo.c @@ -257,6 +257,10 @@ int SVGA_VideoInit(_THIS, SDL_PixelFormat *vformat) } 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) */ vformat->BitsPerPixel = 8; diff --git a/src/video/vgl/SDL_vglvideo.c b/src/video/vgl/SDL_vglvideo.c index 3047f90f2..ba4581162 100644 --- a/src/video/vgl/SDL_vglvideo.c +++ b/src/video/vgl/SDL_vglvideo.c @@ -257,6 +257,12 @@ int VGL_VideoInit(_THIS, SDL_PixelFormat *vformat) 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 */ if (VGLCurMode != NULL) vformat->BitsPerPixel = VGLCurMode->Depth; diff --git a/src/video/windib/SDL_dibvideo.c b/src/video/windib/SDL_dibvideo.c index 582b6ed36..cae20a87a 100644 --- a/src/video/windib/SDL_dibvideo.c +++ b/src/video/windib/SDL_dibvideo.c @@ -334,6 +334,8 @@ int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat) #endif /* Query for the desktop resolution */ 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 */ for ( i=0; EnumDisplaySettings(NULL, i, &settings); ++i ) { diff --git a/src/video/windx5/SDL_dx5video.c b/src/video/windx5/SDL_dx5video.c index 8f322750e..aa83ab9c0 100644 --- a/src/video/windx5/SDL_dx5video.c +++ b/src/video/windx5/SDL_dx5video.c @@ -930,6 +930,8 @@ int DX5_VideoInit(_THIS, SDL_PixelFormat *vformat) #ifndef NO_CHANGEDISPLAYSETTINGS /* Query for the desktop resolution */ 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 /* Enumerate the available fullscreen modes */ diff --git a/src/video/wscons/SDL_wsconsvideo.c b/src/video/wscons/SDL_wsconsvideo.c index 4312b8ba5..4b45a6da7 100644 --- a/src/video/wscons/SDL_wsconsvideo.c +++ b/src/video/wscons/SDL_wsconsvideo.c @@ -300,6 +300,9 @@ int WSCONS_VideoInit(_THIS, SDL_PixelFormat *vformat) height = private->info.height; } + this->info.current_w = width; + this->info.current_h = height; + if (private->shadowFB) { private->shadowmem = (Uint8 *)SDL_malloc(len); if (private->shadowmem == NULL) { diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index 3b0b8553b..56f3fd0e0 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -652,21 +652,21 @@ int X11_ResizeFullScreen(_THIS) if ( currently_fullscreen ) { /* Switch resolution and cover it with the FSwindow */ 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); 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); } - if ( current_h > real_h ) { + if ( window_h > real_h ) { real_h = MAX(real_h, screen_h); } pXMoveResizeWindow(SDL_Display, FSwindow, x, y, real_w, real_h); move_cursor_to(this, real_w/2, real_h/2); /* Center and reparent the drawing window */ - x = (real_w - current_w)/2; - y = (real_h - current_h)/2; + x = (real_w - window_w)/2; + y = (real_h - window_h)/2; pXReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y); /* FIXME: move the mouse to the old relative location */ pXSync(SDL_Display, True); /* Flush spurious mode change events */ @@ -706,10 +706,10 @@ int X11_EnterFullScreen(_THIS) screen_w = DisplayWidth(SDL_Display, SDL_Screen); screen_h = DisplayHeight(SDL_Display, SDL_Screen); 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); } - if ( current_h > real_h ) { + if ( window_h > real_h ) { real_h = MAX(real_h, screen_h); } pXMoveResizeWindow(SDL_Display, FSwindow, diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 7adb2cb54..2a3af35c4 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -508,6 +508,10 @@ static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat) if(X11_GetVideoModes(this) < 0) 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: Use the default visual (or at least one with the same depth) */ SDL_DisplayColormap = DefaultColormap(SDL_Display, SDL_Screen); @@ -863,8 +867,8 @@ static int X11_CreateWindow(_THIS, SDL_Surface *screen, /* resize the (possibly new) window manager window */ if( !SDL_windowid ) { X11_SetSizeHints(this, w, h, flags); - current_w = w; - current_h = h; + window_w = w; + window_h = h; pXResizeWindow(SDL_Display, WMwindow, w, h); } @@ -985,8 +989,8 @@ static int X11_ResizeWindow(_THIS, if ( ! SDL_windowid ) { /* Resize the window manager window */ X11_SetSizeHints(this, w, h, flags); - current_w = w; - current_h = h; + window_w = w; + window_h = h; pXResizeWindow(SDL_Display, WMwindow, w, h); /* Resize the fullscreen and display windows */ diff --git a/src/video/x11/SDL_x11video.h b/src/video/x11/SDL_x11video.h index b7330385b..50da4b363 100644 --- a/src/video/x11/SDL_x11video.h +++ b/src/video/x11/SDL_x11video.h @@ -76,8 +76,8 @@ struct SDL_PrivateVideoData { GC gc; /* The graphic context for drawing */ /* The current width and height of the fullscreen mode */ - int current_w; - int current_h; + int window_w; + int window_h; /* Support for internal mouse warping */ struct { @@ -159,8 +159,8 @@ struct SDL_PrivateVideoData { #define shminfo (this->hidden->shminfo) #define SDL_Ximage (this->hidden->Ximage) #define SDL_GC (this->hidden->gc) -#define current_w (this->hidden->current_w) -#define current_h (this->hidden->current_h) +#define window_w (this->hidden->window_w) +#define window_h (this->hidden->window_h) #define mouse_last (this->hidden->mouse_last) #define mouse_accel (this->hidden->mouse_accel) #define mouse_relative (this->hidden->mouse_relative) diff --git a/src/video/xbios/SDL_xbios.c b/src/video/xbios/SDL_xbios.c index dbb24d05b..5d3994d91 100644 --- a/src/video/xbios/SDL_xbios.c +++ b/src/video/xbios/SDL_xbios.c @@ -416,6 +416,12 @@ static int XBIOS_VideoInit(_THIS, SDL_PixelFormat *vformat) 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; j8 = j16 = 0; for (i=0; ivfmt->BitsPerPixel); +"Current display: %dx%d, %d bits-per-pixel\n", + info->current_w, info->current_h, info->vfmt->BitsPerPixel); if ( info->vfmt->palette == NULL ) { printf(" Red Mask = 0x%.8x\n", info->vfmt->Rmask); printf(" Green Mask = 0x%.8x\n", info->vfmt->Gmask);