27 |
|
* Ctrl-F5 = grab mouse (in windowed mode) |
28 |
|
* |
29 |
|
* FIXMEs and TODOs: |
30 |
+ |
* - Windows requires an extra mouse event to update the actual cursor image? |
31 |
|
* - Ctr-Tab for suspend/resume but how? SDL does not support that for non-Linux |
32 |
|
* - Ctrl-Fn doesn't generate SDL_KEYDOWN events (SDL bug?) |
33 |
|
* - Mouse acceleration, there is no API in SDL yet for that |
34 |
|
* - Force relative mode in Grab mode even if SDL provides absolute coordinates? |
34 |
– |
* - Fullscreen mode |
35 |
|
* - Gamma tables support is likely to be broken here |
36 |
|
* - Events processing is bound to the general emulation thread as SDL requires |
37 |
|
* to PumpEvents() within the same thread as the one that called SetVideoMode(). |
38 |
|
* Besides, there can't seem to be a way to call SetVideoMode() from a child thread. |
39 |
– |
* - Refresh performance is still slow. Use SDL_CreateRGBSurface()? |
39 |
|
* - Backport hw cursor acceleration to Basilisk II? |
40 |
|
* - Factor out code |
41 |
|
*/ |
48 |
|
#include <errno.h> |
49 |
|
#include <vector> |
50 |
|
|
51 |
+ |
#ifdef WIN32 |
52 |
+ |
#include <malloc.h> /* alloca() */ |
53 |
+ |
#endif |
54 |
+ |
|
55 |
|
#include "cpu_emulation.h" |
56 |
|
#include "main.h" |
57 |
|
#include "adb.h" |
719 |
|
* Windowed display driver |
720 |
|
*/ |
721 |
|
|
722 |
+ |
static int SDL_display_opened = FALSE; |
723 |
+ |
|
724 |
|
// Open display |
725 |
|
driver_window::driver_window(SDL_monitor_desc &m) |
726 |
|
: driver_base(m), mouse_grabbed(false) |
732 |
|
// Set absolute mouse mode |
733 |
|
ADBSetRelMouseMode(mouse_grabbed); |
734 |
|
|
735 |
+ |
// This is ugly: |
736 |
+ |
// If we're switching resolutions (ie, not setting it for the first time), |
737 |
+ |
// there's a bug in SDL where the SDL_Surface created will not be properly |
738 |
+ |
// setup. The solution is to SDL_QuitSubSystem(SDL_INIT_VIDEO) before calling |
739 |
+ |
// SDL_SetVideoMode for the second time (SDL_SetVideoMode will call SDL_Init() |
740 |
+ |
// and all will be well). Without this, the video becomes corrupted (at least |
741 |
+ |
// on Mac OS X), after the resolution switch. |
742 |
+ |
if (SDL_display_opened) |
743 |
+ |
SDL_QuitSubSystem(SDL_INIT_VIDEO); |
744 |
+ |
|
745 |
|
// Create surface |
746 |
|
int depth = sdl_depth_of_video_depth(VIDEO_MODE_DEPTH); |
747 |
|
if ((s = SDL_SetVideoMode(width, height, depth, SDL_HWSURFACE)) == NULL) |
748 |
|
return; |
749 |
|
|
750 |
+ |
SDL_display_opened = TRUE; |
751 |
+ |
|
752 |
|
#ifdef ENABLE_VOSF |
753 |
|
use_vosf = true; |
754 |
|
// Allocate memory for frame buffer (SIZE is extended to page-boundary) |
2203 |
|
LOCK_EVENTS; |
2204 |
|
SDL_FreeCursor(sdl_cursor); |
2205 |
|
sdl_cursor = SDL_CreateCursor(MacCursor + 4, MacCursor + 36, 16, 16, MacCursor[2], MacCursor[3]); |
2206 |
< |
if (sdl_cursor) |
2206 |
> |
if (sdl_cursor) { |
2207 |
|
SDL_SetCursor(sdl_cursor); |
2208 |
+ |
#ifdef WIN32 |
2209 |
+ |
// XXX Windows apparently needs an extra mouse event to |
2210 |
+ |
// make the new cursor image visible |
2211 |
+ |
int visible = SDL_ShowCursor(-1); |
2212 |
+ |
if (visible) { |
2213 |
+ |
int x, y; |
2214 |
+ |
SDL_GetMouseState(&x, &y); |
2215 |
+ |
SDL_WarpMouse(x, y); |
2216 |
+ |
} |
2217 |
+ |
#endif |
2218 |
+ |
} |
2219 |
|
UNLOCK_EVENTS; |
2220 |
|
} |
2221 |
|
#endif |
2290 |
|
|
2291 |
|
#ifdef ENABLE_VOSF |
2292 |
|
if (use_vosf) { |
2293 |
< |
vosf_set_dirty_area(x, y, w, h, screen_width, bytes_per_row); |
2293 |
> |
vosf_set_dirty_area(x, y, w, h, screen_width, screen_height, bytes_per_row); |
2294 |
|
return; |
2295 |
|
} |
2296 |
|
#endif |