static void GetDispRect( HWND hWnd, LPRECT lpRect, int iHorzMode, int iVertMode ) /************************************************************************/ // int iHorzMode; /* 0 = GetClientRect 1 = No Scrollbars 2 = With Scrollbars */ // int iVertMode; /* 0 = GetClientRect 1 = No Scrollbars 2 = With Scrollbars */ { RECT rHorz, rVert; int cy, cx; LPDISPLAY lpDisplay; GetScrollBarSize(&cx, &cy); if (iHorzMode == 2) // with horizontal scrollbar { GetRealClientRect(hWnd, &rHorz); rHorz.bottom -= cy; } else if (iHorzMode == 1) // without horizontal scrollbar { GetRealClientRect(hWnd, &rHorz); } else { // actual client size GetClientRect(hWnd, &rHorz); } if (iVertMode == 2) // with vertical scrollbar { GetRealClientRect(hWnd, &rVert); rVert.right -= cx; } else if (iVertMode == 1) // without horizontal scrollbar { GetRealClientRect(hWnd, &rVert); } else // actual client size { GetClientRect(hWnd, &rVert); } lpRect->top = rHorz.top; lpRect->bottom = rHorz.bottom; lpRect->left = rVert.left; lpRect->right = rVert.right; lpDisplay = GetDisplayPtr(hWnd); if (lpDisplay->HasRulers && !IsIconic(hWnd)) { lpRect->top += GetRulerSize(); lpRect->left += GetRulerSize(); } // adjust because our rects include right and bottom lpRect->bottom -= 1; lpRect->right -= 1; }
// Setup the device context for drawing void cef_dark_aero_window::InitDeviceContext(HDC hdc) { if (CanUseAeroGlass()) { RECT rectClipClient; SetRectEmpty(&rectClipClient); GetRealClientRect(&rectClipClient); // exclude the client area to reduce flicker ::ExcludeClipRect(hdc, rectClipClient.left, rectClipClient.top, rectClipClient.right, rectClipClient.bottom); } else { cef_dark_window::InitDeviceContext(hdc); } }
// Computes the Rect where the menu bar is drawn in window coordinates void cef_dark_aero_window::ComputeMenuBarRect(RECT& rect) const { if (CanUseAeroGlass()) { RECT rectClient; RECT rectCaption; ComputeWindowCaptionRect(rectCaption); GetRealClientRect(&rectClient); rect.top = rectCaption.bottom + 1; rect.bottom = rectClient.top - 1; rect.left = rectClient.left; rect.right = rectClient.right; } else { cef_dark_window::ComputeMenuBarRect(rect); } }
// Computes the Rect where the menu bar is drawn in window coordinates void cef_dark_aero_window::ComputeMenuBarRect(RECT& rect) const { if (CanUseAeroGlass()) { RECT rectClient; RECT rectCaption; GetRealClientRect(&rectClient); if (IsZoomed()) { ComputeWindowCaptionRect(rectCaption); rect.top = rectCaption.bottom; } else { rect.top = ::GetSystemMetrics(SM_CYFRAME) + mNcMetrics.iCaptionHeight + 1; } rect.bottom = rectClient.top - 1; rect.left = rectClient.left; rect.right = rectClient.right; } else { cef_dark_window::ComputeMenuBarRect(rect); } }
UINT xxxArrangeIconicWindows( PWND pwnd) { PBWL pbwl; PSMWP psmwp; PWND pwndTest, pwndSort, pwndSwitch; HWND *phwnd, *phwndSort; CHECKPOINT *pcp, *pcpSort; POINT ptSort, ptSrc; WORD nIcons = 0; RECT rc; POINT ptMin; int xOrg, yOrg; int dx, dy; int dxSlot, dySlot; int cIconsPerPass, iIconPass; BOOL fHorizontal, fBreak; TL tlpwndTest; BOOL fHideMe; CheckLock(pwnd); /* * Create a window list of all children of pwnd */ if ((pbwl = BuildHwndList(pwnd->spwndChild, BWL_ENUMLIST, NULL)) == NULL) return 0; fHideMe = IsTrayWindow(pwnd->spwndChild); // // Put these into local vars for efficiency (see ParkIcon()) // dxSlot = SYSMET(CXMINSPACING); dySlot = SYSMET(CYMINSPACING); // // We need to adjust the client rectangle if the parent has scrollbars. // GetRealClientRect(pwnd, &rc, GRC_SCROLLS); /* * find all icons */ pwndSwitch = RevalidateHwnd(ghwndSwitch); for (phwnd = pbwl->rghwnd; *phwnd != (HWND)1; phwnd++) { if (((pwndTest = RevalidateHwnd(*phwnd)) == NULL) || !TestWF(pwndTest , WFVISIBLE) || pwndTest == pwndSwitch || (pcp = (CHECKPOINT *)_GetProp(pwndTest, PROP_CHECKPOINT, PROPF_INTERNAL)) == NULL) { *phwnd = NULL; continue; } if (!TestWF(pwndTest, WFMINIMIZED)) { pcp->fMinInitialized = FALSE; pcp->ptMin.x = pcp->ptMin.y = -1; *phwnd = NULL; continue; } /* * inc count of icons */ nIcons++; /* * we will park in default position again... */ pcp->fDragged = FALSE; /* * ensure the original position is up to date */ pcp->ptMin.x = pwndTest->rcWindow.left - pwnd->rcClient.left; pcp->ptMin.y = pwndTest->rcWindow.top - pwnd->rcClient.top; // Slide into the nearest row or column switch (SYSMET(ARRANGE) & ~ARW_HIDE) { case ARW_TOPLEFT | ARW_RIGHT: case ARW_TOPRIGHT | ARW_LEFT: // Slide into top row pcp->ptMin.y += dySlot / 2; pcp->ptMin.y -= pcp->ptMin.y % dySlot; break; case ARW_TOPLEFT | ARW_DOWN: case ARW_BOTTOMLEFT | ARW_UP: // Slide into left column pcp->ptMin.x += dxSlot / 2; pcp->ptMin.x -= pcp->ptMin.x % dxSlot; break; case ARW_BOTTOMLEFT | ARW_RIGHT: case ARW_BOTTOMRIGHT | ARW_LEFT: // Slide into bottom row pcp->ptMin.y = rc.bottom - pcp->ptMin.y; pcp->ptMin.y += dySlot / 2; pcp->ptMin.y -= pcp->ptMin.y % dySlot; pcp->ptMin.y = rc.bottom - pcp->ptMin.y; break; case ARW_BOTTOMRIGHT | ARW_UP: case ARW_TOPRIGHT | ARW_DOWN: // Slide into right column pcp->ptMin.x = rc.right - pcp->ptMin.x; pcp->ptMin.x += dxSlot / 2; pcp->ptMin.x -= pcp->ptMin.x % dxSlot; pcp->ptMin.x = rc.right - pcp->ptMin.x; break; } } if (nIcons == 0) { /* * no icons were found... break out */ FreeHwndList(pbwl); return 0; } if (fHideMe) { ptMin.x = WHERE_NOONE_CAN_SEE_ME; ptMin.y = WHERE_NOONE_CAN_SEE_ME; goto JustParkEm; } // // Get gravity && move vars // if (SYSMET(ARRANGE) & ARW_STARTRIGHT) { // Starting on right side ptMin.x = xOrg = rc.right - dxSlot; dx = -dxSlot; } else { // Starting on left ptMin.x = xOrg = rc.left + DX_GAP; dx = dxSlot; } if (SYSMET(ARRANGE) & ARW_STARTTOP) { // Starting on top ptMin.y = yOrg = rc.top + DY_GAP; dy = dySlot; } else { // Starting on bottom ptMin.y = yOrg = rc.bottom - dySlot; dy = -dySlot; } // // Get arrange dir // fHorizontal = ( (SYSMET(ARRANGE) & ARW_DOWN) ? FALSE : TRUE ); iIconPass = fHorizontal ? (rc.right / dxSlot) : (rc.bottom / dySlot); cIconsPerPass = iIconPass = max(1, iIconPass); /* * insertion sort of windows by y, and by x within a row. */ for (phwnd = pbwl->rghwnd; *phwnd != (HWND)1; phwnd++) { /* * Check for 0 (window was not icon) and * Check for invalid HWND (window has been destroyed) */ if (*phwnd == NULL || (pwndTest = RevalidateHwnd(*phwnd)) == NULL) continue; pcp = (CHECKPOINT *)_GetProp(pwndTest, PROP_CHECKPOINT, PROPF_INTERNAL); ptSrc = pcp->ptMin; fBreak = FALSE; for (phwndSort = pbwl->rghwnd; phwndSort < phwnd; phwndSort++) { if (*phwndSort == NULL || (pwndSort = RevalidateHwnd(*phwndSort)) == NULL) continue; pcpSort = (CHECKPOINT*)_GetProp(pwndSort, PROP_CHECKPOINT, PROPF_INTERNAL); ptSort = pcpSort->ptMin; // // Is this the position in which to sort this min window? // switch (SYSMET(ARRANGE) & ~ARW_HIDE) { case ARW_BOTTOMLEFT | ARW_RIGHT: // Lower left, moving horizontally if (((ptSort.y == ptSrc.y) && (ptSort.x > ptSrc.x)) || (ptSort.y < ptSrc.y)) fBreak = TRUE; break; case ARW_BOTTOMLEFT | ARW_UP: // Lower left, moving vertically if (((ptSort.x == ptSrc.x) && (ptSort.y < ptSrc.y)) || (ptSort.x > ptSrc.x)) fBreak = TRUE; break; case ARW_BOTTOMRIGHT | ARW_LEFT: // Lower right, moving horizontally if (((ptSort.y == ptSrc.y) && (ptSort.x < ptSrc.x)) || (ptSort.y < ptSrc.y)) fBreak = TRUE; break; case ARW_BOTTOMRIGHT | ARW_UP: // Lower right, moving vertically if (((ptSort.x == ptSrc.x) && (ptSort.y < ptSrc.y)) || (ptSort.x < ptSrc.x)) fBreak = TRUE; break; case ARW_TOPLEFT | ARW_RIGHT: // Top left, moving horizontally if (((ptSort.y == ptSrc.y) && (ptSort.x > ptSrc.x)) || (ptSort.y > ptSrc.y)) fBreak = TRUE; break; case ARW_TOPLEFT | ARW_DOWN: // Top left, moving vertically if (((ptSort.x == ptSrc.x) && (ptSort.y > ptSrc.y)) || (ptSort.x > ptSrc.x)) fBreak = TRUE; break; case ARW_TOPRIGHT | ARW_LEFT: // Top right, moving horizontally if (((ptSort.y == ptSrc.y) && (ptSort.x < ptSrc.x)) || (ptSort.y > ptSrc.y)) fBreak = TRUE; break; case ARW_TOPRIGHT | ARW_DOWN: // Top right, moving vertically if (((ptSort.x == ptSrc.x) && (ptSort.y > ptSrc.y)) || (ptSort.x < ptSrc.x)) fBreak = TRUE; break; } if (fBreak) break; } /* * insert the window at this position by sliding the rest up. * LATER IanJa, use hwnd intermediate variables, avoid PW() & HW() */ while (phwndSort < phwnd) { pwndSort = PW(*phwndSort); *phwndSort = HW(pwndTest); pwndTest = pwndSort; phwndSort++; } /* * replace the window handle in the original position */ *phwnd = HW(pwndTest); } // // Now park the icons. // JustParkEm: for (phwnd = pbwl->rghwnd; *phwnd != (HWND)1; phwnd++) { if (*phwnd == NULL || (pwndTest = RevalidateHwnd(*phwnd)) == NULL) continue; if (fHideMe) { pcp = (CHECKPOINT *)_GetProp(pwndTest, PROP_CHECKPOINT, PROPF_INTERNAL); if (pcp != NULL) { pcp->fMinInitialized = TRUE; pcp->ptMin.x = ptMin.x; pcp->ptMin.y = ptMin.y; } continue; } pcp = (CHECKPOINT *)_GetProp(pwndTest, PROP_CHECKPOINT, PROPF_INTERNAL); if (pcp != NULL) { pcp->fMinInitialized = TRUE; pcp->ptMin.x = ptMin.x; pcp->ptMin.y = ptMin.y; } // Setup to process the next position if (--iIconPass <= 0) { // Need to setup next pass iIconPass = cIconsPerPass; if (fHorizontal) { ptMin.x = xOrg; ptMin.y += dy; } else { ptMin.x += dx; ptMin.y = yOrg; } } else { // Same pass if (fHorizontal) ptMin.x += dx; else ptMin.y += dy; } } psmwp = _BeginDeferWindowPos(2 * nIcons); if (psmwp == NULL) goto ParkExit; for (phwnd = pbwl->rghwnd; *phwnd != (HWND)1; phwnd++) { /* * Check for a NULL (window has gone away) */ if (*phwnd == NULL || (pwndTest = RevalidateHwnd(*phwnd)) == NULL) continue; pcp = (CHECKPOINT *)_GetProp(pwndTest, PROP_CHECKPOINT, PROPF_INTERNAL); ThreadLockAlways(pwndTest, &tlpwndTest); psmwp = _DeferWindowPos(psmwp, pwndTest, NULL, pcp->ptMin.x, pcp->ptMin.y, rgptMinMaxWnd[MMI_MINSIZE].x, rgptMinMaxWnd[MMI_MINSIZE].y, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS); ThreadUnlock(&tlpwndTest); if (psmwp == NULL) break; } if (psmwp != NULL) { /* * Make the swp async so we don't hang waiting for hung apps. */ xxxEndDeferWindowPosEx(psmwp, TRUE); } ParkExit: FreeHwndList(pbwl); return nIcons; }