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
29 #include <SDL_syswm.h>
31 #include "qemu-common.h"
32 #include "ui/console.h"
33 #include "sysemu/sysemu.h"
37 static DisplayChangeListener *dcl;
38 static DisplaySurface *surface;
39 static SDL_Surface *real_screen;
40 static SDL_Surface *guest_screen = NULL;
41 static int gui_grab; /* if true, all keyboard/mouse events are grabbed */
42 static int last_vm_running;
43 static bool gui_saved_scaling;
44 static int gui_saved_width;
45 static int gui_saved_height;
46 static int gui_saved_grab;
47 static int gui_fullscreen;
48 static int gui_noframe;
49 static int gui_key_modifier_pressed;
50 static int gui_keysym;
51 static int gui_grab_code = KMOD_LALT | KMOD_LCTRL;
52 static uint8_t modifiers_state[256];
53 static SDL_Cursor *sdl_cursor_normal;
54 static SDL_Cursor *sdl_cursor_hidden;
55 static int absolute_enabled = 0;
56 static int guest_cursor = 0;
57 static int guest_x, guest_y;
58 static SDL_Cursor *guest_sprite = NULL;
59 static SDL_PixelFormat host_format;
60 static int scaling_active = 0;
61 static Notifier mouse_mode_notifier;
63 static void sdl_update(DisplayChangeListener *dcl,
64 int x, int y, int w, int h)
66 // printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h);
74 if (!scaling_active) {
75 SDL_BlitSurface(guest_screen, &rec, real_screen, &rec);
77 if (sdl_zoom_blit(guest_screen, real_screen, SMOOTHING_ON, &rec) < 0) {
78 fprintf(stderr, "Zoom blit failed\n");
83 SDL_UpdateRect(real_screen, rec.x, rec.y, rec.w, rec.h);
86 static void do_sdl_resize(int width, int height, int bpp)
89 SDL_Surface *tmp_screen;
91 // printf("resizing to %d %d\n", w, h);
93 flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL;
95 flags |= SDL_FULLSCREEN;
97 flags |= SDL_RESIZABLE;
100 flags |= SDL_NOFRAME;
102 tmp_screen = SDL_SetVideoMode(width, height, bpp, flags);
105 fprintf(stderr, "Could not open SDL display (%dx%dx%d): %s\n",
106 width, height, bpp, SDL_GetError());
111 * Revert to the previous video mode if the change of resizing or
115 fprintf(stderr, "Failed to set SDL display (%dx%dx%d): %s\n",
116 width, height, bpp, SDL_GetError());
121 real_screen = tmp_screen;
124 static void sdl_switch(DisplayChangeListener *dcl,
125 DisplaySurface *new_surface)
128 /* temporary hack: allows to call sdl_switch to handle scaling changes */
130 surface = new_surface;
133 if (!scaling_active) {
134 do_sdl_resize(surface_width(surface), surface_height(surface), 0);
135 } else if (real_screen->format->BitsPerPixel !=
136 surface_bits_per_pixel(surface)) {
137 do_sdl_resize(real_screen->w, real_screen->h,
138 surface_bits_per_pixel(surface));
141 if (guest_screen != NULL) {
142 SDL_FreeSurface(guest_screen);
144 guest_screen = SDL_CreateRGBSurfaceFrom
145 (surface_data(surface),
146 surface_width(surface), surface_height(surface),
147 surface_bits_per_pixel(surface), surface_stride(surface),
148 surface->pf.rmask, surface->pf.gmask,
149 surface->pf.bmask, surface->pf.amask);
152 /* generic keyboard conversion */
154 #include "sdl_keysym.h"
156 static kbd_layout_t *kbd_layout = NULL;
158 static uint8_t sdl_keyevent_to_keycode_generic(const SDL_KeyboardEvent *ev)
161 /* workaround for X11+SDL bug with AltGR */
162 keysym = ev->keysym.sym;
163 if (keysym == 0 && ev->keysym.scancode == 113)
165 /* For Japanese key '\' and '|' */
166 if (keysym == 92 && ev->keysym.scancode == 133) {
169 return keysym2scancode(kbd_layout, keysym) & SCANCODE_KEYMASK;
172 /* specific keyboard conversions from scan codes */
176 static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
178 return ev->keysym.scancode;
183 #if defined(SDL_VIDEO_DRIVER_X11)
184 #include <X11/XKBlib.h>
186 static int check_for_evdev(void)
189 XkbDescPtr desc = NULL;
191 char *keycodes = NULL;
193 SDL_VERSION(&info.version);
194 if (!SDL_GetWMInfo(&info)) {
197 desc = XkbGetKeyboard(info.info.x11.display,
198 XkbGBN_AllComponentsMask,
200 if (desc && desc->names) {
201 keycodes = XGetAtomName(info.info.x11.display, desc->names->keycodes);
202 if (keycodes == NULL) {
203 fprintf(stderr, "could not lookup keycode name\n");
204 } else if (strstart(keycodes, "evdev", NULL)) {
206 } else if (!strstart(keycodes, "xfree86", NULL)) {
207 fprintf(stderr, "unknown keycodes `%s', please report to "
213 XkbFreeKeyboard(desc, XkbGBN_AllComponentsMask, True);
221 static int check_for_evdev(void)
227 static uint8_t sdl_keyevent_to_keycode(const SDL_KeyboardEvent *ev)
230 static int has_evdev = -1;
233 has_evdev = check_for_evdev();
235 keycode = ev->keysym.scancode;
239 } else if (keycode < 97) {
240 keycode -= 8; /* just an offset */
241 } else if (keycode < 158) {
242 /* use conversion table */
244 keycode = translate_evdev_keycode(keycode - 97);
246 keycode = translate_xfree86_keycode(keycode - 97);
247 } else if (keycode == 208) { /* Hiragana_Katakana */
249 } else if (keycode == 211) { /* backslash */
259 static void reset_keys(void)
262 for(i = 0; i < 256; i++) {
263 if (modifiers_state[i]) {
264 if (i & SCANCODE_GREY)
265 kbd_put_keycode(SCANCODE_EMUL0);
266 kbd_put_keycode(i | SCANCODE_UP);
267 modifiers_state[i] = 0;
272 static void sdl_process_key(SDL_KeyboardEvent *ev)
276 if (ev->keysym.sym == SDLK_PAUSE) {
279 if (ev->type == SDL_KEYUP)
281 kbd_put_keycode(0xe1);
282 kbd_put_keycode(0x1d | v);
283 kbd_put_keycode(0x45 | v);
288 keycode = sdl_keyevent_to_keycode_generic(ev);
290 keycode = sdl_keyevent_to_keycode(ev);
295 /* sent when leaving window: reset the modifiers state */
298 case 0x2a: /* Left Shift */
299 case 0x36: /* Right Shift */
300 case 0x1d: /* Left CTRL */
301 case 0x9d: /* Right CTRL */
302 case 0x38: /* Left ALT */
303 case 0xb8: /* Right ALT */
304 if (ev->type == SDL_KEYUP)
305 modifiers_state[keycode] = 0;
307 modifiers_state[keycode] = 1;
309 #define QEMU_SDL_VERSION ((SDL_MAJOR_VERSION << 8) + SDL_MINOR_VERSION)
310 #if QEMU_SDL_VERSION < 0x102 || QEMU_SDL_VERSION == 0x102 && SDL_PATCHLEVEL < 14
311 /* SDL versions before 1.2.14 don't support key up for caps/num lock. */
312 case 0x45: /* num lock */
313 case 0x3a: /* caps lock */
314 /* SDL does not send the key up event, so we generate it */
315 kbd_put_keycode(keycode);
316 kbd_put_keycode(keycode | SCANCODE_UP);
321 /* now send the key code */
322 if (keycode & SCANCODE_GREY)
323 kbd_put_keycode(SCANCODE_EMUL0);
324 if (ev->type == SDL_KEYUP)
325 kbd_put_keycode(keycode | SCANCODE_UP);
327 kbd_put_keycode(keycode & SCANCODE_KEYCODEMASK);
330 static void sdl_update_caption(void)
332 char win_title[1024];
333 char icon_title[1024];
334 const char *status = "";
336 if (!runstate_is_running())
337 status = " [Stopped]";
340 status = " - Press Ctrl-Alt-Shift to exit mouse grab";
342 status = " - Press Right-Ctrl to exit mouse grab";
344 status = " - Press Ctrl-Alt to exit mouse grab";
348 snprintf(win_title, sizeof(win_title), "QEMU (%s)%s", qemu_name, status);
349 snprintf(icon_title, sizeof(icon_title), "QEMU (%s)", qemu_name);
351 snprintf(win_title, sizeof(win_title), "QEMU%s", status);
352 snprintf(icon_title, sizeof(icon_title), "QEMU");
355 SDL_WM_SetCaption(win_title, icon_title);
358 static void sdl_hide_cursor(void)
363 if (kbd_mouse_is_absolute()) {
365 SDL_SetCursor(sdl_cursor_hidden);
371 static void sdl_show_cursor(void)
376 if (!kbd_mouse_is_absolute() || !qemu_console_is_graphic(NULL)) {
379 (gui_grab || kbd_mouse_is_absolute() || absolute_enabled))
380 SDL_SetCursor(guest_sprite);
382 SDL_SetCursor(sdl_cursor_normal);
386 static void sdl_grab_start(void)
389 * If the application is not active, do not try to enter grab state. This
390 * prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from blocking all the
391 * application (SDL bug).
393 if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS)) {
397 SDL_SetCursor(guest_sprite);
398 if (!kbd_mouse_is_absolute() && !absolute_enabled)
399 SDL_WarpMouse(guest_x, guest_y);
402 SDL_WM_GrabInput(SDL_GRAB_ON);
404 sdl_update_caption();
407 static void sdl_grab_end(void)
409 SDL_WM_GrabInput(SDL_GRAB_OFF);
412 sdl_update_caption();
415 static void absolute_mouse_grab(void)
417 int mouse_x, mouse_y;
419 SDL_GetMouseState(&mouse_x, &mouse_y);
420 if (mouse_x > 0 && mouse_x < real_screen->w - 1 &&
421 mouse_y > 0 && mouse_y < real_screen->h - 1) {
426 static void sdl_mouse_mode_change(Notifier *notify, void *data)
428 if (kbd_mouse_is_absolute()) {
429 if (!absolute_enabled) {
430 absolute_enabled = 1;
431 if (qemu_console_is_graphic(NULL)) {
432 absolute_mouse_grab();
435 } else if (absolute_enabled) {
436 if (!gui_fullscreen) {
439 absolute_enabled = 0;
443 static void sdl_send_mouse_event(int dx, int dy, int dz, int x, int y, int state)
447 if (state & SDL_BUTTON(SDL_BUTTON_LEFT)) {
448 buttons |= MOUSE_EVENT_LBUTTON;
450 if (state & SDL_BUTTON(SDL_BUTTON_RIGHT)) {
451 buttons |= MOUSE_EVENT_RBUTTON;
453 if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) {
454 buttons |= MOUSE_EVENT_MBUTTON;
457 if (kbd_mouse_is_absolute()) {
458 dx = x * 0x7FFF / (real_screen->w - 1);
459 dy = y * 0x7FFF / (real_screen->h - 1);
460 } else if (guest_cursor) {
469 kbd_mouse_event(dx, dy, dz, buttons);
472 static void sdl_scale(int width, int height)
474 int bpp = real_screen->format->BitsPerPixel;
476 if (bpp != 16 && bpp != 32) {
479 do_sdl_resize(width, height, bpp);
483 static void toggle_full_screen(void)
485 int width = surface_width(surface);
486 int height = surface_height(surface);
487 int bpp = surface_bits_per_pixel(surface);
489 gui_fullscreen = !gui_fullscreen;
490 if (gui_fullscreen) {
491 gui_saved_width = real_screen->w;
492 gui_saved_height = real_screen->h;
493 gui_saved_scaling = scaling_active;
495 do_sdl_resize(width, height, bpp);
498 gui_saved_grab = gui_grab;
501 if (gui_saved_scaling) {
502 sdl_scale(gui_saved_width, gui_saved_height);
504 do_sdl_resize(width, height, 0);
506 if (!gui_saved_grab || !qemu_console_is_graphic(NULL)) {
510 graphic_hw_invalidate(NULL);
511 graphic_hw_update(NULL);
514 static void handle_keydown(SDL_Event *ev)
520 mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) ==
521 (gui_grab_code | KMOD_LSHIFT);
522 } else if (ctrl_grab) {
523 mod_state = (SDL_GetModState() & KMOD_RCTRL) == KMOD_RCTRL;
525 mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code;
527 gui_key_modifier_pressed = mod_state;
529 if (gui_key_modifier_pressed) {
530 keycode = sdl_keyevent_to_keycode(&ev->key);
532 case 0x21: /* 'f' key on US keyboard */
533 toggle_full_screen();
536 case 0x16: /* 'u' key on US keyboard */
537 if (scaling_active) {
539 sdl_switch(dcl, NULL);
540 graphic_hw_invalidate(NULL);
541 graphic_hw_update(NULL);
545 case 0x02 ... 0x0a: /* '1' to '9' keys */
546 /* Reset the modifiers sent to the current console */
548 console_select(keycode - 0x02);
550 if (gui_fullscreen) {
553 if (!qemu_console_is_graphic(NULL)) {
554 /* release grab if going to a text console */
557 } else if (absolute_enabled) {
560 } else if (absolute_enabled) {
562 absolute_mouse_grab();
567 if (!gui_fullscreen) {
568 int width = MAX(real_screen->w + (keycode == 0x1b ? 50 : -50),
570 int height = (surface_height(surface) * width) /
571 surface_width(surface);
573 sdl_scale(width, height);
574 graphic_hw_invalidate(NULL);
575 graphic_hw_update(NULL);
581 } else if (!qemu_console_is_graphic(NULL)) {
584 if (ev->key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
585 switch (ev->key.keysym.sym) {
587 keysym = QEMU_KEY_CTRL_UP;
590 keysym = QEMU_KEY_CTRL_DOWN;
593 keysym = QEMU_KEY_CTRL_LEFT;
596 keysym = QEMU_KEY_CTRL_RIGHT;
599 keysym = QEMU_KEY_CTRL_HOME;
602 keysym = QEMU_KEY_CTRL_END;
605 keysym = QEMU_KEY_CTRL_PAGEUP;
608 keysym = QEMU_KEY_CTRL_PAGEDOWN;
614 switch (ev->key.keysym.sym) {
616 keysym = QEMU_KEY_UP;
619 keysym = QEMU_KEY_DOWN;
622 keysym = QEMU_KEY_LEFT;
625 keysym = QEMU_KEY_RIGHT;
628 keysym = QEMU_KEY_HOME;
631 keysym = QEMU_KEY_END;
634 keysym = QEMU_KEY_PAGEUP;
637 keysym = QEMU_KEY_PAGEDOWN;
640 keysym = QEMU_KEY_BACKSPACE;
643 keysym = QEMU_KEY_DELETE;
650 kbd_put_keysym(keysym);
651 } else if (ev->key.keysym.unicode != 0) {
652 kbd_put_keysym(ev->key.keysym.unicode);
655 if (qemu_console_is_graphic(NULL) && !gui_keysym) {
656 sdl_process_key(&ev->key);
660 static void handle_keyup(SDL_Event *ev)
665 mod_state = (ev->key.keysym.mod & gui_grab_code);
667 mod_state = (ev->key.keysym.mod & (gui_grab_code | KMOD_LSHIFT));
669 if (!mod_state && gui_key_modifier_pressed) {
670 gui_key_modifier_pressed = 0;
671 if (gui_keysym == 0) {
672 /* exit/enter grab if pressing Ctrl-Alt */
674 if (qemu_console_is_graphic(NULL)) {
677 } else if (!gui_fullscreen) {
680 /* SDL does not send back all the modifiers key, so we must
687 if (qemu_console_is_graphic(NULL) && !gui_keysym) {
688 sdl_process_key(&ev->key);
692 static void handle_mousemotion(SDL_Event *ev)
696 if (qemu_console_is_graphic(NULL) &&
697 (kbd_mouse_is_absolute() || absolute_enabled)) {
698 max_x = real_screen->w - 1;
699 max_y = real_screen->h - 1;
700 if (gui_grab && (ev->motion.x == 0 || ev->motion.y == 0 ||
701 ev->motion.x == max_x || ev->motion.y == max_y)) {
705 (ev->motion.x > 0 && ev->motion.x < max_x &&
706 ev->motion.y > 0 && ev->motion.y < max_y)) {
710 if (gui_grab || kbd_mouse_is_absolute() || absolute_enabled) {
711 sdl_send_mouse_event(ev->motion.xrel, ev->motion.yrel, 0,
712 ev->motion.x, ev->motion.y, ev->motion.state);
716 static void handle_mousebutton(SDL_Event *ev)
718 int buttonstate = SDL_GetMouseState(NULL, NULL);
719 SDL_MouseButtonEvent *bev;
722 if (!qemu_console_is_graphic(NULL)) {
727 if (!gui_grab && !kbd_mouse_is_absolute()) {
728 if (ev->type == SDL_MOUSEBUTTONUP && bev->button == SDL_BUTTON_LEFT) {
729 /* start grabbing all events */
734 if (ev->type == SDL_MOUSEBUTTONDOWN) {
735 buttonstate |= SDL_BUTTON(bev->button);
737 buttonstate &= ~SDL_BUTTON(bev->button);
739 #ifdef SDL_BUTTON_WHEELUP
740 if (bev->button == SDL_BUTTON_WHEELUP &&
741 ev->type == SDL_MOUSEBUTTONDOWN) {
743 } else if (bev->button == SDL_BUTTON_WHEELDOWN &&
744 ev->type == SDL_MOUSEBUTTONDOWN) {
748 sdl_send_mouse_event(0, 0, dz, bev->x, bev->y, buttonstate);
752 static void handle_activation(SDL_Event *ev)
755 /* Disable grab if the window no longer has the focus
756 * (Windows-only workaround) */
757 if (gui_grab && ev->active.state == SDL_APPINPUTFOCUS &&
758 !ev->active.gain && !gui_fullscreen) {
762 if (!gui_grab && ev->active.gain && qemu_console_is_graphic(NULL) &&
763 (kbd_mouse_is_absolute() || absolute_enabled)) {
764 absolute_mouse_grab();
766 if (ev->active.state & SDL_APPACTIVE) {
767 if (ev->active.gain) {
768 /* Back to default interval */
769 update_displaychangelistener(dcl, GUI_REFRESH_INTERVAL_DEFAULT);
771 /* Sleeping interval. Not using the long default here as
772 * sdl_refresh does not only update the guest screen, but
773 * also checks for gui events. */
774 update_displaychangelistener(dcl, 500);
779 static void sdl_refresh(DisplayChangeListener *dcl)
781 SDL_Event ev1, *ev = &ev1;
783 if (last_vm_running != runstate_is_running()) {
784 last_vm_running = runstate_is_running();
785 sdl_update_caption();
788 graphic_hw_update(NULL);
789 SDL_EnableUNICODE(!qemu_console_is_graphic(NULL));
791 while (SDL_PollEvent(ev)) {
793 case SDL_VIDEOEXPOSE:
794 sdl_update(dcl, 0, 0, real_screen->w, real_screen->h);
805 qemu_system_shutdown_request();
808 case SDL_MOUSEMOTION:
809 handle_mousemotion(ev);
811 case SDL_MOUSEBUTTONDOWN:
812 case SDL_MOUSEBUTTONUP:
813 handle_mousebutton(ev);
815 case SDL_ACTIVEEVENT:
816 handle_activation(ev);
818 case SDL_VIDEORESIZE:
819 sdl_scale(ev->resize.w, ev->resize.h);
820 graphic_hw_invalidate(NULL);
821 graphic_hw_update(NULL);
829 static void sdl_mouse_warp(DisplayChangeListener *dcl,
830 int x, int y, int on)
835 if (gui_grab || kbd_mouse_is_absolute() || absolute_enabled) {
836 SDL_SetCursor(guest_sprite);
837 if (!kbd_mouse_is_absolute() && !absolute_enabled)
843 guest_x = x, guest_y = y;
846 static void sdl_mouse_define(DisplayChangeListener *dcl,
849 uint8_t *image, *mask;
853 SDL_FreeCursor(guest_sprite);
855 bpl = cursor_get_mono_bpl(c);
856 image = g_malloc0(bpl * c->height);
857 mask = g_malloc0(bpl * c->height);
858 cursor_get_mono_image(c, 0x000000, image);
859 cursor_get_mono_mask(c, 0, mask);
860 guest_sprite = SDL_CreateCursor(image, mask, c->width, c->height,
866 (gui_grab || kbd_mouse_is_absolute() || absolute_enabled))
867 SDL_SetCursor(guest_sprite);
870 static void sdl_cleanup(void)
873 SDL_FreeCursor(guest_sprite);
874 SDL_QuitSubSystem(SDL_INIT_VIDEO);
877 static const DisplayChangeListenerOps dcl_ops = {
879 .dpy_gfx_update = sdl_update,
880 .dpy_gfx_switch = sdl_switch,
881 .dpy_refresh = sdl_refresh,
882 .dpy_mouse_set = sdl_mouse_warp,
883 .dpy_cursor_define = sdl_mouse_define,
886 void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
890 const SDL_VideoInfo *vi;
893 #if defined(__APPLE__)
894 /* always use generic keymaps */
895 if (!keyboard_layout)
896 keyboard_layout = "en-us";
898 if(keyboard_layout) {
899 kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
908 setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0);
911 /* on Linux, SDL may use fbcon|directfb|svgalib when run without
912 * accessible $DISPLAY to open X11 window. This is often the case
913 * when qemu is run using sudo. But in this case, and when actually
914 * run in X11 environment, SDL fights with X11 for the video card,
915 * making current display unavailable, often until reboot.
916 * So make x11 the default SDL video driver if this variable is unset.
917 * This is a bit hackish but saves us from bigger problem.
918 * Maybe it's a good idea to fix this in SDL instead.
920 setenv("SDL_VIDEODRIVER", "x11", 0);
923 /* Enable normal up/down events for Caps-Lock and Num-Lock keys.
924 * This requires SDL >= 1.2.14. */
925 setenv("SDL_DISABLE_LOCK_KEYS", "1", 1);
927 flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE;
928 if (SDL_Init (flags)) {
929 fprintf(stderr, "Could not initialize SDL(%s) - exiting\n",
933 vi = SDL_GetVideoInfo();
934 host_format = *(vi->vfmt);
936 /* Load a 32x32x4 image. White pixels are transparent. */
937 filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "qemu-icon.bmp");
939 SDL_Surface *image = SDL_LoadBMP(filename);
941 uint32_t colorkey = SDL_MapRGB(image->format, 255, 255, 255);
942 SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
943 SDL_WM_SetIcon(image, NULL);
953 dcl = g_malloc0(sizeof(DisplayChangeListener));
955 register_displaychangelistener(dcl);
957 mouse_mode_notifier.notify = sdl_mouse_mode_change;
958 qemu_add_mouse_mode_change_notifier(&mouse_mode_notifier);
960 sdl_update_caption();
961 SDL_EnableKeyRepeat(250, 50);
964 sdl_cursor_hidden = SDL_CreateCursor(&data, &data, 8, 1, 0, 0);
965 sdl_cursor_normal = SDL_GetCursor();