Skip to content

Commit

Permalink
revert SDL
Browse files Browse the repository at this point in the history
  • Loading branch information
kanjitalk755 committed Dec 5, 2017
1 parent ae88e28 commit e42b6a5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
43 changes: 25 additions & 18 deletions BasiliskII/src/SDL/video_sdl.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* - Ctr-Tab for suspend/resume but how? SDL does not support that for non-Linux
* - Ctrl-Fn doesn't generate SDL_KEYDOWN events (SDL bug?)
* - Mouse acceleration, there is no API in SDL yet for that
* - Force relative mode in Grab mode even if SDL provides absolute coordinates?
* - Gamma tables support is likely to be broken here
* - Events processing is bound to the general emulation thread as SDL requires
* to PumpEvents() within the same thread as the one that called SetVideoMode().
Expand Down Expand Up @@ -135,6 +136,7 @@ static bool toggle_fullscreen = false;
static const int sdl_eventmask = SDL_MOUSEEVENTMASK | SDL_KEYEVENTMASK | SDL_VIDEOEXPOSEMASK | SDL_QUITMASK | SDL_ACTIVEEVENTMASK;

static bool mouse_grabbed = false;
static bool mouse_grabbed_window_name_status = false;

// Mutex to protect SDL events
static SDL_mutex *sdl_events_lock = NULL;
Expand Down Expand Up @@ -494,18 +496,15 @@ static void add_mode(int type, int width, int height, int resolution_id, int byt
}

// Set Mac frame layout and base address (uses the_buffer/MacFrameBaseMac)
static void set_mac_frame_buffer(SDL_monitor_desc &monitor, int depth, bool native_byte_order)
static void set_mac_frame_buffer(SDL_monitor_desc &monitor, int depth)
{
#if !REAL_ADDRESSING && !DIRECT_ADDRESSING
int layout = FLAYOUT_DIRECT;
if (depth == VIDEO_DEPTH_16BIT)
layout = (screen_depth == 15) ? FLAYOUT_HOST_555 : FLAYOUT_HOST_565;
else if (depth == VIDEO_DEPTH_32BIT)
layout = (screen_depth == 24) ? FLAYOUT_HOST_888 : FLAYOUT_DIRECT;
if (native_byte_order)
MacFrameLayout = layout;
else
MacFrameLayout = FLAYOUT_DIRECT;
MacFrameLayout = layout;
monitor.set_mac_frame_base(MacFrameBaseMac);

// Set variables used by UAE memory banking
Expand Down Expand Up @@ -686,13 +685,13 @@ void driver_base::init()
}

// Set frame buffer base
set_mac_frame_buffer(monitor, VIDEO_MODE_DEPTH, true);
set_mac_frame_buffer(monitor, VIDEO_MODE_DEPTH);

adapt_to_video_mode();
}

void driver_base::adapt_to_video_mode() {
ADBSetRelMouseMode(mouse_grabbed);
ADBSetRelMouseMode(false);

// Init blitting routines
SDL_PixelFormat *f = s->format;
Expand Down Expand Up @@ -726,7 +725,7 @@ void driver_base::adapt_to_video_mode() {
SDL_ShowCursor(hardware_cursor);

// Set window name/class
set_window_name(mouse_grabbed ? STR_WINDOW_TITLE_GRABBED : STR_WINDOW_TITLE);
set_window_name(STR_WINDOW_TITLE);

// Everything went well
init_ok = true;
Expand Down Expand Up @@ -804,9 +803,8 @@ void driver_base::grab_mouse(void)
if (!mouse_grabbed) {
SDL_GrabMode new_mode = set_grab_mode(SDL_GRAB_ON);
if (new_mode == SDL_GRAB_ON) {
set_window_name(STR_WINDOW_TITLE_GRABBED);
disable_mouse_accel();
ADBSetRelMouseMode(mouse_grabbed = true);
mouse_grabbed = true;
}
}
}
Expand All @@ -817,9 +815,8 @@ void driver_base::ungrab_mouse(void)
if (mouse_grabbed) {
SDL_GrabMode new_mode = set_grab_mode(SDL_GRAB_OFF);
if (new_mode == SDL_GRAB_OFF) {
set_window_name(STR_WINDOW_TITLE);
restore_mouse_accel();
ADBSetRelMouseMode(mouse_grabbed = false);
mouse_grabbed = false;
}
}
}
Expand Down Expand Up @@ -1279,6 +1276,13 @@ void VideoVBL(void)
if (toggle_fullscreen)
do_toggle_fullscreen();

// Setting the window name must happen on the main thread, else it doesn't work on
// some platforms - e.g. macOS Sierra.
if (mouse_grabbed_window_name_status != mouse_grabbed) {
set_window_name(mouse_grabbed ? STR_WINDOW_TITLE_GRABBED : STR_WINDOW_TITLE);
mouse_grabbed_window_name_status = mouse_grabbed;
}

// Temporarily give up frame buffer lock (this is the point where
// we are suspended when the user presses Ctrl-Tab)
UNLOCK_FRAME_BUFFER;
Expand All @@ -1301,6 +1305,13 @@ void VideoInterrupt(void)
if (toggle_fullscreen)
do_toggle_fullscreen();

// Setting the window name must happen on the main thread, else it doesn't work on
// some platforms - e.g. macOS Sierra.
if (mouse_grabbed_window_name_status != mouse_grabbed) {
set_window_name(mouse_grabbed ? STR_WINDOW_TITLE_GRABBED : STR_WINDOW_TITLE);
mouse_grabbed_window_name_status = mouse_grabbed;
}

// Temporarily give up frame buffer lock (this is the point where
// we are suspended when the user presses Ctrl-Tab)
UNLOCK_FRAME_BUFFER;
Expand Down Expand Up @@ -1751,11 +1762,7 @@ static void handle_events(void)

// Mouse moved
case SDL_MOUSEMOTION:
if (mouse_grabbed) {
drv->mouse_moved(event.motion.xrel, event.motion.yrel);
} else {
drv->mouse_moved(event.motion.x, event.motion.y);
}
drv->mouse_moved(event.motion.x, event.motion.y);
break;

// Keyboard
Expand Down Expand Up @@ -1825,7 +1832,7 @@ static void handle_events(void)
// Application activate/deactivate
case SDL_ACTIVEEVENT:
// Force a complete window refresh when activating, to avoid redraw artifacts otherwise.
if (event.active.gain && (event.active.state & SDL_APPACTIVE))
if (event.active.gain)
force_complete_window_refresh();
break;
}
Expand Down
1 change: 1 addition & 0 deletions SheepShaver/src/SDL

0 comments on commit e42b6a5

Please sign in to comment.