Fixed the hang on unclipping the mouse and (hopefully) all the hangs on switching to/from full screen.

This commit is contained in:
OBattler
2017-12-15 18:47:29 +01:00
parent b5bda71d27
commit 4f8506b65e
7 changed files with 38 additions and 47 deletions

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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");

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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);

View File

@@ -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, <decwiz@yahoo.com>
* Based on raw code by RichardG, <richardg867@gmail.com>
@@ -224,6 +224,8 @@ vnc_init(UNUSED(void *arg))
void
vnc_close(void)
{
video_setblit(NULL);
if (rfb != NULL) {
free(rfb->frameBuffer);

View File

@@ -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);
}

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -473,6 +473,8 @@ d3d_close_objects(void)
void
d3d_close(void)
{
video_setblit(NULL);
d3d_close_objects();
if (d3ddev) {

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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;

View File

@@ -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, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com>
@@ -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;
}