diff --git a/cleanup-code.sh b/cleanup-code.sh index 624cdfaf..103fa41a 100755 --- a/cleanup-code.sh +++ b/cleanup-code.sh @@ -156,11 +156,12 @@ tab2space() { # sed -i 's/\/Determine/g' `grep '\' -rl include/ src/` # sed -i 's/\/Check/g' `grep '\' -rl include/ src/` -sed -i 's/\/gui_SetWindowExStyle/g' `grep '\' -rl include/ src/` -sed -i 's/\/gui_AddNewControlClass/g' `grep '\' -rl include/ src/` -sed -i 's/\/gui_SetCtrlClassAddData/g' `grep '\' -rl include/ src/` -sed -i 's/\/gui_GetCtrlClassAddData/g' `grep '\' -rl include/ src/` +#sed -i 's/\/gui_SetWindowExStyle/g' `grep '\' -rl include/ src/` +#sed -i 's/\/gui_AddNewControlClass/g' `grep '\' -rl include/ src/` +#sed -i 's/\/gui_SetCtrlClassAddData/g' `grep '\' -rl include/ src/` +#sed -i 's/\/gui_GetCtrlClassAddData/g' `grep '\' -rl include/ src/` -# sed -i 's/\/gui_AAA/g' `grep '\' -rl include/ src/` +sed -i 's/\/get_effective_dc/g' `grep '\' -rl include/ src/` +sed -i 's/\/release_effective_dc/g' `grep '\' -rl include/ src/` exit 0 diff --git a/src/gui/window.c b/src/gui/window.c index 71b22e73..a7f3afca 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -896,7 +896,7 @@ static BOOL wndDrawNCButtonEx (PMAINWIN pWin, HDC hdc, int downCode, int status) if(hdc == 0) { - hdc = get_valid_dc (pWin, FALSE); + hdc = get_effective_dc (pWin, FALSE); fGetDC = TRUE; } @@ -923,7 +923,7 @@ static BOOL wndDrawNCButtonEx (PMAINWIN pWin, HDC hdc, int downCode, int status) if (pWin->pMainWin->secondaryDC) { draw_secondary_nc_area (pWin, info->we_rdr, hdc, downCode); } - release_valid_dc (pWin, hdc); + release_effective_dc (pWin, hdc); return TRUE; } @@ -1098,7 +1098,7 @@ static BOOL wndDrawNCButtonEx (PMAINWIN pWin, HDC hdc, int downCode, int status) } default: - release_valid_dc (pWin, hdc); + release_effective_dc (pWin, hdc); return FALSE; } @@ -1113,7 +1113,7 @@ static BOOL wndDrawNCButtonEx (PMAINWIN pWin, HDC hdc, int downCode, int status) } if (fGetDC) - release_valid_dc (pWin, hdc); + release_effective_dc (pWin, hdc); pWin->hscroll.status &= ~_status; pWin->vscroll.status &= ~_status; @@ -1505,21 +1505,21 @@ static void wndHandleCustomHotspot (PMAINWIN pWin, movePos = location; hilitePos = HT_UNKNOWN; - hdc = get_valid_dc (pWin, FALSE); + hdc = get_effective_dc (pWin, FALSE); if (rdr->draw_custom_hotspot) rdr->draw_custom_hotspot ((HWND)pWin, hdc, location, LFRDR_BTN_STATUS_PRESSED); if (pWin->pMainWin->secondaryDC) { draw_secondary_nc_area (pWin, rdr, hdc, location); } - release_valid_dc (pWin, hdc); + release_effective_dc (pWin, hdc); if (rdr->on_click_hotspot) rdr->on_click_hotspot ((HWND)pWin, location); break; case MSG_NCLBUTTONUP: - hdc = get_valid_dc (pWin, FALSE); + hdc = get_effective_dc (pWin, FALSE); if (rdr->draw_custom_hotspot && (downPos != HT_UNKNOWN)) { rdr->draw_custom_hotspot ((HWND)pWin, hdc, location, LFRDR_BTN_STATUS_NORMAL); @@ -1527,7 +1527,7 @@ static void wndHandleCustomHotspot (PMAINWIN pWin, if (pWin->pMainWin->secondaryDC) { draw_secondary_nc_area (pWin, rdr, hdc, location); } - release_valid_dc (pWin, hdc); + release_effective_dc (pWin, hdc); downPos = HT_UNKNOWN; movePos = HT_UNKNOWN; @@ -1535,7 +1535,7 @@ static void wndHandleCustomHotspot (PMAINWIN pWin, break; case MSG_NCMOUSEMOVE: - hdc = get_valid_dc (pWin, FALSE); + hdc = get_effective_dc (pWin, FALSE); if (downPos != HT_UNKNOWN) { if (rdr->draw_custom_hotspot) { if (movePos == downPos && location != downPos) @@ -1565,7 +1565,7 @@ static void wndHandleCustomHotspot (PMAINWIN pWin, if (pWin->pMainWin->secondaryDC) { draw_secondary_nc_area (pWin, rdr, hdc, location); } - release_valid_dc (pWin, hdc); + release_effective_dc (pWin, hdc); break; } @@ -2270,7 +2270,7 @@ static void wndEraseBackground(const PMAINWIN pWin, GetWindowInfo ((HWND)pWin)->we_rdr; if (hdc == 0) { - hdc = get_valid_dc ((PMAINWIN)pWin, TRUE); + hdc = get_effective_dc ((PMAINWIN)pWin, TRUE); fGetDC = TRUE; } @@ -2304,7 +2304,7 @@ static void wndEraseBackground(const PMAINWIN pWin, #endif if (fGetDC) { - release_valid_dc ((PMAINWIN)pWin, hdc); + release_effective_dc ((PMAINWIN)pWin, hdc); } } @@ -2320,7 +2320,7 @@ static void wndDrawNCFrame(MAINWIN* pWin, HDC hdc, const RECT* prcInvalid) return; if (hdc == 0) { - hdc = get_valid_dc (pWin, FALSE); + hdc = get_effective_dc (pWin, FALSE); fGetDC = TRUE; } @@ -2384,7 +2384,7 @@ static void wndDrawNCFrame(MAINWIN* pWin, HDC hdc, const RECT* prcInvalid) #endif if (fGetDC) - release_valid_dc (pWin, hdc); + release_effective_dc (pWin, hdc); } /* this function is CONTROL safe. */ @@ -2393,7 +2393,7 @@ static void wndActiveMainWindow (PMAINWIN pWin, BOOL fActive) HDC hdc; const WINDOWINFO *wnd_info; - hdc = get_valid_dc (pWin, FALSE); + hdc = get_effective_dc (pWin, FALSE); wnd_info = GetWindowInfo ((HWND)pWin); wnd_info->we_rdr->draw_caption ((HWND)pWin, hdc, fActive); @@ -2410,7 +2410,7 @@ static void wndActiveMainWindow (PMAINWIN pWin, BOOL fActive) draw_secondary_nc_area (pWin, wnd_info->we_rdr, hdc, HT_BORDER); } - release_valid_dc (pWin, hdc); + release_effective_dc (pWin, hdc); } static LRESULT DefaultPaintMsgHandler(PMAINWIN pWin, UINT message, @@ -2520,7 +2520,7 @@ static LRESULT DefaultControlMsgHandler(PMAINWIN pWin, UINT message, #ifdef _MGRM_PROCESSES SendMessage (HWND_DESKTOP, MSG_CHANGECAPTION, (WPARAM) pWin, 0L); #endif - hdc = get_valid_dc (pWin, FALSE); + hdc = get_effective_dc (pWin, FALSE); info = GetWindowInfo ((HWND)pWin); SetRectEmpty (&rc); @@ -2556,7 +2556,7 @@ static LRESULT DefaultControlMsgHandler(PMAINWIN pWin, UINT message, if (info->we_rdr->draw_custom_hotspot) info->we_rdr->draw_custom_hotspot ((HWND)pWin, hdc, 0, 0); #endif - release_valid_dc (pWin, hdc); + release_effective_dc (pWin, hdc); break; } @@ -5306,12 +5306,12 @@ BOOL GUIAPI MoveWindow (HWND hWnd, int x, int y, int w, int h, BOOL fPaint) InvalidateRect (hWnd, NULL, TRUE); else { HDC hdc; - hdc = get_valid_dc ((PMAINWIN)pParent, TRUE); + hdc = get_effective_dc ((PMAINWIN)pParent, TRUE); BitBlt (hdc, pCtrl->left, pCtrl->top, pCtrl->right - pCtrl->left, pCtrl->bottom - pCtrl->top, hdc, rcResult.left, rcResult.top, 0); - release_valid_dc ((PMAINWIN)pParent, hdc); + release_effective_dc ((PMAINWIN)pParent, hdc); } /* set to invisible temporarily. */ /* FIXME: need more optimization. */ @@ -5370,11 +5370,11 @@ BOOL GUIAPI MoveWindow (HWND hWnd, int x, int y, int w, int h, BOOL fPaint) } else { HDC hdc; - hdc = get_valid_dc ((PMAINWIN)pParent, TRUE); + hdc = get_effective_dc ((PMAINWIN)pParent, TRUE); BitBlt (hdc, rcWindow.left, rcWindow.top, RECTW(rcWindow), RECTH(rcWindow), hdc, rcResult.left, rcResult.top, 0); - release_valid_dc ((PMAINWIN)pParent, hdc); + release_effective_dc ((PMAINWIN)pParent, hdc); for(pChild = pCtrl->next; pChild; pChild = pChild->next) { if(!(pChild->dwStyle & WS_VISIBLE) @@ -5661,7 +5661,7 @@ HDC GUIAPI BeginPaint (HWND hWnd) pWin->pCaretInfo->fBlink = TRUE; } - hdc = get_valid_dc (pWin, TRUE); + hdc = get_effective_dc (pWin, TRUE); #if 0 /* FIXME: why do this? */ @@ -5762,7 +5762,7 @@ void GUIAPI EndPaint (HWND hWnd, HDC hdc) } } - release_valid_dc (pWin, hdc); + release_effective_dc (pWin, hdc); /* privCDC is not need Release, but need clear lcrgn.*/ if (pWin->dwExStyle & WS_EX_USEPRIVATECDC) @@ -6502,7 +6502,7 @@ HICON SetWindowIcon (HWND hWnd, HICON hIcon, BOOL bRedraw) HDC hdc; const WINDOW_ELEMENT_RENDERER* rdr; - hdc = get_valid_dc (pWin, FALSE); + hdc = get_effective_dc (pWin, FALSE); rdr = GetWindowInfo ((HWND)pWin)->we_rdr; rdr ->draw_caption ((HWND)pWin, hdc, !(pWin->dwStyle & WS_DISABLED) && (GetActiveWindow () == hWnd)); @@ -6510,7 +6510,7 @@ HICON SetWindowIcon (HWND hWnd, HICON hIcon, BOOL bRedraw) if (pWin->pMainWin->secondaryDC) { draw_secondary_nc_area (pWin, rdr, hdc, HT_CAPTION); } - release_valid_dc (pWin, hdc); + release_effective_dc (pWin, hdc); } return hOld; } diff --git a/src/include/dc.h b/src/include/dc.h index b3ba971a..3683f975 100644 --- a/src/include/dc.h +++ b/src/include/dc.h @@ -666,7 +666,7 @@ leave_drawing: #endif // #if MGUI_BYTEORDER == MGUI_LIL_ENDIAN -static inline HDC get_valid_dc (PMAINWIN pWin, BOOL client) +static inline HDC get_effective_dc (PMAINWIN pWin, BOOL client) { if (!(pWin->dwExStyle & WS_EX_CTRLASMAINWIN) && (pWin->pMainWin->secondaryDC)) { @@ -690,7 +690,7 @@ static inline HDC get_valid_dc (PMAINWIN pWin, BOOL client) } } -static inline void release_valid_dc (PMAINWIN pWin, HDC hdc) +static inline void release_effective_dc (PMAINWIN pWin, HDC hdc) { if (pWin->pMainWin->secondaryDC) { if (pWin->privCDC != hdc) diff --git a/src/kernel/desktop-comm.c b/src/kernel/desktop-comm.c index 62f0e09a..8c0392b3 100644 --- a/src/kernel/desktop-comm.c +++ b/src/kernel/desktop-comm.c @@ -562,7 +562,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) //client dc would be diffirent, so we must get the scondaryDC, //the update to client dc (dongjunjie 2010/7/28) //hdc = GetClientDC ((HWND)pWin); - hdc = get_valid_dc(pWin, TRUE); + hdc = get_effective_dc(pWin, TRUE); pcrc = kernel_GetGCRgnInfo ((HWND)pWin)->crgn.head; while (pcrc) { @@ -605,7 +605,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) __mg_update_secondary_dc(pWin, hdc, real_dc, pswi->rc1, HT_CLIENT); ReleaseDC (real_dc); } - release_valid_dc(pWin, hdc); + release_effective_dc(pWin, hdc); GetClientRect((HWND)pWin, &rcClient); diff --git a/src/kernel/desktop-procs.c b/src/kernel/desktop-procs.c index e786f15e..1f72317b 100644 --- a/src/kernel/desktop-procs.c +++ b/src/kernel/desktop-procs.c @@ -2524,7 +2524,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) //BUGFIX: if the MainWindow is AutoSecondaryDC, the secondaryDC and //client dc would be diffirent, so we must get the scondaryDC, //the update to client dc (dongjunjie 2010/7/28) - hdc = get_valid_dc(pWin, TRUE); + hdc = get_effective_dc(pWin, TRUE); pcrc = kernel_GetGCRgnInfo ((HWND)pWin)->crgn.head; while (pcrc) { @@ -2565,7 +2565,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) __mg_update_secondary_dc(pWin, hdc, real_dc, pswi->rc1, HT_CLIENT); ReleaseDC (real_dc); } - release_valid_dc(pWin, hdc); + release_effective_dc(pWin, hdc); GetClientRect((HWND)pWin, &rcClient); diff --git a/src/kernel/desktop.c b/src/kernel/desktop.c index e2151d14..ab903229 100644 --- a/src/kernel/desktop.c +++ b/src/kernel/desktop.c @@ -717,7 +717,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) //client dc would be diffirent, so we must get the scondaryDC, //the update to client dc (dongjunjie 2010/7/28) //hdc = GetClientDC ((HWND)pWin); - hdc = get_valid_dc (pWin, TRUE); + hdc = get_effective_dc (pWin, TRUE); #ifndef _MGSCHEMA_COMPOSITING pcrc = kernel_GetGCRgnInfo ((HWND)pWin)->crgn.head; @@ -770,7 +770,7 @@ static int dskScrollMainWindow (PMAINWIN pWin, PSCROLLWINDOWINFO pswi) __mg_update_secondary_dc(pWin, hdc, real_dc, pswi->rc1, HT_CLIENT); ReleaseDC (real_dc); } - release_valid_dc(pWin, hdc); + release_effective_dc(pWin, hdc); GetClientRect((HWND)pWin, &rcClient); diff --git a/src/newgdi/gdi.c b/src/newgdi/gdi.c index 561bbae2..f9dc05c1 100644 --- a/src/newgdi/gdi.c +++ b/src/newgdi/gdi.c @@ -2723,10 +2723,10 @@ HDC GUIAPI GetSecondaryDC (HWND hwnd) return pWin->secondaryDC; } else if (pWin->pMainWin->secondaryDC){ - return get_valid_dc (pWin, FALSE); + return get_effective_dc (pWin, FALSE); } #else - return get_valid_dc (pWin, TRUE); + return get_effective_dc (pWin, TRUE); #endif return HDC_SCREEN; } @@ -2736,7 +2736,7 @@ HDC GUIAPI GetSecondaryClientDC (HWND hwnd) PMAINWIN pWin; pWin = MG_GET_WINDOW_PTR (hwnd); - return get_valid_dc (pWin, TRUE); + return get_effective_dc (pWin, TRUE); } void GUIAPI ReleaseSecondaryDC (HWND hwnd, HDC hdc) @@ -2747,7 +2747,7 @@ void GUIAPI ReleaseSecondaryDC (HWND hwnd, HDC hdc) if (MG_IS_MAIN_WINDOW(hwnd) && pWin->secondaryDC == hdc) return ; - release_valid_dc (pWin, hdc); + release_effective_dc (pWin, hdc); } BOOL dc_GenerateMemDCECRgn(PDC pdc, BOOL fForce)