Skip to content

Commit 01d8530

Browse files
committed
Implement Toggle_Video_Fullscreen with SDL 1.2
1 parent a36cba3 commit 01d8530

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

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
@@ -551,7 +551,11 @@ void WWKeyboardClass::Fill_Buffer_From_System(void)
551551
#ifdef SDL2_BUILD
552552
Put_Key_Message(event.key.keysym.scancode, false);
553553
#else
554-
Put_Key_Message(event.key.keysym.sym, false);
554+
if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) {
555+
/* Switching to full screen is handled in the key up event */
556+
} else {
557+
Put_Key_Message(event.key.keysym.sym, false);
558+
}
555559
#endif
556560
break;
557561
case SDL_KEYUP:
@@ -562,7 +566,11 @@ void WWKeyboardClass::Fill_Buffer_From_System(void)
562566
Put_Key_Message(event.key.keysym.scancode, true);
563567
}
564568
#else
565-
Put_Key_Message(event.key.keysym.sym, true);
569+
if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) {
570+
Toggle_Video_Fullscreen();
571+
} else {
572+
Put_Key_Message(event.key.keysym.sym, true);
573+
}
566574
#endif
567575
break;
568576
case SDL_MOUSEMOTION:

0 commit comments

Comments
 (0)