static DisplayChangeListener *dcl;
static DisplaySurface *surface;
+static DisplayOptions *opts;
static SDL_Surface *real_screen;
static SDL_Surface *guest_screen = NULL;
static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
static int gui_saved_height;
static int gui_saved_grab;
static int gui_fullscreen;
-static int gui_noframe;
static int gui_key_modifier_pressed;
static int gui_keysym;
static int gui_grab_code = KMOD_LALT | KMOD_LCTRL;
} else {
flags |= SDL_RESIZABLE;
}
- if (gui_noframe)
+ if (no_frame) {
flags |= SDL_NOFRAME;
+ }
tmp_screen = SDL_SetVideoMode(width, height, bpp, flags);
if (!real_screen) {
static uint8_t sdl_keyevent_to_keycode_generic(const SDL_KeyboardEvent *ev)
{
+ bool shift = modifiers_state[0x2a] || modifiers_state[0x36];
+ bool altgr = modifiers_state[0xb8];
+ bool ctrl = modifiers_state[0x1d] || modifiers_state[0x9d];
int keysym;
/* workaround for X11+SDL bug with AltGR */
keysym = ev->keysym.sym;
if (keysym == 92 && ev->keysym.scancode == 133) {
keysym = 0xa5;
}
- return keysym2scancode(kbd_layout, keysym) & SCANCODE_KEYMASK;
+ return keysym2scancode(kbd_layout, keysym,
+ shift, altgr, ctrl) & SCANCODE_KEYMASK;
}
static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
{
+ int qcode;
if (!keycode_map) {
return 0;
}
return 0;
}
- return keycode_map[ev->keysym.scancode];
+ qcode = keycode_map[ev->keysym.scancode];
+
+ if (qcode > qemu_input_map_qcode_to_qnum_len) {
+ return 0;
+ }
+
+ return qemu_input_map_qcode_to_qnum[qcode];
}
static void reset_keys(void)
status = " [Stopped]";
else if (gui_grab) {
if (alt_grab)
- status = " - Press Ctrl-Alt-Shift to exit mouse grab";
+ status = " - Press Ctrl-Alt-Shift-G to exit mouse grab";
else if (ctrl_grab)
- status = " - Press Right-Ctrl to exit mouse grab";
+ status = " - Press Right-Ctrl-G to exit mouse grab";
else
- status = " - Press Ctrl-Alt to exit mouse grab";
+ status = " - Press Ctrl-Alt-G to exit mouse grab";
}
if (qemu_name) {
toggle_full_screen();
gui_keysym = 1;
break;
+ case 0x22: /* 'g' key */
+ if (!gui_grab) {
+ if (qemu_console_is_graphic(NULL)) {
+ sdl_grab_start();
+ }
+ } else if (!gui_fullscreen) {
+ sdl_grab_end();
+ }
+ gui_keysym = 1;
+ break;
case 0x16: /* 'u' key on US keyboard */
if (scaling_active) {
scaling_active = 0;
}
if (!mod_state && gui_key_modifier_pressed) {
gui_key_modifier_pressed = 0;
- if (gui_keysym == 0) {
- /* exit/enter grab if pressing Ctrl-Alt */
- if (!gui_grab) {
- if (qemu_console_is_graphic(NULL)) {
- sdl_grab_start();
- }
- } else if (!gui_fullscreen) {
- sdl_grab_end();
- }
- /* SDL does not send back all the modifiers key, so we must
- * correct it. */
- reset_keys();
- return;
- }
gui_keysym = 0;
}
if (qemu_console_is_graphic(NULL) && !gui_keysym) {
static void sdl_refresh(DisplayChangeListener *dcl)
{
SDL_Event ev1, *ev = &ev1;
+ bool allow_close = true;
int idle = 1;
if (last_vm_running != runstate_is_running()) {
handle_keyup(ev);
break;
case SDL_QUIT:
- if (!no_quit) {
+ if (opts->has_window_close && !opts->window_close) {
+ allow_close = false;
+ }
+ if (allow_close) {
no_shutdown = 0;
qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_UI);
}
.dpy_cursor_define = sdl_mouse_define,
};
-void sdl_display_early_init(int opengl)
+void sdl_display_early_init(DisplayOptions *opts)
{
- if (opengl == 1 /* on */) {
+ if (opts->has_gl && opts->gl) {
fprintf(stderr,
"SDL1 display code has no opengl support.\n"
"Please recompile qemu with SDL2, using\n"
}
}
-void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
+void sdl_display_init(DisplayState *ds, DisplayOptions *o)
{
int flags;
uint8_t data = 0;
SDL_SysWMinfo info;
char *filename;
+ assert(o->type == DISPLAY_TYPE_SDL);
+ opts = o;
#if defined(__APPLE__)
/* always use generic keymaps */
if (!keyboard_layout)
g_printerr("Running QEMU with SDL 1.2 is deprecated, and will be removed\n"
"in a future release. Please switch to SDL 2.0 instead\n");
- if (no_frame)
- gui_noframe = 1;
-
- if (!full_screen) {
+ if (opts->has_full_screen && opts->full_screen) {
setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
}
#ifdef __linux__
g_free(filename);
}
- if (full_screen) {
+ if (opts->has_full_screen && opts->full_screen) {
gui_fullscreen = 1;
sdl_grab_start();
}