Commit 8e9c4afe707426487db85e462a3b0c4d15e39261
1 parent
bbc9d348
full screen support (initial patch by malc)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@772 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
49 additions
and
8 deletions
sdl.c
| ... | ... | @@ -32,6 +32,10 @@ |
| 32 | 32 | static SDL_Surface *screen; |
| 33 | 33 | static int gui_grab; /* if true, all keyboard/mouse events are grabbed */ |
| 34 | 34 | static int last_vm_running; |
| 35 | +static int gui_saved_grab; | |
| 36 | +static int gui_fullscreen; | |
| 37 | +static int gui_key_modifier_pressed; | |
| 38 | +static int gui_keysym; | |
| 35 | 39 | |
| 36 | 40 | static void sdl_update(DisplayState *ds, int x, int y, int w, int h) |
| 37 | 41 | { |
| ... | ... | @@ -47,6 +51,8 @@ static void sdl_resize(DisplayState *ds, int w, int h) |
| 47 | 51 | |
| 48 | 52 | flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL; |
| 49 | 53 | flags |= SDL_RESIZABLE; |
| 54 | + if (gui_fullscreen) | |
| 55 | + flags |= SDL_FULLSCREEN; | |
| 50 | 56 | screen = SDL_SetVideoMode(w, h, 0, flags); |
| 51 | 57 | if (!screen) { |
| 52 | 58 | fprintf(stderr, "Could not open SDL display\n"); |
| ... | ... | @@ -208,10 +214,26 @@ static void sdl_send_mouse_event(void) |
| 208 | 214 | kbd_mouse_event(dx, dy, dz, buttons); |
| 209 | 215 | } |
| 210 | 216 | |
| 217 | +static void toggle_full_screen(DisplayState *ds) | |
| 218 | +{ | |
| 219 | + gui_fullscreen = !gui_fullscreen; | |
| 220 | + sdl_resize(ds, screen->w, screen->h); | |
| 221 | + if (gui_fullscreen) { | |
| 222 | + gui_saved_grab = gui_grab; | |
| 223 | + sdl_grab_start(); | |
| 224 | + } else { | |
| 225 | + if (!gui_saved_grab) | |
| 226 | + sdl_grab_end(); | |
| 227 | + } | |
| 228 | + vga_update_display(); | |
| 229 | + sdl_update(ds, 0, 0, screen->w, screen->h); | |
| 230 | +} | |
| 231 | + | |
| 211 | 232 | static void sdl_refresh(DisplayState *ds) |
| 212 | 233 | { |
| 213 | 234 | SDL_Event ev1, *ev = &ev1; |
| 214 | - | |
| 235 | + int mod_state; | |
| 236 | + | |
| 215 | 237 | if (last_vm_running != vm_running) { |
| 216 | 238 | last_vm_running = vm_running; |
| 217 | 239 | sdl_update_caption(); |
| ... | ... | @@ -226,13 +248,32 @@ static void sdl_refresh(DisplayState *ds) |
| 226 | 248 | case SDL_KEYDOWN: |
| 227 | 249 | case SDL_KEYUP: |
| 228 | 250 | if (ev->type == SDL_KEYDOWN) { |
| 229 | - if ((SDL_GetModState() & (KMOD_LSHIFT | KMOD_LCTRL)) == | |
| 230 | - (KMOD_LSHIFT | KMOD_LCTRL)) { | |
| 231 | - /* exit/enter grab if pressing Ctrl-Shift */ | |
| 232 | - if (!gui_grab) | |
| 233 | - sdl_grab_start(); | |
| 234 | - else | |
| 235 | - sdl_grab_end(); | |
| 251 | + mod_state = (SDL_GetModState() & (KMOD_LSHIFT | KMOD_LCTRL)) == | |
| 252 | + (KMOD_LSHIFT | KMOD_LCTRL); | |
| 253 | + gui_key_modifier_pressed = mod_state; | |
| 254 | + if (gui_key_modifier_pressed && | |
| 255 | + ev->key.keysym.sym == SDLK_f) { | |
| 256 | + gui_keysym = ev->key.keysym.sym; | |
| 257 | + } | |
| 258 | + } else if (ev->type == SDL_KEYUP) { | |
| 259 | + mod_state = (SDL_GetModState() & (KMOD_LSHIFT | KMOD_LCTRL)); | |
| 260 | + if (!mod_state) { | |
| 261 | + if (gui_key_modifier_pressed) { | |
| 262 | + switch(gui_keysym) { | |
| 263 | + case SDLK_f: | |
| 264 | + toggle_full_screen(ds); | |
| 265 | + break; | |
| 266 | + case 0: | |
| 267 | + /* exit/enter grab if pressing Ctrl-Shift */ | |
| 268 | + if (!gui_grab) | |
| 269 | + sdl_grab_start(); | |
| 270 | + else | |
| 271 | + sdl_grab_end(); | |
| 272 | + break; | |
| 273 | + } | |
| 274 | + gui_key_modifier_pressed = 0; | |
| 275 | + gui_keysym = 0; | |
| 276 | + } | |
| 236 | 277 | } |
| 237 | 278 | } |
| 238 | 279 | sdl_process_key(&ev->key); | ... | ... |