void ContainerWindow::OnPaint(Canvas &canvas) { children.Paint(canvas); if (HasBorder()) canvas.DrawOutlineRectangle(-1, -1, GetWidth(), GetHeight(), COLOR_BLACK); }
void IFWL_Widget::GetEdgeRect(CFX_RectF& rtEdge) { rtEdge = m_pProperties->m_rtWidget; rtEdge.left = rtEdge.top = 0; if (HasBorder()) { FX_FLOAT fCX = GetBorderSize(); FX_FLOAT fCY = GetBorderSize(false); rtEdge.Deflate(fCX, fCY); } }
FWL_ERR CFWL_CheckBoxImp::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!pGraphics) return FWL_ERR_Indefinite; if (!m_pProperties->m_pThemeProvider) return FWL_ERR_Indefinite; IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; if (HasBorder()) { DrawBorder(pGraphics, FWL_PART_CKB_Border, m_pProperties->m_pThemeProvider, pMatrix); } if (HasEdge()) { DrawEdge(pGraphics, FWL_PART_CKB_Edge, pTheme, pMatrix); } int32_t dwStates = GetPartStates(); { CFWL_ThemeBackground param; param.m_pWidget = m_pInterface; param.m_iPart = FWL_PART_CKB_Background; param.m_dwStates = dwStates; param.m_pGraphics = pGraphics; if (pMatrix) { param.m_matrix.Concat(*pMatrix); } param.m_rtPart = m_rtClient; if (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) { param.m_pData = &m_rtFocus; } pTheme->DrawBackground(¶m); param.m_iPart = FWL_PART_CKB_CheckBox; param.m_rtPart = m_rtBox; pTheme->DrawBackground(¶m); } if (!m_pProperties->m_pDataProvider) return FWL_ERR_Indefinite; { CFX_WideString wsCaption; m_pProperties->m_pDataProvider->GetCaption(m_pInterface, wsCaption); int32_t iLen = wsCaption.GetLength(); if (iLen <= 0) return FWL_ERR_Indefinite; CFWL_ThemeText textParam; textParam.m_pWidget = m_pInterface; textParam.m_iPart = FWL_PART_CKB_Caption; textParam.m_dwStates = dwStates; textParam.m_pGraphics = pGraphics; if (pMatrix) { textParam.m_matrix.Concat(*pMatrix); } textParam.m_rtPart = m_rtCaption; textParam.m_wsText = wsCaption; textParam.m_dwTTOStyles = m_dwTTOStyles; textParam.m_iTTOAlign = m_iTTOAlign; pTheme->DrawText(&textParam); } return FWL_ERR_Succeeded; }
void miSetShape(WindowPtr pWin) { Bool WasViewable = (Bool)(pWin->viewable); ScreenPtr pScreen = pWin->drawable.pScreen; Bool anyMarked = FALSE; WindowPtr pLayerWin; if (WasViewable) { anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin); if (pWin->valdata) { if (HasBorder (pWin)) { RegionPtr borderVisible; borderVisible = REGION_CREATE(pScreen, NullBox, 1); REGION_SUBTRACT(pScreen, borderVisible, &pWin->borderClip, &pWin->winSize); pWin->valdata->before.borderVisible = borderVisible; } pWin->valdata->before.resized = TRUE; } } SetWinSize (pWin); SetBorderSize (pWin); ResizeChildrenWinSize(pWin, 0, 0, 0, 0); if (WasViewable) { anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL); if (anyMarked) (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, VTOther); } if (WasViewable) { if (anyMarked) (*pScreen->HandleExposures)(pLayerWin->parent); if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, VTOther); } if (pWin->realized) WindowsRestructured (); CheckCursorConfinement(pWin); }
void miChangeBorderWidth(WindowPtr pWin, unsigned int width) { int oldwidth; Bool anyMarked = FALSE; ScreenPtr pScreen; Bool WasViewable = (Bool)(pWin->viewable); Bool HadBorder; WindowPtr pLayerWin; oldwidth = wBorderWidth (pWin); if (oldwidth == width) return; HadBorder = HasBorder(pWin); pScreen = pWin->drawable.pScreen; if (WasViewable && width < oldwidth) anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin); pWin->borderWidth = width; SetBorderSize (pWin); if (WasViewable) { if (width > oldwidth) { anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin); /* * save the old border visible region to correctly compute * borderExposed. */ if (pWin->valdata && HadBorder) { RegionPtr borderVisible; borderVisible = REGION_CREATE(pScreen, NULL, 1); REGION_SUBTRACT(pScreen, borderVisible, &pWin->borderClip, &pWin->winSize); pWin->valdata->before.borderVisible = borderVisible; } } if (anyMarked) { (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTOther); (*pScreen->HandleExposures)(pLayerWin->parent); } if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTOther); } if (pWin->realized) WindowsRestructured (); }
void CFWL_PushButton::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!pGraphics) return; if (!m_pProperties->m_pThemeProvider) return; if (HasBorder()) { DrawBorder(pGraphics, CFWL_Part::Border, m_pProperties->m_pThemeProvider, pMatrix); } DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); }
void IFWL_Widget::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { if (!bAutoSize) { rect = m_pProperties->m_rtWidget; return; } if (HasEdge()) { FX_FLOAT fEdge = GetEdgeWidth(); rect.Inflate(fEdge, fEdge); } if (HasBorder()) { FX_FLOAT fBorder = GetBorderSize(); rect.Inflate(fBorder, fBorder); } }
FWL_Error CFWL_PictureBoxImp::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!pGraphics) return FWL_Error::Indefinite; if (!m_pProperties->m_pThemeProvider) return FWL_Error::Indefinite; IFWL_ThemeProvider* pTheme = GetAvailableTheme(); if (HasBorder()) { DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); } if (HasEdge()) { DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); } DrawBkground(pGraphics, pTheme, pMatrix); return FWL_Error::Succeeded; }
void ContainerWindow::OnPaint(Canvas &canvas) { Window *full = NULL; const std::list<Window*> &children = this->children; /* find the last full window, which covers all the other windows behind it */ for (auto i = children.rbegin(); i != children.rend(); ++i) { Window &child = **i; if (child.is_visible() && child.get_left() <= 0 && child.get_right() >= (int)get_width() && child.get_top() <= 0 && child.get_bottom() >= (int)get_height()) full = &child; } for (auto i = children.rbegin(); i != children.rend(); ++i) { Window &child = **i; if (!child.is_visible()) continue; if (full != NULL) { if (&child == full) full = NULL; else /* don't bother to draw the children "behind" the last full window */ continue; } SubCanvas sub_canvas(canvas, child.get_left(), child.get_top(), child.get_width(), child.get_height()); child.Setup(sub_canvas); child.OnPaint(sub_canvas); } assert(full == NULL); if (HasBorder()) { canvas.SelectBlackPen(); canvas.SelectHollowBrush(); canvas.Rectangle(0, 0, get_width() - 1, get_height() - 1); } }
void IFWL_DateTimePicker::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!pGraphics) return; if (!m_pProperties->m_pThemeProvider) return; IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; if (HasBorder()) DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); if (HasEdge()) DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); if (!m_rtBtn.IsEmpty()) DrawDropDownButton(pGraphics, pTheme, pMatrix); if (m_pWidgetMgr->IsFormDisabled()) { DisForm_DrawWidget(pGraphics, pMatrix); return; } }
FWL_WidgetHit IFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { CFX_RectF rtClient; GetClientRect(rtClient); if (rtClient.Contains(fx, fy)) return FWL_WidgetHit::Client; if (HasEdge()) { CFX_RectF rtEdge; GetEdgeRect(rtEdge); if (rtEdge.Contains(fx, fy)) return FWL_WidgetHit::Edge; } if (HasBorder()) { CFX_RectF rtRelative; GetRelativeRect(rtRelative); if (rtRelative.Contains(fx, fy)) return FWL_WidgetHit::Border; } return FWL_WidgetHit::Unknown; }
FWL_ERR CFWL_ScrollBarImp::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!pGraphics) return FWL_ERR_Indefinite; if (!m_pProperties->m_pThemeProvider) return FWL_ERR_Indefinite; IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; if (HasBorder()) { DrawBorder(pGraphics, FWL_PART_SCB_Border, pTheme, pMatrix); } if (HasEdge()) { DrawEdge(pGraphics, FWL_PART_SCB_Edge, pTheme, pMatrix); } DrawTrack(pGraphics, pTheme, TRUE, pMatrix); DrawTrack(pGraphics, pTheme, FALSE, pMatrix); DrawArrowBtn(pGraphics, pTheme, TRUE, pMatrix); DrawArrowBtn(pGraphics, pTheme, FALSE, pMatrix); DrawThumb(pGraphics, pTheme, pMatrix); return FWL_ERR_Succeeded; }
FWL_ERR CFWL_DateTimePickerImp::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!pGraphics) return FWL_ERR_Indefinite; if (!m_pProperties->m_pThemeProvider) return FWL_ERR_Indefinite; IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; if (HasBorder()) { DrawBorder(pGraphics, FWL_PART_DTP_Border, pTheme, pMatrix); } if (HasEdge()) { DrawEdge(pGraphics, FWL_PART_DTP_Edge, pTheme, pMatrix); } if (!m_rtBtn.IsEmpty()) { DrawDropDownButton(pGraphics, pTheme, pMatrix); } if (m_pWidgetMgr->IsFormDisabled()) { return DisForm_DrawWidget(pGraphics, pMatrix); } return FWL_ERR_Succeeded; }
static void xf86SetRootClip (ScreenPtr pScreen, Bool enable) { #if XORG < 19 WindowPtr pWin = WindowTable[pScreen->myNum]; #else WindowPtr pWin = pScreen->root; #endif WindowPtr pChild; Bool WasViewable = (Bool)(pWin->viewable); Bool anyMarked = FALSE; #if XORG < 110 RegionPtr pOldClip = NULL, bsExposed; #ifdef DO_SAVE_UNDERS Bool dosave = FALSE; #endif #endif WindowPtr pLayerWin; BoxRec box; if (WasViewable) { for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { (void) (*pScreen->MarkOverlappedWindows)(pChild, pChild, &pLayerWin); } (*pScreen->MarkWindow) (pWin); anyMarked = TRUE; if (pWin->valdata) { if (HasBorder (pWin)) { RegionPtr borderVisible; borderVisible = REGION_CREATE(pScreen, NullBox, 1); REGION_SUBTRACT(pScreen, borderVisible, &pWin->borderClip, &pWin->winSize); pWin->valdata->before.borderVisible = borderVisible; } pWin->valdata->before.resized = TRUE; } } /* * Use REGION_BREAK to avoid optimizations in ValidateTree * that assume the root borderClip can't change well, normally * it doesn't...) */ if (enable) { box.x1 = 0; box.y1 = 0; box.x2 = pScreen->width; box.y2 = pScreen->height; REGION_INIT (pScreen, &pWin->winSize, &box, 1); REGION_INIT (pScreen, &pWin->borderSize, &box, 1); if (WasViewable) REGION_RESET(pScreen, &pWin->borderClip, &box); pWin->drawable.width = pScreen->width; pWin->drawable.height = pScreen->height; REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList); } else { REGION_EMPTY(pScreen, &pWin->borderClip); REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList); } ResizeChildrenWinSize (pWin, 0, 0, 0, 0); if (WasViewable) { #if XORG < 110 if (pWin->backStorage) { pOldClip = REGION_CREATE(pScreen, NullBox, 1); REGION_COPY(pScreen, pOldClip, &pWin->clipList); } #endif if (pWin->firstChild) { anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild, pWin->firstChild, (WindowPtr *)NULL); } else { (*pScreen->MarkWindow) (pWin); anyMarked = TRUE; } #if XORG < 110 && defined(DO_SAVE_UNDERS) if (DO_SAVE_UNDERS(pWin)) { dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin); } #endif /* DO_SAVE_UNDERS */ if (anyMarked) (*pScreen->ValidateTree)(pWin, NullWindow, VTOther); } #if XORG < 110 if (pWin->backStorage && ((pWin->backingStore == Always) || WasViewable)) { if (!WasViewable) pOldClip = &pWin->clipList; /* a convenient empty region */ bsExposed = (*pScreen->TranslateBackingStore) (pWin, 0, 0, pOldClip, pWin->drawable.x, pWin->drawable.y); if (WasViewable) REGION_DESTROY(pScreen, pOldClip); if (bsExposed) { RegionPtr valExposed = NullRegion; if (pWin->valdata) valExposed = &pWin->valdata->after.exposed; (*pScreen->WindowExposures) (pWin, valExposed, bsExposed); if (valExposed) REGION_EMPTY(pScreen, valExposed); REGION_DESTROY(pScreen, bsExposed); } } #endif if (WasViewable) { if (anyMarked) (*pScreen->HandleExposures)(pWin); #if XORG < 110 && defined(DO_SAVE_UNDERS) if (dosave) (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin); #endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther); } if (pWin->realized) WindowsRestructured (); FlushAllOutput (); }
FWL_ERR CFWL_PushButtonImp::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!pGraphics) return FWL_ERR_Indefinite; if (!m_pProperties->m_pThemeProvider) return FWL_ERR_Indefinite; IFWL_PushButtonDP* pData = static_cast<IFWL_PushButtonDP*>(m_pProperties->m_pDataProvider); CFX_DIBitmap* pPicture = NULL; IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; if (HasBorder()) { DrawBorder(pGraphics, FWL_PART_PSB_Border, m_pProperties->m_pThemeProvider, pMatrix); } if (HasEdge()) { DrawEdge(pGraphics, FWL_PART_PSB_Edge, m_pProperties->m_pThemeProvider, pMatrix); } DrawBkground(pGraphics, m_pProperties->m_pThemeProvider, pMatrix); CFX_Matrix matrix; matrix.Concat(*pMatrix); FX_FLOAT iPicwidth = 0; FX_FLOAT ipicheight = 0; CFX_WideString wsCaption; if (pData) { pData->GetCaption(m_pInterface, wsCaption); } CFX_RectF rtText; rtText.Set(0, 0, 0, 0); if (!wsCaption.IsEmpty()) { CalcTextRect(wsCaption, pTheme, 0, m_iTTOAlign, rtText); } switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_PSB_ModeMask) { case FWL_STYLEEXT_PSB_TextOnly: DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); break; case FWL_STYLEEXT_PSB_IconOnly: if (pData) { pPicture = pData->GetPicture(m_pInterface); } if (pPicture) { CFX_PointF point; switch (m_iTTOAlign) { case 0: { point.x = m_rtClient.left; point.y = m_rtClient.top; break; } case 1: { point.x = m_rtClient.left + (m_rtClient.width / 2 - pPicture->GetWidth() / 2); point.y = m_rtClient.top; break; } case 2: point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth(); point.y = m_rtClient.top; break; case 4: point.x = m_rtClient.left; point.y = m_rtClient.top + m_rtClient.height / 2 - pPicture->GetHeight() / 2; break; case 5: point.x = m_rtClient.left + (m_rtClient.width / 2 - pPicture->GetWidth() / 2); point.y = m_rtClient.top + m_rtClient.height / 2 - pPicture->GetHeight() / 2; break; case 6: point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth(); point.y = m_rtClient.top + m_rtClient.height / 2 - pPicture->GetHeight() / 2; break; case 8: point.x = m_rtClient.left; point.y = m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); break; case 9: point.x = m_rtClient.left + (m_rtClient.width / 2 - pPicture->GetWidth() / 2); point.y = m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); break; case 10: point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth(); point.y = m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); break; } pGraphics->DrawImage(pPicture, point, &matrix); } break; case FWL_STYLEEXT_PSB_TextIcon: if (pPicture) { CFX_PointF point; switch (m_iTTOAlign) { case 0: { point.x = m_rtClient.left; point.y = m_rtClient.top; iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7); ipicheight = pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2; break; } case 1: { point.x = m_rtClient.left + (m_rtClient.width / 2 - (pPicture->GetWidth() + rtText.width) / 2); point.y = m_rtClient.top; iPicwidth = pPicture->GetWidth() - ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + rtText.width / 2 - 7; ipicheight = pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2; break; } case 2: point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth() - rtText.width; point.y = m_rtClient.top; iPicwidth = m_rtClient.left + m_rtClient.width - point.x - pPicture->GetWidth() - rtText.width + 7; ipicheight = pPicture->GetHeight() / 2 - m_rtCaption.top - rtText.height / 2; break; case 4: point.x = m_rtClient.left; point.y = m_rtClient.top + m_rtClient.height / 2 - pPicture->GetHeight() / 2; iPicwidth = m_rtClient.left + pPicture->GetWidth() - 7; break; case 5: point.x = m_rtClient.left + (m_rtClient.width / 2 - (pPicture->GetWidth() + rtText.width) / 2); point.y = m_rtClient.top + m_rtClient.height / 2 - pPicture->GetHeight() / 2; iPicwidth = pPicture->GetWidth() - ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + rtText.width / 2 - 7; break; case 6: point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth() - rtText.width; point.y = m_rtClient.top + m_rtClient.height / 2 - pPicture->GetHeight() / 2; iPicwidth = m_rtClient.left + m_rtClient.width - point.x - pPicture->GetWidth() - rtText.width + 7; break; case 8: point.x = m_rtClient.left; point.y = m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); iPicwidth = (FX_FLOAT)(pPicture->GetWidth() - 7); ipicheight -= rtText.height / 2; break; case 9: point.x = m_rtClient.left + (m_rtClient.width / 2 - (pPicture->GetWidth() + rtText.width) / 2); point.y = m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); iPicwidth = pPicture->GetWidth() - ((m_rtClient.width) / 2 - rtText.width / 2 - point.x) + rtText.width / 2 - 7; ipicheight -= rtText.height / 2; break; case 10: point.x = m_rtClient.left + m_rtClient.width - pPicture->GetWidth() - rtText.width; point.y = m_rtClient.top + m_rtClient.height - pPicture->GetHeight(); iPicwidth = m_rtClient.left + m_rtClient.width - point.x - pPicture->GetWidth() - rtText.width + 7; ipicheight -= rtText.height / 2; break; } pGraphics->DrawImage(pPicture, point, &matrix); } matrix.e += m_rtClient.left + iPicwidth; matrix.f += m_rtClient.top + ipicheight; DrawText(pGraphics, m_pProperties->m_pThemeProvider, &matrix); break; } return FWL_ERR_Succeeded; }
/* *----------------------------------------------------------------------- * miComputeClips -- * Recompute the clipList, borderClip, exposed and borderExposed * regions for pParent and its children. Only viewable windows are * taken into account. * * Results: * None. * * Side Effects: * clipList, borderClip, exposed and borderExposed are altered. * A VisibilityNotify event may be generated on the parent window. * *----------------------------------------------------------------------- */ static void miComputeClips ( WindowPtr pParent, ScreenPtr pScreen, RegionPtr universe, VTKind kind, RegionPtr exposed ) /* for intermediate calculations */ { int dx, dy; RegionRec childUniverse; WindowPtr pChild; int oldVis, newVis; BoxRec borderSize; RegionRec childUnion; Bool overlap; RegionPtr borderVisible; /* * Figure out the new visibility of this window. * The extent of the universe should be the same as the extent of * the borderSize region. If the window is unobscured, this rectangle * will be completely inside the universe (the universe will cover it * completely). If the window is completely obscured, none of the * universe will cover the rectangle. */ borderSize.x1 = pParent->drawable.x - wBorderWidth(pParent); borderSize.y1 = pParent->drawable.y - wBorderWidth(pParent); dx = (int) pParent->drawable.x + (int) pParent->drawable.width + wBorderWidth(pParent); if (dx > 32767) dx = 32767; borderSize.x2 = dx; dy = (int) pParent->drawable.y + (int) pParent->drawable.height + wBorderWidth(pParent); if (dy > 32767) dy = 32767; borderSize.y2 = dy; #ifdef COMPOSITE /* * In redirected drawing case, reset universe to borderSize */ if (pParent->redirectDraw != RedirectDrawNone) { if (miSetRedirectBorderClipProc) { if (TreatAsTransparent (pParent)) RegionEmpty(universe); (*miSetRedirectBorderClipProc) (pParent, universe); } RegionCopy(universe, &pParent->borderSize); } #endif oldVis = pParent->visibility; switch (RegionContainsRect(universe, &borderSize)) { case rgnIN: newVis = VisibilityUnobscured; break; case rgnPART: newVis = VisibilityPartiallyObscured; { RegionPtr pBounding; if ((pBounding = wBoundingShape (pParent))) { switch (miShapedWindowIn (universe, pBounding, &borderSize, pParent->drawable.x, pParent->drawable.y)) { case rgnIN: newVis = VisibilityUnobscured; break; case rgnOUT: newVis = VisibilityFullyObscured; break; } } } break; default: newVis = VisibilityFullyObscured; break; } pParent->visibility = newVis; if (oldVis != newVis && ((pParent->eventMask | wOtherEventMasks(pParent)) & VisibilityChangeMask)) SendVisibilityNotify(pParent); dx = pParent->drawable.x - pParent->valdata->before.oldAbsCorner.x; dy = pParent->drawable.y - pParent->valdata->before.oldAbsCorner.y; /* * avoid computations when dealing with simple operations */ switch (kind) { case VTMap: case VTStack: case VTUnmap: break; case VTMove: if ((oldVis == newVis) && ((oldVis == VisibilityFullyObscured) || (oldVis == VisibilityUnobscured))) { pChild = pParent; while (1) { if (pChild->viewable) { if (pChild->visibility != VisibilityFullyObscured) { RegionTranslate(&pChild->borderClip, dx, dy); RegionTranslate(&pChild->clipList, dx, dy); pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER; if (pScreen->ClipNotify) (* pScreen->ClipNotify) (pChild, dx, dy); } if (pChild->valdata) { RegionNull(&pChild->valdata->after.borderExposed); if (HasParentRelativeBorder(pChild)) { RegionSubtract(&pChild->valdata->after.borderExposed, &pChild->borderClip, &pChild->winSize); } RegionNull(&pChild->valdata->after.exposed); } if (pChild->firstChild) { pChild = pChild->firstChild; continue; } } while (!pChild->nextSib && (pChild != pParent)) pChild = pChild->parent; if (pChild == pParent) break; pChild = pChild->nextSib; } return; } /* fall through */ default: /* * To calculate exposures correctly, we have to translate the old * borderClip and clipList regions to the window's new location so there * is a correspondence between pieces of the new and old clipping regions. */ if (dx || dy) { /* * We translate the old clipList because that will be exposed or copied * if gravity is right. */ RegionTranslate(&pParent->borderClip, dx, dy); RegionTranslate(&pParent->clipList, dx, dy); } break; case VTBroken: RegionEmpty(&pParent->borderClip); RegionEmpty(&pParent->clipList); break; } borderVisible = pParent->valdata->before.borderVisible; RegionNull(&pParent->valdata->after.borderExposed); RegionNull(&pParent->valdata->after.exposed); /* * Since the borderClip must not be clipped by the children, we do * the border exposure first... * * 'universe' is the window's borderClip. To figure the exposures, remove * the area that used to be exposed from the new. * This leaves a region of pieces that weren't exposed before. */ if (HasBorder (pParent)) { if (borderVisible) { /* * when the border changes shape, the old visible portions * of the border will be saved by DIX in borderVisible -- * use that region and destroy it */ RegionSubtract(exposed, universe, borderVisible); RegionDestroy(borderVisible); } else { RegionSubtract(exposed, universe, &pParent->borderClip); } if (HasParentRelativeBorder(pParent) && (dx || dy)) RegionSubtract(&pParent->valdata->after.borderExposed, universe, &pParent->winSize); else RegionSubtract(&pParent->valdata->after.borderExposed, exposed, &pParent->winSize); RegionCopy(&pParent->borderClip, universe); /* * To get the right clipList for the parent, and to make doubly sure * that no child overlaps the parent's border, we remove the parent's * border from the universe before proceeding. */ RegionIntersect(universe, universe, &pParent->winSize); } else RegionCopy(&pParent->borderClip, universe); if ((pChild = pParent->firstChild) && pParent->mapped) { RegionNull(&childUniverse); RegionNull(&childUnion); if ((pChild->drawable.y < pParent->lastChild->drawable.y) || ((pChild->drawable.y == pParent->lastChild->drawable.y) && (pChild->drawable.x < pParent->lastChild->drawable.x))) { for (; pChild; pChild = pChild->nextSib) { if (pChild->viewable && !TreatAsTransparent(pChild)) RegionAppend(&childUnion, &pChild->borderSize); } } else { for (pChild = pParent->lastChild; pChild; pChild = pChild->prevSib) { if (pChild->viewable && !TreatAsTransparent(pChild)) RegionAppend(&childUnion, &pChild->borderSize); } } RegionValidate(&childUnion, &overlap); for (pChild = pParent->firstChild; pChild; pChild = pChild->nextSib) { if (pChild->viewable) { /* * If the child is viewable, we want to remove its extents * from the current universe, but we only re-clip it if * it's been marked. */ if (pChild->valdata) { /* * Figure out the new universe from the child's * perspective and recurse. */ RegionIntersect(&childUniverse, universe, &pChild->borderSize); miComputeClips (pChild, pScreen, &childUniverse, kind, exposed); } /* * Once the child has been processed, we remove its extents * from the current universe, thus denying its space to any * other sibling. */ if (overlap && !TreatAsTransparent (pChild)) RegionSubtract(universe, universe, &pChild->borderSize); } } if (!overlap) RegionSubtract(universe, universe, &childUnion); RegionUninit(&childUnion); RegionUninit(&childUniverse); } /* if any children */ /* * 'universe' now contains the new clipList for the parent window. * * To figure the exposure of the window we subtract the old clip from the * new, just as for the border. */ if (oldVis == VisibilityFullyObscured || oldVis == VisibilityNotViewable) { RegionCopy(&pParent->valdata->after.exposed, universe); } else if (newVis != VisibilityFullyObscured && newVis != VisibilityNotViewable) { RegionSubtract(&pParent->valdata->after.exposed, universe, &pParent->clipList); } /* HACK ALERT - copying contents of regions, instead of regions */ { RegionRec tmp; tmp = pParent->clipList; pParent->clipList = *universe; *universe = tmp; } #ifdef NOTDEF RegionCopy(&pParent->clipList, universe); #endif pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER; if (pScreen->ClipNotify) (* pScreen->ClipNotify) (pParent, dx, dy); }
void miSlideAndSizeWindow(WindowPtr pWin, int x, int y, unsigned int w, unsigned int h, WindowPtr pSib) { WindowPtr pParent; Bool WasViewable = (Bool)(pWin->viewable); unsigned short width = pWin->drawable.width, height = pWin->drawable.height; short oldx = pWin->drawable.x, oldy = pWin->drawable.y; int bw = wBorderWidth (pWin); short dw, dh; DDXPointRec oldpt; RegionPtr oldRegion = NULL; Bool anyMarked = FALSE; ScreenPtr pScreen; WindowPtr pFirstChange; WindowPtr pChild; RegionPtr gravitate[StaticGravity + 1]; unsigned g; int nx, ny; /* destination x,y */ int newx, newy; /* new inner window position */ RegionPtr pRegion = NULL; RegionPtr destClip; /* portions of destination already written */ RegionPtr oldWinClip = NULL; /* old clip list for window */ RegionPtr borderVisible = NullRegion; /* visible area of the border */ Bool shrunk = FALSE; /* shrunk in an inner dimension */ Bool moved = FALSE; /* window position changed */ WindowPtr pLayerWin; /* if this is a root window, can't be resized */ if (!(pParent = pWin->parent)) return ; pScreen = pWin->drawable.pScreen; newx = pParent->drawable.x + x + bw; newy = pParent->drawable.y + y + bw; if (WasViewable) { anyMarked = FALSE; /* * save the visible region of the window */ oldRegion = REGION_CREATE(pScreen, NullBox, 1); REGION_COPY(pScreen, oldRegion, &pWin->winSize); /* * categorize child windows into regions to be moved */ for (g = 0; g <= StaticGravity; g++) gravitate[g] = (RegionPtr) NULL; for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { g = pChild->winGravity; if (g != UnmapGravity) { if (!gravitate[g]) gravitate[g] = REGION_CREATE(pScreen, NullBox, 1); REGION_UNION(pScreen, gravitate[g], gravitate[g], &pChild->borderClip); } else { UnmapWindow(pChild, TRUE); anyMarked = TRUE; } } anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin); oldWinClip = NULL; if (pWin->bitGravity != ForgetGravity) { oldWinClip = REGION_CREATE(pScreen, NullBox, 1); REGION_COPY(pScreen, oldWinClip, &pWin->clipList); } /* * if the window is changing size, borderExposed * can't be computed correctly without some help. */ if (pWin->drawable.height > h || pWin->drawable.width > w) shrunk = TRUE; if (newx != oldx || newy != oldy) moved = TRUE; if ((pWin->drawable.height != h || pWin->drawable.width != w) && HasBorder (pWin)) { borderVisible = REGION_CREATE(pScreen, NullBox, 1); /* for tiled borders, we punt and draw the whole thing */ if (pWin->borderIsPixel || !moved) { if (shrunk || moved) REGION_SUBTRACT(pScreen, borderVisible, &pWin->borderClip, &pWin->winSize); else REGION_COPY(pScreen, borderVisible, &pWin->borderClip); } } } pWin->origin.x = x + bw; pWin->origin.y = y + bw; pWin->drawable.height = h; pWin->drawable.width = w; x = pWin->drawable.x = newx; y = pWin->drawable.y = newy; SetWinSize (pWin); SetBorderSize (pWin); dw = (int)w - (int)width; dh = (int)h - (int)height; ResizeChildrenWinSize(pWin, x - oldx, y - oldy, dw, dh); /* let the hardware adjust background and border pixmaps, if any */ (*pScreen->PositionWindow)(pWin, x, y); pFirstChange = MoveWindowInStack(pWin, pSib); if (WasViewable) { pRegion = REGION_CREATE(pScreen, NullBox, 1); if (pLayerWin == pWin) anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, NULL); else anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pLayerWin, NULL); if (pWin->valdata) { pWin->valdata->before.resized = TRUE; pWin->valdata->before.borderVisible = borderVisible; } if (anyMarked) (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, VTOther); /* * the entire window is trashed unless bitGravity * recovers portions of it */ REGION_COPY(pScreen, &pWin->valdata->after.exposed, &pWin->clipList); } GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny); if (WasViewable) { /* avoid the border */ if (HasBorder (pWin)) { int offx, offy, dx, dy; /* kruft to avoid double translates for each gravity */ offx = 0; offy = 0; for (g = 0; g <= StaticGravity; g++) { if (!gravitate[g]) continue; /* align winSize to gravitate[g]. * winSize is in new coordinates, * gravitate[g] is still in old coordinates */ GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny); dx = (oldx - nx) - offx; dy = (oldy - ny) - offy; if (dx || dy) { REGION_TRANSLATE(pScreen, &pWin->winSize, dx, dy); offx += dx; offy += dy; } REGION_INTERSECT(pScreen, gravitate[g], gravitate[g], &pWin->winSize); } /* get winSize back where it belongs */ if (offx || offy) REGION_TRANSLATE(pScreen, &pWin->winSize, -offx, -offy); } /* * add screen bits to the appropriate bucket */ if (oldWinClip) { /* * clip to new clipList */ REGION_COPY(pScreen, pRegion, oldWinClip); REGION_TRANSLATE(pScreen, pRegion, nx - oldx, ny - oldy); REGION_INTERSECT(pScreen, oldWinClip, pRegion, &pWin->clipList); /* * don't step on any gravity bits which will be copied after this * region. Note -- this assumes that the regions will be copied * in gravity order. */ for (g = pWin->bitGravity + 1; g <= StaticGravity; g++) { if (gravitate[g]) REGION_SUBTRACT(pScreen, oldWinClip, oldWinClip, gravitate[g]); } REGION_TRANSLATE(pScreen, oldWinClip, oldx - nx, oldy - ny); g = pWin->bitGravity; if (!gravitate[g]) gravitate[g] = oldWinClip; else { REGION_UNION(pScreen, gravitate[g], gravitate[g], oldWinClip); REGION_DESTROY(pScreen, oldWinClip); } } /* * move the bits on the screen */ destClip = NULL; for (g = 0; g <= StaticGravity; g++) { if (!gravitate[g]) continue; GravityTranslate (x, y, oldx, oldy, dw, dh, g, &nx, &ny); oldpt.x = oldx + (x - nx); oldpt.y = oldy + (y - ny); /* Note that gravitate[g] is *translated* by CopyWindow */ /* only copy the remaining useful bits */ REGION_INTERSECT(pScreen, gravitate[g], gravitate[g], oldRegion); /* clip to not overwrite already copied areas */ if (destClip) { REGION_TRANSLATE(pScreen, destClip, oldpt.x - x, oldpt.y - y); REGION_SUBTRACT(pScreen, gravitate[g], gravitate[g], destClip); REGION_TRANSLATE(pScreen, destClip, x - oldpt.x, y - oldpt.y); } /* and move those bits */ if (oldpt.x != x || oldpt.y != y #ifdef COMPOSITE || pWin->redirectDraw #endif ) { (*pWin->drawable.pScreen->CopyWindow)(pWin, oldpt, gravitate[g]); } /* remove any overwritten bits from the remaining useful bits */ REGION_SUBTRACT(pScreen, oldRegion, oldRegion, gravitate[g]); /* * recompute exposed regions of child windows */ for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { if (pChild->winGravity != g) continue; REGION_INTERSECT(pScreen, pRegion, &pChild->borderClip, gravitate[g]); TraverseTree (pChild, miRecomputeExposures, (pointer)pRegion); } /* * remove the successfully copied regions of the * window from its exposed region */ if (g == pWin->bitGravity) REGION_SUBTRACT(pScreen, &pWin->valdata->after.exposed, &pWin->valdata->after.exposed, gravitate[g]); if (!destClip) destClip = gravitate[g]; else { REGION_UNION(pScreen, destClip, destClip, gravitate[g]); REGION_DESTROY(pScreen, gravitate[g]); } } REGION_DESTROY(pScreen, oldRegion); REGION_DESTROY(pScreen, pRegion); if (destClip) REGION_DESTROY(pScreen, destClip); if (anyMarked) (*pScreen->HandleExposures)(pLayerWin->parent); if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, VTOther); } if (pWin->realized) WindowsRestructured (); }
void KdSetRootClip (ScreenPtr pScreen, BOOL enable) { #ifndef FB_OLD_SCREEN WindowPtr pWin = WindowTable[pScreen->myNum]; WindowPtr pChild; Bool WasViewable; Bool anyMarked = FALSE; RegionPtr pOldClip = 0, bsExposed; #ifdef DO_SAVE_UNDERS Bool dosave = FALSE; #endif WindowPtr pLayerWin; BoxRec box; if (!pWin) return; WasViewable = (Bool)(pWin->viewable); if (WasViewable) { for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) { (void) (*pScreen->MarkOverlappedWindows)(pChild, pChild, &pLayerWin); } (*pScreen->MarkWindow) (pWin); anyMarked = TRUE; if (pWin->valdata) { if (HasBorder (pWin)) { RegionPtr borderVisible; borderVisible = REGION_CREATE(pScreen, NullBox, 1); REGION_SUBTRACT(pScreen, borderVisible, &pWin->borderClip, &pWin->winSize); pWin->valdata->before.borderVisible = borderVisible; } pWin->valdata->before.resized = TRUE; } } if (enable) { box.x1 = 0; box.y1 = 0; box.x2 = pScreen->width; box.y2 = pScreen->height; pWin->drawable.width = pScreen->width; pWin->drawable.height = pScreen->height; REGION_INIT (pScreen, &pWin->winSize, &box, 1); REGION_INIT (pScreen, &pWin->borderSize, &box, 1); REGION_RESET(pScreen, &pWin->borderClip, &box); REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList); } else { REGION_EMPTY(pScreen, &pWin->borderClip); REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList); } ResizeChildrenWinSize (pWin, 0, 0, 0, 0); if (WasViewable) { if (pWin->backStorage) { pOldClip = REGION_CREATE(pScreen, NullBox, 1); REGION_COPY(pScreen, pOldClip, &pWin->clipList); } if (pWin->firstChild) { anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild, pWin->firstChild, (WindowPtr *)NULL); } else { (*pScreen->MarkWindow) (pWin); anyMarked = TRUE; } #ifdef DO_SAVE_UNDERS if (DO_SAVE_UNDERS(pWin)) { dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin); } #endif /* DO_SAVE_UNDERS */ if (anyMarked) (*pScreen->ValidateTree)(pWin, NullWindow, VTOther); } if (pWin->backStorage && ((pWin->backingStore == Always) || WasViewable)) { if (!WasViewable) pOldClip = &pWin->clipList; /* a convenient empty region */ bsExposed = (*pScreen->TranslateBackingStore) (pWin, 0, 0, pOldClip, pWin->drawable.x, pWin->drawable.y); if (WasViewable) REGION_DESTROY(pScreen, pOldClip); if (bsExposed) { RegionPtr valExposed = NullRegion; if (pWin->valdata) valExposed = &pWin->valdata->after.exposed; (*pScreen->WindowExposures) (pWin, valExposed, bsExposed); if (valExposed) REGION_EMPTY(pScreen, valExposed); REGION_DESTROY(pScreen, bsExposed); } } if (WasViewable) { if (anyMarked) (*pScreen->HandleExposures)(pWin); #ifdef DO_SAVE_UNDERS if (dosave) (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin); #endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther); } if (pWin->realized) WindowsRestructured (); #endif /* !FB_OLD_SCREEN */ }