Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Toggle_Video_Fullscreen with SDL 1.2 #934

Open
wants to merge 1 commit into
base: vanilla
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions common/video_sdl1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,24 @@ bool Set_Video_Mode(int w, int h, int bits_per_pixel)
void Toggle_Video_Fullscreen()
{
Settings.Video.Windowed = !Settings.Video.Windowed;

if (window) {
int win_flags = SDL_HWSURFACE | SDL_HWPALETTE;
SDL_Surface* new_window;

if (!Settings.Video.Windowed) {
win_flags |= SDL_FULLSCREEN;
}

new_window = SDL_SetVideoMode(window->w, window->h, 8, win_flags);
if (new_window) {
window = new_window;

/* The palette needs to be restored when switching to a new video mode */
SDL_SetPalette(window, SDL_LOGPAL, logpal, 0, 256);
SDL_SetPalette(window, SDL_PHYSPAL, physpal, 0, 256);
}
}
}

void Get_Video_Scale(float& x, float& y)
Expand Down
12 changes: 10 additions & 2 deletions common/wwkeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,11 @@ void WWKeyboardClass::Fill_Buffer_From_System(void)
#ifdef SDL2_BUILD
Put_Key_Message(event.key.keysym.scancode, false);
#else
Put_Key_Message(event.key.keysym.sym, false);
if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) {
/* Switching to full screen is handled in the key up event */
} else {
Put_Key_Message(event.key.keysym.sym, false);
}
#endif
break;
case SDL_KEYUP:
Expand All @@ -565,7 +569,11 @@ void WWKeyboardClass::Fill_Buffer_From_System(void)
Put_Key_Message(event.key.keysym.scancode, true);
}
#else
Put_Key_Message(event.key.keysym.sym, true);
if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) {
Toggle_Video_Fullscreen();
} else {
Put_Key_Message(event.key.keysym.sym, true);
}
#endif
break;
case SDL_MOUSEMOTION:
Expand Down
Loading