From a926754a6b8d0f021343cfb43613666e71ee967c Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Mon, 26 Sep 2022 20:03:20 +0800 Subject: [PATCH] Tuning: the MSG_IDLE message will be relayed to the descendant control if the control captured the mouse currently --- include/window.h | 3 +++ src/gui/window.c | 21 +++++---------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/include/window.h b/include/window.h index 2e053015..7bb9be7d 100644 --- a/include/window.h +++ b/include/window.h @@ -2905,6 +2905,9 @@ typedef struct _WINMASKINFO { * * This message is sent to the all main windows when the system * enters idle loop. + * + * Since 5.0.10, this messasge will be relayed to the descendant control + * if the control captured the mouse event. */ #define MSG_IDLE 0x0142 diff --git a/src/gui/window.c b/src/gui/window.c index acb35683..1ffa5c49 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -2607,13 +2607,12 @@ static LRESULT DefaultSystemMsgHandler(PMAINWIN pWin, UINT message, ** MSG_IDLE, MSG_CARETBLINK: */ if (message == MSG_IDLE) { -#if 0 /* deprecated code */ - if (pWin == checkAndGetMainWinIfWindow (sg_repeat_msg.hwnd)) { - SendNotifyMessage (sg_repeat_msg.hwnd, - sg_repeat_msg.message, - sg_repeat_msg.wParam, sg_repeat_msg.lParam); + /* Since 5.0.10, MSG_IDLE will also be relayed to + the descendant control if the control captured the mouse event. */ + HWND captured = GetCapture(); + if (captured && GetMainWindowHandle(captured) == (HWND)pWin) { + PostMessage(captured, MSG_IDLE, wParam, lParam); } -#endif /* deprecated code */ } else if (message == MSG_CARETBLINK && pWin->dwStyle & WS_VISIBLE) { BlinkCaret ((HWND)pWin); @@ -4537,11 +4536,6 @@ BOOL GUIAPI DestroyMainWindow (HWND hWnd) SendMessage (HWND_DESKTOP, MSG_REMOVEMAINWIN, (WPARAM)hWnd, 0); -#if 0 /* deprecated code */ - if (sg_repeat_msg.hwnd == hWnd) - sg_repeat_msg.hwnd = 0; -#endif /* deprecated code */ - /* make the window to be invalid for PeekMessageEx, PostMessage etc */ pWin->DataType = TYPE_WINTODEL; @@ -6093,11 +6087,6 @@ BOOL GUIAPI DestroyWindow (HWND hWnd) pCtrl->privCDC = 0; } -#if 0 /* deprecated code */ - if (sg_repeat_msg.hwnd == hWnd) - sg_repeat_msg.hwnd = 0; -#endif /* deprecated code */ - ThrowAwayMessages (hWnd); if (pCtrl->dwExStyle & WS_EX_CTRLASMAINWIN) {