use new inline functions for checking and returning the window ptr

This commit is contained in:
Vincent Wei
2020-02-28 17:12:05 +08:00
parent 92a20d4cb8
commit 04535d691f
5 changed files with 28 additions and 22 deletions

View File

@@ -161,7 +161,10 @@ tab2space() {
#sed -i 's/\<SetCtrlClassAddData\>/gui_SetCtrlClassAddData/g' `grep '\<SetCtrlClassAddData\>' -rl include/ src/`
#sed -i 's/\<GetCtrlClassAddData\>/gui_GetCtrlClassAddData/g' `grep '\<GetCtrlClassAddData\>' -rl include/ src/`
sed -i 's/\<get_valid_dc\>/get_effective_dc/g' `grep '\<get_valid_dc\>' -rl include/ src/`
sed -i 's/\<release_valid_dc\>/release_effective_dc/g' `grep '\<release_valid_dc\>' -rl include/ src/`
# sed -i 's/\<get_valid_dc\>/get_effective_dc/g' `grep '\<get_valid_dc\>' -rl include/ src/`
# sed -i 's/\<release_valid_dc\>/release_effective_dc/g' `grep '\<release_valid_dc\>' -rl include/ src/`
sed -i 's/\<gui_GetMainWindowPtrOfControl\>/checkAndGetMainWindowPtrOfControl/g' `grep '\<gui_GetMainWindowPtrOfControl\>' -rl include/ src/`
sed -i 's/\<gui_CheckAndGetMainWindowPtr\>/checkAndGetMainWindowPtrOfMainWin/g' `grep '\<gui_CheckAndGetMainWindowPtr\>' -rl include/ src/`
exit 0

View File

@@ -1297,7 +1297,7 @@ HMENU GUIAPI SetMenu (HWND hwnd, HMENU hmnu)
PMAINWIN pWin;
HMENU hOld;
if (!(pWin = gui_CheckAndGetMainWindowPtr (hwnd))) return 0;
if (!(pWin = checkAndGetMainWindowPtrOfMainWin (hwnd))) return 0;
hOld = pWin->hMenu;
pWin->hMenu = hmnu;
@@ -1317,7 +1317,7 @@ HMENU GUIAPI GetMenu (HWND hwnd)
{
PMAINWIN pWin;
if (!(pWin = gui_CheckAndGetMainWindowPtr (hwnd))) return 0;
if (!(pWin = checkAndGetMainWindowPtrOfMainWin (hwnd))) return 0;
return pWin->hMenu;
}
@@ -1326,7 +1326,7 @@ HMENU GUIAPI GetSystemMenu (HWND hwnd, BOOL flag)
{
PMAINWIN pWin;
if (!(pWin = gui_CheckAndGetMainWindowPtr (hwnd))) return 0;
if (!(pWin = checkAndGetMainWindowPtrOfMainWin (hwnd))) return 0;
return pWin->hSysMenu;
}
@@ -1561,7 +1561,7 @@ HMENU GUIAPI GetMenuBarItemRect (HWND hwnd, int pos, RECT* prc)
int count;
SIZE size;
if (!(pWin = gui_CheckAndGetMainWindowPtr (hwnd))) return 0;
if (!(pWin = checkAndGetMainWindowPtrOfMainWin (hwnd))) return 0;
if (!pWin->hMenu) return 0;
@@ -1607,7 +1607,7 @@ static BOOL mnuGetMenuBarRect (HWND hwnd, RECT* prc)
PMAINWIN pWin;
int h;
if (!(pWin = gui_CheckAndGetMainWindowPtr (hwnd))) return FALSE;
if (!(pWin = checkAndGetMainWindowPtrOfMainWin (hwnd))) return FALSE;
prc->left = pWin->cl - pWin->left;
@@ -1693,7 +1693,7 @@ int MenuBarHitTest (HWND hwnd, int mx, int my)
int count;
SIZE size;
if (!(pWin = gui_CheckAndGetMainWindowPtr (hwnd))) return -1;
if (!(pWin = checkAndGetMainWindowPtrOfMainWin (hwnd))) return -1;
if (!pWin->hMenu) return -1;
@@ -1811,7 +1811,7 @@ void GUIAPI DrawMenuBar (HWND hwnd)
PMAINWIN pWin;
HDC hdc;
if (!(pWin = gui_CheckAndGetMainWindowPtr (hwnd))) return;
if (!(pWin = checkAndGetMainWindowPtrOfMainWin (hwnd))) return;
if (!pWin->hMenu) return;

View File

@@ -533,7 +533,7 @@ static void dskEnableWindow (PMAINWIN pWin, int flags)
if (pWin->dwStyle & WS_DISABLED) {
if (__mg_captured_wnd &&
gui_GetMainWindowPtrOfControl (__mg_captured_wnd) == pWin)
checkAndGetMainWindowPtrOfControl (__mg_captured_wnd) == pWin)
__mg_captured_wnd = 0;
if (dskGetActiveWindow () == pWin) {
@@ -928,7 +928,7 @@ static HWND DesktopSetCapture (HWND hwnd)
HWND hTemp;
_mgs_old_under_p = NULL;
_mgs_button_down_main_window = gui_GetMainWindowPtrOfControl (hwnd);
_mgs_button_down_main_window = checkAndGetMainWindowPtrOfControl (hwnd);
_mgs_down_buttons = DOWN_BUTTON_NONE;
hTemp = __mg_captured_wnd;
@@ -1554,7 +1554,7 @@ static LRESULT WindowMessageHandler(UINT message, PMAINWIN pWin, LPARAM lParam)
while (from) {
hwnd = nodes[from].hwnd;
if ((pWin = gui_CheckAndGetMainWindowPtr (hwnd)) &&
if ((pWin = checkAndGetMainWindowPtrOfMainWin (hwnd)) &&
!(pWin->dwExStyle & WS_EX_CTRLASMAINWIN)) {
break;
}
@@ -2130,7 +2130,7 @@ static int dskRegisterIMEWnd (HWND hwnd)
if (__mg_ime_wnd != 0)
return ERR_IME_TOOMUCHIMEWND;
if (!gui_CheckAndGetMainWindowPtr (hwnd))
if (!checkAndGetMainWindowPtrOfMainWin (hwnd))
return ERR_INV_HWND;
__mg_ime_wnd = hwnd;
@@ -2526,7 +2526,7 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message,
uCounter += (__mg_tick_counter - blink_counter) * 10;
blink_counter = __mg_tick_counter;
if (sg_hCaretWnd != 0
&& gui_GetMainWindowPtrOfControl (sg_hCaretWnd) ==
&& checkAndGetMainWindowPtrOfControl (sg_hCaretWnd) ==
dskGetActiveWindow()
&& uCounter >= sg_uCaretBTime) {
PostMessage (sg_hCaretWnd, MSG_CARETBLINK, 0, 0);

View File

@@ -2492,7 +2492,7 @@ static void dskEnableWindow (PMAINWIN pWin, int flags)
if (pWin->dwStyle & WS_DISABLED) {
if (__mg_captured_wnd &&
gui_GetMainWindowPtrOfControl (__mg_captured_wnd) == pWin)
checkAndGetMainWindowPtrOfControl (__mg_captured_wnd) == pWin)
__mg_captured_wnd = 0;
if (dskGetActiveWindow (NULL) == (HWND)pWin) {
@@ -2697,7 +2697,7 @@ static HWND dskGetNextMainWindow (PMAINWIN pWin)
hwnd = nodes[from].hwnd;
if ((nodes[from].cli == __mg_client_id) &&
(pWin = gui_CheckAndGetMainWindowPtr (hwnd)) &&
(pWin = checkAndGetMainWindowPtrOfMainWin (hwnd)) &&
!(pWin->dwExStyle & WS_EX_CTRLASMAINWIN)) {
break;
}
@@ -4033,7 +4033,7 @@ static int srvRegisterIMEWnd (HWND hwnd)
if (__mg_ime_wnd != 0)
return ERR_IME_TOOMUCHIMEWND;
if (!gui_CheckAndGetMainWindowPtr (hwnd))
if (!checkAndGetMainWindowPtrOfMainWin (hwnd))
return ERR_INV_HWND;
__mg_ime_wnd = hwnd;
@@ -4206,7 +4206,7 @@ static void dskOnTimer (void)
blink_counter = __mg_tick_counter;
if (sg_hCaretWnd != 0
&& (HWND)gui_GetMainWindowPtrOfControl (sg_hCaretWnd)
&& (HWND)checkAndGetMainWindowPtrOfControl (sg_hCaretWnd)
== dskGetActiveWindow (NULL)
&& uCounter >= sg_uCaretBTime) {
PostMessage (sg_hCaretWnd, MSG_CARETBLINK, 0, 0);

View File

@@ -1435,6 +1435,9 @@ LRESULT GUIAPI DispatchMessage (PMSG pMsg)
return lRet;
}
/* Throw away messages in the message queue for the specified window.
If the specified window is a main window, all messages sent
to the controls of the main window will be thrown away asw well. */
int __mg_throw_away_messages (PMSGQUEUE pMsgQueue, HWND hWnd)
{
PMAINWIN pMainWin = NULL;
@@ -1458,7 +1461,7 @@ int __mg_throw_away_messages (PMSGQUEUE pMsgQueue, HWND hWnd)
pMsg = &pQMsg->Msg;
if (pMsg->hwnd == hWnd ||
gui_GetMainWindowPtrOfControl (pMsg->hwnd) == pMainWin) {
checkAndGetMainWindowPtrOfControl (pMsg->hwnd) == pMainWin) {
pMsg->hwnd = HWND_INVALID;
nCountN ++;
}
@@ -1479,7 +1482,7 @@ int __mg_throw_away_messages (PMSGQUEUE pMsgQueue, HWND hWnd)
pMsg = &pSyncMsg->Msg;
if (pMsg->hwnd == hWnd ||
gui_GetMainWindowPtrOfControl (pMsg->hwnd) == pMainWin) {
checkAndGetMainWindowPtrOfControl (pMsg->hwnd) == pMainWin) {
pMsg->hwnd = HWND_INVALID;
nCountS ++;
@@ -1515,7 +1518,7 @@ int __mg_throw_away_messages (PMSGQUEUE pMsgQueue, HWND hWnd)
pMsg = pMsgQueue->msg + readpos;
if (pMsg->hwnd == hWnd ||
gui_GetMainWindowPtrOfControl (pMsg->hwnd) == pMainWin) {
checkAndGetMainWindowPtrOfControl (pMsg->hwnd) == pMainWin) {
pMsg->hwnd = HWND_INVALID;
nCountP ++;
}
@@ -1531,7 +1534,7 @@ int __mg_throw_away_messages (PMSGQUEUE pMsgQueue, HWND hWnd)
if (pMsgQueue->expired_timer_mask & (0x01UL << slot)) {
HWND timer_wnd = pMsgQueue->timer_slots [slot]->hWnd;
if (timer_wnd == hWnd ||
gui_GetMainWindowPtrOfControl (timer_wnd) == pMainWin) {
checkAndGetMainWindowPtrOfControl (timer_wnd) == pMainWin) {
pMsgQueue->expired_timer_mask &= ~(0x01UL << slot);
}
}