From: Toni Wilen Date: Sat, 18 Dec 2021 17:49:15 +0000 (+0200) Subject: Process Windows non-input messages only during vblank. X-Git-Tag: 4910~45 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=a45290240123e82a9cec53b0fde8b1010e134aef;p=francis%2Fwinuae.git Process Windows non-input messages only during vblank. --- diff --git a/include/inputdevice.h b/include/inputdevice.h index 0e7aeae0..bae3230b 100644 --- a/include/inputdevice.h +++ b/include/inputdevice.h @@ -237,6 +237,7 @@ extern void mousehack_wakeup(void); extern void mousehack_write(int reg, uae_u16 val); extern void setmouseactive(int monid, int); extern bool ismouseactive(void); +extern void inputdevice_read_msg(bool); extern void setmousebuttonstateall (int mouse, uae_u32 buttonbits, uae_u32 buttonmask); extern void setjoybuttonstateall (int joy, uae_u32 buttonbits, uae_u32 buttonmask); diff --git a/include/xwin.h b/include/xwin.h index add1b131..fb538986 100644 --- a/include/xwin.h +++ b/include/xwin.h @@ -25,7 +25,7 @@ extern int graphics_init (bool); extern void graphics_leave(void); extern void graphics_reset(bool); extern bool handle_events (void); -extern int handle_msgpump (void); +extern int handle_msgpump (bool); extern void setup_brkhandler (void); extern int isfullscreen (void); extern void toggle_fullscreen(int monid, int); diff --git a/inputdevice.cpp b/inputdevice.cpp index 56ce79da..93424b64 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -2254,7 +2254,7 @@ static bool get_mouse_position(int *xp, int *yp, int inx, int iny) x = inx; y = iny; - getgfxoffset(0, &fdx, &fdy, &fmx, &fmy); + getgfxoffset(monid, &fdx, &fdy, &fmx, &fmy); //write_log("%.2f*%.2f %.2f*%.2f\n", fdx, fdy, fmx, fmy); @@ -3206,17 +3206,22 @@ static void joymousecounter (int joy) static int inputread; -static void inputdevice_read(void) +void inputdevice_read_msg(bool vblank) { -// if ((inputdevice_logging & (2 | 4))) -// write_log(_T("INPUTREAD\n")); int got2 = 0; for (;;) { - int got = handle_msgpump(); + int got = handle_msgpump(vblank); if (!got) break; got2 = 1; } +} + +static void inputdevice_read(void) +{ +// if ((inputdevice_logging & (2 | 4))) +// write_log(_T("INPUTREAD\n")); + inputdevice_read_msg(false); if (inputread <= 0) { idev[IDTYPE_MOUSE].read(); idev[IDTYPE_JOYSTICK].read(); @@ -3957,7 +3962,7 @@ void inputdevice_hsync (bool forceread) while (inprec_playevent (&nr, &state, &max, &autofire)) handle_input_event (nr, state, max, (autofire ? HANDLE_IE_FLAG_AUTOFIRE : 0) | HANDLE_IE_FLAG_PLAYBACKEVENT); if (vpos == 0) - handle_msgpump (); + handle_msgpump(true); } if (!input_record && !input_play) { if (forceread) { diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index b7b2e25b..5116be33 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -3068,15 +3068,19 @@ static LRESULT CALLBACK BlankWindowProc (HWND hWnd, UINT message, WPARAM wParam, return DefWindowProc (hWnd, message, wParam, lParam); } -int handle_msgpump (void) +int handle_msgpump(bool vblank) { - int got = 0; MSG msg; + int got = 0; - while (PeekMessage (&msg, 0, 0, 0, PM_REMOVE)) { + UINT wRemoveMsg = PM_REMOVE | PM_NOYIELD | PM_QS_INPUT; + if (vblank) { + wRemoveMsg |= PM_QS_PAINT | PM_QS_POSTMESSAGE | PM_QS_SENDMESSAGE; + } + while (PeekMessage(&msg, 0, 0, 0, wRemoveMsg)) { got = 1; - TranslateMessage (&msg); - DispatchMessage (&msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } while (checkIPC (globalipc, &currprefs)); return got;