Skip to content

Commit 0a3d2c7

Browse files
ccawley2011OmniBlade
authored andcommitted
Implement Toggle_Video_Fullscreen with SDL 1.2
1 parent 110d13a commit 0a3d2c7

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_sdl1.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,18 @@ void WWKeyboardClassSDL1::Fill_Buffer_From_System(void)
4242
exit(0);
4343
break;
4444
case SDL_KEYDOWN:
45-
Put_Key_Message(event.key.keysym.sym, false);
45+
if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) {
46+
/* Switching to full screen is handled in the key up event */
47+
} else {
48+
Put_Key_Message(event.key.keysym.sym, false);
49+
}
4650
break;
4751
case SDL_KEYUP:
48-
Put_Key_Message(event.key.keysym.sym, true);
52+
if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) {
53+
Toggle_Video_Fullscreen();
54+
} else {
55+
Put_Key_Message(event.key.keysym.sym, true);
56+
}
4957
break;
5058
case SDL_MOUSEMOTION:
5159
Move_Video_Mouse(static_cast<float>(event.motion.xrel), static_cast<float>(event.motion.yrel));

0 commit comments

Comments
 (0)