+static void sdl_fill(DisplayState *ds, int x, int y, int w, int h, uint32_t c)
+{
+ SDL_Rect dst = { x, y, w, h };
+ SDL_FillRect(real_screen, &dst, c);
+}
+
+static void sdl_mouse_warp(int x, int y, int on)
+{
+ if (on) {
+ if (!guest_cursor)
+ sdl_show_cursor();
+ if (gui_grab || kbd_mouse_is_absolute() || absolute_enabled) {
+ SDL_SetCursor(guest_sprite);
+ if (!kbd_mouse_is_absolute() && !absolute_enabled)
+ SDL_WarpMouse(x, y);
+ }
+ } else if (gui_grab)
+ sdl_hide_cursor();
+ guest_cursor = on;
+ guest_x = x, guest_y = y;
+}
+
+static void sdl_mouse_define(int width, int height, int bpp,
+ int hot_x, int hot_y,
+ uint8_t *image, uint8_t *mask)
+{
+ uint8_t sprite[256], *line;
+ int x, y, dst, bypl, src = 0;
+ if (guest_sprite)
+ SDL_FreeCursor(guest_sprite);
+
+ memset(sprite, 0, 256);
+ bypl = ((width * bpp + 31) >> 5) << 2;
+ for (y = 0, dst = 0; y < height; y ++, image += bypl) {
+ line = image;
+ for (x = 0; x < width; x ++, dst ++) {
+ switch (bpp) {
+ case 24:
+ src = *(line ++); src |= *(line ++); src |= *(line ++);
+ break;
+ case 16:
+ case 15:
+ src = *(line ++); src |= *(line ++);
+ break;
+ case 8:
+ src = *(line ++);
+ break;
+ case 4:
+ src = 0xf & (line[x >> 1] >> ((x & 1)) << 2);
+ break;
+ case 2:
+ src = 3 & (line[x >> 2] >> ((x & 3)) << 1);
+ break;
+ case 1:
+ src = 1 & (line[x >> 3] >> (x & 7));
+ break;
+ }
+ if (!src)
+ sprite[dst >> 3] |= (1 << (~dst & 7)) & mask[dst >> 3];
+ }
+ }
+ guest_sprite = SDL_CreateCursor(sprite, mask, width, height, hot_x, hot_y);
+
+ if (guest_cursor &&
+ (gui_grab || kbd_mouse_is_absolute() || absolute_enabled))
+ SDL_SetCursor(guest_sprite);
+}
+
+static void sdl_cleanup(void)