// printf("resizing to %d %d\n", w, h);
flags = SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL;
- flags |= SDL_RESIZABLE;
if (gui_fullscreen)
flags |= SDL_FULLSCREEN;
+
+ again:
screen = SDL_SetVideoMode(w, h, 0, flags);
if (!screen) {
fprintf(stderr, "Could not open SDL display\n");
exit(1);
}
+ if (!screen->pixels && (flags & SDL_HWSURFACE) && (flags & SDL_FULLSCREEN)) {
+ flags &= ~SDL_HWSURFACE;
+ goto again;
+ }
+
+ if (!screen->pixels) {
+ fprintf(stderr, "Could not open SDL display\n");
+ exit(1);
+ }
ds->data = screen->pixels;
ds->linesize = screen->pitch;
ds->depth = screen->format->BitsPerPixel;
sdl_update_caption();
}
-static void sdl_send_mouse_event(void)
+static void sdl_send_mouse_event(int dz)
{
- int dx, dy, dz, state, buttons;
+ int dx, dy, state, buttons;
state = SDL_GetRelativeMouseState(&dx, &dy);
buttons = 0;
if (state & SDL_BUTTON(SDL_BUTTON_LEFT))
buttons |= MOUSE_EVENT_RBUTTON;
if (state & SDL_BUTTON(SDL_BUTTON_MIDDLE))
buttons |= MOUSE_EVENT_MBUTTON;
- /* XXX: test wheel */
- dz = 0;
-#ifdef SDL_BUTTON_WHEELUP
- if (state & SDL_BUTTON(SDL_BUTTON_WHEELUP))
- dz--;
- if (state & SDL_BUTTON(SDL_BUTTON_WHEELDOWN))
- dz++;
-#endif
kbd_mouse_event(dx, dy, dz, buttons);
}
break;
case SDL_MOUSEMOTION:
if (gui_grab) {
- sdl_send_mouse_event();
+ sdl_send_mouse_event(0);
}
break;
case SDL_MOUSEBUTTONDOWN:
sdl_grab_start();
}
} else {
- sdl_send_mouse_event();
+ int dz;
+ dz = 0;
+#ifdef SDL_BUTTON_WHEELUP
+ if (bev->button == SDL_BUTTON_WHEELUP) {
+ dz = -1;
+ } else if (bev->button == SDL_BUTTON_WHEELDOWN) {
+ dz = 1;
+ }
+#endif
+ sdl_send_mouse_event(dz);
}
}
break;