Skip to content

Commit a243436

Browse files
ccawley2011hifi
authored andcommitted
Implement Toggle_Video_Fullscreen with SDL 1.2
1 parent e57652a commit a243436

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

common/video_sdl1.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,24 @@ bool Set_Video_Mode(int w, int h, int bits_per_pixel)
157157
void Toggle_Video_Fullscreen()
158158
{
159159
Settings.Video.Windowed = !Settings.Video.Windowed;
160+
161+
if (window) {
162+
int win_flags = SDL_HWSURFACE | SDL_HWPALETTE;
163+
SDL_Surface* new_window;
164+
165+
if (!Settings.Video.Windowed) {
166+
win_flags |= SDL_FULLSCREEN;
167+
}
168+
169+
new_window = SDL_SetVideoMode(window->w, window->h, 8, win_flags);
170+
if (new_window) {
171+
window = new_window;
172+
173+
/* The palette needs to be restored when switching to a new video mode */
174+
SDL_SetPalette(window, SDL_LOGPAL, logpal, 0, 256);
175+
SDL_SetPalette(window, SDL_PHYSPAL, physpal, 0, 256);
176+
}
177+
}
160178
}
161179

162180
void Get_Video_Scale(float& x, float& y)

common/wwkeyboard.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,11 @@ void WWKeyboardClass::Fill_Buffer_From_System(void)
554554
#ifdef SDL2_BUILD
555555
Put_Key_Message(event.key.keysym.scancode, false);
556556
#else
557-
Put_Key_Message(event.key.keysym.sym, false);
557+
if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) {
558+
/* Switching to full screen is handled in the key up event */
559+
} else {
560+
Put_Key_Message(event.key.keysym.sym, false);
561+
}
558562
#endif
559563
break;
560564
case SDL_KEYUP:
@@ -565,7 +569,11 @@ void WWKeyboardClass::Fill_Buffer_From_System(void)
565569
Put_Key_Message(event.key.keysym.scancode, true);
566570
}
567571
#else
568-
Put_Key_Message(event.key.keysym.sym, true);
572+
if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) {
573+
Toggle_Video_Fullscreen();
574+
} else {
575+
Put_Key_Message(event.key.keysym.sym, true);
576+
}
569577
#endif
570578
break;
571579
case SDL_MOUSEMOTION:

0 commit comments

Comments
 (0)