From 4f8506b65ef80bd941664a734a97964752a64c37 Mon Sep 17 00:00:00 2001 From: OBattler Date: Fri, 15 Dec 2017 18:47:29 +0100 Subject: [PATCH] Fixed the hang on unclipping the mouse and (hopefully) all the hangs on switching to/from full screen. --- src/pc.c | 9 +-------- src/video/video.c | 9 +++++---- src/vnc.c | 4 +++- src/win/win.c | 23 +++++------------------ src/win/win_d3d.cpp | 4 +++- src/win/win_ddraw.cpp | 4 +++- src/win/win_ui.c | 32 ++++++++++++++++++-------------- 7 files changed, 38 insertions(+), 47 deletions(-) diff --git a/src/pc.c b/src/pc.c index 241a2a4df..7392eb0ae 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Main emulator module where most things are controlled. * - * Version: @(#)pc.c 1.0.49 2017/12/09 + * Version: @(#)pc.c 1.0.50 2017/12/15 * * Authors: Sarah Walker, * Miran Grca, @@ -1096,13 +1096,6 @@ pc_thread(void *param) doresize = 0; } - - /* If requested, leave full-screen mode. */ - if (leave_fullscreen_flag) { - pclog("Leaving full-screen mode..\n"); - plat_setfullscreen(0); - leave_fullscreen_flag = 0; - } } pclog("PC: main thread done.\n"); diff --git a/src/video/video.c b/src/video/video.c index 1302ef1de..06529623e 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -40,7 +40,7 @@ * W = 3 bus clocks * L = 4 bus clocks * - * Version: @(#)video.c 1.0.10 2017/11/18 + * Version: @(#)video.c 1.0.11 2017/12/15 * * Authors: Sarah Walker, * Miran Grca, @@ -200,9 +200,10 @@ void blit_thread(void *param) thread_wait_event(blit_data.wake_blit_thread, -1); thread_reset_event(blit_data.wake_blit_thread); - blit_func(blit_data.x, blit_data.y, - blit_data.y1, blit_data.y2, - blit_data.w, blit_data.h); + if (blit_func) + blit_func(blit_data.x, blit_data.y, + blit_data.y1, blit_data.y2, + blit_data.w, blit_data.h); blit_data.busy = 0; thread_set_event(blit_data.blit_complete); diff --git a/src/vnc.c b/src/vnc.c index 0e41bd46f..7ec3ec2d8 100644 --- a/src/vnc.c +++ b/src/vnc.c @@ -8,7 +8,7 @@ * * Implement the VNC remote renderer with LibVNCServer. * - * Version: @(#)vnc.c 1.0.9 2017/11/18 + * Version: @(#)vnc.c 1.0.10 2017/12/15 * * Authors: Fred N. van Kempen, * Based on raw code by RichardG, @@ -224,6 +224,8 @@ vnc_init(UNUSED(void *arg)) void vnc_close(void) { + video_setblit(NULL); + if (rfb != NULL) { free(rfb->frameBuffer); diff --git a/src/win/win.c b/src/win/win.c index 42cd60050..a5b55bee4 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -335,6 +335,9 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow) wchar_t **argw = NULL; int argc, i; + /* Set this to the default value (windowed mode). */ + video_fullscreen = 0; + /* We need this later. */ hinstance = hInst; @@ -689,7 +692,6 @@ get_vidpause(void) void plat_setfullscreen(int on) { - static int flag = 0; HWND *hw; /* Want off and already off? */ @@ -698,25 +700,12 @@ plat_setfullscreen(int on) /* Want on and already on? */ if (on && video_fullscreen) return; - if (!on && !flag) { - /* We want to leave FS mode. */ - flag = 1; - -#ifdef USE_WX - goto doit; -#endif - return; - } - - if (video_fullscreen_first) { + if (on && video_fullscreen_first) { video_fullscreen_first = 0; ui_msgbox(MBX_INFO, (wchar_t *)IDS_2074); } /* OK, claim the video. */ -#ifdef USE_WX -doit: -#endif startblit(); video_wait_for_blit(); @@ -727,7 +716,6 @@ doit: video_fullscreen = on; hw = (video_fullscreen) ? &hwndMain : &hwndRender; vid_apis[video_fullscreen][vid_api].init((void *) *hw); - flag = 0; #ifdef USE_WX wx_set_fullscreen(on); @@ -735,13 +723,12 @@ doit: win_mouse_init(); - leave_fullscreen_flag = 0; - /* Release video and make it redraw the screen. */ endblit(); device_force_redraw(); /* Finally, handle the host's mouse cursor. */ + pclog("%s full screen, %s cursor\n", on ? "enter" : "leave", on ? "hide" : "show"); show_cursor(video_fullscreen ? 0 : -1); } diff --git a/src/win/win_d3d.cpp b/src/win/win_d3d.cpp index 9e367fb71..818694045 100644 --- a/src/win/win_d3d.cpp +++ b/src/win/win_d3d.cpp @@ -8,7 +8,7 @@ * * Rendering module for Microsoft Direct3D 9. * - * Version: @(#)win_d3d.cpp 1.0.8 2017/12/15 + * Version: @(#)win_d3d.cpp 1.0.9 2017/12/15 * * Authors: Sarah Walker, * Miran Grca, @@ -473,6 +473,8 @@ d3d_close_objects(void) void d3d_close(void) { + video_setblit(NULL); + d3d_close_objects(); if (d3ddev) { diff --git a/src/win/win_ddraw.cpp b/src/win/win_ddraw.cpp index 10d908127..3ed6b9dd0 100644 --- a/src/win/win_ddraw.cpp +++ b/src/win/win_ddraw.cpp @@ -11,7 +11,7 @@ * NOTES: This code should be re-merged into a single init() with a * 'fullscreen' argument, indicating FS mode is requested. * - * Version: @(#)win_ddraw.cpp 1.0.3 2017/12/15 + * Version: @(#)win_ddraw.cpp 1.0.4 2017/12/15 * * Authors: Sarah Walker, * Miran Grca, @@ -514,6 +514,8 @@ ddraw_init_fs(HWND h) void ddraw_close(void) { + video_setblit(NULL); + if (lpdds_back2) { lpdds_back2->Release(); lpdds_back2 = NULL; diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 5632a083a..05f00b6ae 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -8,7 +8,7 @@ * * user Interface module for WinAPI on Windows. * - * Version: @(#)win_ui.c 1.0.9 2017/12/15 + * Version: @(#)win_ui.c 1.0.10 2017/12/15 * * Authors: Sarah Walker, * Miran Grca, @@ -64,21 +64,23 @@ static int hook_enabled = 0; static int save_window_pos = 0; +static int vis = -1; + /* Set host cursor visible or not. */ void show_cursor(int val) { - static int old = -1, vis = -1; + if (val == vis) + return; - if (vis == val) return; - - if (val < 0) - val = old; - - old = vis; - while (1) { - if (ShowCursor((val == 0) ? FALSE : TRUE) < 0) break; + if (val == 0) { + while (1) { + if (ShowCursor(FALSE) < 0) break; + } + } else { + ShowCursor(TRUE); } + vis = val; } @@ -367,6 +369,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case IDM_VID_FULLSCREEN: + pclog("enter full screen though menu\n"); plat_setfullscreen(1); config_save(); break; @@ -539,8 +542,6 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_KILLFOCUS: infocus = 0; plat_mouse_capture(0); - if (video_fullscreen) - leave_fullscreen_flag = 1; if (hook_enabled) { UnhookWindowsHookEx(hKeyboardHook); hook_enabled = 0; @@ -617,9 +618,9 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_LEAVEFULLSCREEN: + pclog("leave full screen on window message\n"); plat_setfullscreen(0); config_save(); - cgapal_rebuild(); break; case WM_KEYDOWN: @@ -841,6 +842,7 @@ ui_init(int nCmdShow) if (video_fullscreen && keyboard_isfsexit()) { /* Signal "exit fullscreen mode". */ + pclog("leave full screen though key combination\n"); plat_setfullscreen(0); } } @@ -957,12 +959,14 @@ plat_mouse_capture(int on) GetClipCursor(&oldclip); GetWindowRect(hwndRender, &rect); ClipCursor(&rect); + pclog("mouse capture off, hide cursor\n"); show_cursor(0); mouse_capture = 1; } else if (!on && mouse_capture) { /* Disable the in-app mouse. */ ClipCursor(&oldclip); - show_cursor(1); + pclog("mouse capture on, show cursor\n"); + show_cursor(-1); mouse_capture = 0; }