From e42b6a50c388a0e5316385c92b6cf972f1abdeda Mon Sep 17 00:00:00 2001 From: kanjitalk755 Date: Tue, 5 Dec 2017 23:49:59 +0900 Subject: [PATCH] revert SDL --- BasiliskII/src/SDL/video_sdl.cpp | 43 +++++++++++++++++++------------- SheepShaver/src/SDL | 1 + 2 files changed, 26 insertions(+), 18 deletions(-) mode change 100755 => 100644 BasiliskII/src/SDL/video_sdl.cpp create mode 120000 SheepShaver/src/SDL diff --git a/BasiliskII/src/SDL/video_sdl.cpp b/BasiliskII/src/SDL/video_sdl.cpp old mode 100755 new mode 100644 index 798ed8e8..011941f9 --- a/BasiliskII/src/SDL/video_sdl.cpp +++ b/BasiliskII/src/SDL/video_sdl.cpp @@ -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(). @@ -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; @@ -494,7 +496,7 @@ 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; @@ -502,10 +504,7 @@ static void set_mac_frame_buffer(SDL_monitor_desc &monitor, int depth, bool nati 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 @@ -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; @@ -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; @@ -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; } } } @@ -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; } } } @@ -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; @@ -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; @@ -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 @@ -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; } diff --git a/SheepShaver/src/SDL b/SheepShaver/src/SDL new file mode 120000 index 00000000..48cb61eb --- /dev/null +++ b/SheepShaver/src/SDL @@ -0,0 +1 @@ +../../BasiliskII/src/SDL \ No newline at end of file