Commit d7bd0b04 authored by Nathan Heisey's avatar Nathan Heisey

Fixed some problems with switching to/from fullscreen

parent 23e3df14
...@@ -848,7 +848,7 @@ SDL_WM_ToggleFullScreen(SDL_Surface * surface) ...@@ -848,7 +848,7 @@ SDL_WM_ToggleFullScreen(SDL_Surface * surface)
/* Copy the old bits out */ /* Copy the old bits out */
length = SDL_PublicSurface->w * SDL_PublicSurface->format->BytesPerPixel; length = SDL_PublicSurface->w * SDL_PublicSurface->format->BytesPerPixel;
pixels = SDL_malloc(SDL_PublicSurface->h * length); pixels = SDL_malloc(SDL_PublicSurface->h * length);
if (pixels) { if (pixels && SDL_PublicSurface->pixels) {
src = (Uint8*)SDL_PublicSurface->pixels; src = (Uint8*)SDL_PublicSurface->pixels;
dst = (Uint8*)pixels; dst = (Uint8*)pixels;
for (row = 0; row < SDL_PublicSurface->h; ++row) { for (row = 0; row < SDL_PublicSurface->h; ++row) {
......
...@@ -98,8 +98,10 @@ class SDL_BWin:public BDirectWindow ...@@ -98,8 +98,10 @@ class SDL_BWin:public BDirectWindow
#if SDL_VIDEO_OPENGL #if SDL_VIDEO_OPENGL
if (_SDL_GLView) { if (_SDL_GLView) {
_SDL_GLView->UnlockGL(); _SDL_GLView->UnlockGL();
RemoveChild(_SDL_GLView); /* Why was this outside the if
statement before? */
} }
RemoveChild(_SDL_GLView);
#endif #endif
Unlock(); Unlock();
#if SDL_VIDEO_OPENGL #if SDL_VIDEO_OPENGL
...@@ -129,6 +131,7 @@ class SDL_BWin:public BDirectWindow ...@@ -129,6 +131,7 @@ class SDL_BWin:public BDirectWindow
gl_flags); gl_flags);
} }
AddChild(_SDL_GLView); AddChild(_SDL_GLView);
_SDL_GLView->EnableDirectMode(true);
_SDL_GLView->LockGL(); /* "New" GLViews are created */ _SDL_GLView->LockGL(); /* "New" GLViews are created */
Unlock(); Unlock();
return (_SDL_GLView); return (_SDL_GLView);
......
...@@ -32,12 +32,12 @@ ...@@ -32,12 +32,12 @@
extern "C" { extern "C" {
#endif #endif
#if 1
/* This wrapper is here so that the driverdata can be freed */ /* This wrapper is here so that the driverdata can be freed */
typedef struct SDL_DisplayModeData { typedef struct SDL_DisplayModeData {
display_mode *bmode; display_mode *bmode;
}; };
#endif
static inline SDL_BWin *_ToBeWin(SDL_Window *window) { static inline SDL_BWin *_ToBeWin(SDL_Window *window) {
return ((SDL_BWin*)(window->driverdata)); return ((SDL_BWin*)(window->driverdata));
...@@ -47,6 +47,13 @@ static inline SDL_BApp *_GetBeApp() { ...@@ -47,6 +47,13 @@ static inline SDL_BApp *_GetBeApp() {
return ((SDL_BApp*)be_app); return ((SDL_BApp*)be_app);
} }
static inline display_mode * _ExtractBMode(SDL_DisplayMode *mode) {
#if 0
return (display_mode*)(mode->driverdata);
#else
return ((SDL_DisplayModeData*)mode->driverdata)->bmode;
#endif
}
/* Copied from haiku/trunk/src/preferences/screen/ScreenMode.cpp */ /* Copied from haiku/trunk/src/preferences/screen/ScreenMode.cpp */
static float get_refresh_rate(display_mode &mode) { static float get_refresh_rate(display_mode &mode) {
...@@ -114,9 +121,14 @@ static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode, ...@@ -114,9 +121,14 @@ static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode,
mode->w = bmode->virtual_width; mode->w = bmode->virtual_width;
mode->h = bmode->virtual_height; mode->h = bmode->virtual_height;
mode->refresh_rate = (int)get_refresh_rate(*bmode); mode->refresh_rate = (int)get_refresh_rate(*bmode);
#if 1
SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, sizeof(SDL_DisplayModeData)); SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, sizeof(SDL_DisplayModeData));
data->bmode = bmode; data->bmode = bmode;
mode->driverdata = data; mode->driverdata = data;
#else
mode->driverdata = bmode;
#endif
/* Set the format */ /* Set the format */
int32 bpp = ColorSpaceToBitsPerPixel(bmode->space); int32 bpp = ColorSpaceToBitsPerPixel(bmode->space);
...@@ -127,14 +139,15 @@ static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode, ...@@ -127,14 +139,15 @@ static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode,
void BE_AddDisplay(BScreen *screen) { void BE_AddDisplay(BScreen *screen) {
SDL_VideoDisplay display; SDL_VideoDisplay display;
SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1, sizeof(SDL_DisplayMode)); SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1, sizeof(SDL_DisplayMode));
display_mode bmode; display_mode *bmode = (display_mode*)SDL_calloc(1, sizeof(display_mode));
screen->GetMode(&bmode); screen->GetMode(bmode);
BE_BDisplayModeToSdlDisplayMode(&bmode, mode); BE_BDisplayModeToSdlDisplayMode(bmode, mode);
SDL_zero(display); SDL_zero(display);
display.desktop_mode = *mode; display.desktop_mode = *mode;
display.current_mode = *mode; display.current_mode = *mode;
SDL_AddVideoDisplay(&display); SDL_AddVideoDisplay(&display);
} }
...@@ -142,20 +155,19 @@ int BE_InitModes(_THIS) { ...@@ -142,20 +155,19 @@ int BE_InitModes(_THIS) {
BScreen screen; BScreen screen;
/* Save the current display mode */ /* Save the current display mode */
display_mode *prevMode; // display_mode *prevMode;
screen.GetMode(prevMode); // screen.GetMode(prevMode);
_GetBeApp()->SetPrevMode(prevMode); // _GetBeApp()->SetPrevMode(prevMode);
/* Only one possible video display right now */ /* Only one possible video display right now */
BE_AddDisplay(&screen); BE_AddDisplay(&screen);
} }
int BE_QuitModes(_THIS) { int BE_QuitModes(_THIS) {
/* printf(__FILE__": %d; Begin quit\n", __LINE__);*/
/* Restore the previous video mode */ /* Restore the previous video mode */
BScreen screen; BScreen screen;
display_mode *savedMode = _GetBeApp()->GetPrevMode(); // display_mode *savedMode = _GetBeApp()->GetPrevMode();
screen.SetMode(savedMode); // screen.SetMode(savedMode);
return 0; return 0;
} }
...@@ -197,13 +209,37 @@ void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { ...@@ -197,13 +209,37 @@ void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) {
int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){ int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
/* Get the current screen */ /* Get the current screen */
BScreen bscreen; BScreen bscreen;
if(!bscreen.IsValid()) {
printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__);
}
/* Set the mode using the driver data */ /* Set the mode using the driver data */
display_mode *bmode = ((SDL_DisplayModeData*)mode->driverdata)->bmode; display_mode *bmode = _ExtractBMode(mode);
if(bscreen.SetMode(bmode) == B_OK) {
status_t s;
if((s = bscreen.SetMode(bmode)) == B_OK) {
return 0; /* No error */ return 0; /* No error */
} }
printf(__FILE__": %d - ERROR: FAILED TO CHANGE VIDEO MODE; s = %i, status = B_BAD_VALUE? %i\n", __LINE__, s, s == B_BAD_VALUE);
display_mode *bmode_list;
uint32 count;
bscreen.GetModeList(&bmode_list, &count);
s = bscreen.ProposeMode(bmode, &bmode_list[count - 1], &bmode_list[0]);
switch(s) {
case B_OK:
printf(__FILE__": %d - B_OK\n", __LINE__);
break;
case B_BAD_VALUE:
printf(__FILE__": %d - B_BAD_VALUE\n", __LINE__);
break;
case B_ERROR:
printf(__FILE__": %d - B_ERROR\n", __LINE__);
break;
default:
printf(__FILE__": %d - (unknown error code)\n", __LINE__);
break;
}
free(bmode_list);
return -1; return -1;
} }
......
...@@ -51,7 +51,7 @@ int _InitWindow(_THIS, SDL_Window *window) { ...@@ -51,7 +51,7 @@ int _InitWindow(_THIS, SDL_Window *window) {
if(window->flags & SDL_WINDOW_OPENGL) { if(window->flags & SDL_WINDOW_OPENGL) {
} }
if(!(window->flags & SDL_WINDOW_RESIZABLE)) { if(!(window->flags & SDL_WINDOW_RESIZABLE)) {
flags |= B_NOT_RESIZABLE; flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE;
} }
if(window->flags & SDL_WINDOW_BORDERLESS) { if(window->flags & SDL_WINDOW_BORDERLESS) {
} }
......
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