2 * QEMU SDL display driver
4 * Copyright (c) 2003 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 /* Avoid compiler warning because macro is redefined in SDL_syswm.h. */
26 #undef WIN32_LEAN_AND_MEAN
30 #if SDL_MAJOR_VERSION == 1
31 #include <SDL_syswm.h>
33 #include "qemu-common.h"
34 #include "ui/console.h"
36 #include "sysemu/sysemu.h"
40 static DisplayChangeListener *dcl;
41 static DisplaySurface *surface;
42 static SDL_Surface *real_screen;
43 static SDL_Surface *guest_screen = NULL;
44 static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
45 static int last_vm_running;
46 static bool gui_saved_scaling;
47 static int gui_saved_width;
48 static int gui_saved_height;
49 static int gui_saved_grab;
50 static int gui_fullscreen;
51 static int gui_noframe;
52 static int gui_key_modifier_pressed;
53 static int gui_keysym;
54 static int gui_grab_code = KMOD_LALT | KMOD_LCTRL;
55 static uint8_t modifiers_state[256];
56 static SDL_Cursor *sdl_cursor_normal;
57 static SDL_Cursor *sdl_cursor_hidden;
58 static int absolute_enabled = 0;
59 static int guest_cursor = 0;
60 static int guest_x, guest_y;
61 static SDL_Cursor *guest_sprite = NULL;
62 static SDL_PixelFormat host_format;
63 static int scaling_active = 0;
64 static Notifier mouse_mode_notifier;
66 static void sdl_update(DisplayChangeListener *dcl,
67 int x, int y, int w, int h)
69 // printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h);
77 if (!scaling_active) {
78 SDL_BlitSurface(guest_screen, &rec, real_screen, &rec);
80 if (sdl_zoom_blit(guest_screen, real_screen, SMOOTHING_ON, &rec) < 0) {
81 fprintf(stderr, "Zoom blit failed\n");
86 SDL_UpdateRect(real_screen, rec.x, rec.y, rec.w, rec.h);
89 static void do_sdl_resize(int width, int height, int bpp)
92 SDL_Surface *tmp_screen;
94 // printf("resizing to %d %d\n", w, h);
96 flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL;
98 flags |= SDL_FULLSCREEN;
100 flags |= SDL_RESIZABLE;
103 flags |= SDL_NOFRAME;
105 tmp_screen = SDL_SetVideoMode(width, height, bpp, flags);
108 fprintf(stderr, "Could not open SDL display (%dx%dx%d): %s\n",
109 width, height, bpp, SDL_GetError());
114 * Revert to the previous video mode if the change of resizing or
118 fprintf(stderr, "Failed to set SDL display (%dx%dx%d): %s\n",
119 width, height, bpp, SDL_GetError());
124 real_screen = tmp_screen;
127 static void sdl_switch(DisplayChangeListener *dcl,
128 DisplaySurface *new_surface)
131 /* temporary hack: allows to call sdl_switch to handle scaling changes */
133 surface = new_surface;
136 if (!scaling_active) {
137 do_sdl_resize(surface_width(surface), surface_height(surface), 0);
138 } else if (real_screen->format->BitsPerPixel !=
139 surface_bits_per_pixel(surface)) {
140 do_sdl_resize(real_screen->w, real_screen->h,
141 surface_bits_per_pixel(surface));
144 if (guest_screen != NULL) {
145 SDL_FreeSurface(guest_screen);
147 guest_screen = SDL_CreateRGBSurfaceFrom
148 (surface_data(surface),
149 surface_width(surface), surface_height(surface),
150 surface_bits_per_pixel(surface), surface_stride(surface),
151 surface->pf.rmask, surface->pf.gmask,
152 surface->pf.bmask, surface->pf.amask);
155 /* generic keyboard conversion */
157 #include "sdl_keysym.h"
159 static kbd_layout_t *kbd_layout = NULL;
161 static uint8_t sdl_keyevent_to_keycode_generic(const SDL_KeyboardEvent *ev)
164 /* workaround for X11+SDL bug with AltGR */
165 keysym = ev->keysym.sym;
166 if (keysym == 0 && ev->keysym.scancode == 113)
168 /* For Japanese key '\' and '|' */
169 if (keysym == 92 && ev->keysym.scancode == 133) {
172 return keysym2scancode(kbd_layout, keysym) & SCANCODE_KEYMASK;
175 /* specific keyboard conversions from scan codes */
179 static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
181 return ev->keysym.scancode;
186 #if defined(SDL_VIDEO_DRIVER_X11)
187 #include <X11/XKBlib.h>
189 static int check_for_evdev(void)
192 XkbDescPtr desc = NULL;
194 char *keycodes = NULL;
196 SDL_VERSION(&info.version);
197 if (!SDL_GetWMInfo(&info)) {
200 desc = XkbGetKeyboard(info.info.x11.display,
201 XkbGBN_AllComponentsMask,
203 if (desc && desc->names) {
204 keycodes = XGetAtomName(info.info.x11.display, desc->names->keycodes);
205 if (keycodes == NULL) {
206 fprintf(stderr, "could not lookup keycode name\n");
207 } else if (strstart(keycodes, "evdev", NULL)) {
209 } else if (!strstart(keycodes, "xfree86", NULL)) {
210 fprintf(stderr, "unknown keycodes `%s', please report to "
216 XkbFreeKeyboard(desc, XkbGBN_AllComponentsMask, True);
224 static int check_for_evdev(void)
230 static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
233 static int has_evdev = -1;
236 has_evdev = check_for_evdev();
238 keycode = ev->keysym.scancode;
242 } else if (keycode < 97) {
243 keycode -= 8; /* just an offset */
244 } else if (keycode < 158) {
245 /* use conversion table */
247 keycode = translate_evdev_keycode(keycode - 97);
249 keycode = translate_xfree86_keycode(keycode - 97);
250 } else if (keycode == 208) { /* Hiragana_Katakana */
252 } else if (keycode == 211) { /* backslash */
262 static void reset_keys(void)
265 for(i = 0; i < 256; i++) {
266 if (modifiers_state[i]) {
267 qemu_input_event_send_key_number(dcl->con, i, false);
268 modifiers_state[i] = 0;
273 static void sdl_process_key(SDL_KeyboardEvent *ev)
277 if (ev->keysym.sym == SDLK_PAUSE) {
279 qemu_input_event_send_key_qcode(dcl->con, Q_KEY_CODE_PAUSE,
280 ev->type == SDL_KEYDOWN);
285 keycode = sdl_keyevent_to_keycode_generic(ev);
287 keycode = sdl_keyevent_to_keycode(ev);
292 /* sent when leaving window: reset the modifiers state */
295 case 0x2a: /* Left Shift */
296 case 0x36: /* Right Shift */
297 case 0x1d: /* Left CTRL */
298 case 0x9d: /* Right CTRL */
299 case 0x38: /* Left ALT */
300 case 0xb8: /* Right ALT */
301 if (ev->type == SDL_KEYUP)
302 modifiers_state[keycode] = 0;
304 modifiers_state[keycode] = 1;
306 #define QEMU_SDL_VERSION ((SDL_MAJOR_VERSION << 8) + SDL_MINOR_VERSION)
307 #if QEMU_SDL_VERSION < 0x102 || QEMU_SDL_VERSION == 0x102 && SDL_PATCHLEVEL < 14
308 /* SDL versions before 1.2.14 don't support key up for caps/num lock. */
309 case 0x45: /* num lock */
310 case 0x3a: /* caps lock */
311 /* SDL does not send the key up event, so we generate it */
312 qemu_input_event_send_key_number(dcl->con, keycode, true);
313 qemu_input_event_send_key_number(dcl->con, keycode, false);
318 /* now send the key code */
319 qemu_input_event_send_key_number(dcl->con, keycode,
320 ev->type == SDL_KEYDOWN);
323 static void sdl_update_caption(void)
325 char win_title[1024];
326 char icon_title[1024];
327 const char *status = "";
329 if (!runstate_is_running())
330 status = " [Stopped]";
333 status = " - Press Ctrl-Alt-Shift to exit mouse grab";
335 status = " - Press Right-Ctrl to exit mouse grab";
337 status = " - Press Ctrl-Alt to exit mouse grab";
341 snprintf(win_title, sizeof(win_title), "QEMU (%s)%s", qemu_name, status);
342 snprintf(icon_title, sizeof(icon_title), "QEMU (%s)", qemu_name);
344 snprintf(win_title, sizeof(win_title), "QEMU%s", status);
345 snprintf(icon_title, sizeof(icon_title), "QEMU");
348 SDL_WM_SetCaption(win_title, icon_title);
351 static void sdl_hide_cursor(void)
356 if (qemu_input_is_absolute()) {
358 SDL_SetCursor(sdl_cursor_hidden);
364 static void sdl_show_cursor(void)
369 if (!qemu_input_is_absolute() || !qemu_console_is_graphic(NULL)) {
372 (gui_grab || qemu_input_is_absolute() || absolute_enabled))
373 SDL_SetCursor(guest_sprite);
375 SDL_SetCursor(sdl_cursor_normal);
379 static void sdl_grab_start(void)
382 * If the application is not active, do not try to enter grab state. This
383 * prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from blocking all the
384 * application (SDL bug).
386 if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS)) {
390 SDL_SetCursor(guest_sprite);
391 if (!qemu_input_is_absolute() && !absolute_enabled) {
392 SDL_WarpMouse(guest_x, guest_y);
396 SDL_WM_GrabInput(SDL_GRAB_ON);
398 sdl_update_caption();
401 static void sdl_grab_end(void)
403 SDL_WM_GrabInput(SDL_GRAB_OFF);
406 sdl_update_caption();
409 static void absolute_mouse_grab(void)
411 int mouse_x, mouse_y;
413 SDL_GetMouseState(&mouse_x, &mouse_y);
414 if (mouse_x > 0 && mouse_x < real_screen->w - 1 &&
415 mouse_y > 0 && mouse_y < real_screen->h - 1) {
420 static void sdl_mouse_mode_change(Notifier *notify, void *data)
422 if (qemu_input_is_absolute()) {
423 if (!absolute_enabled) {
424 absolute_enabled = 1;
425 if (qemu_console_is_graphic(NULL)) {
426 absolute_mouse_grab();
429 } else if (absolute_enabled) {
430 if (!gui_fullscreen) {
433 absolute_enabled = 0;
437 static void sdl_send_mouse_event(int dx, int dy, int x, int y, int state)
439 static uint32_t bmap[INPUT_BUTTON_MAX] = {
440 [INPUT_BUTTON_LEFT] = SDL_BUTTON(SDL_BUTTON_LEFT),
441 [INPUT_BUTTON_MIDDLE] = SDL_BUTTON(SDL_BUTTON_MIDDLE),
442 [INPUT_BUTTON_RIGHT] = SDL_BUTTON(SDL_BUTTON_RIGHT),
443 [INPUT_BUTTON_WHEEL_UP] = SDL_BUTTON(SDL_BUTTON_WHEELUP),
444 [INPUT_BUTTON_WHEEL_DOWN] = SDL_BUTTON(SDL_BUTTON_WHEELDOWN),
446 static uint32_t prev_state;
448 if (prev_state != state) {
449 qemu_input_update_buttons(dcl->con, bmap, prev_state, state);
453 if (qemu_input_is_absolute()) {
454 qemu_input_queue_abs(dcl->con, INPUT_AXIS_X, x,
456 qemu_input_queue_abs(dcl->con, INPUT_AXIS_Y, y,
467 qemu_input_queue_rel(dcl->con, INPUT_AXIS_X, dx);
468 qemu_input_queue_rel(dcl->con, INPUT_AXIS_Y, dy);
470 qemu_input_event_sync();
473 static void sdl_scale(int width, int height)
475 int bpp = real_screen->format->BitsPerPixel;
477 if (bpp != 16 && bpp != 32) {
480 do_sdl_resize(width, height, bpp);
484 static void toggle_full_screen(void)
486 int width = surface_width(surface);
487 int height = surface_height(surface);
488 int bpp = surface_bits_per_pixel(surface);
490 gui_fullscreen = !gui_fullscreen;
491 if (gui_fullscreen) {
492 gui_saved_width = real_screen->w;
493 gui_saved_height = real_screen->h;
494 gui_saved_scaling = scaling_active;
496 do_sdl_resize(width, height, bpp);
499 gui_saved_grab = gui_grab;
502 if (gui_saved_scaling) {
503 sdl_scale(gui_saved_width, gui_saved_height);
505 do_sdl_resize(width, height, 0);
507 if (!gui_saved_grab || !qemu_console_is_graphic(NULL)) {
511 graphic_hw_invalidate(NULL);
512 graphic_hw_update(NULL);
515 static void handle_keydown(SDL_Event *ev)
521 mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) ==
522 (gui_grab_code | KMOD_LSHIFT);
523 } else if (ctrl_grab) {
524 mod_state = (SDL_GetModState() & KMOD_RCTRL) == KMOD_RCTRL;
526 mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code;
528 gui_key_modifier_pressed = mod_state;
530 if (gui_key_modifier_pressed) {
531 keycode = sdl_keyevent_to_keycode(&ev->key);
533 case 0x21: /* 'f' key on US keyboard */
534 toggle_full_screen();
537 case 0x16: /* 'u' key on US keyboard */
538 if (scaling_active) {
540 sdl_switch(dcl, NULL);
541 graphic_hw_invalidate(NULL);
542 graphic_hw_update(NULL);
546 case 0x02 ... 0x0a: /* '1' to '9' keys */
547 /* Reset the modifiers sent to the current console */
549 console_select(keycode - 0x02);
551 if (gui_fullscreen) {
554 if (!qemu_console_is_graphic(NULL)) {
555 /* release grab if going to a text console */
558 } else if (absolute_enabled) {
561 } else if (absolute_enabled) {
563 absolute_mouse_grab();
568 if (!gui_fullscreen) {
569 int width = MAX(real_screen->w + (keycode == 0x1b ? 50 : -50),
571 int height = (surface_height(surface) * width) /
572 surface_width(surface);
574 sdl_scale(width, height);
575 graphic_hw_invalidate(NULL);
576 graphic_hw_update(NULL);
582 } else if (!qemu_console_is_graphic(NULL)) {
585 if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
586 switch (ev->key.keysym.sym) {
588 keysym = QEMU_KEY_CTRL_UP;
591 keysym = QEMU_KEY_CTRL_DOWN;
594 keysym = QEMU_KEY_CTRL_LEFT;
597 keysym = QEMU_KEY_CTRL_RIGHT;
600 keysym = QEMU_KEY_CTRL_HOME;
603 keysym = QEMU_KEY_CTRL_END;
606 keysym = QEMU_KEY_CTRL_PAGEUP;
609 keysym = QEMU_KEY_CTRL_PAGEDOWN;
615 switch (ev->key.keysym.sym) {
617 keysym = QEMU_KEY_UP;
620 keysym = QEMU_KEY_DOWN;
623 keysym = QEMU_KEY_LEFT;
626 keysym = QEMU_KEY_RIGHT;
629 keysym = QEMU_KEY_HOME;
632 keysym = QEMU_KEY_END;
635 keysym = QEMU_KEY_PAGEUP;
638 keysym = QEMU_KEY_PAGEDOWN;
641 keysym = QEMU_KEY_BACKSPACE;
644 keysym = QEMU_KEY_DELETE;
651 kbd_put_keysym(keysym);
652 } else if (ev->key.keysym.unicode != 0) {
653 kbd_put_keysym(ev->key.keysym.unicode);
656 if (qemu_console_is_graphic(NULL) && !gui_keysym) {
657 sdl_process_key(&ev->key);
661 static void handle_keyup(SDL_Event *ev)
666 mod_state = (ev->key.keysym.mod & gui_grab_code);
668 mod_state = (ev->key.keysym.mod & (gui_grab_code | KMOD_LSHIFT));
670 if (!mod_state && gui_key_modifier_pressed) {
671 gui_key_modifier_pressed = 0;
672 if (gui_keysym == 0) {
673 /* exit/enter grab if pressing Ctrl-Alt */
675 if (qemu_console_is_graphic(NULL)) {
678 } else if (!gui_fullscreen) {
681 /* SDL does not send back all the modifiers key, so we must
688 if (qemu_console_is_graphic(NULL) && !gui_keysym) {
689 sdl_process_key(&ev->key);
693 static void handle_mousemotion(SDL_Event *ev)
697 if (qemu_console_is_graphic(NULL) &&
698 (qemu_input_is_absolute() || absolute_enabled)) {
699 max_x = real_screen->w - 1;
700 max_y = real_screen->h - 1;
701 if (gui_grab && (ev->motion.x == 0 || ev->motion.y == 0 ||
702 ev->motion.x == max_x || ev->motion.y == max_y)) {
706 (ev->motion.x > 0 && ev->motion.x < max_x &&
707 ev->motion.y > 0 && ev->motion.y < max_y)) {
711 if (gui_grab || qemu_input_is_absolute() || absolute_enabled) {
712 sdl_send_mouse_event(ev->motion.xrel, ev->motion.yrel,
713 ev->motion.x, ev->motion.y, ev->motion.state);
717 static void handle_mousebutton(SDL_Event *ev)
719 int buttonstate = SDL_GetMouseState(NULL, NULL);
720 SDL_MouseButtonEvent *bev;
722 if (!qemu_console_is_graphic(NULL)) {
727 if (!gui_grab && !qemu_input_is_absolute()) {
728 if (ev->type == SDL_MOUSEBUTTONUP && bev->button == SDL_BUTTON_LEFT) {
729 /* start grabbing all events */
733 if (ev->type == SDL_MOUSEBUTTONDOWN) {
734 buttonstate |= SDL_BUTTON(bev->button);
736 buttonstate &= ~SDL_BUTTON(bev->button);
738 sdl_send_mouse_event(0, 0, bev->x, bev->y, buttonstate);
742 static void handle_activation(SDL_Event *ev)
745 /* Disable grab if the window no longer has the focus
746 * (Windows-only workaround) */
747 if (gui_grab && ev->active.state == SDL_APPINPUTFOCUS &&
748 !ev->active.gain && !gui_fullscreen) {
752 if (!gui_grab && ev->active.gain && qemu_console_is_graphic(NULL) &&
753 (qemu_input_is_absolute() || absolute_enabled)) {
754 absolute_mouse_grab();
756 if (ev->active.state & SDL_APPACTIVE) {
757 if (ev->active.gain) {
758 /* Back to default interval */
759 update_displaychangelistener(dcl, GUI_REFRESH_INTERVAL_DEFAULT);
761 /* Sleeping interval. Not using the long default here as
762 * sdl_refresh does not only update the guest screen, but
763 * also checks for gui events. */
764 update_displaychangelistener(dcl, 500);
769 static void sdl_refresh(DisplayChangeListener *dcl)
771 SDL_Event ev1, *ev = &ev1;
773 if (last_vm_running != runstate_is_running()) {
774 last_vm_running = runstate_is_running();
775 sdl_update_caption();
778 graphic_hw_update(NULL);
779 SDL_EnableUNICODE(!qemu_console_is_graphic(NULL));
781 while (SDL_PollEvent(ev)) {
783 case SDL_VIDEOEXPOSE:
784 sdl_update(dcl, 0, 0, real_screen->w, real_screen->h);
795 qemu_system_shutdown_request();
798 case SDL_MOUSEMOTION:
799 handle_mousemotion(ev);
801 case SDL_MOUSEBUTTONDOWN:
802 case SDL_MOUSEBUTTONUP:
803 handle_mousebutton(ev);
805 case SDL_ACTIVEEVENT:
806 handle_activation(ev);
808 case SDL_VIDEORESIZE:
809 sdl_scale(ev->resize.w, ev->resize.h);
810 graphic_hw_invalidate(NULL);
811 graphic_hw_update(NULL);
819 static void sdl_mouse_warp(DisplayChangeListener *dcl,
820 int x, int y, int on)
825 if (gui_grab || qemu_input_is_absolute() || absolute_enabled) {
826 SDL_SetCursor(guest_sprite);
827 if (!qemu_input_is_absolute() && !absolute_enabled) {
834 guest_x = x, guest_y = y;
837 static void sdl_mouse_define(DisplayChangeListener *dcl,
840 uint8_t *image, *mask;
844 SDL_FreeCursor(guest_sprite);
846 bpl = cursor_get_mono_bpl(c);
847 image = g_malloc0(bpl * c->height);
848 mask = g_malloc0(bpl * c->height);
849 cursor_get_mono_image(c, 0x000000, image);
850 cursor_get_mono_mask(c, 0, mask);
851 guest_sprite = SDL_CreateCursor(image, mask, c->width, c->height,
857 (gui_grab || qemu_input_is_absolute() || absolute_enabled))
858 SDL_SetCursor(guest_sprite);
861 static void sdl_cleanup(void)
864 SDL_FreeCursor(guest_sprite);
865 SDL_QuitSubSystem(SDL_INIT_VIDEO);
868 static const DisplayChangeListenerOps dcl_ops = {
870 .dpy_gfx_update = sdl_update,
871 .dpy_gfx_switch = sdl_switch,
872 .dpy_refresh = sdl_refresh,
873 .dpy_mouse_set = sdl_mouse_warp,
874 .dpy_cursor_define = sdl_mouse_define,
877 void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
881 const SDL_VideoInfo *vi;
884 #if defined(__APPLE__)
885 /* always use generic keymaps */
886 if (!keyboard_layout)
887 keyboard_layout = "en-us";
889 if(keyboard_layout) {
890 kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
899 setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
902 /* on Linux, SDL may use fbcon|directfb|svgalib when run without
903 * accessible $DISPLAY to open X11 window. This is often the case
904 * when qemu is run using sudo. But in this case, and when actually
905 * run in X11 environment, SDL fights with X11 for the video card,
906 * making current display unavailable, often until reboot.
907 * So make x11 the default SDL video driver if this variable is unset.
908 * This is a bit hackish but saves us from bigger problem.
909 * Maybe it's a good idea to fix this in SDL instead.
911 setenv("SDL_VIDEODRIVER", "x11", 0);
914 /* Enable normal up/down events for Caps-Lock and Num-Lock keys.
915 * This requires SDL >= 1.2.14. */
916 setenv("SDL_DISABLE_LOCK_KEYS", "1", 1);
918 flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
919 if (SDL_Init (flags)) {
920 fprintf(stderr, "Could not initialize SDL(%s) - exiting\n",
924 vi = SDL_GetVideoInfo();
925 host_format = *(vi->vfmt);
927 /* Load a 32x32x4 image. White pixels are transparent. */
928 filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
930 SDL_Surface *image = SDL_LoadBMP(filename);
932 uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
933 SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
934 SDL_WM_SetIcon(image, NULL);
944 dcl = g_malloc0(sizeof(DisplayChangeListener));
946 register_displaychangelistener(dcl);
948 mouse_mode_notifier.notify = sdl_mouse_mode_change;
949 qemu_add_mouse_mode_change_notifier(&mouse_mode_notifier);
951 sdl_update_caption();
952 SDL_EnableKeyRepeat(250, 50);
955 sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0);
956 sdl_cursor_normal = SDL_GetCursor();